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');
|
signatureTypeChoices = document.querySelector('#signature-type-choice');
|
||||||
;
|
;
|
||||||
|
|
||||||
console.log('signature type', signatureTypeChoices);
|
|
||||||
|
|
||||||
let
|
let
|
||||||
transitionFilterContainer = document.querySelector('#transitionFilter'),
|
transitionFilterContainer = document.querySelector('#transitionFilter'),
|
||||||
transitionsContainer = document.querySelector('#transitions')
|
transitionsContainer = document.querySelector('#transitions')
|
||||||
@ -21,39 +19,26 @@ window.addEventListener('DOMContentLoaded', function() {
|
|||||||
futureDestUsersContainer.style.display = 'none';
|
futureDestUsersContainer.style.display = 'none';
|
||||||
signatureTypeChoices.style.display = 'none';
|
signatureTypeChoices.style.display = 'none';
|
||||||
|
|
||||||
// ShowHide instance for signatureTypeChoices and futureDestUsersContainer
|
// ShowHide instance for signatureTypeChoices
|
||||||
new ShowHide({
|
new ShowHide({
|
||||||
load_event: null,
|
debug: true,
|
||||||
froms: [transitionsContainer],
|
froms: [divTransitions],
|
||||||
container: [signatureTypeChoices, futureDestUsersContainer],
|
container: [signatureTypeChoices],
|
||||||
test: function() {
|
test: function(transitions) {
|
||||||
const selectedTransition = document.querySelector('input[name="workflow_step[transition]"]:checked');
|
for (let transition of transitions) {
|
||||||
console.log('transition', selectedTransition)
|
for (let input of transition.querySelectorAll('input')) {
|
||||||
if (!selectedTransition) {
|
if (input.checked) {
|
||||||
return false; // No transition selected, hide all
|
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() {
|
signatureTypeChoices.addEventListener('change', function() {
|
||||||
// ShowHide instance for personSignatureField and userSignatureField
|
// ShowHide instance for personSignatureField and userSignatureField
|
||||||
new ShowHide({
|
new ShowHide({
|
||||||
@ -61,9 +46,7 @@ window.addEventListener('DOMContentLoaded', function() {
|
|||||||
froms: [signatureTypeChoices],
|
froms: [signatureTypeChoices],
|
||||||
container: [personSignatureField, userSignatureField],
|
container: [personSignatureField, userSignatureField],
|
||||||
test: function() {
|
test: function() {
|
||||||
console.log(signatureTypeChoices)
|
|
||||||
const selectedSignatureType = document.querySelector('input[name="workflow_step[isPersonOrUserSignature]"]:checked');
|
const selectedSignatureType = document.querySelector('input[name="workflow_step[isPersonOrUserSignature]"]:checked');
|
||||||
console.log('signataure type', selectedSignatureType)
|
|
||||||
if (!selectedSignatureType) {
|
if (!selectedSignatureType) {
|
||||||
return false; // No signature type selected, hide both fields
|
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
|
return true; // Always return true to ensure ShowHide manages visibility
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
|
|
||||||
if (null !== divTransitions) {
|
/* if (null !== divTransitions) {
|
||||||
new ShowHide({
|
new ShowHide({
|
||||||
load_event: null,
|
load_event: null,
|
||||||
froms: [divTransitions],
|
froms: [divTransitions],
|
||||||
container: [futureDestUsersContainer],
|
container: [futureDestUsersContainer],
|
||||||
test: function(divs, arg2, arg3) {
|
test: function(divs, arg2, arg3) {
|
||||||
for (let div of divs) {
|
for (let div of divs) {
|
||||||
for (let input of div.querySelectorAll('input')) {
|
for (let input of div.querySelectorAll('input')) {
|
||||||
if (input.checked) {
|
if (input.checked) {
|
||||||
if (input.dataset.toFinal === "1") {
|
if (input.dataset.toFinal === "1") {
|
||||||
@ -105,7 +88,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