mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +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')
|
transitionsContainer = document.querySelector('#transitions')
|
||||||
;
|
;
|
||||||
|
|
||||||
personSignatureField.style.display = 'none';
|
new ShowHide({
|
||||||
userSignatureField.style.display = 'none';
|
debug: false,
|
||||||
futureDestUsersContainer.style.display = 'none';
|
froms: [signatureTypeChoices],
|
||||||
signatureTypeChoices.style.display = 'none';
|
container: [personSignatureField],
|
||||||
|
test: function(froms, event) {
|
||||||
// ShowHide instance for signatureTypeChoices
|
// console.log('froms', froms)
|
||||||
new ShowHide({
|
for (let container of froms) {
|
||||||
debug: true,
|
if (container.children.length === 0) {
|
||||||
froms: [divTransitions],
|
console.log('im empty dont show person or user picker');
|
||||||
container: [signatureTypeChoices],
|
return false
|
||||||
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 = '';
|
|
||||||
} else {
|
} else {
|
||||||
personSignatureField.style.display = 'none';
|
return container.querySelector('input[value="person"]').checked;
|
||||||
userSignatureField.style.display = 'none';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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({
|
new ShowHide({
|
||||||
load_event: null,
|
load_event: null,
|
||||||
froms: [divTransitions],
|
froms: [divTransitions],
|
||||||
@ -88,7 +110,7 @@ window.addEventListener('DOMContentLoaded', function() {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (null !== transitionFilterContainer) {
|
if (null !== transitionFilterContainer) {
|
||||||
transitionsContainer.querySelectorAll('.form-check').forEach(function(row) {
|
transitionsContainer.querySelectorAll('.form-check').forEach(function(row) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user