feat: grouped pair by group
All checks were successful
Build and Deploy Angular App / build (push) Successful in 49s
All checks were successful
Build and Deploy Angular App / build (push) Successful in 49s
This commit is contained in:
parent
9d9302525b
commit
4bfd919bbc
@ -1,4 +1,5 @@
|
|||||||
<section class="mat-elevation-z8 table-section" tabindex="0" [style.overflow]="(dataSource.length === 0 || isLoad ? 'hidden' : 'auto')">
|
<section class="mat-elevation-z8 table-section" tabindex="0"
|
||||||
|
[style.overflow]="(dataSource.length === 0 || isLoad ? 'hidden' : 'auto')">
|
||||||
@if (dataSource.length === 0 || isLoad) {
|
@if (dataSource.length === 0 || isLoad) {
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
@if (isLoad) {
|
@if (isLoad) {
|
||||||
@ -97,14 +98,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<!-- Group -->
|
<!-- Group -->
|
||||||
@if (!isOneGroup) {
|
|
||||||
<div class="mat-body">
|
<div class="mat-body">
|
||||||
<i>
|
<i>
|
||||||
<mat-icon fontIcon="group"/>
|
<mat-icon fontIcon="group"/>
|
||||||
</i>
|
</i>
|
||||||
{{ elementData["group"] }}
|
{{ elementData["group"] }}
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
@if ($index + 1 !== element.data[daysOfWeek.indexOf(day) + 1].length) {
|
@if ($index + 1 !== element.data[daysOfWeek.indexOf(day) + 1].length) {
|
||||||
<hr style="margin: 10px 0;"/>
|
<hr style="margin: 10px 0;"/>
|
||||||
|
@ -31,17 +31,16 @@ interface Dictionary {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export class TableComponent implements OnChanges {
|
export class TableComponent implements OnChanges {
|
||||||
|
@Input() currentWeek!: number;
|
||||||
|
@Input() startWeek!: Date;
|
||||||
|
@Input() isLoad: boolean = false;
|
||||||
|
|
||||||
private isDisciplineWithWeeks: boolean = false;
|
private isDisciplineWithWeeks: boolean = false;
|
||||||
protected tableDataSource: MatTableDataSource<TableData> = new MatTableDataSource<TableData>([]);
|
protected tableDataSource: MatTableDataSource<TableData> = new MatTableDataSource<TableData>([]);
|
||||||
private backupDisciplines: string[] = [];
|
private backupDisciplines: string[] = [];
|
||||||
protected daysOfWeek: string[] = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'];
|
protected daysOfWeek: string[] = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'];
|
||||||
protected displayedColumns: string[] = ['pairNumber'];
|
protected displayedColumns: string[] = ['pairNumber'];
|
||||||
protected dataSource: ScheduleResponse[] = [];
|
protected dataSource: ScheduleResponse[] = [];
|
||||||
protected isOneGroup: boolean = false;
|
|
||||||
|
|
||||||
@Input() currentWeek!: number;
|
|
||||||
@Input() startWeek!: Date;
|
|
||||||
@Input() isLoad: boolean = false;
|
|
||||||
|
|
||||||
@Input() set disciplineWithWeeks(value: boolean) {
|
@Input() set disciplineWithWeeks(value: boolean) {
|
||||||
this.isDisciplineWithWeeks = value;
|
this.isDisciplineWithWeeks = value;
|
||||||
@ -51,7 +50,6 @@ export class TableComponent implements OnChanges {
|
|||||||
@Input() set data(schedule: ScheduleResponse[]) {
|
@Input() set data(schedule: ScheduleResponse[]) {
|
||||||
this.dataSource = schedule;
|
this.dataSource = schedule;
|
||||||
this.convertData();
|
this.convertData();
|
||||||
this.isOneGroup = schedule.every((item, _, array) => item.group === array[0].group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: any) {
|
ngOnChanges(changes: any) {
|
||||||
@ -68,16 +66,16 @@ export class TableComponent implements OnChanges {
|
|||||||
this.isLoad = true;
|
this.isLoad = true;
|
||||||
let tableData: TableData[] = [];
|
let tableData: TableData[] = [];
|
||||||
|
|
||||||
for (let i: number = 1; i <= 7; i++) {
|
for (let pairNumber: number = 1; pairNumber <= 7; pairNumber++) {
|
||||||
let convertedData: TableData = {
|
let convertedData: TableData = {
|
||||||
pairNumber: i,
|
pairNumber: pairNumber,
|
||||||
data: {}
|
data: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let k: number = 1; k < 7; k++) {
|
for (let dayOfWeek: number = 1; dayOfWeek < 7; dayOfWeek++) {
|
||||||
let filteredData = this.dataSource.filter(x =>
|
let filteredData = this.dataSource.filter(x =>
|
||||||
x.pairNumber === i &&
|
x.pairNumber === pairNumber &&
|
||||||
x.dayOfWeek === k &&
|
x.dayOfWeek === dayOfWeek &&
|
||||||
x.isEven === (this.currentWeek % 2 === 0)
|
x.isEven === (this.currentWeek % 2 === 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -85,25 +83,34 @@ export class TableComponent implements OnChanges {
|
|||||||
filteredData = filteredData.filter(x =>
|
filteredData = filteredData.filter(x =>
|
||||||
x.isExcludedWeeks == undefined ||
|
x.isExcludedWeeks == undefined ||
|
||||||
x.weeks == undefined ||
|
x.weeks == undefined ||
|
||||||
(x.isExcludedWeeks && (!x.weeks.includes(this.currentWeek))) ||
|
(x.isExcludedWeeks && !x.weeks.includes(this.currentWeek)) ||
|
||||||
(!x.isExcludedWeeks && (x.weeks.includes(this.currentWeek)))
|
(!x.isExcludedWeeks && x.weeks.includes(this.currentWeek))
|
||||||
);
|
);
|
||||||
|
|
||||||
filteredData.forEach(x => {
|
const groupedData = filteredData.reduce((acc, item) => {
|
||||||
if (this.isDisciplineWithWeeks) {
|
const key = `${item.lectureHalls}-${item.campus}-${item.discipline}-${item.professors.join(', ')}-${item.isExcludedWeeks}-${item.weeks?.join(', ') || ''}`;
|
||||||
if (x.isExcludedWeeks != undefined && x.weeks != undefined) {
|
if (!acc[key])
|
||||||
if (this.backupDisciplines[x.disciplineId])
|
acc[key] = {...item, groups: [item.group]};
|
||||||
x.discipline = this.backupDisciplines[x.disciplineId];
|
|
||||||
else
|
else
|
||||||
this.backupDisciplines[x.disciplineId] = x.discipline;
|
acc[key].groups.push(item.group);
|
||||||
|
return acc;
|
||||||
|
}, {} as { [key: string]: ScheduleResponse & { groups: string[] } });
|
||||||
|
|
||||||
x.discipline = `${(x.isExcludedWeeks ? 'кр.' : 'н.')} ${x.weeks.join(', ')} ${x.discipline}`;
|
convertedData.data[dayOfWeek.toString()] = Object.values(groupedData).map(item => {
|
||||||
|
item.group = item.groups.join(', ');
|
||||||
|
|
||||||
|
if (this.isDisciplineWithWeeks && item.weeks && item.isExcludedWeeks !== undefined) {
|
||||||
|
if (this.backupDisciplines[item.disciplineId]) {
|
||||||
|
item.discipline = this.backupDisciplines[item.disciplineId];
|
||||||
|
} else {
|
||||||
|
this.backupDisciplines[item.disciplineId] = item.discipline;
|
||||||
}
|
}
|
||||||
} else if (this.backupDisciplines[x.disciplineId])
|
item.discipline = `${item.isExcludedWeeks ? 'кр.' : 'н.'} ${item.weeks.join(', ')} ${item.discipline}`;
|
||||||
x.discipline = this.backupDisciplines[x.disciplineId];
|
} else if (this.backupDisciplines[item.disciplineId])
|
||||||
});
|
item.discipline = this.backupDisciplines[item.disciplineId];
|
||||||
|
|
||||||
convertedData.data[k.toString()] = filteredData;
|
return item;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.push(convertedData);
|
tableData.push(convertedData);
|
||||||
|
Loading…
Reference in New Issue
Block a user