Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Coach > Lessons - 'Recipients' drop-down not working #12911

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
:inline="true"
/>
<KSelect
v-model="filterRecipents"
:value="{ label: coreString('allLabel'), value: coreString('allLabel') }"
class="select"
:label="coachString('recipientsLabel')"
:options="[]"
:options="recipientOptions"
:inline="true"
/>
</div>
Expand Down Expand Up @@ -196,6 +197,7 @@
import useSnackbar from 'kolibri/composables/useSnackbar';
import CoachAppBarPage from '../CoachAppBarPage';
import commonCoach from '../common';
import { coachStrings } from '../common/commonCoachStrings';
import AssignmentDetailsModal from '../common/assignments/AssignmentDetailsModal';
import { useLessons } from '../../composables/useLessons';
import ReportsControls from '../common/ReportsControls';
Expand All @@ -216,10 +218,11 @@
mixins: [commonCoach, commonCoreStrings],
setup() {
const { show } = useKShow();
const { entireClassLabel$ } = coachStrings;
const { lessonsAreLoading } = useLessons();
const { createSnackbar } = useSnackbar();
const { windowIsSmall } = useKResponsiveWindow();
return { show, lessonsAreLoading, createSnackbar, windowIsSmall };
return { show, lessonsAreLoading, createSnackbar, windowIsSmall, entireClassLabel$ };
},
data() {
return {
Expand All @@ -228,6 +231,10 @@
showLessonIsNotVisibleModal: false,
activeLesson: null,
filterSelection: {},
filterRecipents: {
label: this.entireClassLabel$(),
value: this.entireClassLabel$(),
},
detailsModalIsDisabled: false,
dontShowAgainChecked: false,
learnOnlyDevicesExist: false,
Expand All @@ -241,7 +248,7 @@
...mapState('lessonsRoot', ['lessons', 'learnerGroups']),
sortedLessons() {
const sorted = this._.orderBy(this.lessons, ['date_created'], ['desc']);
return sorted.map(lesson => {
const allLessons = sorted.map(lesson => {
const learners = this.getLearnersForLesson(lesson);
const sortedLesson = {
totalLearners: learners.length,
Expand All @@ -253,6 +260,13 @@
Object.assign(sortedLesson, lesson);
return sortedLesson;
});

if (this.filterRecipents.label === this.entireClassLabel$()) {
return allLessons;
}
return allLessons.filter(lesson => {
return lesson.recipientNames.includes(this.filterRecipents.label);
});
},
userHasDismissedModal() {
return Lockr.get(LESSON_VISIBILITY_MODAL_DISMISSED);
Expand Down Expand Up @@ -301,6 +315,26 @@
}
return null;
},
recipientOptions() {
const groupOptions = this.groups.map(group => ({
label: group.name,
value: group.id,
}));

const learnerOptions = this.learners.map(learner => ({
label: learner.name,
value: learner.id,
}));

return [
{
label: this.entireClassLabel$(),
value: this.entireClassLabel$(),
},
...groupOptions,
...learnerOptions,
];
},
},
beforeMount() {
this.filterSelection = this.filterOptions[0];
Expand Down
Loading