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

[GSoC] Use KTable in Facility -> Classes #12571

Merged
merged 20 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 2 additions & 1 deletion kolibri/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"js-cookie": "^3.0.5",
"knuth-shuffle-seeded": "^1.0.6",
"kolibri-constants": "0.2.6",
"kolibri-design-system": "5.0.0-rc2",
"kolibri-design-system": "https://github.com/BabyElias/kolibri-design-system#7764ef4b5f9b66ebd90d2ad389ae3d44252437a0",
MisRob marked this conversation as resolved.
Show resolved Hide resolved

"lockr": "0.8.5",
"lodash": "^4.17.21",
"loglevel": "^1.9.1",
Expand Down
146 changes: 79 additions & 67 deletions kolibri/plugins/facility/assets/src/views/ManageClassPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,70 +35,50 @@
</KGridItem>
</KGrid>

<CoreTable
:dataLoading="dataLoading"
<KTable
:headers="tableHeaders"
:rows="tableRows"
:caption="$tr('tableCaption')"
:emptyMessage="$tr('noClassesExist')"
:dataLoading="dataLoading"
sortable
>
<caption class="visuallyhidden">
{{
$tr('tableCaption')
}}
</caption>
<template #headers>
<th>{{ coreString('classNameLabel') }}</th>
<th>{{ coreString('coachesLabel') }}</th>
<th>{{ coreString('learnersLabel') }}</th>
<th>
<span class="visuallyhidden">
{{ coreString('userActionsColumnHeader') }}
</span>
</th>
<template #header="{ header, index }">
<span :class="{ visuallyhidden: index === 3 }">{{ header.label }}</span>
</template>
<template #tbody>
<transition-group
tag="tbody"
name="list"
>
<tr
v-for="classroom in sortedClassrooms"
:key="classroom.id"
<template #cell="{ content, rowIndex, colIndex, row }">
BabyElias marked this conversation as resolved.
Show resolved Hide resolved
<span v-if="colIndex === 0">
<KRouterLink
:text="content"
:to="$store.getters.facilityPageLinks.ClassEditPage(row[3].id)"
icon="classes"
/>
</span>
<span v-else-if="colIndex === 1">
<KOptionalText :text="coachNames(row[3]).length ? formattedCoachNames(row[3]) : ''" />
<KTooltip
v-if="formattedCoachNamesTooltip(row[3])"
:reference="`coachNames${row[3].id}`"
:refs="$refs"
>
<td>
<KRouterLink
:text="classroom.name"
:to="$store.getters.facilityPageLinks.ClassEditPage(classroom.id)"
icon="classes"
/>
</td>
<td>
<span :ref="`coachNames${classroom.id}`">
<KOptionalText
:text="coachNames(classroom).length ? formattedCoachNames(classroom) : ''"
/>
</span>
<KTooltip
v-if="formattedCoachNamesTooltip(classroom)"
:reference="`coachNames${classroom.id}`"
:refs="$refs"
>
{{ formattedCoachNamesTooltip(classroom) }}
</KTooltip>
</td>

<td>
{{ $formatNumber(classroom.learner_count) }}
</td>
<td class="core-table-button-col">
<KButton
appearance="flat-button"
:text="$tr('deleteClass')"
@click="selectClassToDelete(classroom)"
/>
</td>
</tr>
</transition-group>
{{ formattedCoachNamesTooltip(row[3]) }}
</KTooltip>
</span>
<span v-else-if="colIndex === 2">
{{ content }}
</span>
<span
v-else-if="colIndex === 3"
class="core-table-button-col"
>
<KButton
appearance="flat-button"
:text="$tr('deleteClass')"
@click="selectClassToDelete(row[3])"
/>
</span>
</template>
</CoreTable>
</KTable>

<ClassDeleteModal
v-if="Boolean(classToDelete)"
Expand All @@ -108,7 +88,7 @@
/>
<ClassCreateModal
v-if="modalShown === Modals.CREATE_CLASS"
:classes="sortedClassrooms"
:classes="classes"
@cancel="closeModal"
@success="handleCreateSuccess()"
/>
Expand All @@ -121,8 +101,6 @@
<script>

