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 @@
Associer un
-
+
@@ -19,7 +19,7 @@
- +
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index 7e1e191a8..79f05aeed 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -93,5 +93,7 @@ {% endblock %} {% block js %} - {{ encore_entry_script_tags('page_person_resource') }} + {{ encore_entry_script_tags('page_person_resource_person_input') }} + {{ encore_entry_script_tags('page_person_resource_thirdparty_input') }} + {{ encore_entry_script_tags('page_person_resource_freetext_input') }} {% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index 968c0a751..45003307b 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -18,6 +18,9 @@ module.exports = function(encore, entries) encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js'); encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js'); encore.addEntry('page_accompanying_course_index_masonry', __dirname + '/Resources/public/page/accompanying_course_index/masonry.js'); + encore.addEntry('page_person_resource_person_input', __dirname + '/Resources/public/page/person_resource/person-input.js'); + encore.addEntry('page_person_resource_thirdparty_input', __dirname + '/Resources/public/page/person_resource/thirdparty-input.js'); + encore.addEntry('page_person_resource_freetext_input', __dirname + '/Resources/public/page/person_resource/freetext-input.js'); encore.addEntry('page_suggest_names', __dirname + '/Resources/public/page/person/suggest-names.js'); encore.addEntry('page_person_resource', __dirname + '/Resources/public/page/person_resource/index.js'); };