Display checklists on ticket page

This commit is contained in:
Benbb96 2023-04-22 23:56:23 +02:00
parent 9e7b4ef9bf
commit 8be55fb7f2
No known key found for this signature in database
2 changed files with 66 additions and 0 deletions

View File

@ -2049,6 +2049,14 @@ class Checklist(models.Model):
return self.name return self.name
class ChecklistTaskQuerySet(models.QuerySet):
def todo(self):
return self.filter(completion_date__isnull=True)
def completed(self):
return self.filter(completion_date__isnull=False)
class ChecklistTask(models.Model): class ChecklistTask(models.Model):
checklist = models.ForeignKey( checklist = models.ForeignKey(
Checklist, Checklist,
@ -2066,6 +2074,8 @@ class ChecklistTask(models.Model):
blank=True blank=True
) )
objects = ChecklistTaskQuerySet.as_manager()
class Meta: class Meta:
verbose_name = _('Checklist Task') verbose_name = _('Checklist Task')
verbose_name_plural = _('Checklist Tasks') verbose_name_plural = _('Checklist Tasks')

View File

@ -171,6 +171,62 @@
</ul> </ul>
</td> </td>
</tr> </tr>
<tr>
<th class="table-active">{% trans "Checklists" %}</th>
<td colspan="3">
<div class="container-fluid">
<div class="row">
{% for checklist in ticket.checklists.all %}
<div class="col-sm-4 col-xs-12">
<div class="card">
<div class="card-header" data-toggle="collapse" data-target="#checklist{{ checklist.id }}" onclick="$(this).find('i').toggleClass('fa-caret-down fa-caret-up')">
<h4>
{{ checklist }}
<button class="btn btn-link float-right">
<i class="fas fa-caret-down"></i>
</button>
</h4>
</div>
<div class="card-body collapse" id="checklist{{ checklist.id }}">
<div class="list-group">
{% for task in checklist.tasks.all %}
<div class="list-group-item">
<input type="checkbox" disabled{% if task.completion_date %} checked{% endif %}>
{{ task }}
{% if task.completion_date %}
<i>
({% trans "Completed on" %} {{ task.completion_date }})
</i>
{% endif %}
</div>
{% endfor %}
</div>
</div>
<div class="card-footer">
<div class="progress">
{% widthratio checklist.tasks.completed.count checklist.tasks.count 100 as width %}
<div class="progress-bar" role="progressbar" style="width: {{ width }}%" aria-valuenow="{{ width }}" aria-valuemin="0" aria-valuemax="100">
{{ width }}%
</div>
</div>
</div>
</div>
</div>
{% endfor %}
<div class="col-sm-4 col-xs-12">
<div class="card">
<div class="card-header">
<h4>Add a checklist</h4>
</div>
<div class="card-body">
TODO
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr> <tr>
<td id="ticket-description" colspan='4'> <td id="ticket-description" colspan='4'>
<h4>{% trans "Description" %}</h4> <h4>{% trans "Description" %}</h4>