Compare commits
2 Commits
b341d66f08
...
4bfd919bbc
Author | SHA1 | Date | |
---|---|---|---|
4bfd919bbc | |||
9d9302525b |
@ -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) {
|
||||
<div class="overlay">
|
||||
@if (isLoad) {
|
||||
@ -97,14 +98,12 @@
|
||||
}
|
||||
|
||||
<!-- Group -->
|
||||
@if (!isOneGroup) {
|
||||
<div class="mat-body">
|
||||
<i>
|
||||
<mat-icon fontIcon="group"/>
|
||||
</i>
|
||||
{{ elementData["group"] }}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if ($index + 1 !== element.data[daysOfWeek.indexOf(day) + 1].length) {
|
||||
<hr style="margin: 10px 0;"/>
|
||||
|
@ -31,17 +31,16 @@ interface Dictionary {
|
||||
})
|
||||
|
||||
export class TableComponent implements OnChanges {
|
||||
@Input() currentWeek!: number;
|
||||
@Input() startWeek!: Date;
|
||||
@Input() isLoad: boolean = false;
|
||||
|
||||
private isDisciplineWithWeeks: boolean = false;
|
||||
protected tableDataSource: MatTableDataSource<TableData> = new MatTableDataSource<TableData>([]);
|
||||
private backupDisciplines: string[] = [];
|
||||
protected daysOfWeek: string[] = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'];
|
||||
protected displayedColumns: string[] = ['pairNumber'];
|
||||
protected dataSource: ScheduleResponse[] = [];
|
||||
protected isOneGroup: boolean = false;
|
||||
|
||||
@Input() currentWeek!: number;
|
||||
@Input() startWeek!: Date;
|
||||
@Input() isLoad: boolean = false;
|
||||
|
||||
@Input() set disciplineWithWeeks(value: boolean) {
|
||||
this.isDisciplineWithWeeks = value;
|
||||
@ -51,7 +50,6 @@ export class TableComponent implements OnChanges {
|
||||
@Input() set data(schedule: ScheduleResponse[]) {
|
||||
this.dataSource = schedule;
|
||||
this.convertData();
|
||||
this.isOneGroup = schedule.every((item, _, array) => item.group === array[0].group);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: any) {
|
||||
@ -68,16 +66,16 @@ export class TableComponent implements OnChanges {
|
||||
this.isLoad = true;
|
||||
let tableData: TableData[] = [];
|
||||
|
||||
for (let i: number = 1; i <= 7; i++) {
|
||||
for (let pairNumber: number = 1; pairNumber <= 7; pairNumber++) {
|
||||
let convertedData: TableData = {
|
||||
pairNumber: i,
|
||||
pairNumber: pairNumber,
|
||||
data: {}
|
||||
};
|
||||
|
||||
for (let k: number = 1; k < 7; k++) {
|
||||
for (let dayOfWeek: number = 1; dayOfWeek < 7; dayOfWeek++) {
|
||||
let filteredData = this.dataSource.filter(x =>
|
||||
x.pairNumber === i &&
|
||||
x.dayOfWeek === k &&
|
||||
x.pairNumber === pairNumber &&
|
||||
x.dayOfWeek === dayOfWeek &&
|
||||
x.isEven === (this.currentWeek % 2 === 0)
|
||||
);
|
||||
|
||||
@ -85,25 +83,34 @@ export class TableComponent implements OnChanges {
|
||||
filteredData = filteredData.filter(x =>
|
||||
x.isExcludedWeeks == 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 => {
|
||||
if (this.isDisciplineWithWeeks) {
|
||||
if (x.isExcludedWeeks != undefined && x.weeks != undefined) {
|
||||
if (this.backupDisciplines[x.disciplineId])
|
||||
x.discipline = this.backupDisciplines[x.disciplineId];
|
||||
const groupedData = filteredData.reduce((acc, item) => {
|
||||
const key = `${item.lectureHalls}-${item.campus}-${item.discipline}-${item.professors.join(', ')}-${item.isExcludedWeeks}-${item.weeks?.join(', ') || ''}`;
|
||||
if (!acc[key])
|
||||
acc[key] = {...item, groups: [item.group]};
|
||||
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])
|
||||
x.discipline = this.backupDisciplines[x.disciplineId];
|
||||
});
|
||||
item.discipline = `${item.isExcludedWeeks ? 'кр.' : 'н.'} ${item.weeks.join(', ')} ${item.discipline}`;
|
||||
} else if (this.backupDisciplines[item.disciplineId])
|
||||
item.discipline = this.backupDisciplines[item.disciplineId];
|
||||
|
||||
convertedData.data[k.toString()] = filteredData;
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
tableData.push(convertedData);
|
||||
|
@ -78,8 +78,8 @@ export class ProfessorComponent implements OnInit, IScheduleTab {
|
||||
if (value === '')
|
||||
return [];
|
||||
|
||||
const filterValue = value.toLowerCase();
|
||||
return this.professors?.filter(teacher => teacher.name.toLowerCase().includes(filterValue)) ?? [];
|
||||
const filterValue = value.toLowerCase().replace('ё', 'е');
|
||||
return this.professors?.filter(teacher => teacher.name.toLowerCase().replace('ё', 'е').includes(filterValue)) ?? [];
|
||||
} else {
|
||||
const selectedTeacher = this.professors?.find(teacher => teacher.id === value);
|
||||
return selectedTeacher ? [selectedTeacher] : [];
|
||||
|
Loading…
Reference in New Issue
Block a user