feat: split group by graduate

This commit is contained in:
Polianin Nikita 2024-08-31 02:18:55 +03:00
parent 5ee350b66c
commit 42d831892a
3 changed files with 82 additions and 8 deletions

View File

@ -0,0 +1,5 @@
.div-wrapper {
display: block;
width: 100%;
padding: 10px 0;
}

View File

@ -6,11 +6,13 @@
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<mat-chip-listbox hideSingleSelectionIndicator (change)="onFacultySelected($event.value)" #facultyChip> <mat-chip-listbox hideSingleSelectionIndicator (change)="onFacultySelected($event.value)" #facultyChip>
@for (faculty of faculties; track $index) { @for (faculty of faculties; track $index) {
<mat-chip-option [value]="faculty.id" color="accent"> <mat-chip-option [value]="faculty.id" color="accent">
{{ faculty.name }} {{ faculty.name }}
</mat-chip-option> </mat-chip-option>
} }
@if (faculties === null) { @if (faculties === null) {
<app-loading-indicator [loading]="true" <app-loading-indicator [loading]="true"
(retryFunction)="loadFaculties()" (retryFunction)="loadFaculties()"
@ -28,11 +30,13 @@
<mat-chip-listbox hideSingleSelectionIndicator (change)="onCourseSelected($event.value)" <mat-chip-listbox hideSingleSelectionIndicator (change)="onCourseSelected($event.value)"
[formControl]="formChipCourse" [formControl]="formChipCourse"
#courseChip> #courseChip>
@for (course of courseNumbers; track $index) { @for (course of courseNumbers; track $index) {
<mat-chip-option [value]="course" color="accent"> <mat-chip-option [value]="course" color="accent">
{{ course }} {{ course }}
</mat-chip-option> </mat-chip-option>
} }
@if (courseNumbers === null) { @if (courseNumbers === null) {
<app-loading-indicator [loading]="true" <app-loading-indicator [loading]="true"
(retryFunction)="loadCourseGroup()" (retryFunction)="loadCourseGroup()"
@ -50,11 +54,63 @@
<mat-chip-listbox hideSingleSelectionIndicator (change)="onGroupSelected($event.value)" <mat-chip-listbox hideSingleSelectionIndicator (change)="onGroupSelected($event.value)"
[formControl]="formChipGroup" [formControl]="formChipGroup"
#groupChip> #groupChip>
@for (group of filteredGroups; track $index) {
@if (filteredGroupsSpecialist && filteredGroupsSpecialist.length > 0) {
<div class="div-wrapper">
Специалитет:
</div>
<div class="div-wrapper">
@for (group of filteredGroupsSpecialist; track $index) {
<mat-chip-option [value]="group.id" color="accent"> <mat-chip-option [value]="group.id" color="accent">
{{ group.name }} {{ group.name }}
</mat-chip-option> </mat-chip-option>
} }
</div>
}
@if (filteredGroupsSpecialist && filteredGroupsSpecialist.length > 0 && (filteredGroupsBehaviour && filteredGroupsBehaviour.length > 0 || filteredGroupsMagistracy && filteredGroupsMagistracy.length > 0)) {
<div class="div-wrapper">
<hr/>
</div>
}
@if (filteredGroupsBehaviour && filteredGroupsBehaviour.length > 0) {
<div class="div-wrapper">
Бакалавариат:
</div>
<div class="div-wrapper">
@for (group of filteredGroupsBehaviour; track $index) {
<mat-chip-option [value]="group.id" color="accent">
{{ group.name }}
</mat-chip-option>
}
</div>
}
@if (((filteredGroupsSpecialist && filteredGroupsSpecialist.length > 0 && filteredGroupsBehaviour && filteredGroupsBehaviour.length > 0) ||
((!filteredGroupsSpecialist || filteredGroupsSpecialist.length === 0) && filteredGroupsBehaviour && filteredGroupsBehaviour.length > 0)) &&
filteredGroupsMagistracy && filteredGroupsMagistracy.length > 0) {
<div class="div-wrapper">
<hr/>
</div>
}
@if (filteredGroupsMagistracy && filteredGroupsMagistracy.length > 0) {
<div class="div-wrapper">
Магистратура:
</div>
<div>
@for (group of filteredGroupsMagistracy; track $index) {
<mat-chip-option [value]="group.id" color="accent">
{{ group.name }}
</mat-chip-option>
}
</div>
}
@if (faculties === null) { @if (faculties === null) {
<app-loading-indicator [loading]="true" <app-loading-indicator [loading]="true"
(retryFunction)="loadCourseGroup()" (retryFunction)="loadCourseGroup()"

View File

@ -30,7 +30,9 @@ export class GroupComponent implements IScheduleTab {
protected faculties: FacultyResponse[] | null = null; protected faculties: FacultyResponse[] | null = null;
protected courseNumbers: number[] | null = null; protected courseNumbers: number[] | null = null;
private groups: GroupResponse[] | null = null; private groups: GroupResponse[] | null = null;
protected filteredGroups: GroupResponse[] | null = []; protected filteredGroupsBehaviour: GroupResponse[] | null = null;
protected filteredGroupsMagistracy: GroupResponse[] | null = null;
protected filteredGroupsSpecialist: GroupResponse[] | null = null;
protected facultyId: number | null = null; protected facultyId: number | null = null;
protected courseNumber: number | null = null; protected courseNumber: number | null = null;
@ -132,8 +134,17 @@ export class GroupComponent implements IScheduleTab {
return; return;
} }
if (this.courseNumber !== null) if (this.courseNumber !== null) {
this.filteredGroups = this.groups!.filter(x => x.courseNumber === this.courseNumber); const groupByCourse = this.groups!.filter(x => x.courseNumber === this.courseNumber);
groupByCourse.forEach(x => {
if (x.name[2].toUpperCase() === 'Б')
this.filteredGroupsBehaviour?.push(x);
else if (x.name[2].toUpperCase() === 'С')
this.filteredGroupsSpecialist?.push(x);
else
this.filteredGroupsMagistracy?.push(x);
});
}
} }
protected onFacultySelected(index: number) { protected onFacultySelected(index: number) {
@ -156,7 +167,9 @@ export class GroupComponent implements IScheduleTab {
} }
protected onCourseSelected(course: number) { protected onCourseSelected(course: number) {
this.filteredGroups = []; this.filteredGroupsBehaviour = [];
this.filteredGroupsMagistracy = [];
this.filteredGroupsSpecialist = [];
this.formChipGroup.reset(); this.formChipGroup.reset();
if (course === undefined) { if (course === undefined) {