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 student number to table, sort rooms #616

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions front-end/src/components/Personnel/Students/Students.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
row-hover
@row-click="onEdit"
>
<PrimeColumn
header="№"
header-style="width: 68px"
body-style="width: 68px"
column-key="index"
:sortable="false"
>
<template #body="{ index }">
{{ index + 1 }}
</template>
</PrimeColumn>
<PrimeColumn
field="fullname"
header="ФИО"
Expand Down
24 changes: 24 additions & 0 deletions front-end/src/store/modules/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,30 @@ class Reference extends VuexModule {
return await getFetchRequest(
getRooms,
data => {
data.sort((a, b) => {
const titleA = a.title;
const titleB = b.title;

const numA = Number(titleA);
const numB = Number(titleB);

const isNumA = !Number.isNaN(numA);
const isNumB = !Number.isNaN(numB);

if (isNumA && isNumB) {
return numA - numB;
}

if (isNumA) {
return -1;
}

if (isNumB) {
return 1;
}

return titleA.localeCompare(titleB);
});
this.SET_ROOMS(data);
this.SET_IS_LOADED({ field: "_roomsLoaded", value: true });
},
Expand Down
Loading