Compare commits

..

No commits in common. "4bfd919bbc4082f0ecf898d64ae0b6cc8fa7bc4c" and "b341d66f08dd38e0671a7e3848c2342e0ae16cdb" have entirely different histories.

3 changed files with 37 additions and 43 deletions

View File

@ -1,5 +1,4 @@
<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) {
@ -54,7 +53,7 @@
@if ($index !== 0) {
<br/>
}
<div class="mat-body">({{ typeOfOccupation }})</div>
<div class="mat-body">({{typeOfOccupation}})</div>
}
<!-- Professors -->
@ -98,12 +97,14 @@
}
<!-- Group -->
<div class="mat-body">
<i>
<mat-icon fontIcon="group"/>
</i>
{{ elementData["group"] }}
</div>
@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;"/>

View File

@ -31,16 +31,17 @@ 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;
@ -50,6 +51,7 @@ 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) {
@ -66,16 +68,16 @@ export class TableComponent implements OnChanges {
this.isLoad = true;
let tableData: TableData[] = [];
for (let pairNumber: number = 1; pairNumber <= 7; pairNumber++) {
for (let i: number = 1; i <= 7; i++) {
let convertedData: TableData = {
pairNumber: pairNumber,
pairNumber: i,
data: {}
};
for (let dayOfWeek: number = 1; dayOfWeek < 7; dayOfWeek++) {
for (let k: number = 1; k < 7; k++) {
let filteredData = this.dataSource.filter(x =>
x.pairNumber === pairNumber &&
x.dayOfWeek === dayOfWeek &&
x.pairNumber === i &&
x.dayOfWeek === k &&
x.isEven === (this.currentWeek % 2 === 0)
);
@ -83,34 +85,25 @@ 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)))
);
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
acc[key].groups.push(item.group);
return acc;
}, {} as { [key: string]: ScheduleResponse & { groups: string[] } });
filteredData.forEach(x => {
if (this.isDisciplineWithWeeks) {
if (x.isExcludedWeeks != undefined && x.weeks != undefined) {
if (this.backupDisciplines[x.disciplineId])
x.discipline = this.backupDisciplines[x.disciplineId];
else
this.backupDisciplines[x.disciplineId] = 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;
x.discipline = `${(x.isExcludedWeeks ? 'кр.' : 'н.')} ${x.weeks.join(', ')} ${x.discipline}`;
}
item.discipline = `${item.isExcludedWeeks ? 'кр.' : 'н.'} ${item.weeks.join(', ')} ${item.discipline}`;
} else if (this.backupDisciplines[item.disciplineId])
item.discipline = this.backupDisciplines[item.disciplineId];
return item;
} else if (this.backupDisciplines[x.disciplineId])
x.discipline = this.backupDisciplines[x.disciplineId];
});
convertedData.data[k.toString()] = filteredData;
}
tableData.push(convertedData);

View File

@ -78,8 +78,8 @@ export class ProfessorComponent implements OnInit, IScheduleTab {
if (value === '')
return [];
const filterValue = value.toLowerCase().replace('ё', 'е');
return this.professors?.filter(teacher => teacher.name.toLowerCase().replace('ё', 'е').includes(filterValue)) ?? [];
const filterValue = value.toLowerCase();
return this.professors?.filter(teacher => teacher.name.toLowerCase().includes(filterValue)) ?? [];
} else {
const selectedTeacher = this.professors?.find(teacher => teacher.id === value);
return selectedTeacher ? [selectedTeacher] : [];