import { mapState, mapActions, mapGetters } from 'vuex';
import CoreTable from 'kolibri.coreVue.components.CoreTable';
import orderBy from 'lodash/orderBy';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import useUser from 'kolibri.coreVue.composables.useUser';
import { Modals } from '../../constants';
Expand All @@ -140,7 +118,6 @@
},
components: {
FacilityAppBarPage,
CoreTable,
ClassCreateModal,
ClassDeleteModal,
},
Expand All @@ -158,9 +135,43 @@
computed: {
...mapState('classManagement', ['modalShown', 'classes', 'dataLoading']),
...mapGetters(['facilityPageLinks']),

Modals: () => Modals,
sortedClassrooms() {
return orderBy(this.classes, [classroom => classroom.name.toUpperCase()], ['asc']);
tableHeaders() {
return [
{
label: this.coreString('classNameLabel'),
dataType: 'string',
minWidth: '150px',
width: '20%',
},
{
label: this.coreString('coachesLabel'),
dataType: 'others',
minWidth: '150px',
width: '30%',
},
{
label: this.coreString('learnersLabel'),
dataType: 'numeric',
minWidth: '150px',
width: '20%',
},
{
label: this.coreString('userActionsColumnHeader'),
dataType: 'others',
minWidth: '150px',
width: '30%',
},
];
},
tableRows() {
return this.classes.map(classroom => [
classroom.name,
this.formattedCoachNames(classroom),
this.$formatNumber(classroom.learner_count),
classroom,
]);
},
},
methods: {
Expand All @@ -183,12 +194,13 @@
}
},
// Duplicated in class-list-page
coachNames(classroom) {
const { coaches } = classroom;
coachNames(classes) {
const { coaches } = classes;
return coaches.map(({ full_name }) => full_name);
},
formattedCoachNames(classroom) {
const coach_names = this.coachNames(classroom);

if (coach_names.length === 1) {
return coach_names[0];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kolibri-core-for-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"js-cookie": "^3.0.5",
"knuth-shuffle-seeded": "^1.0.6",
"kolibri-constants": "0.2.6",
"kolibri-design-system": "5.0.0-rc2",
"kolibri-design-system": "https://github.com/BabyElias/kolibri-design-system#7764ef4b5f9b66ebd90d2ad389ae3d44252437a0",
MisRob marked this conversation as resolved.
Show resolved Hide resolved
"lockr": "0.8.5",
"lodash": "^4.17.21",
"loglevel": "^1.9.1",
Expand Down
51 changes: 35 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2972,15 +2972,6 @@ anymatch@^3.0.3, anymatch@~3.1.2:
normalize-path "^3.0.0"
picomatch "^2.0.4"

"aphrodite@git+https://github.com/learningequality/aphrodite.git":
version "2.2.3"
uid fdc8d7be8912a5cf17f74ff10f124013c52c3e32
resolved "git+https://github.com/learningequality/aphrodite.git#fdc8d7be8912a5cf17f74ff10f124013c52c3e32"
dependencies:
asap "^2.0.3"
inline-style-prefixer "^4.0.2"
string-hash "^1.1.3"

"aphrodite@https://github.com/learningequality/aphrodite/":
version "2.2.3"
resolved "https://github.com/learningequality/aphrodite/#fdc8d7be8912a5cf17f74ff10f124013c52c3e32"
Expand Down Expand Up @@ -3810,7 +3801,7 @@ collect-v8-coverage@^1.0.0:
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59"
integrity sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==

color-convert@^1.9.0:
color-convert@^1.9.0, color-convert@^1.9.3:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
Expand All @@ -3829,16 +3820,32 @@ [email protected]:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=

color-name@~1.1.4:
color-name@^1.0.0, color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

color-string@^1.6.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4"
integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==
dependencies:
color-name "^1.0.0"
simple-swizzle "^0.2.2"

color-support@^1.1.2:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==

[email protected]:
version "3.2.1"
resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164"
integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==
dependencies:
color-convert "^1.9.3"
color-string "^1.6.0"

colord@^2.9.3:
version "2.9.3"
resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.3.tgz#4f8ce919de456f1d5c1c368c307fe20f3e59fb43"
Expand Down Expand Up @@ -6656,6 +6663,11 @@ is-arrayish@^0.2.1:
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=

is-arrayish@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03"
integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==

is-bigint@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3"
Expand Down Expand Up @@ -7668,14 +7680,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/kolibri-constants/-/kolibri-constants-0.2.6.tgz#d13762862505a3a6ec58a104870b21da96778656"
integrity sha512-gQaY2wFNFrsB+9+xQNeEcLHixNuZEK+GHyKKr78s/hg8gFU3YVsnhlYp0u+du4XeVwewpyN1ajGb4UrrdF8rTA==

[email protected]:
version "5.0.0-rc2"
resolved "https://registry.yarnpkg.com/kolibri-design-system/-/kolibri-design-system-5.0.0-rc2.tgz#3f1122e8d198d8b3eeb26a83e864fb9d72f8f2de"
integrity sha512-qt6kbYGPdQUkMb0BxuEK7llU8C1K3Zh/RTUGNm6b1KioVD2yuMHKEwUOhYha0spp9orXYgMIaL6V3KUpVhYz+w==
"kolibri-design-system@https://github.com/BabyElias/kolibri-design-system#7764ef4b5f9b66ebd90d2ad389ae3d44252437a0":
version "5.0.0-rc3"
resolved "https://github.com/BabyElias/kolibri-design-system#7764ef4b5f9b66ebd90d2ad389ae3d44252437a0"
dependencies:
"@vue/composition-api" "1.7.2"
aphrodite "git+https://github.com/learningequality/aphrodite.git"
aphrodite "https://github.com/learningequality/aphrodite/"
autosize "3.0.21"
color "3.2.1"
css-element-queries "1.2.0"
date-fns "1.30.1"
frame-throttle "3.0.0"
Expand Down Expand Up @@ -10291,6 +10303,13 @@ signal-exit@^4.0.1:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04"
integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==

simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==
dependencies:
is-arrayish "^0.3.1"

sisteransi@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
Expand Down