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

Add empty states to various coach tables and widgets #5051

Merged
23 changes: 23 additions & 0 deletions kolibri/core/assets/src/views/CoreTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
default: false,
required: false,
},
emptyMessage: {
type: String,
required: false,
},
},
computed: {
tHeadStyle() {
Expand Down Expand Up @@ -38,11 +42,20 @@
},
},
render(createElement) {
let tableHasRows = true;
this.$slots.thead.forEach(thead => {
thead.data.style = Object.assign(thead.data.style || {}, this.tHeadStyle);
});

this.$slots.tbody.forEach(tbody => {
// Need to check componentOptions if wrapped in <transition-group>, or just children
// if in regular <tbody>
if (tbody.componentOptions && tbody.componentOptions.children) {
tableHasRows = tbody.componentOptions.children.length > 0;
}

if (tbody.children) {
tableHasRows = tbody.children.length > 0;
tbody.children.forEach(child => {
if (!child.data) {
child.data = {};
Expand All @@ -56,12 +69,18 @@
});
}
});

// Insert an empty message as a <p> at the end if it is provided and the
// table has no rows.
const showEmptyMessage = this.emptyMessage && !tableHasRows;

return createElement('div', { class: 'core-table-container' }, [
createElement('table', { class: 'core-table' }, [
...(this.$slots.default || []),
this.$slots.thead,
this.$slots.tbody,
]),
showEmptyMessage && createElement('p', this.emptyMessage),
]);
},
};
Expand Down Expand Up @@ -110,4 +129,8 @@
}
}

/deep/ .core-table-button-col {
padding: 4px;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
computed: {
...mapGetters('coachNotifications', ['summarizedNotifications']),
notifications() {
return orderBy(this.summarizedNotifications, 'lastId', ['desc']).slice(
0,
MAX_NOTIFICATIONS
);
return orderBy(this.summarizedNotifications, ({ lastId }) => Number(lastId), [
'desc',
]).slice(0, MAX_NOTIFICATIONS);
},
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,11 @@
/>
</KGridItem>

<KGridItem size="75" percentage>
<KGridItem size="100" percentage>
<StatusSummary
:tally="tally"
/>
</KGridItem>

<KGridItem size="25" percentage alignment="right">
<HelpNeeded
v-if="tally.helpNeeded"
:count="tally.helpNeeded"
:verbose="false"
:ratio="false"
/>
</KGridItem>
</KGrid>
</router-link>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{{ coachStrings.$tr('lessonsLabel') }}
</KLabeledIcon>

<p v-if="table.length === 0">
{{ coachStrings.$tr('lessonListEmptyState') }}
</p>

<BlockItem
v-for="tableRow in table"
:key="tableRow.key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{{ coachStrings.$tr('quizzesLabel') }}
</KLabeledIcon>

<p v-if="table.length === 0">
{{ coachStrings.$tr('quizListEmptyState') }}
</p>

<BlockItem
v-for="tableRow in table"
:key="tableRow.key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<QuizActive :active="exam.active" />
</td>

<td class="options">
<td class="options core-table-button-col">
<KDropdownMenu
slot="optionsDropdown"
:text="examReportPageStrings.$tr('options')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<td>
{{ group.users.length }}
</td>
<td class="ta-r">
<td class="ta-r core-table-button-col">
<KDropdownMenu
v-if="!isUngrouped"
appearance="flat-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ActivityList
:notificationParams="notificationParams"
embeddedPageName="ReportsGroupActivityPage"
:noActivityString="coachStrings.$tr('activityListEmptyState')"
/>

</KPageContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<KPageContainer>
<ReportsGroupHeader />
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('learnerListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<KPageContainer>
<ReportsHeader />
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('groupListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('groupNameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<StatusSummary :tally="tally" />
</p>

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('activityListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ReportsGroupReportLessonExerciseHeader />

<h2>{{ coachStrings.$tr('overallLabel') }}</h2>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('questionListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('questionLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<HeaderTable>
<HeaderTableRow>
<template slot="key">{{ coachStrings.$tr('statusLabel') }}</template>
<template slot="value"><LessonActive :active="true" /></template>
<template slot="value"><LessonActive :active="lesson.active" /></template>
</HeaderTableRow>
<!-- TODO COACH
<HeaderTableRow>
Expand All @@ -31,7 +31,7 @@
-->
</HeaderTable>

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('lessonListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<p>
<StatusSummary :tally="tally" />
</p>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('activityListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<ReportsGroupReportQuizHeader />

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('activityListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
<th>{{ coachStrings.$tr('progressLabel') }}</th>
<th>{{ coachStrings.$tr('scoreLabel') }}</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ReportsGroupReportQuizHeader />

<h2>{{ coachStrings.$tr('overallLabel') }}</h2>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('questionListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('questionLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ActivityList
:notificationParams="notificationParams"
embeddedPageName="ReportsLearnerActivityPage"
:noActivityString="coachStrings.$tr('activityListEmptyState')"
/>

</KPageContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<KCheckbox :label="coachStrings.$tr('viewByGroupsLabel')" />
<h2>{{ coachStrings.$tr('overallLabel') }}</h2>
-->
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('learnerListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<HeaderTable>
<HeaderTableRow>
<template slot="key">{{ coachStrings.$tr('statusLabel') }}</template>
<template slot="value"><LessonActive :active="true" /></template>
<template slot="value"><LessonActive :active="lesson.active" /></template>
</HeaderTableRow>
<!-- TODO COACH
<HeaderTableRow>
Expand All @@ -35,7 +35,7 @@
-->
</HeaderTable>

<CoreTable>
<CoreTable :emptyMessage="emptyMessage">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand Down Expand Up @@ -78,13 +78,19 @@

<script>

import { crossComponentTranslator } from 'kolibri.utils.i18n';
import commonCoach from '../common';
import LessonSummaryPage from '../plan/LessonSummaryPage';

const LessonSummaryPageStrings = crossComponentTranslator(LessonSummaryPage);

export default {
name: 'ReportsLearnerReportLessonPage',
components: {},
mixins: [commonCoach],
computed: {
emptyMessage() {
return LessonSummaryPageStrings.$tr('noResourcesInLesson');
},
lesson() {
return this.lessonMap[this.$route.params.lessonId];
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<KGrid>
<KGridItem :sizes="[100, 100, 50]" percentage>
<h2>{{ coachStrings.$tr('lessonsAssignedLabel') }}</h2>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('lessonListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand All @@ -43,7 +43,7 @@
</KGridItem>
<KGridItem :sizes="[100, 100, 50]" percentage>
<h2>{{ coachStrings.$tr('quizzesAssignedLabel') }}</h2>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('quizListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<StatusSummary :tally="tally" />
</p>

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('activityListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->

<h2>{{ coachStrings.$tr('overallLabel') }}</h2>
<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('questionListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('questionLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

<h2>{{ coachStrings.$tr('overallLabel') }}</h2>

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('learnerListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
<th>{{ coachStrings.$tr('nameLabel') }}</th>
<th>{{ coachStrings.$tr('progressLabel') }}</th>
<th>{{ coachStrings.$tr('groupsLabel') }}</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</KLabeledIcon>
</h1>

<CoreTable>
<CoreTable :emptyMessage="coachStrings.$tr('activityListEmptyState')">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:options="filterOptions"
:inline="true"
/>
<CoreTable>
<CoreTable :emptyMessage="emptyMessage">
<thead slot="thead">
<tr>
<th>{{ coachStrings.$tr('titleLabel') }}</th>
Expand Down Expand Up @@ -59,9 +59,13 @@

<script>

import { crossComponentTranslator } from 'kolibri.utils.i18n';
import commonCoach from '../common';
import LessonsRootPage from '../plan/LessonsRootPage';
import ReportsHeader from './ReportsHeader';

const LessonsRootPageStrings = crossComponentTranslator(LessonsRootPage);

export default {
name: 'ReportsLessonListPage',
components: {
Expand All @@ -74,6 +78,17 @@
};
},
computed: {
emptyMessage() {
if (this.filter.value === 'allLessons') {
return this.coachStrings.$tr('lessonListEmptyState');
}
if (this.filter.value === 'activeLessons') {
return LessonsRootPageStrings.$tr('noActiveLessons');
}
if (this.filter.value === 'inactiveLessons') {
return LessonsRootPageStrings.$tr('noInactiveLessons');
}
},
filterOptions() {
return [
{
Expand Down
Loading