mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-06 09:46:51 +02:00
Exclude related JavaScript function from staff Ticket view when attachments are not enabled
This commit is contained in:
parent
3dcbdad638
commit
78cf89ca9b
@ -266,71 +266,74 @@ $( function() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type='text/javascript' language='javascript'>
|
<script type='text/javascript' language='javascript'>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#ShowFurtherEditOptions").click(function() {
|
$("#ShowFurtherEditOptions").click(function() {
|
||||||
$("#FurtherEditOptions").toggle();
|
$("#FurtherEditOptions").toggle();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#ShowChecklistEditOptions").click(function() {
|
$("#ShowChecklistEditOptions").click(function() {
|
||||||
$("#checklistEdit").toggle();
|
$("#checklistEdit").toggle();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#ShowFileUpload").click(function() {
|
$('#id_preset').change(function() {
|
||||||
$("#FileUpload").fadeIn();
|
preset = $('#id_preset').val();
|
||||||
$("#ShowFileUploadPara").hide();
|
if (preset != '') {
|
||||||
});
|
$.get("{% url 'helpdesk:raw' 'preset' %}?id=" + preset, function(data) {
|
||||||
|
$("#commentBox").val(data)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#id_preset').change(function() {
|
// Preset name of checklist when a template is selected
|
||||||
preset = $('#id_preset').val();
|
$('#id_checklist_template').on('change', function() {
|
||||||
if (preset != '') {
|
const nameField = $('#id_name')
|
||||||
$.get("{% url 'helpdesk:raw' 'preset' %}?id=" + preset, function(data) {
|
const selectedTemplate = $(this).children(':selected')
|
||||||
$("#commentBox").val(data)
|
if (nameField.val() === '' && selectedTemplate.val()) {
|
||||||
});
|
nameField.val(selectedTemplate.text())
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// Preset name of checklist when a template is selected
|
$('.disabledTask').on('click', () => {
|
||||||
$('#id_checklist_template').on('change', function() {
|
alert('{% trans 'If you want to update state of checklist tasks, please do a Follow-Up response and click on "Update checklists"' %}')
|
||||||
const nameField = $('#id_name')
|
})
|
||||||
const selectedTemplate = $(this).children(':selected')
|
|
||||||
if (nameField.val() === '' && selectedTemplate.val()) {
|
|
||||||
nameField.val(selectedTemplate.text())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$('.disabledTask').on('click', () => {
|
$("[data-toggle=tooltip]").tooltip();
|
||||||
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();
|
{% 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
|
// lists for file input change events, then updates the associated text label
|
||||||
// with the file name selected
|
// with the file name selected
|
||||||
$('.add_file_fields_wrap').on('fileselect', ':file', function(event, numFiles, label, browseButtonNum) {
|
$('.add_file_fields_wrap').on('fileselect', ':file', function(event, numFiles, label, browseButtonNum) {
|
||||||
$("#selectedfilename"+browseButtonNum).html(label);
|
$("#selectedfilename"+browseButtonNum).html(label);
|
||||||
});
|
});
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var wrapper = $(".add_file_fields_wrap"); //Fields wrapper
|
var wrapper = $(".add_file_fields_wrap"); //Fields wrapper
|
||||||
var add_button = $(".add_file_field_button"); //Add button ID
|
var add_button = $(".add_file_field_button"); //Add button ID
|
||||||
|
|
||||||
$(add_button).click(function(e){ //on add input button click
|
$(add_button).click(function(e){ //on add input button click
|
||||||
x++;
|
x++;
|
||||||
e.preventDefault();
|
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> </span><span id='selectedfilename" + x + "'>{% trans 'No files selected.' %}</span></div>"); //add input box
|
$(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> </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
|
||||||
// this function listens for changes on any file input, and
|
// emits the appropriate event to update the input's text.
|
||||||
// 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...)
|
||||||
// Needed to have properly styled file input buttons! (this really shouldn't be this hard...)
|
$(document).on('change', ':file', function() {
|
||||||
$(document).on('change', ':file', function() {
|
var input = $(this),
|
||||||
var input = $(this),
|
inputWidgetNum = $(this).attr('id').split("file")[1],
|
||||||
inputWidgetNum = $(this).attr('id').split("file")[1],
|
numFiles = input.get(0).files ? input.get(0).files.length : 1,
|
||||||
numFiles = input.get(0).files ? input.get(0).files.length : 1,
|
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
|
||||||
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
|
input.trigger('fileselect', [numFiles, label, inputWidgetNum]);
|
||||||
input.trigger('fileselect', [numFiles, label, inputWidgetNum]);
|
});
|
||||||
});
|
{% endif %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user