Skip to content
Snippets Groups Projects
Commit a6b17d4d authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

refactor content modules

parent a5af3c2b
No related branches found
No related tags found
1 merge request!14Draft: Data vue app
......@@ -83,18 +83,16 @@ class Course_ContentmodulesController extends AuthenticatedController
Sidebar::Get()->addWidget($widget);
}
PageLayout::addHeadElement('script', [
'type' => 'text/javascript',
], sprintf(
'window.ContentModulesStoreData = %s;',
json_encode([
'setCategories' => $this->categories,
'setHighlighted' => $this->highlighted_modules,
'setModules' => array_values($this->modules),
'setUserId' => User::findCurrent()->id,
'setView' => $GLOBALS['user']->cfg->CONTENTMODULES_TILED_DISPLAY ? 'tiles' : 'table',
])
));
$this->render_vue_app(
Studip\VueApp::create('ContentModules')
->withStore('ContentModulesStore', 'contentmodules', [
'setCategories' => $this->categories,
'setHighlighted' => $this->highlighted_modules,
'setModules' => array_values($this->modules),
'setUserId' => User::findCurrent()->id,
'setView' => $GLOBALS['user']->cfg->CONTENTMODULES_TILED_DISPLAY ? 'tiles' : 'table',
])
);
}
public function trigger_action()
......
<div class="content-modules-vue-app" is="ContentModules"></div>
......@@ -18,7 +18,9 @@
<? endif; ?>
</div>
</div>
<div class="content-modules-controls-vue-app" is="ContentModulesControl" module_id="<?= htmlReady($plugin->getPluginId()) ?>"></div>
<?= Studip\VueApp::create('ContentModulesControl')->withProps([
'module_id' => (string) $plugin->getPluginId(),
]) ?>
<? $keywords = preg_split( "/;/", $metadata['keywords'] ?? '', -1, PREG_SPLIT_NO_EMPTY) ?>
<? if (count($keywords) > 0) : ?>
<ul class="keywords">
......
STUDIP.domReady(() => {
const node = document.querySelector('.content-modules-vue-app');
if (!node) {
return;
}
Promise.all([
STUDIP.Vue.load(),
import('../../../vue/store/ContentModulesStore.js').then((config) => config.default),
import('../../../vue/components/ContentModules.vue').then((component) => component.default),
]).then(([{ createApp, store }, storeConfig, ContentModules]) => {
store.registerModule('contentmodules', storeConfig);
Object.entries(window.ContentModulesStoreData ?? {}).forEach(([key, value]) => {
store.commit(`contentmodules/${key}`, value);
});
const vm = createApp({
components: { ContentModules }
});
vm.$mount(node);
});
});
STUDIP.dialogReady((event) => {
let target = event.target ?? document;
if (target instanceof jQuery) {
target = target.get(0);
}
const node = target.querySelector('.content-modules-controls-vue-app');
if (!node) {
return;
}
Promise.all([
STUDIP.Vue.load(),
import('../../../vue/components/ContentModulesControl.vue').then((component) => component.default),
]).then(([{ createApp }, ContentModulesControl]) => {
const vm = createApp({
components: { ContentModulesControl }
});
vm.$mount(node);
});
});
......@@ -76,7 +76,6 @@ import "./bootstrap/scroll_to_top.js"
import "./bootstrap/admin-courses.js"
import "./bootstrap/oer.js"
import "./bootstrap/courseware.js"
import "./bootstrap/contentmodules.js"
import "./bootstrap/stock-images.js"
import "./bootstrap/external_pages.js"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment