Skip to content

Commit

Permalink
Show loader in the table in Coach-Plan-Groups
Browse files Browse the repository at this point in the history
  • Loading branch information
MisRob committed Jul 7, 2023
1 parent 2134f34 commit 9261dab
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
15 changes: 15 additions & 0 deletions kolibri/plugins/coach/assets/src/composables/useGroups.js
Original file line number Diff line number Diff line change
@@ -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,
};
}
11 changes: 9 additions & 2 deletions kolibri/plugins/coach/assets/src/modules/groups/handlers.js
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down Expand Up @@ -36,7 +43,7 @@ export function showGroupsPage(store, classId) {
groups,
groupModalShown: false,
});
store.dispatch('notLoading');
setGroupsLoading(false);
store.dispatch('clearError');
}
},
Expand Down
12 changes: 7 additions & 5 deletions kolibri/plugins/coach/assets/src/views/plan/GroupsPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
/>
</div>

<CoreTable>
<CoreTable
:dataLoading="groupsAreLoading"
:emptyMessage="$tr('noGroups')"
>
<template #headers>
<th>{{ coachString('nameLabel') }}</th>
<th>{{ coreString('learnersLabel') }}</th>
Expand All @@ -38,10 +41,6 @@
</template>
</CoreTable>

<p v-if="!sortedGroups.length">
{{ $tr('noGroups') }}
</p>

<CreateGroupModal
v-if="showCreateGroupModal"
:groups="sortedGroups"
Expand Down Expand Up @@ -79,6 +78,7 @@
import CoreTable from 'kolibri.coreVue.components.CoreTable';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import commonCoach from '../../common';
import { useGroups } from '../../../composables/useGroups';
import CoachAppBarPage from '../../CoachAppBarPage';
import PlanHeader from '../../plan/PlanHeader';
import { GroupModals } from '../../../constants';
Expand All @@ -101,6 +101,7 @@
},
mixins: [commonCoach, commonCoreStrings],
setup() {
const { groupsAreLoading } = useGroups();
const selectedGroup = ref({
name: '',
id: '',
Expand All @@ -113,6 +114,7 @@
setSelectedGroup(name, id) {
selectedGroup.value = { name, id };
},
groupsAreLoading,
};
},
computed: {
Expand Down

0 comments on commit 9261dab

Please sign in to comment.