Búsquedas recientes


No hay búsquedas recientes

Ben Weaving's Avatar

Ben Weaving

Incorporación 15 abr 2021

·

Última actividad 29 oct 2021

Seguimientos

0

Seguidores

0

Actividad total

8

Votos

2

Suscripciones

4

RESUMEN DE LA ACTIVIDAD

Última actividad de Ben Weaving

Ben Weaving hizo un comentario,

Comentario de la comunidad Feedback - Ticketing system (Support)

We need this for large corporate customers and it's rather bemusing this actually isn't possible on such a fantastic product. Zendesk please look into this as a serious change request.

 

Increments of 5 mins would be ideal!

 

 

Thankyou

Ver comentario · Publicado 26 ene 2021 · Ben Weaving

0

Seguidores

0

Votos

0

Comentarios


Ben Weaving hizo un comentario,

Comentario de la comunidad Discussion - Tips and best practices from the community

I am also struggling to get this functioning.

Code as below

Console log output

Code implemented, changing only the elements you mentioned.

 

 

$(document).ready(function() {
// Function to start observing node for mutations
var startObserveMutations = function (nodeSelector, options, callbackFunction) {
var node = document.querySelector(nodeSelector);
if (node) {
var observer = new MutationObserver(callbackFunction);
observer.observe(node, options);
return observer;
}
};

// Callback function to execute when mutations in form attachments or dropdown are observed:
// clear or select Attachment checkbox according to dropdown
var mutationObservedForm = function (mutationsList) {
mutationsList.forEach(function (mutation) {
if (mutation.type == 'childList') {
setFormAttachmentCheckbox();
}
});
};

// Define some variables for requiring form attachments
var attachmentCheckboxField = 'request_custom_fields_360012233180';
var attachmentCheckboxId = '#' + attachmentCheckboxField;
var attachmentErrorNotification = 'Attachments required before submitting';
var formDropdownClass = '.request_custom_fields_360012190719';
var formObserveMutationOptions = { childList: true, subtree: true };

// Clear or select checkbox according to dropdown and attachments:
// Set Attachment checkbox if no attachments required, or if attachments are required and at least one is uploaded, otherwise clear it
function setFormAttachmentCheckbox() {
if (isFormAttachmentRequired()) {
if ($('#request-attachments-pool .upload-item').length) {
selectCheckbox(attachmentCheckboxId);
}
else {
clearCheckbox(attachmentCheckboxId);
}
}
else {
selectCheckbox(attachmentCheckboxId);
}
}

// Return true if dropdown option 'ABCD' is selected
function isFormAttachmentRequired() {
return $(formDropdownClass + ' a.nesty-input').attr('aria-expanded') &&
$(formDropdownClass + ' a.nesty-input').text() === 'no';
}

// Select checkbox
function selectCheckbox(eltselector) {
$(eltselector).prop('checked', true);
}

// Clear checkbox
function clearCheckbox(eltselector) {
$(eltselector).prop('checked', false);
}

// If attachment checkbox field exists:
// Select the checkbox if attachment is not required
// Watch for changes to attachments and dropdown
if ($(attachmentCheckboxId).length) {
if (!isFormAttachmentRequired(formAttachmentDropdownClass)) {
selectCheckbox(attachmentCheckboxId);
}
startObserveMutations('#request-attachments-pool', formObserveMutationOptions, mutationObservedForm);
startObserveMutations(formDropdownClass, formObserveMutationOptions, mutationObservedForm);
}

// Adjust attachment error notification
var attachmentErrorElt = $('.' + attachmentCheckboxField + ' .notification-error');
if (attachmentErrorElt.length) {
attachmentErrorElt.text(attachmentErrorNotification);
}

Ver comentario · Publicado 14 jul 2020 · Ben Weaving

0

Seguidores

0

Votos

0

Comentarios