Skip to content
Snippets Groups Projects
Select Git revision
  • 60c69f2ab1e5a81eb2196821e5aa932df8e5f6cf
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

Course.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    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', '');
        });
    });