diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js index ad4a648f5..9c5f9eaa7 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js @@ -5,82 +5,89 @@ import App from './App.vue'; const i18n = _createI18n(addressMessages); -let inputs = document.querySelectorAll('input[type="hidden"][data-input-address]'); +const addAddressInput = (inputs) => { -const isNumeric = function(v) { return !isNaN(v); }; + inputs.forEach(el => { + let + addressId = el.value, + uniqid = el.dataset.inputAddress, + container = document.querySelector('div[data-input-address-container="' + uniqid + '"]'), + isEdit = addressId !== '', + addressIdInt = addressId !== '' ? parseInt(addressId) : null + ; -inputs.forEach(el => { - let - addressId = el.value, - uniqid = el.dataset.inputAddress, - container = document.querySelector('div[data-input-address-container="' + uniqid + '"]'), - isEdit = addressId !== '', - addressIdInt = addressId !== '' ? parseInt(addressId) : null - ; + if (container === null) { + throw Error("no container"); + } + console.log('useValidFrom', el.dataset.useValidFrom === '1'); - if (container === null) { - throw Error("no container"); - } - console.log('useValidFrom', el.dataset.useValidFrom === '1'); - - const app = createApp({ - template: ``, - data() { - return { - addAddress: { - context: { - // for legacy ? can be remove ? - target: { - name: 'input-address', - id: addressIdInt, - }, - edit: isEdit, - addressId: addressIdInt, - }, - options: { - /// Options override default. - /// null value take default component value defined in AddAddress data() - button: { - text: { - create: el.dataset.buttonTextCreate || null, - edit: el.dataset.buttonTextUpdate || null, + const app = createApp({ + template: ``, + data() { + return { + addAddress: { + context: { + // for legacy ? can be remove ? + target: { + name: 'input-address', + id: addressIdInt, }, - size: null, - displayText: true + edit: isEdit, + addressId: addressIdInt, }, + options: { + /// Options override default. + /// null value take default component value defined in AddAddress data() + button: { + text: { + create: el.dataset.buttonTextCreate || null, + edit: el.dataset.buttonTextUpdate || null, + }, + size: null, + displayText: true + }, - /// Modal title text if create or edit address (trans chain, see i18n) - title: { - create: null, - edit: null, - }, + /// Modal title text if create or edit address (trans chain, see i18n) + title: { + create: null, + edit: null, + }, - /// Display panes in Modal for step123 - openPanesInModal: true, + /// Display panes in Modal for step123 + openPanesInModal: true, - /// Display actions buttons of panes in a sticky-form-button navbar - stickyActions: false, - showMessageWhenNoAddress: true, + /// Display actions buttons of panes in a sticky-form-button navbar + stickyActions: false, + showMessageWhenNoAddress: true, - /// Use Date fields - useDate: { - validFrom: el.dataset.useValidFrom === '1' || false, //boolean, default: false - validTo: el.dataset.useValidTo === '1' || false, //boolean, default: false - }, + /// Use Date fields + useDate: { + validFrom: el.dataset.useValidFrom === '1' || false, //boolean, default: false + validTo: el.dataset.useValidTo === '1' || false, //boolean, default: false + }, - /// Don't display show renderbox Address: showPane display only a button - onlyButton: false, + /// Don't display show renderbox Address: showPane display only a button + onlyButton: false, + } } } + }, + methods: { + associateToInput(payload) { + el.value = payload.addressId; + } } - }, - methods: { - associateToInput(payload) { - el.value = payload.addressId; - } - } - }) - .use(i18n) - .component('app', App) - .mount(container); -}); + }) + .use(i18n) + .component('app', App) + .mount(container); + }); +}; + +document.addEventListener('DOMContentLoaded', (_e) => + addAddressInput(document.querySelectorAll('input[type="hidden"][data-input-address]')) +); + +window.addEventListener('collection-add-entry', (_e) => + addAddressInput(document.querySelectorAll('input[type="hidden"][data-input-address]')) +); \ No newline at end of file