-
Notifications
You must be signed in to change notification settings - Fork 135
/
categories.html
46 lines (40 loc) · 1.71 KB
/
categories.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for #}
{# more information about the licensing of this file. #}
{% if short %}
{% set categories = element.get_task_dispenser().get_categories(taskid) %}
{{_("Categories")}} :
<span class="categories-span">{{ ','.join(categories) }}</span>
{% else %}
<div class="mt-3">{{_("Categories")}}</div>
<div class="form-group categories">
<input id="categories{%if grouped %}_grouped{% endif %}" type="text" class="form-control" placeholder="{{ _('Tag name, separated by commas') }}">
</div>
{% if not grouped %}
<script>
// Feed modal
$("#edit_task_modal").on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var taskid = button.data('taskid');
if (!("categories" in dispenser_config[taskid]))
return;
var field = $(this).find(".categories input");
field.val(dispenser_config[taskid]["categories"].join(','));
});
// Catch modal changes
$("#edit_task_modal .categories input").change(function () {
var taskid = $("#edit_task_modal").data("taskid");
dispenser_config[taskid]["categories"] = $(this).val().split(",");
$("#task_" + taskid + " .categories-span").text($(this).val()).change();
});
// Catch grouped action changes
$("#grouped-actions-edit .categories input").change(function () {
let value = $(this).val();
$(".grouped-actions-task:checked").each(function () {
var taskid = $(this).data("taskid");
dispenser_config[taskid]["categories"] = value.split(",");
$("#task_" + taskid + " .categories-span").text(value);
});
});
</script>
{% endif %}
{% endif %}