From 9261dababc3db6c45a9b2688231f3dfdd307ea25 Mon Sep 17 00:00:00 2001 From: MisRob Date: Tue, 4 Jul 2023 12:58:47 +0200 Subject: [PATCH] Show loader in the table in Coach-Plan-Groups --- .../coach/assets/src/composables/useGroups.js | 15 +++++++++++++++ .../coach/assets/src/modules/groups/handlers.js | 11 +++++++++-- .../assets/src/views/plan/GroupsPage/index.vue | 12 +++++++----- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 kolibri/plugins/coach/assets/src/composables/useGroups.js diff --git a/kolibri/plugins/coach/assets/src/composables/useGroups.js b/kolibri/plugins/coach/assets/src/composables/useGroups.js new file mode 100644 index 00000000000..9cac09dc6f9 --- /dev/null +++ b/kolibri/plugins/coach/assets/src/composables/useGroups.js @@ -0,0 +1,15 @@ +import { ref } from 'kolibri.lib.vueCompositionApi'; + +// Place outside the function to keep the state +const groupsAreLoading = ref(false); + +export function useGroups() { + function setGroupsLoading(loading) { + groupsAreLoading.value = loading; + } + + return { + groupsAreLoading, + setGroupsLoading, + }; +} diff --git a/kolibri/plugins/coach/assets/src/modules/groups/handlers.js b/kolibri/plugins/coach/assets/src/modules/groups/handlers.js index 918030e533d..ffe9e32b06b 100644 --- a/kolibri/plugins/coach/assets/src/modules/groups/handlers.js +++ b/kolibri/plugins/coach/assets/src/modules/groups/handlers.js @@ -1,8 +1,15 @@ import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator'; import { LearnerGroupResource, FacilityUserResource } from 'kolibri.resources'; +import { useGroups } from '../../composables/useGroups'; + +const { setGroupsLoading } = useGroups(); export function showGroupsPage(store, classId) { - store.dispatch('loading'); + // on this page, don't handle loading state globally so we can do it locally + store.dispatch('notLoading'); + + setGroupsLoading(true); + const promises = [ FacilityUserResource.fetchCollection({ getParams: { member_of: classId }, @@ -36,7 +43,7 @@ export function showGroupsPage(store, classId) { groups, groupModalShown: false, }); - store.dispatch('notLoading'); + setGroupsLoading(false); store.dispatch('clearError'); } }, diff --git a/kolibri/plugins/coach/assets/src/views/plan/GroupsPage/index.vue b/kolibri/plugins/coach/assets/src/views/plan/GroupsPage/index.vue index daa81efcba6..bab3c09b1ef 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/GroupsPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/GroupsPage/index.vue @@ -19,7 +19,10 @@ /> - + -

- {{ $tr('noGroups') }} -

-