mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Adjust implementation of showHide (wip)
This commit is contained in:
parent
7351a35c42
commit
c33e4adeec
@ -9,8 +9,6 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
signatureTypeChoices = document.querySelector('#signature-type-choice');
|
||||
;
|
||||
|
||||
console.log('signature type', signatureTypeChoices);
|
||||
|
||||
let
|
||||
transitionFilterContainer = document.querySelector('#transitionFilter'),
|
||||
transitionsContainer = document.querySelector('#transitions')
|
||||
@ -21,39 +19,26 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
futureDestUsersContainer.style.display = 'none';
|
||||
signatureTypeChoices.style.display = 'none';
|
||||
|
||||
// ShowHide instance for signatureTypeChoices and futureDestUsersContainer
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [transitionsContainer],
|
||||
container: [signatureTypeChoices, futureDestUsersContainer],
|
||||
test: function() {
|
||||
const selectedTransition = document.querySelector('input[name="workflow_step[transition]"]:checked');
|
||||
console.log('transition', selectedTransition)
|
||||
if (!selectedTransition) {
|
||||
return false; // No transition selected, hide all
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
|
||||
const isSignature = JSON.parse(selectedTransition.getAttribute('data-is-signature') || '[]');
|
||||
|
||||
if (isSignature.includes('person') && isSignature.includes('user')) {
|
||||
signatureTypeChoices.style.display = '';
|
||||
} else {
|
||||
signatureTypeChoices.style.display = 'none';
|
||||
}
|
||||
|
||||
if (!isSignature.length) {
|
||||
futureDestUsersContainer.style.display = '';
|
||||
personSignatureField.style.display = 'none';
|
||||
userSignatureField.style.display = 'none';
|
||||
} else {
|
||||
futureDestUsersContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
return true; // Always return true to ensure ShowHide manages visibility
|
||||
}
|
||||
});
|
||||
|
||||
// Event listener for changes in signature type selection
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* // Event listener for changes in signature type selection
|
||||
signatureTypeChoices.addEventListener('change', function() {
|
||||
// ShowHide instance for personSignatureField and userSignatureField
|
||||
new ShowHide({
|
||||
@ -61,9 +46,7 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
froms: [signatureTypeChoices],
|
||||
container: [personSignatureField, userSignatureField],
|
||||
test: function() {
|
||||
console.log(signatureTypeChoices)
|
||||
const selectedSignatureType = document.querySelector('input[name="workflow_step[isPersonOrUserSignature]"]:checked');
|
||||
console.log('signataure type', selectedSignatureType)
|
||||
if (!selectedSignatureType) {
|
||||
return false; // No signature type selected, hide both fields
|
||||
}
|
||||
@ -82,15 +65,15 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
return true; // Always return true to ensure ShowHide manages visibility
|
||||
}
|
||||
});
|
||||
});
|
||||
});*/
|
||||
|
||||
if (null !== divTransitions) {
|
||||
/* if (null !== divTransitions) {
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [divTransitions],
|
||||
container: [futureDestUsersContainer],
|
||||
test: function(divs, arg2, arg3) {
|
||||
for (let div of divs) {
|
||||
for (let div of divs) {
|
||||
for (let input of div.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
if (input.dataset.toFinal === "1") {
|
||||
@ -105,7 +88,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