Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket Forms: Add checkbox list input #30

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion helpdesk/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -454,7 +459,6 @@ def decompress(self, value):
return formatted
return []


class EditQueueForm(forms.ModelForm):
error_css_class = 'text-danger'

Expand Down
18 changes: 18 additions & 0 deletions helpdesk/migrations/0106_add_checkbox_list_data_type.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
1 change: 1 addition & 0 deletions helpdesk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ class CustomField(models.Model):
('slug', _('Slug')),
('attachment', _('Attachment')),
('key_value', _('Key Value')),
('checkbox_list', _('Checkbox List')),
)

data_type = models.CharField(
Expand Down
3 changes: 3 additions & 0 deletions helpdesk/templates/helpdesk/edit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down