From 0bd10b6dfa45b9e2af48fe7045d64c40e8a7360a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 25 Jan 2022 14:45:38 +0100 Subject: [PATCH] show-hide files combined into one js file --- .../page/person_resource/freetext-input.js | 25 --------------- .../page/person_resource/showhide-input.js | 32 ++++++++++++++++++- .../page/person_resource/thirdparty-input.js | 25 --------------- .../views/PersonResource/list.html.twig | 28 +++++++--------- .../ChillPersonBundle/chill.webpack.config.js | 4 +-- 5 files changed, 43 insertions(+), 71 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/freetext-input.js delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js 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 deleted file mode 100644 index 65b66dc13..000000000 --- a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/freetext-input.js +++ /dev/null @@ -1,25 +0,0 @@ -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/showhide-input.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/showhide-input.js index da5f812c6..d9da5eb79 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/showhide-input.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/showhide-input.js @@ -3,7 +3,9 @@ import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js'; window.addEventListener('DOMContentLoaded', function() { let personContainer = document.querySelector('#person-entity'), - entitySelector = document.querySelector('#entity-selector') + entitySelector = document.querySelector('#entity-selector'), + freetextContainer = document.querySelector('#freetext-entity'), + thirdpartyContainer = document.querySelector('#thirdparty-entity') ; if (null === entitySelector) { return; @@ -22,4 +24,32 @@ window.addEventListener('DOMContentLoaded', function() { return false; }, }) + + 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; + }, + }) + + 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/thirdparty-input.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js deleted file mode 100644 index 876adc7c9..000000000 --- a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/thirdparty-input.js +++ /dev/null @@ -1,25 +0,0 @@ -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/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index b572d9d11..cb542b6a1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -5,16 +5,12 @@ {% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %} {% block js %} - {{ 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') }} + {{ encore_entry_script_tags('page_person_resource_showhide_input') }} {{ encore_entry_script_tags('mod_pickentity_type') }} {% endblock %} {% block css %} - {{ encore_entry_link_tags('page_person_resource_person_input') }} - {{ encore_entry_link_tags('page_person_resource_thirdparty_input') }} - {{ encore_entry_link_tags('page_person_resource_freetext_input') }} + {{ encore_entry_link_tags('page_person_resource_showhide_input') }} {{ encore_entry_link_tags('mod_pickentity_type') }} {% endblock %} @@ -63,17 +59,15 @@ -
-
- {% if resource.kind %} -
-
{{ resource.comment.comment }}
-
- {% else %} -

{{ 'no comment found'|trans|capitalize }}

- {% endif %} -
-
+ {% if resource.kind %} +
+
+
+
{{ resource.comment.comment }}
+
+
+
+ {% endif %}
    diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index 109810075..3825d46d7 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -18,8 +18,6 @@ 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_person_resource_showhide_input', __dirname + '/Resources/public/page/person_resource/showhide-input.js'); encore.addEntry('page_suggest_names', __dirname + '/Resources/public/page/person/suggest-names.js'); };