diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 1c5ed3c13..4f3498358 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -133,6 +133,11 @@ def customfield_to_field(self, field, instanceargs, kwargs={}): instanceargs['key_field'] = forms.ChoiceField(choices=choices, widget=key_widget) instanceargs['value_field'] = forms.CharField(widget=value_widget) + elif field.data_type == 'checkbox_list': + fieldclass = forms.MultipleChoiceField + choices = field.choices_as_array + instanceargs['choices'] = choices + instanceargs['widget'] = forms.CheckboxSelectMultiple(attrs={'class': 'list-unstyled ml-2'}) else: # Try to use the immediate equivalences dictionary try: @@ -454,7 +459,6 @@ def decompress(self, value): return formatted return [] - class EditQueueForm(forms.ModelForm): error_css_class = 'text-danger' diff --git a/helpdesk/migrations/0106_add_checkbox_list_data_type.py b/helpdesk/migrations/0106_add_checkbox_list_data_type.py new file mode 100644 index 000000000..bcd490e13 --- /dev/null +++ b/helpdesk/migrations/0106_add_checkbox_list_data_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.20 on 2024-10-10 17:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0105_disallow_null_savedsearch_organization'), + ] + + operations = [ + migrations.AlterField( + model_name='customfield', + name='data_type', + field=models.CharField(blank=True, choices=[('varchar', 'Character (single line)'), ('text', 'Text (multi-line)'), ('integer', 'Integer'), ('decimal', 'Decimal'), ('list', 'List'), ('boolean', 'Boolean (checkbox yes/no)'), ('date', 'Date'), ('time', 'Time'), ('datetime', 'Date & Time'), ('email', 'E-Mail Address'), ('url', 'URL'), ('ipaddress', 'IP Address'), ('slug', 'Slug'), ('attachment', 'Attachment'), ('key_value', 'Key Value'), ('checkbox_list', 'Checkbox List')], help_text='Allows you to restrict the data entered into this field', max_length=100, null=True, verbose_name='Data Type'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index 01ca5ba78..78a1ca27f 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -2103,6 +2103,7 @@ class CustomField(models.Model): ('slug', _('Slug')), ('attachment', _('Attachment')), ('key_value', _('Key Value')), + ('checkbox_list', _('Checkbox List')), ) data_type = models.CharField( diff --git a/helpdesk/templates/helpdesk/edit_form.html b/helpdesk/templates/helpdesk/edit_form.html index adcd7a435..48c68d7c5 100644 --- a/helpdesk/templates/helpdesk/edit_form.html +++ b/helpdesk/templates/helpdesk/edit_form.html @@ -171,6 +171,9 @@ form.querySelector('[id$=-empty_selection_list]').parentElement.parentElement.hidden = false; form.querySelector('[id$=-list_values]').parentElement.parentElement.hidden = false; } + if (dataType == 'checkbox_list') { + form.querySelector('[id$=-list_values]').parentElement.parentElement.hidden = false; + } if (dataType == 'email') { form.querySelector('[id$=-notifications]').parentElement.parentElement.hidden = false; }