Select Git revision
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Jan-Hendrik Willms authored
Closes #3700 Merge request studip/studip!2569
Jan-Hendrik Willms authoredCloses #3700 Merge request studip/studip!2569
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
vue.js 1.97 KiB
/**
* The following block of code is used to automatically register your
* Vue components. It will recursively scan this directory for the Vue
* components and automatically register them with their "basename".
*
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
*/
STUDIP.ready(() => {
$('[data-vue-app]').each(function () {
if ($(this).is('[data-vue-app-created]')) {
return;
}
const config = Object.assign({}, {
id: false,
components: [],
store: false
}, $(this).data().vueApp);
let data = {};
if (config.id && window.STUDIP.AppData && window.STUDIP.AppData.hasOwnProperty(config.id)) {
data = window.STUDIP.AppData[config.id];
}
let components = {};
config.components.forEach(component => {
components[component] = () => import(`../../../vue/components/${component}.vue`);
});
STUDIP.Vue.load().then(async ({createApp, store}) => {
let vm;
if (config.store) {
const storeConfig = await import(`../../../vue/store/${config.store}.js`);
console.log('store', storeConfig.default);
store.registerModule(config.id, storeConfig.default, {root: true});
Object.keys(data).forEach(command => {
store.commit(`${config.id}/${command}`, data[command]);
});
vm = createApp({
components,
...mapGetters()
});
} else {
vm = createApp({data, components});
}
// import myCoursesStore from '../stores/MyCoursesStore.js';
//
// myCoursesStore.namespaced = true;
//
// store.registerModule('my-courses', myCoursesStore);
vm.$mount(this);
});
$(this).attr('data-vue-app-created', '');
});
});