mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
twig pass arguments to vue_address with dataset attributes
This commit is contained in:
@@ -1,13 +1,61 @@
|
||||
import { createApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { addressMessages } from './i18n';
|
||||
import App from './App.vue';
|
||||
|
||||
const i18n = _createI18n( addressMessages );
|
||||
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount('#address');
|
||||
let containers = document.querySelectorAll('.address-container');
|
||||
containers.forEach((container) => {
|
||||
const app = createApp({
|
||||
template: `<app v-bind:addAddress="this.addAddress" ></app>`,
|
||||
data() {
|
||||
return {
|
||||
addAddress: {
|
||||
context: {
|
||||
edit: container.dataset.mode === 'edit',
|
||||
entity: {
|
||||
type: container.dataset.targetEntityName,
|
||||
id: container.dataset.targetEntityId
|
||||
},
|
||||
addressId: container.dataset.addressId | null,
|
||||
backUrl: container.dataset.backUrl,
|
||||
valid: {
|
||||
from: new Date()
|
||||
},
|
||||
},
|
||||
options: {
|
||||
|
||||
/// Options override default.
|
||||
/// null value take default component value defined in AddAddress data()
|
||||
button: {
|
||||
text: {
|
||||
create: container.dataset.buttonText || null,
|
||||
edit: container.dataset.buttonText || null
|
||||
},
|
||||
size: container.dataset.buttonSize || null,
|
||||
displayText: container.dataset.buttonDisplayText //boolean, default: true
|
||||
},
|
||||
|
||||
/// Modal title text if create or edit address (trans chain, see i18n)
|
||||
title: {
|
||||
create: container.dataset.modalTitle || null,
|
||||
edit: container.dataset.modalTitle || null
|
||||
},
|
||||
|
||||
/// Display each step in page or Modal
|
||||
bindModal: {
|
||||
step1: container.dataset.bindModalStep1, //boolean, default: true
|
||||
step2: container.dataset.bindModalStep2 //boolean, default: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount(container);
|
||||
|
||||
console.log('container dataset', container.dataset);
|
||||
});
|
||||
|
Reference in New Issue
Block a user