Skip to content

Commit

Permalink
[task_dispensers] remove categories specific code from main code
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonygego committed Aug 9, 2023
1 parent 1cca275 commit c42d44f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 1 addition & 3 deletions inginious/frontend/static/js/task_dispensers.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ function dispenser_util_add_tasks_to_section(button) {
// Copy and add the new fields
var new_modal_clone = $("#edit-modals-template").clone();
new_modal_clone.html(new_modal_clone.html().replaceAll("NEWTASKID", selected_tasks[i]));
new_modal_clone.find(".categories").selectize({delimiter: ",", persist: false,
create: function (input) { return {value: input, text: input}; },
});
$("#edit-modals").append(new_modal_clone.children(".modal"));
$("#edit-modals").trigger("new_task");
dispenser_add_task(selected_tasks[i]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
$("#edit_" + $(this).data("taskid") + " input.categories").val(value).change();
});
});

$(function() {
$("#edit-modals .categories").each(function () {
$(this).selectize({delimiter: ",", persist: false,
create: function (input) { return { value: input, text: input }; }
});
});
$("#edit-modals").on("new_task", function () {
$(this).find(".categories").last().selectize({delimiter: ",", persist: false,
create: function (input) { return { value: input, text: input }; }
});
});
});
</script>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,6 @@ <h4>{{ _("Import from course filesystem") }}</h4>
});
});

$("#edit-modals .categories").each(function(){
$(this).selectize({
delimiter: ",",
persist: false,
create: function (input) {
return {
value: input,
text: input,
};
},
});
});

dispenser_util_adapt_viewport();
$(window).on( "resize", dispenser_util_adapt_viewport);
});
Expand Down

0 comments on commit c42d44f

Please sign in to comment.