aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/store/courseware/public-structure.module.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/vue/store/courseware/public-structure.module.js')
-rw-r--r--resources/vue/store/courseware/public-structure.module.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/resources/vue/store/courseware/public-structure.module.js b/resources/vue/store/courseware/public-structure.module.js
index af8f262..fba2384 100644
--- a/resources/vue/store/courseware/public-structure.module.js
+++ b/resources/vue/store/courseware/public-structure.module.js
@@ -52,8 +52,35 @@ const actions = {
commit('setChildren', children);
const ordered = [...visitTree(children, context.rootId)];
+
commit('setOrdered', ordered);
},
+ async load({ dispatch, rootGetters }) {
+ const context = rootGetters['context'];
+
+ await dispatch('courseware-structural-elements/loadById', {
+ id: context.rootId,
+ options: {
+ include: 'containers,containers.blocks',
+ },
+ }, { root: true });
+ const root = rootGetters['courseware-structural-elements/byId']({id: context.rootId});
+ await dispatch('loadDescendants', { root });
+ },
+ loadDescendants({ dispatch }, { root }) {
+ const parent = { id: root.id, type: root.type };
+ const relationship = 'descendants';
+ const options = {
+ 'page[offset]': 0,
+ 'page[limit]': 10000,
+ };
+
+ return dispatch(
+ 'courseware-structural-elements/loadRelated',
+ { parent, relationship, options },
+ { root: true }
+ );
+ },
};
function* visitTree(tree, current) {