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" <section class="mat-elevation-z8 table-section" tabindex="0" [style.overflow]="(dataSource.length === 0 || isLoad ? 'hidden' : 'auto')">
[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) {
@ -54,7 +53,7 @@
@if ($index !== 0) { @if ($index !== 0) {
<br/> <br/>
} }
<div class="mat-body">({{ typeOfOccupation }})</div> <div class="mat-body">({{typeOfOccupation}})</div>
} }
<!-- Professors --> <!-- Professors -->
@ -98,12 +97,14 @@
} }
<!-- Group --> <!-- Group -->
<div class="mat-body"> @if (!isOneGroup) {
<i> <div class="mat-body">
<mat-icon fontIcon="group"/> <i>
</i> <mat-icon fontIcon="group"/>
{{ elementData["group"] }} </i>
</div> {{ elementData["group"] }}
</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;"/>

View File

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

View File

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