diff --git a/assets/vue/mixins/ListMixin.js b/assets/vue/mixins/ListMixin.js index 65c109c15e..43cf4199fb 100644 --- a/assets/vue/mixins/ListMixin.js +++ b/assets/vue/mixins/ListMixin.js @@ -12,7 +12,7 @@ export default { //sortBy: [], vuetify //sortDesc: [], , vuetify page: 1, - itemsPerPage: 5 + itemsPerPage: 20 }, filters: {} }; @@ -40,10 +40,36 @@ export default { this.options.totalItems = this.totalItems; } }, - methods: { + fetchNewItems({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) { + let params = { + ...this.filters + }; + + if (itemsPerPage > 0) { + params = { ...params, itemsPerPage, page }; + } + + if (this.$route.params.node) { + params[`resourceNode.parent`] = this.$route.params.node; + } + + if (isString(sortBy) && isBoolean(sortDesc)) { + //params[`order[${sortBy[0]}]`] = sortDesc[0] ? 'desc' : 'asc' + params[`order[${sortBy}]`] = sortDesc ? 'desc' : 'asc' + } + + //this.resetList = true; + + this.getPage(params).then(() => { + this.options.sortBy = sortBy; + this.options.sortDesc = sortDesc; + this.options.itemsPerPage = itemsPerPage; + this.options.totalItems = totalItems; + }); + }, onUpdateOptions({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) { - console.log({ page, itemsPerPage, sortBy, sortDesc, totalItems }); + //console.log({ page, itemsPerPage, sortBy, sortDesc, totalItems }); let params = { ...this.filters }; @@ -62,7 +88,6 @@ export default { } this.resetList = true; - console.log(params); this.getPage(params).then(() => { this.options.sortBy = sortBy; diff --git a/assets/vue/store/modules/crud.js b/assets/vue/store/modules/crud.js index 1417811044..6976e4169b 100644 --- a/assets/vue/store/modules/crud.js +++ b/assets/vue/store/modules/crud.js @@ -121,7 +121,6 @@ export default function makeCrudModule({ retrieved['hydra:totalItems'] ); commit(ACTIONS.SET_VIEW, retrieved['hydra:view']); - if (true === state.resetList) { commit(ACTIONS.RESET_LIST); } diff --git a/assets/vue/store/security.js b/assets/vue/store/security.js index 7c6fc47958..735107c8aa 100644 --- a/assets/vue/store/security.js +++ b/assets/vue/store/security.js @@ -29,6 +29,9 @@ export default { isAdmin(state, getters) { return getters.isAuthenticated && (getters.hasRole('ROLE_SUPER_ADMIN') || getters.hasRole('ROLE_ADMIN')); }, + isCurrentTeacher(state, getters) { + return getters.isAuthenticated && (getters.hasRole('ROLE_CURRENT_COURSE_TEACHER')); + }, getUser(state) { return state.user; }, diff --git a/assets/vue/views/documents/List.vue b/assets/vue/views/documents/List.vue index cfd1dfe58c..12941bade2 100644 --- a/assets/vue/views/documents/List.vue +++ b/assets/vue/views/documents/List.vue @@ -27,6 +27,20 @@ + + + + + + + + + + + + + + - + + + + + + + + + +