Exclude related JavaScript function from staff Ticket view when attachments are not enabled

This commit is contained in:
Georg Lehner 2024-06-10 11:24:00 +02:00
parent 3dcbdad638
commit 78cf89ca9b

View File

@ -275,11 +275,6 @@ $(document).ready(function() {
$("#checklistEdit").toggle();
});
$("#ShowFileUpload").click(function() {
$("#FileUpload").fadeIn();
$("#ShowFileUploadPara").hide();
});
$('#id_preset').change(function() {
preset = $('#id_preset').val();
if (preset != '') {
@ -304,6 +299,12 @@ $(document).ready(function() {
$("[data-toggle=tooltip]").tooltip();
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
$("#ShowFileUpload").click(function() {
$("#FileUpload").fadeIn();
$("#ShowFileUploadPara").hide();
});
// lists for file input change events, then updates the associated text label
// with the file name selected
$('.add_file_fields_wrap').on('fileselect', ':file', function(event, numFiles, label, browseButtonNum) {
@ -319,9 +320,10 @@ $(document).ready(function() {
e.preventDefault();
$(wrapper).append("<div><label class='btn btn-primary btn-sm btn-file'>Browse... <input type='file' name='attachment' id='file" + x + "' multiple style='display: none;'/></label><span>&nbsp;</span><span id='selectedfilename" + x + "'>{% trans 'No files selected.' %}</span></div>"); //add input box
});
{% endif %}
});
{% if helpdesk_settings.HELPDESK_ENABLE_ATTACHMENTS %}
// this function listens for changes on any file input, and
// emits the appropriate event to update the input's text.
// Needed to have properly styled file input buttons! (this really shouldn't be this hard...)
@ -332,5 +334,6 @@ $(document).on('change', ':file', function() {
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [numFiles, label, inputWidgetNum]);
});
{% endif %}
</script>
{% endblock %}