diff --git a/src/components/admin/schedule-file-upload/schedule-file-upload.component.html b/src/components/admin/schedule-file-upload/schedule-file-upload.component.html
index bc7e156..76e4bc0 100644
--- a/src/components/admin/schedule-file-upload/schedule-file-upload.component.html
+++ b/src/components/admin/schedule-file-upload/schedule-file-upload.component.html
@@ -19,17 +19,21 @@
Выбранные файлы:
@for (item of selectedFiles; track $index) {
-
-
- {{ item.file.name }}
-
-
-
- Кампус по умолчанию
-
-
-
-
+
+ {{ item.file.name }}
+
+
+ Кампус по умолчанию
+
+
+ @for (option of onFilter(item.campus); track $index) {
+
+ {{ option }}
+
+ }
+
+
}
}
diff --git a/src/components/admin/schedule-file-upload/schedule-file-upload.component.ts b/src/components/admin/schedule-file-upload/schedule-file-upload.component.ts
index a69fde5..d604605 100644
--- a/src/components/admin/schedule-file-upload/schedule-file-upload.component.ts
+++ b/src/components/admin/schedule-file-upload/schedule-file-upload.component.ts
@@ -10,9 +10,11 @@ import {MatIcon} from "@angular/material/icon";
import {ScheduleService} from "@api/v1/configuration/schedule.service";
import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.component";
import {MatFormFieldModule} from "@angular/material/form-field";
-import {FormsModule} from "@angular/forms";
+import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {MatInput} from "@angular/material/input";
import {ToastrService} from "ngx-toastr";
+import {MatAutocomplete, MatAutocompleteTrigger, MatOption} from "@angular/material/autocomplete";
+import {CampusService} from "@api/v1/campus.service";
@Component({
selector: 'app-schedule-file-upload',
@@ -23,17 +25,33 @@ import {ToastrService} from "ngx-toastr";
DataSpinnerComponent,
MatFormFieldModule,
FormsModule,
- MatInput
+ MatInput,
+ MatAutocomplete,
+ MatAutocompleteTrigger,
+ MatOption,
+ ReactiveFormsModule
],
templateUrl: './schedule-file-upload.component.html',
- providers: [ScheduleService]
+ providers: [ScheduleService, CampusService]
})
export class ScheduleFileUploadComponent {
- selectedFiles: { file: File, campus: string }[] = [];
- fileLoading: boolean = false;
+ protected selectedFiles: { file: File, campus: string }[] = [];
+ protected fileLoading: boolean = false;
+ protected campuses: string[] = [];
@ViewChild('fileInput') input!: ElementRef;
- constructor(private dialog: MatDialog, private api: ScheduleService, private notify: ToastrService) {
+ constructor(
+ private dialog: MatDialog,
+ private api: ScheduleService,
+ private notify: ToastrService,
+ campus: CampusService) {
+ campus.getCampus().subscribe(data => {
+ this.campuses = data.map(x => x.codeName);
+ });
+ }
+
+ protected onSelectCampus(value: string, item: { file: File, campus: string }) {
+ item.campus = value;
}
protected saveFunction() {
@@ -49,18 +67,22 @@ export class ScheduleFileUploadComponent {
};
}
- onFileChooseClick() {
+ protected onFilter(value: string): string[] {
+ const filterValue = value?.toLowerCase() || '';
+ return this.campuses.filter(campus => campus.toLowerCase().includes(filterValue));
+ }
+
+ protected onFileChooseClick() {
this.fileLoading = true;
this.input.nativeElement.click();
}
- onFileSelected(event: any): void {
+ protected onFileSelected(event: any): void {
this.fileLoading = false;
- this.selectedFiles = Array.from(event.target.files)
- .map(x => <{file: File, campus: string}>{file: x, campus: ''});
+ this.selectedFiles = Array.from(event.target.files).map(file => ({file: file, campus: ''}));
}
- onUpload(data: Observable): void {
+ protected onUpload(data: Observable): void {
data.subscribe(_ => {
this.notify.info(`Файлы в размере ${this.selectedFiles.length} успешно загружены. Задача поставлена в очередь`);
this.selectedFiles = [];