mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Change funtioning of showHide (wip)
This commit is contained in:
parent
c33e4adeec
commit
1396304af5
@ -14,60 +14,82 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
transitionsContainer = document.querySelector('#transitions')
|
||||
;
|
||||
|
||||
personSignatureField.style.display = 'none';
|
||||
userSignatureField.style.display = 'none';
|
||||
futureDestUsersContainer.style.display = 'none';
|
||||
signatureTypeChoices.style.display = 'none';
|
||||
|
||||
// ShowHide instance for signatureTypeChoices
|
||||
new ShowHide({
|
||||
debug: true,
|
||||
froms: [divTransitions],
|
||||
container: [signatureTypeChoices],
|
||||
test: function(transitions) {
|
||||
for (let transition of transitions) {
|
||||
for (let input of transition.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
const inputData = JSON.parse(input.getAttribute('data-is-signature'))
|
||||
return inputData.includes('person') || inputData.includes('user');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* // Event listener for changes in signature type selection
|
||||
signatureTypeChoices.addEventListener('change', function() {
|
||||
// ShowHide instance for personSignatureField and userSignatureField
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [signatureTypeChoices],
|
||||
container: [personSignatureField, userSignatureField],
|
||||
test: function() {
|
||||
const selectedSignatureType = document.querySelector('input[name="workflow_step[isPersonOrUserSignature]"]:checked');
|
||||
if (!selectedSignatureType) {
|
||||
return false; // No signature type selected, hide both fields
|
||||
}
|
||||
|
||||
if (selectedSignatureType.value === 'person') {
|
||||
personSignatureField.style.display = '';
|
||||
userSignatureField.style.display = 'none';
|
||||
} else if (selectedSignatureType.value === 'user') {
|
||||
personSignatureField.style.display = 'none';
|
||||
userSignatureField.style.display = '';
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
froms: [signatureTypeChoices],
|
||||
container: [personSignatureField],
|
||||
test: function(froms, event) {
|
||||
// console.log('froms', froms)
|
||||
for (let container of froms) {
|
||||
if (container.children.length === 0) {
|
||||
console.log('im empty dont show person or user picker');
|
||||
return false
|
||||
} else {
|
||||
personSignatureField.style.display = 'none';
|
||||
userSignatureField.style.display = 'none';
|
||||
return container.querySelector('input[value="person"]').checked;
|
||||
}
|
||||
|
||||
return true; // Always return true to ensure ShowHide manages visibility
|
||||
}
|
||||
});
|
||||
});*/
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
/* if (null !== divTransitions) {
|
||||
// ShowHide instance for userSignatureField
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
froms: [signatureTypeChoices],
|
||||
container: [userSignatureField],
|
||||
test: function(froms, event) {
|
||||
for (let container of froms) {
|
||||
if (container.children.length === 0) {
|
||||
console.log('im empty dont show person or user picker');
|
||||
return false
|
||||
} else {
|
||||
return container.querySelector('input[value="person"]').checked;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
// ShowHide instance for signatureTypeChoices
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [divTransitions],
|
||||
container: [signatureTypeChoices],
|
||||
test: function(froms, event) {
|
||||
for (let transition of froms) {
|
||||
for (let input of transition.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
const inputData = JSON.parse(input.getAttribute('data-is-signature'))
|
||||
return inputData.includes('person') && inputData.includes('user');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// ShowHide instance for future dest users
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [divTransitions],
|
||||
container: [futureDestUsersContainer],
|
||||
test: function(froms, event) {
|
||||
for (let transition of froms) {
|
||||
for (let input of transition.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
const inputData = JSON.parse(input.getAttribute('data-is-signature'))
|
||||
return !(inputData.includes('person') || inputData.includes('user'));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (null !== divTransitions) {
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [divTransitions],
|
||||
@ -88,7 +110,7 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}*/
|
||||
}
|
||||
|
||||
if (null !== transitionFilterContainer) {
|
||||
transitionsContainer.querySelectorAll('.form-check').forEach(function(row) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user