diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/freetext-input.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/freetext-input.js new file mode 100644 index 000000000..65b66dc13 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/freetext-input.js @@ -0,0 +1,25 @@ +import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js'; + +window.addEventListener('DOMContentLoaded', function() { + let + freetextContainer = document.querySelector('#freetext-entity'), + entitySelector = document.querySelector('#entity-selector') + ; + if (null === entitySelector) { + return; + } + + new ShowHide({ + debug: true, + load_event: null, + froms: [entitySelector], + container: [freetextContainer], + test: function(froms, event) { + for (let container of froms) { + return container.querySelector('input[value="freetext"]').checked; + } + console.log('we couldnt find the input'); + return false; + }, + }) +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/person-input.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/person-input.js index b7007dd2b..da5f812c6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/person-input.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/person-input.js @@ -2,26 +2,24 @@ import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js'; window.addEventListener('DOMContentLoaded', function() { let - linkedEntityContainer = document.querySelector('#linked-entity'), personContainer = document.querySelector('#person-entity'), - thirdpartyContainer = document.querySelector('#thirdparty-entity'), - freetextContainer = document.querySelector('#freetext-entity') + entitySelector = document.querySelector('#entity-selector') ; - if (null === linkedEntityContainer) { + if (null === entitySelector) { return; } new ShowHide({ debug: true, load_event: null, - froms: [linkedEntityContainer], - container: [personContainer, thirdpartyContainer, freetextContainer], + froms: [entitySelector], + container: [personContainer], test: function(froms, event) { - if (event) { - console.log(event); + for (let container of froms) { + return container.querySelector('input[value="person"]').checked; } - - return true; + console.log('we couldnt find the input'); + return false; }, }) }); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js new file mode 100644 index 000000000..876adc7c9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js @@ -0,0 +1,25 @@ +import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js'; + +window.addEventListener('DOMContentLoaded', function() { + let + thirdpartyContainer = document.querySelector('#thirdparty-entity'), + entitySelector = document.querySelector('#entity-selector') + ; + if (null === entitySelector) { + return; + } + + new ShowHide({ + debug: true, + load_event: null, + froms: [entitySelector], + container: [thirdpartyContainer], + test: function(froms, event) { + for (let container of froms) { + return container.querySelector('input[value="thirdparty"]').checked; + } + console.log('we couldnt find the input'); + return false; + }, + }) +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig index 6b9389f3b..9bf140b0f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -9,7 +9,7 @@