diff --git a/helpdesk/forms.py b/helpdesk/forms.py index f1496ccb..7dee26ce 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -641,15 +641,8 @@ class CreateChecklistForm(ChecklistForm): required=False, ) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.fields['name'].required = False - - def clean(self): - if not self.cleaned_data.get('checklist_template') and not self.cleaned_data.get('name'): - raise ValidationError(_('Please choose at least a name or a template for the new checklist')) - if self.cleaned_data.get('checklist_template') and self.cleaned_data.get('name'): - raise ValidationError(_('Please choose either a name or a template for the new checklist')) + class Meta(ChecklistForm.Meta): + fields = ('checklist_template', 'name') class FormControlDeleteFormSet(forms.BaseInlineFormSet): diff --git a/helpdesk/models.py b/helpdesk/models.py index c2e90bb6..eeca54e2 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -2028,12 +2028,6 @@ class ChecklistTemplate(models.Model): def __str__(self): return self.name - def create_checklist_for_ticket(self, ticket): - checklist = ticket.checklists.create(name=self.name) - for position, task in enumerate(self.task_list): - checklist.tasks.create(description=task, position=position) - return checklist - class Checklist(models.Model): ticket = models.ForeignKey( @@ -2054,6 +2048,10 @@ class Checklist(models.Model): def __str__(self): return self.name + def create_tasks_from_template(self, template): + for position, task in enumerate(template.task_list): + self.tasks.create(description=task, position=position) + class ChecklistTaskQuerySet(models.QuerySet): def todo(self): diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 772b49a9..bf817d52 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -245,6 +245,33 @@ + +
{% endif %} {% endblock %} @@ -280,6 +307,19 @@ $(document).ready(function() { } }); + // Preset name of checklist when a template is selected + $('#id_checklist_template').on('change', function() { + const nameField = $('#id_name') + const selectedTemplate = $(this).children(':selected') + if (nameField.val() === '' && selectedTemplate.val()) { + nameField.val(selectedTemplate.text()) + } + }) + + $('.disabledTask').on('click', () => { + alert('{% trans 'If you want to update state of checklist tasks, please do a Follow-Up response and click on "Update checklists"' %}') + }) + $("[data-toggle=tooltip]").tooltip(); // lists for file input change events, then updates the associated text label diff --git a/helpdesk/templates/helpdesk/ticket_desc_table.html b/helpdesk/templates/helpdesk/ticket_desc_table.html index 967196e2..1c3d3cfd 100644 --- a/helpdesk/templates/helpdesk/ticket_desc_table.html +++ b/helpdesk/templates/helpdesk/ticket_desc_table.html @@ -196,7 +196,7 @@