From 7b8e451968adc98cc1bf6d072328b2cb589e963f Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 27 Jan 2022 16:18:43 +0200 Subject: [PATCH 01/20] delete --- .../category-card.component.html | 5 ++ .../category-card.component.scss | 23 +++++- .../category-card/category-card.component.ts | 7 +- src/app/shared/enum/modal-confirmation.ts | 3 + .../services/categories/categories.service.ts | 13 +++ src/app/shared/store/admin.actions.ts | 39 ++++++++- src/app/shared/store/admin.state.ts | 81 ++++++++++++++++++- .../create-direction.component.spec.ts | 3 +- .../create-direction.component.ts | 6 +- .../platform/platform.component.html | 10 +-- .../platform/platform.component.spec.ts | 6 +- .../platform/platform.component.ts | 24 +++++- .../admin-tools/platform/platform.module.ts | 2 +- 13 files changed, 199 insertions(+), 23 deletions(-) diff --git a/src/app/shared/components/category-card/category-card.component.html b/src/app/shared/components/category-card/category-card.component.html index ea4600212d..bd24b69e98 100644 --- a/src/app/shared/components/category-card/category-card.component.html +++ b/src/app/shared/components/category-card/category-card.component.html @@ -8,6 +8,11 @@ edit +
+ +
diff --git a/src/app/shared/components/category-card/category-card.component.scss b/src/app/shared/components/category-card/category-card.component.scss index ba1f76068b..a62f9824bd 100644 --- a/src/app/shared/components/category-card/category-card.component.scss +++ b/src/app/shared/components/category-card/category-card.component.scss @@ -24,7 +24,7 @@ color: #3849F9; text-align: center; text-decoration: none; - a { + a span{ display: flex; justify-content: center; align-items: center; @@ -41,7 +41,24 @@ .config_edit-icon { position: absolute; top: 12px; - right: 16px; + right: 32px; + z-index: 2; + color : #3849F9; + .mat-icon { + font-size: 16px; + width: 16px; + height: 16px; + } + .mat-button { + padding: 0px; + min-width:auto; + line-height: 16px; + } +} +.del-icon { + position: absolute; + top: 12px; + right: 12px; z-index: 2; color : #3849F9; .mat-icon { @@ -58,4 +75,4 @@ .config-support p { margin: 0; -} \ No newline at end of file +} diff --git a/src/app/shared/components/category-card/category-card.component.ts b/src/app/shared/components/category-card/category-card.component.ts index f051668214..10b25d932c 100644 --- a/src/app/shared/components/category-card/category-card.component.ts +++ b/src/app/shared/components/category-card/category-card.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Store } from '@ngxs/store'; import { CategoryIcons } from '../../enum/category-icons'; import { Direction } from '../../models/category.model'; @@ -14,6 +14,7 @@ export class CategoryCardComponent implements OnInit { @Input() isEditMode: boolean; @Input() direction: Direction; @Input() icons: {}; + @Output() deleteDirection = new EventEmitter(); public categoryIcons = CategoryIcons; constructor(private store: Store) { @@ -22,6 +23,10 @@ export class CategoryCardComponent implements OnInit { ngOnInit(): void { } + onDelete(): void { + this.deleteDirection.emit(this.direction); + } + selectDirection(direction: Direction): void { this.store.dispatch(new SetDirections([direction])); } diff --git a/src/app/shared/enum/modal-confirmation.ts b/src/app/shared/enum/modal-confirmation.ts index 41be88890b..350b16d725 100644 --- a/src/app/shared/enum/modal-confirmation.ts +++ b/src/app/shared/enum/modal-confirmation.ts @@ -1,5 +1,6 @@ export enum ModalConfirmationType { delete = 'delete', + deleteDirection = 'deleteDirection', leaveWorkshop = 'leaveWorkshop', deleteChild = 'deleteChild', leavePage = 'leavePage', @@ -10,6 +11,7 @@ export enum ModalConfirmationType { } export enum ModalConfirmationTitle { delete = 'ВИДАЛИТИ ГУРТОК?', + deleteDirection ='ВИДАЛИТИ НАПРЯМОК?', deleteChild = 'ВИЛУЧИТИ ДАНІ ПРО ДИТИНУ?', leaveWorkshop = 'ЗАЛИШИТИ ГУРТОК?', leavePage = 'ЗАЛИШИТИ СТОРІНКУ?', @@ -20,6 +22,7 @@ export enum ModalConfirmationTitle { export enum ModalConfirmationText { delete = 'Ви впевнені, що хочете видалити гурток', + deleteDirection = 'Ви впевнені, що хочете видалити напрямок', deleteChild = 'Ви впевнені, що хочете вилучити дані про дитину', leaveWorkshop = 'Ви впевнені, що хочете залишити гурток', leavePage = 'Ви впевнені, що хочете залишити сторінку?', diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 6b3c29d28a..d55c366d83 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -17,6 +17,15 @@ export class CategoriesService { getTopDirections(): Observable { return this.http.get(`/api/v1/Statistic/GetDirections`); } + createDirection(direction: Direction): Observable { + return this.http.post('/api/v1/Direction/Create', direction); + } + updateDirection(direction: Direction): Observable { + return this.http.put('/api/v1/Direction/Update', direction); + } + deleteDirection(id: number): Observable { + return this.http.delete(`/api/v1/Direction/Delete/${id}`); + } getDepartmentsBytDirectionId(id: number): Observable { return this.http.get(`/api/v1/Department/GetByDirectionId/${id}`); @@ -25,4 +34,8 @@ export class CategoriesService { getClassByDepartmentId(id: number): Observable { return this.http.get(`/api/v1/Class/GetByDepartmentId/${id}`); } + + getDirectionById(id: string): Observable { + return this.http.get(`/api/v1/Direction/GetById/${id}`); + } } diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index 64914785e7..c908e42f3f 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -1,3 +1,4 @@ +import { Direction } from "@angular/cdk/bidi"; import { AboutPortal } from "../models/aboutPortal.model"; export class GetInfoAboutPortal { @@ -15,4 +16,40 @@ export class OnUpdateInfoAboutPortalFail { export class OnUpdateInfoAboutPortalSuccess { static readonly type = '[admin] update Information About Portal Success'; constructor(public payload) { } -} \ No newline at end of file +} +export class DeleteDirectionById { + static readonly type = '[admin] delete Direction'; + constructor(public payload) { } +} +export class OnDeleteDirectionFail { + static readonly type = '[admin] delete Direction fail'; + constructor(public payload: Error) { } +} +export class OnDeleteDirectionSuccess { + static readonly type = '[admin] delete Direction success'; + constructor(public payload) { } +} +export class CreateDirection { + static readonly type = '[admin] create Direction'; + constructor(public payload) { } +} +export class OnCreateDirectionFail { + static readonly type = '[admin] create Direction fail'; + constructor(public payload: Error) { } +} +export class OnCreateDirectionSuccess { + static readonly type = '[admin] create Direction success'; + constructor(public payload) { } +} +export class UpdateDirection { + static readonly type = '[admin] update Direction'; + constructor(public payload) { } +} +export class OnUpdateDirectionFail { + static readonly type = '[admin] update Direction fail'; + constructor(public payload: Error) { } +} +export class OnUpdateDirectionSuccess { + static readonly type = '[admin] update Direction success'; + constructor(public payload) { } +} diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 3388ab9c4c..06707d245a 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -4,27 +4,34 @@ import { Action, Selector, State, StateContext } from "@ngxs/store"; import { Observable, of, throwError } from "rxjs"; import { catchError, tap } from "rxjs/operators"; import { AboutPortal } from "../models/aboutPortal.model"; +import { Direction } from "../models/category.model"; +import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { GetInfoAboutPortal, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal } from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail,} from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { + directions: Direction; aboutPortal: AboutPortal; } @State({ name: 'admin', defaults: { aboutPortal: null, + directions: null, } }) @Injectable() export class AdminState { @Selector() static aboutPortal(state: AdminStateModel): AboutPortal { return state.aboutPortal; } + @Selector() + static directions(state: AdminStateModel): Direction { return state.directions; } constructor( private portalService: PortalService, - private router: Router + private categoriesService: CategoriesService, + private router: Router, ) { } @Action(GetInfoAboutPortal) @@ -59,4 +66,72 @@ export class AdminState { dispatch(new ShowMessageBar({ message: 'Інформація про портал успішно відредагована', type: 'success' })); this.router.navigate(['/admin-tools/platform/about']); } -} \ No newline at end of file + + @Action(DeleteDirectionById) + DeleteDirectionById({ dispatch }: StateContext, { payload }: DeleteDirectionById): Observable { + return this.categoriesService + .deleteDirection(payload) + .pipe( + tap((res) => dispatch(new OnDeleteDirectionSuccess(res))), + catchError((error: Error) => of(dispatch(new OnDeleteDirectionFail(error)))) + ); + } + + @Action(OnDeleteDirectionFail) + OnDeleteDirectionFail({ dispatch }: StateContext, { payload }: OnDeleteDirectionFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnDeleteDirectionSuccess) + OnDeleteDirectionSuccess({ dispatch }: StateContext, { payload }: OnDeleteDirectionSuccess): void { + console.log('Direction is deleted', payload); + dispatch(new ShowMessageBar({ message: 'Напрямок видалено!', type: 'success' })); + this.router.navigate(['/admin-tools/platform/about']); + } + + @Action(CreateDirection) + CreateDirection({ dispatch }: StateContext, { payload }: CreateDirection): Observable { + return this.categoriesService + .createDirection(payload) + .pipe( + tap((res) => dispatch(new OnCreateDirectionSuccess(res))), + catchError((error: Error) => of(dispatch(new OnCreateDirectionFail(error)))) + ); + } + + @Action(OnCreateDirectionFail) + OnCreateDirectionFail({ dispatch }: StateContext, { payload }: OnCreateDirectionFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnCreateDirectionSuccess) + OnCreateDirectionSuccess({ dispatch }: StateContext, { payload }: OnCreateDirectionSuccess): void { + dispatch(new MarkFormDirty(false)); + console.log('Direction is created', payload); + dispatch(new ShowMessageBar({ message: 'Напрямок успішно створенний', type: 'success' })); + this.router.navigate(['/admin-tools/platform/about']); + } + @Action(UpdateDirection) + updateChild({ dispatch }: StateContext, { payload }: UpdateDirection): Observable { + return this.categoriesService + .updateDirection(payload) + .pipe( + tap((res) => dispatch(new OnUpdateDirectionSuccess(res))), + catchError((error: Error) => of(dispatch(new OnUpdateDirectionFail(error)))) + ); + } + @Action(OnUpdateDirectionFail) + onUpdateChildfail({ dispatch }: StateContext, { payload }: OnUpdateDirectionFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + @Action(OnUpdateDirectionSuccess) + onUpdateChildSuccess({ dispatch }: StateContext, { payload }: OnUpdateDirectionSuccess): void { + dispatch(new MarkFormDirty(false)); + console.log('Direction is updated', payload); + dispatch(new ShowMessageBar({ message: 'Дитина успішно відредагована', type: 'success' })); + this.router.navigate(['/admin-tools/platform/about']); + } +} diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index 8159bca585..664198d7d6 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -60,4 +60,5 @@ class MockValidationHintForInputComponent { @Input() invalid: boolean; @Input() isEmptyCheck: boolean; @Input() forbiddenCharacter: string; -} \ No newline at end of file + @Input() directionFormGroup: FormGroup; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index 1c3d4449e4..fb0e788972 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -23,9 +23,9 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { constructor( private fb: FormBuilder, - private store: Store, - private navigationBarService: NavigationBarService) { - + private store: Store, + private navigationBarService: NavigationBarService) { + this.directionFormGroup = this.fb.group({ image: new FormControl(''), directionName: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index 5b6bb9fcf4..627af53747 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -1,5 +1,5 @@ - +
- +
+ [isEditMode]="true" (deleteDirection)="onDelete($event)">
- +
@@ -80,4 +80,4 @@
Підтримка
- \ No newline at end of file + diff --git a/src/app/shell/admin-tools/platform/platform.component.spec.ts b/src/app/shell/admin-tools/platform/platform.component.spec.ts index 04c8504962..c16d3e2e53 100644 --- a/src/app/shell/admin-tools/platform/platform.component.spec.ts +++ b/src/app/shell/admin-tools/platform/platform.component.spec.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatButtonModule } from '@angular/material/button'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -25,9 +26,10 @@ describe('PlatformComponent', () => { MatButtonModule, MatFormFieldModule, MatInputModule, - NoopAnimationsModule + NoopAnimationsModule, + MatDialogModule, ], - declarations: [ + declarations: [ PlatformComponent, MockAllCategoriesCardComponent, MockAllCategoriesSearchbarComponent diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index 8d91ee54d2..93492a381e 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -1,12 +1,15 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction } from 'src/app/shared/models/category.model'; -import { GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; +import { DeleteDirectionById, GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; import { GetDirections } from 'src/app/shared/store/meta-data.actions'; import { MetaDataState } from 'src/app/shared/store/meta-data.state'; @@ -28,8 +31,9 @@ export class PlatformComponent implements OnInit, OnDestroy { constructor( private store: Store, + private route: ActivatedRoute, private router: Router, - private route: ActivatedRoute) { } + private matDialog: MatDialog) { } ngOnInit(): void { this.store.dispatch(new GetDirections()); @@ -42,7 +46,21 @@ export class PlatformComponent implements OnInit, OnDestroy { onSelectedTabChange(event: MatTabChangeEvent): void { this.router.navigate([`admin-tools/platform/${this.adminTabs[event.index]}`]); } - + + onDelete(direction: Direction): void { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.deleteDirection, + property: direction.title + } + }); + + dialogRef.afterClosed().subscribe((result: boolean) => { + result && this.store.dispatch(new DeleteDirectionById(direction.id)); + }); + } + ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); diff --git a/src/app/shell/admin-tools/platform/platform.module.ts b/src/app/shell/admin-tools/platform/platform.module.ts index 4513a78f40..e7679672e4 100644 --- a/src/app/shell/admin-tools/platform/platform.module.ts +++ b/src/app/shell/admin-tools/platform/platform.module.ts @@ -16,7 +16,7 @@ import { CreateDirectionComponent } from './create-direction/create-direction.co SupportEditComponent, AboutFormComponent, SupportFormComponent, - CreateDirectionComponent + CreateDirectionComponent, ], imports: [ CommonModule, From e2cf1676cec8a8fb9b999c524aa1628d056c22af Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Mon, 21 Feb 2022 16:34:42 +0200 Subject: [PATCH 02/20] create without classes create without classes --- src/app/shared/enum/modal-confirmation.ts | 8 +- src/app/shared/enum/navigation-bar.ts | 1 + src/app/shared/enum/provider.ts | 6 ++ src/app/shared/models/category.model.ts | 18 +++- .../services/categories/categories.service.ts | 13 +-- src/app/shared/store/admin.actions.ts | 20 +++++ src/app/shared/store/admin.state.ts | 66 ++++++++++++-- src/app/shared/store/meta-data.state.ts | 2 +- src/app/shared/store/user.state.ts | 6 +- .../add-class-form.component.html | 41 +++++++++ .../add-class-form.component.scss | 26 ++++++ .../add-class-form.component.spec.ts | 59 ++++++++++++ .../add-class-form.component.ts | 62 +++++++++++++ .../add-department-form.component.html | 32 +++++++ .../add-department-form.component.scss | 22 +++++ .../add-department-form.component.spec.ts | 59 ++++++++++++ .../add-department-form.component.ts | 90 +++++++++++++++++++ .../add-direction-form.component.html | 23 +++++ .../add-direction-form.component.scss | 18 ++++ .../add-direction-form.component.spec.ts | 59 ++++++++++++ .../add-direction-form.component.ts | 88 ++++++++++++++++++ .../create-direction.component.html | 88 ++++++------------ .../create-direction.component.spec.ts | 33 ++++++- .../create-direction.component.ts | 72 ++++++++++----- .../admin-tools/platform/platform.module.ts | 6 ++ 25 files changed, 818 insertions(+), 100 deletions(-) create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.scss create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts diff --git a/src/app/shared/enum/modal-confirmation.ts b/src/app/shared/enum/modal-confirmation.ts index 350b16d725..690ca93426 100644 --- a/src/app/shared/enum/modal-confirmation.ts +++ b/src/app/shared/enum/modal-confirmation.ts @@ -8,10 +8,14 @@ export enum ModalConfirmationType { createApplication = 'createApplication', approveApplication = 'approveApplication', rejectApplication = 'rejectApplication', + createDirection = 'createDirection', + createDepartment = 'createDepartment', } export enum ModalConfirmationTitle { delete = 'ВИДАЛИТИ ГУРТОК?', - deleteDirection ='ВИДАЛИТИ НАПРЯМОК?', + deleteDirection = 'ВИДАЛИТИ НАПРЯМОК?', + createDirection = 'CТВОРИТИ НАПРЯМОК?', + createDepartment = 'CТВОРИТИ ВІДДІЛЕННЯ?', deleteChild = 'ВИЛУЧИТИ ДАНІ ПРО ДИТИНУ?', leaveWorkshop = 'ЗАЛИШИТИ ГУРТОК?', leavePage = 'ЗАЛИШИТИ СТОРІНКУ?', @@ -23,6 +27,8 @@ export enum ModalConfirmationTitle { export enum ModalConfirmationText { delete = 'Ви впевнені, що хочете видалити гурток', deleteDirection = 'Ви впевнені, що хочете видалити напрямок', + createDirection = 'Ви впевнені, що хочете створити напрямок?', + createDepartment = 'Ви впевнені, що хочете створити відділення?', deleteChild = 'Ви впевнені, що хочете вилучити дані про дитину', leaveWorkshop = 'Ви впевнені, що хочете залишити гурток', leavePage = 'Ви впевнені, що хочете залишити сторінку?', diff --git a/src/app/shared/enum/navigation-bar.ts b/src/app/shared/enum/navigation-bar.ts index 47d4e0dc69..53619e673a 100644 --- a/src/app/shared/enum/navigation-bar.ts +++ b/src/app/shared/enum/navigation-bar.ts @@ -16,6 +16,7 @@ export enum NavBarName { EditInformationAboutChild = 'Редагувати дані про дитину', EditInstitutions = 'Редагувати заклад', EditInformationAbout = 'Редагування особистої інформації', + EditDirection = 'Редагування напрямку', Platform = 'Портал', NewWorkshop = 'Новий гурток', EditWorkshop = 'Редагування гуртка' diff --git a/src/app/shared/enum/provider.ts b/src/app/shared/enum/provider.ts index a66876ebec..b53a9264c7 100644 --- a/src/app/shared/enum/provider.ts +++ b/src/app/shared/enum/provider.ts @@ -45,3 +45,9 @@ export enum createProviderSteps { 'contacts', 'description' } + +export enum createDirectionSteps { + 'direction', + 'department', + 'class' +} diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index e65bca8628..05a789c2e1 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -1,13 +1,27 @@ -export interface Direction { +export class Direction { id: number; title: string; description: string; + + constructor(info, id?) { + this.id = id; + this.title = info.title; + this.description = info.title; + } } -export interface Department { + +export class Department { id: number; directionId: number; title: string; description: string; + + constructor(info, directionId, id?) { + this.id = id; + this.directionId = directionId; + this.title = info.title; + this.description = info.title; + } } export interface IClass { diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index d55c366d83..5a22485462 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -17,8 +17,11 @@ export class CategoriesService { getTopDirections(): Observable { return this.http.get(`/api/v1/Statistic/GetDirections`); } - createDirection(direction: Direction): Observable { - return this.http.post('/api/v1/Direction/Create', direction); + createDirection(direction: Direction): Observable { + return this.http.post('/api/v1/Direction/Create', direction); + } + createDepartment(department: Department): Observable { + return this.http.post('/api/v1/Department/Create', department); } updateDirection(direction: Direction): Observable { return this.http.put('/api/v1/Direction/Update', direction); @@ -27,15 +30,15 @@ export class CategoriesService { return this.http.delete(`/api/v1/Direction/Delete/${id}`); } - getDepartmentsBytDirectionId(id: number): Observable { + getDepartmentsByDirectionId(id: number): Observable { return this.http.get(`/api/v1/Department/GetByDirectionId/${id}`); } getClassByDepartmentId(id: number): Observable { return this.http.get(`/api/v1/Class/GetByDepartmentId/${id}`); } - - getDirectionById(id: string): Observable { + + getDirectionById(id: number): Observable { return this.http.get(`/api/v1/Direction/GetById/${id}`); } } diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index c908e42f3f..e6b044a7af 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -53,3 +53,23 @@ export class OnUpdateDirectionSuccess { static readonly type = '[admin] update Direction success'; constructor(public payload) { } } +export class CreateDepartment { + static readonly type = '[admin] create Department'; + constructor(public payload) { } +} +export class OnCreateDepartmentFail { + static readonly type = '[admin] create Department fail'; + constructor(public payload: Error) { } +} +export class OnCreateDepartmentSuccess { + static readonly type = '[admin] create Department success'; + constructor(public payload) { } +} +export class GetDirectionById { + static readonly type = '[admin] get Direction By Direction Id'; + constructor(public payload) { } +} +export class GetDepartmentByDirectionId { + static readonly type = '[admin] get Department By Direction Id'; + constructor(public payload) { } +} diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 06707d245a..3e2b582ec0 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -4,21 +4,27 @@ import { Action, Selector, State, StateContext } from "@ngxs/store"; import { Observable, of, throwError } from "rxjs"; import { catchError, tap } from "rxjs/operators"; import { AboutPortal } from "../models/aboutPortal.model"; -import { Direction } from "../models/category.model"; +import { Department, Direction } from "../models/category.model"; import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail,} from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId,} from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { - directions: Direction; + isLoading: boolean; + direction: Direction; aboutPortal: AboutPortal; + departments: Department[]; + selectedDirection: Direction; } @State({ name: 'admin', defaults: { aboutPortal: null, - directions: null, + direction: undefined, + departments: [], + isLoading: false, + selectedDirection: null, } }) @Injectable() @@ -26,7 +32,9 @@ export class AdminState { @Selector() static aboutPortal(state: AdminStateModel): AboutPortal { return state.aboutPortal; } @Selector() - static directions(state: AdminStateModel): Direction { return state.directions; } + static direction(state: AdminStateModel): Direction { return state.direction; } + @Selector() + static departments(state: AdminStateModel): Department [] { return state.departments; } constructor( private portalService: PortalService, @@ -93,7 +101,7 @@ export class AdminState { @Action(CreateDirection) CreateDirection({ dispatch }: StateContext, { payload }: CreateDirection): Observable { return this.categoriesService - .createDirection(payload) + .createDirection(payload) .pipe( tap((res) => dispatch(new OnCreateDirectionSuccess(res))), catchError((error: Error) => of(dispatch(new OnCreateDirectionFail(error)))) @@ -107,11 +115,11 @@ export class AdminState { } @Action(OnCreateDirectionSuccess) - OnCreateDirectionSuccess({ dispatch }: StateContext, { payload }: OnCreateDirectionSuccess): void { + OnCreateDirectionSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDirectionSuccess): void { dispatch(new MarkFormDirty(false)); + patchState({direction: payload}); console.log('Direction is created', payload); dispatch(new ShowMessageBar({ message: 'Напрямок успішно створенний', type: 'success' })); - this.router.navigate(['/admin-tools/platform/about']); } @Action(UpdateDirection) updateChild({ dispatch }: StateContext, { payload }: UpdateDirection): Observable { @@ -134,4 +142,46 @@ export class AdminState { dispatch(new ShowMessageBar({ message: 'Дитина успішно відредагована', type: 'success' })); this.router.navigate(['/admin-tools/platform/about']); } + @Action(CreateDepartment) + CreateDepartment({ dispatch }: StateContext, { payload }: CreateDepartment): Observable { + return this.categoriesService + .createDepartment(payload) + .pipe( + tap((res) => dispatch(new OnCreateDepartmentSuccess(res))), + catchError((error: Error) => of(dispatch(new OnCreateDepartmentFail(error)))) + ); + } + + @Action(OnCreateDepartmentFail) + OnCreateDepartmentFail({ dispatch }: StateContext, { payload }: OnCreateDepartmentFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnCreateDepartmentSuccess) + OnCreateDepartmentSuccess({ dispatch }: StateContext, { payload }: OnCreateDepartmentSuccess): void { + dispatch(new MarkFormDirty(false)); + console.log('Department is created', payload); + dispatch(new ShowMessageBar({ message: 'Напрямок успішно створенний', type: 'success' })); + } + @Action(GetDirectionById) + getDirectionById({ patchState }: StateContext, { payload }: GetDirectionById): Observable { + patchState({ isLoading: true }); + return this.categoriesService + .getDirectionById(payload) + .pipe( + tap((direction: Direction) => { + return patchState({ selectedDirection: direction, isLoading: false }); + })); + } + @Action(GetDepartmentByDirectionId) + getDepartmentByDirectionId({ patchState }: StateContext, { payload }: GetDepartmentByDirectionId): Observable { + patchState({ isLoading: true }); + return this.categoriesService + .getDepartmentsByDirectionId(payload) + .pipe( + tap((department: Department[]) => { + return patchState({ departments: department, isLoading: false }); + })); + } } diff --git a/src/app/shared/store/meta-data.state.ts b/src/app/shared/store/meta-data.state.ts index 389ee5d8c1..56e1467ad5 100644 --- a/src/app/shared/store/meta-data.state.ts +++ b/src/app/shared/store/meta-data.state.ts @@ -146,7 +146,7 @@ export class MetaDataState { @Action(GetDepartments) getDepartments({ patchState }: StateContext, { payload }: GetDepartments): Observable { return this.categoriesService - .getDepartmentsBytDirectionId(payload) + .getDepartmentsByDirectionId(payload) .pipe( tap((departments: Department[]) => patchState({ departments: departments }) )) diff --git a/src/app/shared/store/user.state.ts b/src/app/shared/store/user.state.ts index 5e4bc8dd61..9bdbaf5479 100644 --- a/src/app/shared/store/user.state.ts +++ b/src/app/shared/store/user.state.ts @@ -482,9 +482,9 @@ export class UserState { @Action(OnUpdateApplicationSuccess) onUpdateApplicationSuccess({ dispatch }: StateContext, { payload }: OnUpdateApplicationSuccess): void { - - dispatch(new ShowMessageBar({ message: payload.status === ApplicationStatus.Left - ? messageStatus.left + + dispatch(new ShowMessageBar({ message: payload.status === ApplicationStatus.Left + ? messageStatus.left : messageStatus.approved, type: 'success' })); dispatch(new GetApplicationsByParentId(payload.parentId)); } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html new file mode 100644 index 0000000000..e81d9674ee --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -0,0 +1,41 @@ +
+
+ + info_outline +
+
Name
+
+ + info_outline +
+
Name
+
+ + info_outline +
+ + + + + + + +
+ +
+ + +
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss new file mode 100644 index 0000000000..1719c996fe --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss @@ -0,0 +1,26 @@ +@import "src/app/shared/styles/create-form.scss"; +@import "src/app/shared/styles/validation-form.scss"; +@import "src/app/shared/styles/create-form-wrapper.scss"; +@import "src/app/shared/styles/buttons.scss"; + +.activeInfoBtn { + color: #3849f9; +} + +.inactiveInfoBtn { + color: #AAAAAA; +} + +.status-info-icon { + cursor: pointer; + margin: auto 0.5rem; + font-size: 16px; +} +.direction{ + color: gray; + margin-bottom: 25px; +} +.department{ + color: gray; + margin-bottom: 25px; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts new file mode 100644 index 0000000000..b896fcc71d --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts @@ -0,0 +1,59 @@ +import { Component, Input } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; +import { NgxsModule } from '@ngxs/store'; + +import { AddClassFormComponent } from './add-class-form.component'; + +describe('AddClassFormComponent', () => { + let component: AddClassFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + FormsModule, + RouterTestingModule, + ReactiveFormsModule, + MatFormFieldModule, + MatInputModule, + MatIconModule, + BrowserAnimationsModule, + NgxsModule.forRoot([]), + ], + declarations: [ + AddClassFormComponent, + MockValidationHintForInputComponent, + ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AddClassFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); +@Component({ + selector: 'app-validation-hint-for-input', + template: '' +}) + +class MockValidationHintForInputComponent { + @Input() type: string; + @Input() invalid: boolean; + @Input() minLength: boolean; + @Input() minCharachters: number; + @Input() forbiddenCharacter: string; + @Input() isEmptyCheck: boolean; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts new file mode 100644 index 0000000000..d824bc25b6 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -0,0 +1,62 @@ +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; +import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Store } from '@ngxs/store'; +import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; +import { NavBarName } from 'src/app/shared/enum/navigation-bar'; +import { CategoriesService } from 'src/app/shared/services/categories/categories.service'; +import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; +import { AddNavPath } from 'src/app/shared/store/navigation.actions'; +import { CreateFormComponent } from 'src/app/shell/personal-cabinet/create-form/create-form.component'; +import { IClass } from 'src/app/shared/models/category.model'; +import { takeUntil } from 'rxjs/operators'; +import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; + + +@Component({ + selector: 'app-add-class-form', + templateUrl: './add-class-form.component.html', + styleUrls: ['./add-class-form.component.scss'] +}) +export class AddClassFormComponent implements OnInit { + + classFormGroup: FormGroup; + isActiveClassInfoButton = false; + isActiveDepartmentInfoButton = false; + isActiveDirectionInfoButton = false; + editMode = false; + + + @Input() admin: TechAdmin; + //@Output() passDirectionFormGroup = new EventEmitter(); + + constructor(private formBuilder: FormBuilder) { + this.classFormGroup = this.formBuilder.group({ + className: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + }); + } + + ngOnInit(): void { + (this.admin) && this.classFormGroup.patchValue(this.admin, { emitEvent: false }); + // this.passDirectionFormGroup.emit(this.classFormGroup); + } + + onSubmit(): void { } + + /** + * This method receives a form and marks each control of this form as touched + * @param FormGroup form + */ + //private checkValidation(form: FormGroup): void { + // Object.keys(form.controls).forEach(key => { + // form.get(key).markAsTouched(); + //}); + //} + + + +} + + + + diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html new file mode 100644 index 0000000000..848e4c9809 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html @@ -0,0 +1,32 @@ +
+
+ + info_outline +
+
{{ direction?.title }}
+ + +
+ + info_outline +
+ + + + + + + + +
+ diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss new file mode 100644 index 0000000000..e4d387fb05 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss @@ -0,0 +1,22 @@ +@import "src/app/shared/styles/create-form.scss"; +@import "src/app/shared/styles/validation-form.scss"; +@import "src/app/shared/styles/create-form-wrapper.scss"; +@import "src/app/shared/styles/buttons.scss"; + +.activeInfoBtn { + color: #3849f9; +} + +.inactiveInfoBtn { + color: #AAAAAA; +} + +.status-info-icon { + cursor: pointer; + margin: auto 0.5rem; + font-size: 16px; +} +.direction{ + color: gray; + margin-bottom: 25px; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts new file mode 100644 index 0000000000..088dc706f8 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -0,0 +1,59 @@ +import { Component, Input } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; +import { NgxsModule } from '@ngxs/store'; + +import { AddDepartmentFormComponent } from './add-department-form.component'; + +describe('AddClassFormComponent', () => { + let component: AddDepartmentFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + FormsModule, + RouterTestingModule, + ReactiveFormsModule, + MatFormFieldModule, + MatInputModule, + MatIconModule, + BrowserAnimationsModule, + NgxsModule.forRoot([]), + ], + declarations: [ + AddDepartmentFormComponent, + MockValidationHintForInputComponent, + ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AddDepartmentFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); +@Component({ + selector: 'app-validation-hint-for-input', + template: '' +}) + +class MockValidationHintForInputComponent { + @Input() type: string; + @Input() invalid: boolean; + @Input() minLength: boolean; + @Input() minCharachters: number; + @Input() forbiddenCharacter: string; + @Input() isEmptyCheck: boolean; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts new file mode 100644 index 0000000000..4619286c8e --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts @@ -0,0 +1,90 @@ +import { CdkStepper } from '@angular/cdk/stepper'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; +import { ActivatedRoute } from '@angular/router'; +import { Select, Store } from '@ngxs/store'; +import { Observable, Subject } from 'rxjs'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; +import { Department, Direction } from 'src/app/shared/models/category.model'; +import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; +import { CreateDepartment, GetDirectionById } from 'src/app/shared/store/admin.actions'; +import { AdminState } from 'src/app/shared/store/admin.state'; +import { GetDirections } from 'src/app/shared/store/meta-data.actions'; +import { MetaDataState } from 'src/app/shared/store/meta-data.state'; + +@Component({ + selector: 'app-add-department-form', + templateUrl: './add-department-form.component.html', + styleUrls: ['./add-department-form.component.scss'] +}) +export class AddDepartmentFormComponent implements OnInit { + + @Select(MetaDataState.departments) + departments$: Observable; + destroy$: Subject = new Subject(); + + departmentFormGroup: FormGroup; + directionFormGroup: FormGroup; + isActiveDepartmentInfoButton = false; + isActiveDirectionInfoButton = false; + + department: Department; + + @Input() admin: TechAdmin; + @Input() direction: Direction; + @Input() CategoryFormGroup: FormGroup; + + + constructor( + private store: Store, + private matDialog: MatDialog, + private _stepper: CdkStepper, + private formBuilder: FormBuilder) { + this.departmentFormGroup = this.formBuilder.group({ + title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + }); + } + + ngOnInit(): void { + this.store.dispatch(new GetDirections()); + (this.admin) && this.departmentFormGroup.patchValue(this.admin, { emitEvent: false }); + //this.passDepartmentFormGroup.emit(this.departmentFormGroup); + + } + + onSubmit(): void { + if (this.departmentFormGroup.invalid) { + this.checkValidation(this.departmentFormGroup); + } else { + const direction = this.store.selectSnapshot(AdminState.direction); + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.createDepartment, + } + }); + dialogRef.afterClosed().subscribe((result: boolean) => { + const department = new Department(this.departmentFormGroup.value, direction.id); + result && this.store.dispatch(new CreateDepartment(department)); + this._stepper.next(); + }) + } + } + + ngOnDestroy(): void { + this.destroy$.next(true); + this.destroy$.unsubscribe(); + } + + checkValidation(form: FormGroup): void { + Object.keys(form.controls).forEach(key => { + form.get(key).markAsTouched(); + }); + } + + + } + diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html new file mode 100644 index 0000000000..842bbb7e6a --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html @@ -0,0 +1,23 @@ +
+
+ + info_outline +
+ + + + + + + + +
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.scss new file mode 100644 index 0000000000..087c39e9c6 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.scss @@ -0,0 +1,18 @@ +@import "src/app/shared/styles/create-form.scss"; +@import "src/app/shared/styles/validation-form.scss"; +@import "src/app/shared/styles/create-form-wrapper.scss"; +@import "src/app/shared/styles/buttons.scss"; + +.activeInfoBtn { + color: #3849f9; +} + +.inactiveInfoBtn { + color: #AAAAAA; +} + +.status-info-icon { + cursor: pointer; + margin: auto 0.5rem; + font-size: 16px; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts new file mode 100644 index 0000000000..9c52710968 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts @@ -0,0 +1,59 @@ +import { Component, Input } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; +import { NgxsModule } from '@ngxs/store'; + +import { AddDirectionFormComponent } from './add-direction-form.component'; + +describe('AddDirectionFormComponent', () => { + let component: AddDirectionFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + FormsModule, + RouterTestingModule, + ReactiveFormsModule, + MatFormFieldModule, + MatInputModule, + MatIconModule, + BrowserAnimationsModule, + NgxsModule.forRoot([]), + ], + declarations: [ + AddDirectionFormComponent, + MockValidationHintForInputComponent, + ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AddDirectionFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); +@Component({ + selector: 'app-validation-hint-for-input', + template: '' +}) + +class MockValidationHintForInputComponent { + @Input() type: string; + @Input() invalid: boolean; + @Input() minLength: boolean; + @Input() minCharachters: number; + @Input() forbiddenCharacter: string; + @Input() isEmptyCheck: boolean; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts new file mode 100644 index 0000000000..4941a6c84b --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts @@ -0,0 +1,88 @@ +import { CdkStepper, STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; +import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; +import { MatStepper } from '@angular/material/stepper'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Select, Store } from '@ngxs/store'; +import { Observable, Subject } from 'rxjs'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; +import { Direction } from 'src/app/shared/models/category.model'; +import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; +import { CreateDirection } from 'src/app/shared/store/admin.actions'; +import { AdminStateModel } from 'src/app/shared/store/admin.state'; +import { MetaDataState } from 'src/app/shared/store/meta-data.state'; + +@Component({ + selector: 'app-add-direction-form', + templateUrl: './add-direction-form.component.html', + styleUrls: ['./add-direction-form.component.scss'], + providers: [{ + provide: STEPPER_GLOBAL_OPTIONS, + useValue: { displayDefaultIndicatorType: false } + }] +}) +export class AddDirectionFormComponent implements OnInit { + + @Select(MetaDataState.directions) + directions$: Observable; + destroy$: Subject = new Subject(); + + + isActiveDirectionInfoButton = false; + AdminStateModel: AdminStateModel; + direction: Direction; + + + @Input() admin: TechAdmin; + directionFormGroup: FormGroup; + + constructor( + private store: Store, + private matDialog: MatDialog, + private _stepper: CdkStepper, + private formBuilder: FormBuilder){ + this.directionFormGroup = this.formBuilder.group({ + title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + }); + } + + ngOnInit(): void { + (this.admin) && this.directionFormGroup.patchValue(this.admin, { emitEvent: false }); + + } + + onSubmit(): void { + if (this.directionFormGroup.invalid) { + this.checkValidation(this.directionFormGroup); + } else { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.createDirection, + } + }); + dialogRef.afterClosed().subscribe((result: boolean) => { + const direction = new Direction(this.directionFormGroup.value); + result && this.store.dispatch(new CreateDirection(direction)); + this._stepper.next(); + }) + } + } + + ngOnDestroy(): void { + this.destroy$.next(true); + this.destroy$.unsubscribe(); + } + + checkValidation(form: FormGroup): void { + Object.keys(form.controls).forEach(key => { + form.get(key).markAsTouched(); + }); + } + +} + + diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html index 6b2a66db39..99697854e5 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html @@ -3,65 +3,35 @@

{{(editMode) ? 'РЕДАГУВАТИ' : 'ДОДАТИ'}} НАПРЯМОК

-
-
-
- - info_outline -
- - - - - - - -
- - info_outline -
- - - - - - - + + + +

Напрямок

+
+ + + +
+ + + +

Відділення

+
+ + + +
+ + + +

Клас

+
+ + +
+ +
-
- - info_outline -
- - - - - - - -
-
- - \ No newline at end of file + diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index 664198d7d6..c713421934 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -4,9 +4,11 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; +import { MatStepperModule } from '@angular/material/stepper'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; +import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; import { CreateDirectionComponent } from './create-direction.component'; @@ -24,10 +26,14 @@ describe('CreateDirectionComponent', () => { MatInputModule, BrowserAnimationsModule, RouterTestingModule, + MatStepperModule, ], declarations: [ CreateDirectionComponent, - MockValidationHintForInputComponent + MockValidationHintForInputComponent, + MockAddDepartmentFormComponent, + MockAddDirectionFormComponent, + MockAddClassFormComponent ] }) .compileComponents(); @@ -61,4 +67,29 @@ class MockValidationHintForInputComponent { @Input() isEmptyCheck: boolean; @Input() forbiddenCharacter: string; @Input() directionFormGroup: FormGroup; + @Input() classFormGroup: FormGroup; + @Input() departmentFormGroup: FormGroup; +} +@Component({ + selector: 'app-add-direction-form', + template: '' +}) +class MockAddDirectionFormComponent { + @Input() admin: TechAdmin; +} + +@Component({ + selector: 'app-add-department-form', + template: '' +}) +class MockAddDepartmentFormComponent { + @Input() admin: TechAdmin; +} + +@Component({ + selector: 'app-add-class-form', + template: '' +}) +class MockAddClassFormComponent { + @Input() admin: TechAdmin; } diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index fb0e788972..9a07cccea2 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -1,47 +1,79 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; +import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatStepper } from '@angular/material/stepper'; +import { ActivatedRoute, Params } from '@angular/router'; import { Store } from '@ngxs/store'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; +import { createDirectionSteps } from 'src/app/shared/enum/provider'; +import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; +import { AdminState } from 'src/app/shared/store/admin.state'; import { AddNavPath, DeleteNavPath } from 'src/app/shared/store/navigation.actions'; @Component({ selector: 'app-create-direction', templateUrl: './create-direction.component.html', - styleUrls: ['./create-direction.component.scss'] + styleUrls: ['./create-direction.component.scss'], + providers: [{ + provide: STEPPER_GLOBAL_OPTIONS, + useValue: { displayDefaultIndicatorType: false } + }] }) + export class CreateDirectionComponent implements OnInit, OnDestroy { + techAdmin: TechAdmin; directionFormGroup: FormGroup; + departmentFormGroup: FormGroup; + classFormGroup: FormGroup; editMode = false; - isActiveDirectionInfoButton = false; - isActiveSectionInfoButton = false; - isActiveClassInfoButton = false; + @ViewChild('stepper') stepper: MatStepper; constructor( - private fb: FormBuilder, - private store: Store, - private navigationBarService: NavigationBarService) { - - this.directionFormGroup = this.fb.group({ - image: new FormControl(''), - directionName: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), - sectionName: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), - className: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), - }); + private route: ActivatedRoute, + private store: Store,) { + } ngOnInit(): void { - this.store.dispatch(new AddNavPath(this.navigationBarService.creatNavPaths( - { name: NavBarName.AdminTools, isActive: false, disable: false }, - { name: NavBarName.Platform, isActive: false, disable: false }, - { name: NavBarName.Direction, isActive: false, disable: true } - ))); + + } + ngAfterViewInit(): void { + if (this.editMode) { + this.route.params.subscribe((params: Params) => { + this.stepper.selectedIndex = +createDirectionSteps[params.param]; + }); + } } + /** + * This method receives a form from create-info child component and assigns to the Info FormGroup + * @param FormGroup form + */ + //onReceiveDirectionFormGroup(form: FormGroup): void { + // this.directionFormGroup = form; + // } + + /** + * This method receives a form from create-info child component and assigns to the Info FormGroup + * @param FormGroup form + */ + // onReceiveDepartmentFormGroup(form: FormGroup): void { + // this.departmentFormGroup = form; + // } + + /** + * This method receives a form from create-info child component and assigns to the Info FormGroup + * @param FormGroup form + */ + // onReceiveClassFormGroup(form: FormGroup): void { + // this.classFormGroup = form; + // } + onSubmit(): void { } ngOnDestroy(): void { diff --git a/src/app/shell/admin-tools/platform/platform.module.ts b/src/app/shell/admin-tools/platform/platform.module.ts index e7679672e4..4a8aec135a 100644 --- a/src/app/shell/admin-tools/platform/platform.module.ts +++ b/src/app/shell/admin-tools/platform/platform.module.ts @@ -9,6 +9,9 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { RouterModule } from '@angular/router'; import { SupportFormComponent } from './support-edit/support-form/support-form.component'; import { CreateDirectionComponent } from './create-direction/create-direction.component'; +import { AddClassFormComponent } from './create-direction/add-class-form/add-class-form.component'; +import { AddDepartmentFormComponent } from './create-direction/add-department-form/add-department-form.component'; +import { AddDirectionFormComponent } from './create-direction/add-direction-form/add-direction-form.component'; @NgModule({ declarations: [ @@ -17,6 +20,9 @@ import { CreateDirectionComponent } from './create-direction/create-direction.co AboutFormComponent, SupportFormComponent, CreateDirectionComponent, + AddClassFormComponent, + AddDepartmentFormComponent, + AddDirectionFormComponent, ], imports: [ CommonModule, From 1e099276bcb8f6e3dd770f3d065963d273f979ea Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Wed, 9 Mar 2022 11:53:28 +0200 Subject: [PATCH 03/20] paginator paginator --- src/app/shared/models/category.model.ts | 5 +++++ src/app/shared/store/admin.actions.ts | 5 +++++ src/app/shared/store/admin.state.ts | 12 +++++++++++- .../platform/platform.component.html | 3 +++ .../platform/platform.component.ts | 19 +++++++++++++++++-- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index 05a789c2e1..2286d26d29 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -30,3 +30,8 @@ export interface IClass { description: string; departmentId: number; } + +export interface Directions { + totalAmount: number; + entities: Direction[]; +} diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index e6b044a7af..92b3067a8a 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -1,5 +1,6 @@ import { Direction } from "@angular/cdk/bidi"; import { AboutPortal } from "../models/aboutPortal.model"; +import { PaginationElement } from "../models/paginationElement.model"; export class GetInfoAboutPortal { static readonly type = '[admin] Get Information About Portal'; @@ -73,3 +74,7 @@ export class GetDepartmentByDirectionId { static readonly type = '[admin] get Department By Direction Id'; constructor(public payload) { } } +export class CabinetPageChange { + static readonly type = '[filter] Change Page'; + constructor(public payload: PaginationElement) { } +} diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 3e2b582ec0..4f237679c5 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -5,9 +5,10 @@ import { Observable, of, throwError } from "rxjs"; import { catchError, tap } from "rxjs/operators"; import { AboutPortal } from "../models/aboutPortal.model"; import { Department, Direction } from "../models/category.model"; +import { PaginationElement } from "../models/paginationElement.model"; import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId,} from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, CabinetPageChange,} from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { @@ -16,6 +17,7 @@ export interface AdminStateModel { aboutPortal: AboutPortal; departments: Department[]; selectedDirection: Direction; + currentPage: PaginationElement; } @State({ name: 'admin', @@ -25,6 +27,10 @@ export interface AdminStateModel { departments: [], isLoading: false, selectedDirection: null, + currentPage: { + element: 1, + isActive: true + }, } }) @Injectable() @@ -184,4 +190,8 @@ export class AdminState { return patchState({ departments: department, isLoading: false }); })); } + @Action(CabinetPageChange) + pageChange({ patchState }: StateContext, { payload }: CabinetPageChange): void { + patchState({ currentPage: payload }); + } } diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index 627af53747..b544314602 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -51,6 +51,9 @@
Про портал
+ + diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index 93492a381e..74cfba825b 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { ActivatedRoute, Params, Router } from '@angular/router'; @@ -9,10 +9,12 @@ import { ConfirmationModalWindowComponent } from 'src/app/shared/components/conf import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction } from 'src/app/shared/models/category.model'; -import { DeleteDirectionById, GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; +import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; +import { CabinetPageChange, DeleteDirectionById, GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; import { GetDirections } from 'src/app/shared/store/meta-data.actions'; import { MetaDataState } from 'src/app/shared/store/meta-data.state'; + @Component({ selector: 'app-platform', templateUrl: './platform.component.html', @@ -27,8 +29,16 @@ export class PlatformComponent implements OnInit, OnDestroy { directions$: Observable; destroy$: Subject = new Subject(); + + currentPage: PaginationElement = { + element: 1, + isActive: true + }; + tabIndex: number; + + constructor( private store: Store, private route: ActivatedRoute, @@ -47,6 +57,11 @@ export class PlatformComponent implements OnInit, OnDestroy { this.router.navigate([`admin-tools/platform/${this.adminTabs[event.index]}`]); } + onPageChange(page: PaginationElement): void { + this.currentPage = page; + this.store.dispatch(new CabinetPageChange(page)); + } + onDelete(direction: Direction): void { const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { width: '330px', From a8daf5a5d3ef97effb7a4a3e1f3f13c0d7768ca3 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Wed, 16 Mar 2022 09:41:40 +0200 Subject: [PATCH 04/20] pagg pagg --- src/app/shared/models/category.model.ts | 4 ++- .../services/categories/categories.service.ts | 28 +++++++++++++-- src/app/shared/store/admin.actions.ts | 15 +++++++- src/app/shared/store/admin.state.ts | 34 ++++++++++++++++-- .../platform/platform.component.html | 5 +-- .../platform/platform.component.ts | 33 +++++++++++++++-- src/assets/icons/marker1.png | Bin 0 -> 465 bytes src/assets/icons/marker2.png | Bin 0 -> 767 bytes src/assets/icons/marker3.svg | 3 ++ src/assets/icons/selectMarker2.png | Bin 0 -> 1234 bytes 10 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 src/assets/icons/marker1.png create mode 100644 src/assets/icons/marker2.png create mode 100644 src/assets/icons/marker3.svg create mode 100644 src/assets/icons/selectMarker2.png diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index 2286d26d29..5a733943ef 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -2,11 +2,13 @@ export class Direction { id: number; title: string; description: string; + constructor(info, id?) { this.id = id; this.title = info.title; this.description = info.title; + } } @@ -31,7 +33,7 @@ export interface IClass { departmentId: number; } -export interface Directions { +export interface DirectionsFilter { totalAmount: number; entities: Direction[]; } diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 5a22485462..3640d7383a 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -1,7 +1,9 @@ -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { IClass, Department, Direction } from '../../models/category.model'; +import { Constants } from '../../constants/constants'; +import { IClass, Department, Direction, DirectionsFilter } from '../../models/category.model'; +import { AdminStateModel } from '../../store/admin.state'; @Injectable({ providedIn: 'root' @@ -10,6 +12,28 @@ export class CategoriesService { constructor(private http: HttpClient) { } + private setParams(filters: AdminStateModel): HttpParams { + let params = new HttpParams(); + + if (filters.searchQuery) { + params = params.set('Name', filters.searchQuery); + } + + if (filters.currentPage) { + const size: number = Constants.ITEMS_PER_PAGE; + const from: number = size * (+filters.currentPage.element - 1); + + params = params.set('Size', size.toString()); + params = params.set('From', from.toString()); + } + return params; + } + + getFilteredDirections(filters: AdminStateModel): Observable { + const options = { params: this.setParams(filters) }; + return this.http.get('/api/v1/Workshop/GetByFilter', options); + } + getDirections(): Observable { return this.http.get('/api/v1/Direction/Get'); } diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index 92b3067a8a..cf2fbdf036 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -75,6 +75,19 @@ export class GetDepartmentByDirectionId { constructor(public payload) { } } export class CabinetPageChange { - static readonly type = '[filter] Change Page'; + static readonly type = '[admin] Change Page'; constructor(public payload: PaginationElement) { } } +export class SetFirstPage { + static readonly type = '[admin] Set First Page'; + constructor() { } +} +export class SetSearchQueryValue { + static readonly type = '[admin] Set Search Quesry Value'; + constructor(public payload: string) { } +} +export class GetFilteredDirections { + static readonly type = '[admin] Get Filtered Directions'; + constructor( ) { } +} + diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 4f237679c5..0a24d277d2 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -4,11 +4,11 @@ import { Action, Selector, State, StateContext } from "@ngxs/store"; import { Observable, of, throwError } from "rxjs"; import { catchError, tap } from "rxjs/operators"; import { AboutPortal } from "../models/aboutPortal.model"; -import { Department, Direction } from "../models/category.model"; +import { Department, Direction, DirectionsFilter } from "../models/category.model"; import { PaginationElement } from "../models/paginationElement.model"; import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, CabinetPageChange,} from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, CabinetPageChange, SetFirstPage, SetSearchQueryValue, GetFilteredDirections, } from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { @@ -18,6 +18,8 @@ export interface AdminStateModel { departments: Department[]; selectedDirection: Direction; currentPage: PaginationElement; + searchQuery: string; + filteredDirections: DirectionsFilter; } @State({ name: 'admin', @@ -27,6 +29,8 @@ export interface AdminStateModel { departments: [], isLoading: false, selectedDirection: null, + searchQuery: '', + filteredDirections: undefined, currentPage: { element: 1, isActive: true @@ -35,12 +39,18 @@ export interface AdminStateModel { }) @Injectable() export class AdminState { + adminStateModel: any; @Selector() static aboutPortal(state: AdminStateModel): AboutPortal { return state.aboutPortal; } @Selector() static direction(state: AdminStateModel): Direction { return state.direction; } @Selector() static departments(state: AdminStateModel): Department [] { return state.departments; } + @Selector() + static searchQuery(state: AdminStateModel): string { return state.searchQuery } + @Selector() + static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections }; + constructor( private portalService: PortalService, @@ -194,4 +204,24 @@ export class AdminState { pageChange({ patchState }: StateContext, { payload }: CabinetPageChange): void { patchState({ currentPage: payload }); } + @Action(SetFirstPage) + setFirstPage({ patchState }: StateContext) { + patchState({ currentPage: { element: 1, isActive: true } }); + } + @Action(SetSearchQueryValue) + setSearchQueryValue({ patchState }: StateContext, { payload }: SetSearchQueryValue) { + patchState({ searchQuery: payload }); + } + + @Action(GetFilteredDirections) + getFilteredDIrection({ patchState, getState }: StateContext, { }: GetFilteredDirections) { + patchState({ isLoading: true }); + const state: AdminStateModel = getState(); + + return this.categoriesService + .getFilteredDirections( state ) + .pipe(tap((filterResult: DirectionsFilter) => patchState(filterResult ? { filteredDirections: filterResult, isLoading: false } : { filteredDirections: undefined, isLoading: false }), + () => patchState({ isLoading: false }))); +} + } diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index b544314602..fccc5b1bdf 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -41,8 +41,9 @@
Про портал
diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index 74cfba825b..6888722dd3 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { ActivatedRoute, Params, Router } from '@angular/router'; @@ -10,7 +11,8 @@ import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction } from 'src/app/shared/models/category.model'; import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; -import { CabinetPageChange, DeleteDirectionById, GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; +import { CabinetPageChange, DeleteDirectionById, GetFilteredDirections, GetInfoAboutPortal, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; +import { AdminState } from 'src/app/shared/store/admin.state'; import { GetDirections } from 'src/app/shared/store/meta-data.actions'; import { MetaDataState } from 'src/app/shared/store/meta-data.state'; @@ -25,9 +27,16 @@ export class PlatformComponent implements OnInit, OnDestroy { readonly adminTabs = AdminTabs; readonly adminTabsUkr = AdminTabsUkr; + searchValue = new FormControl('', [Validators.maxLength(200)]); + isResultPage = false; + Name: string; + @Select(MetaDataState.directions) directions$: Observable; destroy$: Subject = new Subject(); + @Select(AdminState.searchQuery) + searchQuery$: Observable; + currentPage: PaginationElement = { @@ -36,6 +45,7 @@ export class PlatformComponent implements OnInit, OnDestroy { }; tabIndex: number; + @@ -44,13 +54,27 @@ export class PlatformComponent implements OnInit, OnDestroy { private route: ActivatedRoute, private router: Router, private matDialog: MatDialog) { } + ngOnInit(): void { - this.store.dispatch(new GetDirections()); + this.store.dispatch(new GetFilteredDirections()); this.store.dispatch(new GetInfoAboutPortal()); this.route.params.pipe( takeUntil(this.destroy$)) - .subscribe((params: Params) => this.tabIndex = +this.adminTabs[params.index]) + .subscribe((params: Params) => this.tabIndex = +this.adminTabs[params.index]); + + this.searchValue.valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe((val: string) => { + this.Name = val; + if (val.length === 0) { + this.store.dispatch(new SetSearchQueryValue('')); + } + }); + + this.searchQuery$ + .pipe(takeUntil(this.destroy$)) + .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); } onSelectedTabChange(event: MatTabChangeEvent): void { @@ -80,4 +104,7 @@ export class PlatformComponent implements OnInit, OnDestroy { this.destroy$.next(true); this.destroy$.unsubscribe(); } + onSearch(): void { + this.store.dispatch(new SetSearchQueryValue(this.Name || '')); + } } diff --git a/src/assets/icons/marker1.png b/src/assets/icons/marker1.png new file mode 100644 index 0000000000000000000000000000000000000000..a8623f1ead240601146195764038d1050b8cadd8 GIT binary patch literal 465 zcmV;?0WSWDP)EI^VKd`PAl5VA& zP%~)~?+r;U(Mo~`ZoIMCpnqPeQyP8IaE1=&iS>MnjB}sbt332 zpp5MFt{SX300000NkvXX Hu0mjf`t!$0 literal 0 HcmV?d00001 diff --git a/src/assets/icons/marker2.png b/src/assets/icons/marker2.png new file mode 100644 index 0000000000000000000000000000000000000000..55943c4f0200064deffe0666ac1f0e7838bc6fed GIT binary patch literal 767 zcmV?wQ^w@aHE4k*SZ6&h?)S{1ibFic&mD4wWBZ?D8$S#gP}vr$6NxT zLZo$@!1v5pgb-nM7-Xj^XsH7y zfTBIFVE-=J&r}uyI~@AEavJ@=_y*YAK`XI6s@^G|K^};M*1Cj9No=p8dCy}G-id=A zchD?}nv-4ppN+S`JQriGXQTq0bvz~uCoxlRP=?WW!&&MxjVJgru4e?y zs(dcPaVjOk?6zC7k}%J>J^)K&g-99oV7$2wL``5>fZvDN&v2Zne6n9KsMbhi?|;w_ zJZxdgwXViC-iieC`YdaRDzGlP>o%z0AY0YJ9Q?Lr0CAg58*}s?8y$f$cf^%ES?72RWRp xqm1+c=V^qvfd5}3MWcXu<8&9dR}TL#zX8bo1XU>&9oGN=002ovPDHLkV1kapThssm literal 0 HcmV?d00001 diff --git a/src/assets/icons/marker3.svg b/src/assets/icons/marker3.svg new file mode 100644 index 0000000000..9c2e3ddc24 --- /dev/null +++ b/src/assets/icons/marker3.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/icons/selectMarker2.png b/src/assets/icons/selectMarker2.png new file mode 100644 index 0000000000000000000000000000000000000000..6bb54e8a71b03f5bd13d66fc85aa8970e21af878 GIT binary patch literal 1234 zcmV;@1TFiCP)n3*nxG3nN z#2dqlE+YsMQ|ZPajS>k9Di9@-G<9~Ctq2LjOx8UsZX`;PC7KuJ=PrBB%z3(Swu@DF zp7))zUHHG8^Z!53^FQy$dERpdZV*VG!SsP8)00wtk%&BtY6Z9tn9;m^4)`6BAyvMQ zMml=s=!D;2GZ-6C&;p3-W>-tey5zdl?yw;H!+SAVOn@xj_m&1MHIM@b-{wpG)#9gbtVAr zNyGXMoz-1*5jh!2&Ud{9@}yf`UU({*E~{Mx=Bd@(Vvpg!JGmms3i4p*!QS62Wb=qL zpA-L=34ka_vp20|(}?K93(9HKbqciXUzZmyhsnt8GQ9UvE23#clBl%U(Zm?=Ap!Hl zM!g(1>SY4vgKlhIv!W|0mU=A2f`!!VolKbpPAb8|Xs|jo;nD%%KvL=XRD`O+ou+uo zbHJCac(yfir2({H>^dg?LloCyRTg0#8O4;_y4deG@-|OqVjNLii$OjyMHE|ZtC5>b ztSs1Sj0cigxi?!#RwJeb64o#MVvI*PHfrssG7HISjr?OFrG@fC z#(1PDCaxf7Ej*JEfnydPL1U?j2cW?#w%mHul-fedz&M{}MN;W$xm{l2=n7kIHRZNV zEg?4XpeRChGBZh~ry@cXh%5n>V8B+QCD`2VTT|pT_BEA&e2ipU$9JcCRDML!mzyJD zG6B@XNN37{z6-60<~BZ=+cOBZr)+Le*%!sVPg|(wHeQiE{uTK_V3(C^KOqLeHm_>@ zp>@&iRt2b@4bZTXKrP=BM{jn0|Tj(#x+SjV?A!iRaaanWZ@=Pk+YG~;l96s&s}v^ zsOm4Lspxti?W7Q0EyMk$wtXVJi~vNP z<#oWHzWS>m91Z2nW?#9t5!t_e6qQxJ`fC*OhU-o>LGO<+eryY1YO`D5yTYMbwVeQM z84=cGD6azEcM=%MG(0t(r@A>KlR&~Zz+fjNFv~2_+x~OYGhCQS|7iM*R zkVg%S|?VgXyKA^)W8PlvWuQ=52a|5nIE+YaE9qRi@Ro7Yhg09TV1mtK0Aeu3{ z2KccRPlay^gHODlXYO48!T~Tcr~9r#2QkRZ>rl>wL8BrA{ipKGo9l?cm8McvmUHd* z#SKxG=4}F|zz9GwuI&&SsBK)Z>J(>?o(?V3X)cOzCd^hKvZ`Y;=UKf_-5Y~ wrcZA^5Kv7=mZxFqUIZ Date: Wed, 16 Mar 2022 14:12:49 +0200 Subject: [PATCH 05/20] pgg pgg --- src/app/shared/services/categories/categories.service.ts | 2 +- src/app/shell/admin-tools/platform/platform.component.html | 4 ++-- src/app/shell/admin-tools/platform/platform.component.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 3640d7383a..4fa4fe6edf 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -31,7 +31,7 @@ export class CategoriesService { getFilteredDirections(filters: AdminStateModel): Observable { const options = { params: this.setParams(filters) }; - return this.http.get('/api/v1/Workshop/GetByFilter', options); + return this.http.get('/api/v1/Direction/GetByFilter', options); } getDirections(): Observable { diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index fccc5b1bdf..236eb145ae 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -49,10 +49,10 @@
Про портал
- -
diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index 6888722dd3..abef95de4e 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -9,7 +9,7 @@ import { takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; -import { Direction } from 'src/app/shared/models/category.model'; +import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; import { CabinetPageChange, DeleteDirectionById, GetFilteredDirections, GetInfoAboutPortal, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; @@ -31,8 +31,8 @@ export class PlatformComponent implements OnInit, OnDestroy { isResultPage = false; Name: string; - @Select(MetaDataState.directions) - directions$: Observable; + @Select(AdminState.filteredDirections) + filteredDirections$: Observable; destroy$: Subject = new Subject(); @Select(AdminState.searchQuery) searchQuery$: Observable; From f09a18df9cabfa06ff8a765debf0f215f45d82d7 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Wed, 23 Mar 2022 17:11:35 +0200 Subject: [PATCH 06/20] search + paging search + paging --- src/app/shared/enum/no-results.ts | 3 +- .../services/categories/categories.service.ts | 4 +- src/app/shared/store/admin.actions.ts | 13 ++- src/app/shared/store/admin.state.ts | 51 +++++--- .../shell/admin-tools/admin-tools.module.ts | 6 + .../add-class-form.component.html | 10 +- .../create-direction.component.html | 1 + .../create-direction.component.ts | 1 + .../directions/directions.component.html | 25 ++++ .../directions/directions.component.scss | 89 ++++++++++++++ .../directions/directions.component.spec.ts | 25 ++++ .../directions/directions.component.ts | 110 ++++++++++++++++++ .../platform/platform.component.html | 19 +-- .../platform/platform.component.ts | 56 +-------- .../admin-tools/platform/platform.module.ts | 7 +- 15 files changed, 319 insertions(+), 101 deletions(-) create mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.html create mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.scss create mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.spec.ts create mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.ts diff --git a/src/app/shared/enum/no-results.ts b/src/app/shared/enum/no-results.ts index 9d515ccbbb..e6cec0bd8b 100644 --- a/src/app/shared/enum/no-results.ts +++ b/src/app/shared/enum/no-results.ts @@ -2,5 +2,6 @@ export enum NoResultsTitle { noApplication = 'Заявок поки немає', noResultWorkshops = 'За результатами нічого не знайдено', noParentWorkshops = 'Тут буде відображатися інформація про гуртки, секцію фбо школу для навчання. Ще жодної заяви на гурток не подано.', - noFavoriteWorkshops = 'Улюблених гуртків поки немає' + noFavoriteWorkshops = 'Улюблених гуртків поки немає', + noDirections = 'За результатами нічого не знайдено', } diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 4fa4fe6edf..eb648e8179 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -17,8 +17,8 @@ export class CategoriesService { if (filters.searchQuery) { params = params.set('Name', filters.searchQuery); - } - + } + if (filters.currentPage) { const size: number = Constants.ITEMS_PER_PAGE; const from: number = size * (+filters.currentPage.element - 1); diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index cf2fbdf036..4ce76c2818 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -74,12 +74,12 @@ export class GetDepartmentByDirectionId { static readonly type = '[admin] get Department By Direction Id'; constructor(public payload) { } } -export class CabinetPageChange { +export class PageChange { static readonly type = '[admin] Change Page'; constructor(public payload: PaginationElement) { } } -export class SetFirstPage { - static readonly type = '[admin] Set First Page'; +export class FilterChange { + static readonly type = '[admin] Filter Change'; constructor() { } } export class SetSearchQueryValue { @@ -88,6 +88,11 @@ export class SetSearchQueryValue { } export class GetFilteredDirections { static readonly type = '[admin] Get Filtered Directions'; - constructor( ) { } + constructor() { } +} +export class FilterClear { + static readonly type = '[filter] Filter Clear'; + constructor() { } } + diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 0a24d277d2..6f251bb423 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -8,7 +8,7 @@ import { Department, Direction, DirectionsFilter } from "../models/category.mode import { PaginationElement } from "../models/paginationElement.model"; import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, CabinetPageChange, SetFirstPage, SetSearchQueryValue, GetFilteredDirections, } from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, SetFirstPage, SetSearchQueryValue, GetFilteredDirections, PageChange, FilterChange, ResetSelectedDirection, FilterClear, } from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { @@ -49,7 +49,11 @@ export class AdminState { @Selector() static searchQuery(state: AdminStateModel): string { return state.searchQuery } @Selector() - static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections }; + static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections } + @Selector() + static currentPage(state: AdminStateModel): {} { return state.currentPage }; + @Selector() + static isLoading(state: AdminStateModel): boolean { return state.isLoading }; constructor( @@ -200,28 +204,43 @@ export class AdminState { return patchState({ departments: department, isLoading: false }); })); } - @Action(CabinetPageChange) - pageChange({ patchState }: StateContext, { payload }: CabinetPageChange): void { - patchState({ currentPage: payload }); - } - @Action(SetFirstPage) - setFirstPage({ patchState }: StateContext) { - patchState({ currentPage: { element: 1, isActive: true } }); - } + + @Action(SetSearchQueryValue) - setSearchQueryValue({ patchState }: StateContext, { payload }: SetSearchQueryValue) { + setSearchQueryValue({ patchState, dispatch }: StateContext, { payload }: SetSearchQueryValue) { patchState({ searchQuery: payload }); + dispatch(new FilterChange()); } + @Action(FilterChange) + filterChange({ }: StateContext, { }: FilterChange) { } + + @Action(GetFilteredDirections) - getFilteredDIrection({ patchState, getState }: StateContext, { }: GetFilteredDirections) { + getFilteredDirections({ patchState, getState }: StateContext, { }: GetFilteredDirections) { patchState({ isLoading: true }); const state: AdminStateModel = getState(); return this.categoriesService - .getFilteredDirections( state ) + .getFilteredDirections( state) .pipe(tap((filterResult: DirectionsFilter) => patchState(filterResult ? { filteredDirections: filterResult, isLoading: false } : { filteredDirections: undefined, isLoading: false }), - () => patchState({ isLoading: false }))); -} - + () => patchState({ isLoading: false, selectedDirection: null }))); + } + + @Action(PageChange) + pageChange({ patchState, dispatch }: StateContext, { payload }: PageChange): void { + patchState({ currentPage: payload }); + dispatch(new GetFilteredDirections()); + } + @Action(FilterClear) + FilterClear({ patchState }: StateContext, { }: FilterChange) { + patchState({ + searchQuery: '', + currentPage: { + element: 1, + isActive: true + } + }); + } + } diff --git a/src/app/shell/admin-tools/admin-tools.module.ts b/src/app/shell/admin-tools/admin-tools.module.ts index 3c937b1139..e1f6b0a2bc 100644 --- a/src/app/shell/admin-tools/admin-tools.module.ts +++ b/src/app/shell/admin-tools/admin-tools.module.ts @@ -4,17 +4,23 @@ import { AdminToolsRoutingModule } from './admin-tools-routing.module'; import { PlatformComponent } from './platform/platform.component'; import { SharedModule } from 'src/app/shared/shared.module'; import { FlexLayoutModule } from '@angular/flex-layout'; +import { DirectionsComponent } from './platform/directions/directions.component'; @NgModule({ declarations: [ PlatformComponent, + DirectionsComponent, + ], imports: [ CommonModule, AdminToolsRoutingModule, SharedModule, FlexLayoutModule + ], + exports: [ + DirectionsComponent ] }) export class AdminToolsModule { } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html index e81d9674ee..d2313af996 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -17,15 +17,15 @@ [ngClass]="isActiveClassInfoButton ? 'activeInfoBtn' : 'inactiveInfoBtn'">info_outline - + + [isEmptyCheck]="classFormGroup.get('title').errors?.required" + [invalid]="classFormGroup.get('title').invalid && classFormGroup.get('title').touched"> + [invalid]="classFormGroup.get('title').invalid && classFormGroup.get('title').touched" + [forbiddenCharacter]="classFormGroup.get('title').errors?.pattern?.requiredPattern">
+
+ +
+ + + + + +
+ + + + diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.scss b/src/app/shell/admin-tools/platform/directions/directions.component.scss new file mode 100644 index 0000000000..c341a1427c --- /dev/null +++ b/src/app/shell/admin-tools/platform/directions/directions.component.scss @@ -0,0 +1,89 @@ + +@import "src/app/shared/styles/card-wrapper.scss"; +@import "src/app/shared/styles/config.scss"; +@import "src/app/shared/styles/navigation-tabs.scss"; +@import "src/app/shared/styles/buttons.scss"; +.wrapper{ + p { + font-family: Open Sans; + font-style: normal; + font-weight: normal; + font-size: 13px; + line-height: 18px; + } +} + +.link { + color: blue; + font-weight: 300!important; +} + +.support-title { + margin-bottom: 1rem; +} + +.config-button { + font-weight: 300; + font-family:Open Sans; +} + +.config-support p { + margin: 0; +} + +.header-wrapper{ + margin-bottom: 2rem; +} + +.title{ + margin-right: 1rem; +} + +@media(max-width: 750px) { + .header-wrapper{ + margin: 2rem 1rem; + } +} + +:host ::ng-deep .mat-form-field-wrapper { + padding: 0 0 0 10px; + width: 100%; +} + +:host ::ng-deep .mat-form-field-infix { + border: none; + display: flex; +} + +button { + border: none; + height: 100%; +} + +input { + font-weight: normal; + line-height: 22px; + color: #161414; + opacity: 0.4; + text-overflow: ellipsis; +} + +.icon { + margin: 0 1rem; + color: #AAAAAA; + line-height: 26px; + cursor: pointer; +} + +.search { + background: white; + margin: 1rem 0.5rem; + border-radius: 60px; + min-width: 300px; + max-width: 378px; + width: 100%; +} + +.shadow { + box-shadow: 0px 6px 16px rgb(0 0 0 / 8%); +} diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts b/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts new file mode 100644 index 0000000000..55def506a4 --- /dev/null +++ b/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DirectionsComponent } from './directions.component'; + +describe('DirectionsComponent', () => { + let component: DirectionsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ DirectionsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DirectionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.ts b/src/app/shell/admin-tools/platform/directions/directions.component.ts new file mode 100644 index 0000000000..e81931bf1c --- /dev/null +++ b/src/app/shell/admin-tools/platform/directions/directions.component.ts @@ -0,0 +1,110 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; +import { MatTabChangeEvent } from '@angular/material/tabs'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Actions, ofAction, Select, Store } from '@ngxs/store'; +import { Observable, Subject } from 'rxjs'; +import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; +import { NoResultsTitle } from 'src/app/shared/enum/no-results'; +import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; +import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; +import { DeleteDirectionById, FilterChange, FilterClear, GetFilteredDirections, PageChange, ResetSelectedDirection, SetFirstPage, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; +import { AdminState } from 'src/app/shared/store/admin.state'; +import { ResetSelectedWorkshop } from 'src/app/shared/store/user.actions'; + +@Component({ + selector: 'app-directions', + templateUrl: './directions.component.html', + styleUrls: ['./directions.component.scss'] +}) +export class DirectionsComponent implements OnInit { + + readonly noDirections = NoResultsTitle.noDirections; + searchValue = new FormControl('', [Validators.maxLength(200)]); + isResultPage = true; + searchedText: string; + + @Select(AdminState.filteredDirections) + filteredDirections$: Observable; + + @Select(AdminState.searchQuery) + searchQuery$: Observable; + + @Select(AdminState.isLoading) + isLoading$: Observable; + + destroy$: Subject = new Subject(); + + currentPage: PaginationElement = { + element: 1, + isActive: true + }; + + tabIndex: number; + + constructor( + private store: Store, + private route: ActivatedRoute, + private router: Router, + private actions$: Actions, + private matDialog: MatDialog) { } + + + ngOnInit(): void { + this.store.dispatch([new FilterClear(), new GetFilteredDirections(), ]); + + this.searchValue.valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe((val: string) => { + this.searchedText = val; + if (val.length === 0) { + this.store.dispatch(new SetSearchQueryValue('')); + } + }); + + this.searchQuery$ + .pipe(takeUntil(this.destroy$)) + .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); + + this.actions$.pipe(ofAction(FilterChange)) + .pipe( + debounceTime(1000), + distinctUntilChanged(), + takeUntil(this.destroy$)) + .subscribe(() => this.store.dispatch([ + new GetFilteredDirections(), + ])); + } + + onSearch(): void { + + this.store.dispatch(new SetSearchQueryValue(this.searchedText || '')); + } + + onPageChange(page: PaginationElement): void { + this.currentPage = page; + this.store.dispatch(new PageChange(page)); + } + + onDelete(direction: Direction): void { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.deleteDirection, + property: direction.title + } + }); + + dialogRef.afterClosed().subscribe((result: boolean) => { + result && this.store.dispatch(new DeleteDirectionById(direction.id)); + }); + } + + ngOnDestroy(): void { + this.destroy$.next(true); + this.destroy$.unsubscribe(); + } +} diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index 236eb145ae..a13249b0f1 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -38,24 +38,7 @@
Про портал
-
- - -
-
- - - - -
+
diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index abef95de4e..4dedff185a 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -6,12 +6,10 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; -import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; -import { CabinetPageChange, DeleteDirectionById, GetFilteredDirections, GetInfoAboutPortal, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; +import { GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; import { GetDirections } from 'src/app/shared/store/meta-data.actions'; import { MetaDataState } from 'src/app/shared/store/meta-data.state'; @@ -27,26 +25,12 @@ export class PlatformComponent implements OnInit, OnDestroy { readonly adminTabs = AdminTabs; readonly adminTabsUkr = AdminTabsUkr; - searchValue = new FormControl('', [Validators.maxLength(200)]); - isResultPage = false; - Name: string; - @Select(AdminState.filteredDirections) filteredDirections$: Observable; destroy$: Subject = new Subject(); - @Select(AdminState.searchQuery) - searchQuery$: Observable; - - - currentPage: PaginationElement = { - element: 1, - isActive: true - }; tabIndex: number; - - constructor( @@ -54,57 +38,21 @@ export class PlatformComponent implements OnInit, OnDestroy { private route: ActivatedRoute, private router: Router, private matDialog: MatDialog) { } - + ngOnInit(): void { - this.store.dispatch(new GetFilteredDirections()); this.store.dispatch(new GetInfoAboutPortal()); this.route.params.pipe( takeUntil(this.destroy$)) .subscribe((params: Params) => this.tabIndex = +this.adminTabs[params.index]); - this.searchValue.valueChanges - .pipe(takeUntil(this.destroy$)) - .subscribe((val: string) => { - this.Name = val; - if (val.length === 0) { - this.store.dispatch(new SetSearchQueryValue('')); - } - }); - - this.searchQuery$ - .pipe(takeUntil(this.destroy$)) - .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); } - onSelectedTabChange(event: MatTabChangeEvent): void { this.router.navigate([`admin-tools/platform/${this.adminTabs[event.index]}`]); } - onPageChange(page: PaginationElement): void { - this.currentPage = page; - this.store.dispatch(new CabinetPageChange(page)); - } - - onDelete(direction: Direction): void { - const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { - width: '330px', - data: { - type: ModalConfirmationType.deleteDirection, - property: direction.title - } - }); - - dialogRef.afterClosed().subscribe((result: boolean) => { - result && this.store.dispatch(new DeleteDirectionById(direction.id)); - }); - } - ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); } - onSearch(): void { - this.store.dispatch(new SetSearchQueryValue(this.Name || '')); - } } diff --git a/src/app/shell/admin-tools/platform/platform.module.ts b/src/app/shell/admin-tools/platform/platform.module.ts index 4a8aec135a..398320aa71 100644 --- a/src/app/shell/admin-tools/platform/platform.module.ts +++ b/src/app/shell/admin-tools/platform/platform.module.ts @@ -12,6 +12,9 @@ import { CreateDirectionComponent } from './create-direction/create-direction.co import { AddClassFormComponent } from './create-direction/add-class-form/add-class-form.component'; import { AddDepartmentFormComponent } from './create-direction/add-department-form/add-department-form.component'; import { AddDirectionFormComponent } from './create-direction/add-direction-form/add-direction-form.component'; +import { DirectionsComponent } from './directions/directions.component'; +import { AdminToolsModule } from '../admin-tools.module'; +import { NoResultCardComponent } from 'src/app/shared/components/no-result-card/no-result-card.component'; @NgModule({ declarations: [ @@ -23,13 +26,15 @@ import { AddDirectionFormComponent } from './create-direction/add-direction-form AddClassFormComponent, AddDepartmentFormComponent, AddDirectionFormComponent, + ], imports: [ CommonModule, FlexLayoutModule, SharedModule, MaterialModule, - RouterModule + RouterModule, + AdminToolsModule, ] }) export class PlatformModule { } From 500180b0ff62f8c42e0960531c0c19c56c861506 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 24 Mar 2022 16:05:40 +0200 Subject: [PATCH 07/20] test test --- src/app/shared/enum/modal-confirmation.ts | 3 + src/app/shared/models/category.model.ts | 11 +- .../services/categories/categories.service.ts | 3 + src/app/shared/store/admin.actions.ts | 15 ++- src/app/shared/store/admin.state.ts | 39 +++++- src/app/shared/store/meta-data.state.ts | 1 + .../shell/admin-tools/admin-tools.module.ts | 2 +- .../add-class-form.component.html | 11 -- .../add-class-form.component.ts | 34 +----- .../add-department-form.component.spec.ts | 3 +- .../create-direction.component.html | 10 +- .../create-direction.component.spec.ts | 3 +- .../create-direction.component.ts | 112 ++++++++++++------ .../directions/directions.component.html | 25 ++++ .../directions/directions.component.scss | 89 ++++++++++++++ .../directions/directions.component.spec.ts | 47 ++++++++ .../directions/directions.component.ts | 109 +++++++++++++++++ .../platform/platform.component.spec.ts | 3 +- .../admin-tools/platform/platform.module.ts | 2 +- 19 files changed, 437 insertions(+), 85 deletions(-) create mode 100644 src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html create mode 100644 src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss create mode 100644 src/app/shell/admin-tools/platform/create-direction/directions/directions.component.spec.ts create mode 100644 src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts diff --git a/src/app/shared/enum/modal-confirmation.ts b/src/app/shared/enum/modal-confirmation.ts index 690ca93426..51ac66b736 100644 --- a/src/app/shared/enum/modal-confirmation.ts +++ b/src/app/shared/enum/modal-confirmation.ts @@ -10,12 +10,14 @@ export enum ModalConfirmationType { rejectApplication = 'rejectApplication', createDirection = 'createDirection', createDepartment = 'createDepartment', + createClass = 'createClass', } export enum ModalConfirmationTitle { delete = 'ВИДАЛИТИ ГУРТОК?', deleteDirection = 'ВИДАЛИТИ НАПРЯМОК?', createDirection = 'CТВОРИТИ НАПРЯМОК?', createDepartment = 'CТВОРИТИ ВІДДІЛЕННЯ?', + createClass = 'CТВОРИТИ КЛАС?', deleteChild = 'ВИЛУЧИТИ ДАНІ ПРО ДИТИНУ?', leaveWorkshop = 'ЗАЛИШИТИ ГУРТОК?', leavePage = 'ЗАЛИШИТИ СТОРІНКУ?', @@ -29,6 +31,7 @@ export enum ModalConfirmationText { deleteDirection = 'Ви впевнені, що хочете видалити напрямок', createDirection = 'Ви впевнені, що хочете створити напрямок?', createDepartment = 'Ви впевнені, що хочете створити відділення?', + createClass = 'Ви впевнені, що хочете створити клас?', deleteChild = 'Ви впевнені, що хочете вилучити дані про дитину', leaveWorkshop = 'Ви впевнені, що хочете залишити гурток', leavePage = 'Ви впевнені, що хочете залишити сторінку?', diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index 5a733943ef..64d236b384 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -26,11 +26,18 @@ export class Department { } } -export interface IClass { +export class IClass { id: number; + departmentId: number; title: string; description: string; - departmentId: number; + + constructor(info, departmentId, id?) { + this.id = id; + this.departmentId = departmentId; + this.title = info.title; + this.description = info.title; + } } export interface DirectionsFilter { diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index eb648e8179..422ce8459a 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -65,4 +65,7 @@ export class CategoriesService { getDirectionById(id: number): Observable { return this.http.get(`/api/v1/Direction/GetById/${id}`); } + createClass(iClass: IClass): Observable { + return this.http.post('/api/v1/Class/CreateMultiple', iClass); + } } diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index 4ce76c2818..6d01151907 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -1,5 +1,6 @@ import { Direction } from "@angular/cdk/bidi"; import { AboutPortal } from "../models/aboutPortal.model"; +import { IClass } from "../models/category.model"; import { PaginationElement } from "../models/paginationElement.model"; export class GetInfoAboutPortal { @@ -72,7 +73,7 @@ export class GetDirectionById { } export class GetDepartmentByDirectionId { static readonly type = '[admin] get Department By Direction Id'; - constructor(public payload) { } + constructor(public payload: number) { } } export class PageChange { static readonly type = '[admin] Change Page'; @@ -94,5 +95,17 @@ export class FilterClear { static readonly type = '[filter] Filter Clear'; constructor() { } } +export class CreateClass { + static readonly type = '[admin] create Children'; + constructor(public payload) { } +} +export class OnCreateClassFail { + static readonly type = '[admin] create Children fail'; + constructor(public payload: Error) { } +} +export class OnCreateClassSuccess { + static readonly type = '[admin] create Children success'; + constructor(public payload) { } +} diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 6f251bb423..2f271cc7c6 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -4,18 +4,20 @@ import { Action, Selector, State, StateContext } from "@ngxs/store"; import { Observable, of, throwError } from "rxjs"; import { catchError, tap } from "rxjs/operators"; import { AboutPortal } from "../models/aboutPortal.model"; -import { Department, Direction, DirectionsFilter } from "../models/category.model"; +import { Department, Direction, DirectionsFilter, IClass } from "../models/category.model"; import { PaginationElement } from "../models/paginationElement.model"; import { CategoriesService } from "../services/categories/categories.service"; import { PortalService } from "../services/portal/portal.service"; -import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, SetFirstPage, SetSearchQueryValue, GetFilteredDirections, PageChange, FilterChange, ResetSelectedDirection, FilterClear, } from "./admin.actions"; +import { DeleteDirectionById, GetInfoAboutPortal, OnDeleteDirectionFail, OnDeleteDirectionSuccess, OnUpdateInfoAboutPortalFail, OnUpdateInfoAboutPortalSuccess, UpdateInfoAboutPortal,CreateDirection, OnCreateDirectionFail, OnCreateDirectionSuccess, UpdateDirection, OnUpdateDirectionSuccess, OnUpdateDirectionFail, CreateDepartment, OnCreateDepartmentFail, OnCreateDepartmentSuccess, GetDirectionById, GetDepartmentByDirectionId, SetSearchQueryValue, GetFilteredDirections, PageChange, FilterChange, FilterClear, OnCreateClassFail, OnCreateClassSuccess, CreateClass, } from "./admin.actions"; import { MarkFormDirty, ShowMessageBar } from "./app.actions"; export interface AdminStateModel { isLoading: boolean; direction: Direction; + department: Department; aboutPortal: AboutPortal; departments: Department[]; + classes: IClass[]; selectedDirection: Direction; currentPage: PaginationElement; searchQuery: string; @@ -26,7 +28,9 @@ export interface AdminStateModel { defaults: { aboutPortal: null, direction: undefined, + department: undefined, departments: [], + classes: [], isLoading: false, selectedDirection: null, searchQuery: '', @@ -45,8 +49,12 @@ export class AdminState { @Selector() static direction(state: AdminStateModel): Direction { return state.direction; } @Selector() + static department(state: AdminStateModel): Department { return state.department; } + @Selector() static departments(state: AdminStateModel): Department [] { return state.departments; } @Selector() + static classes(state: AdminStateModel): IClass [] { return state.classes; } + @Selector() static searchQuery(state: AdminStateModel): string { return state.searchQuery } @Selector() static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections } @@ -179,11 +187,36 @@ export class AdminState { } @Action(OnCreateDepartmentSuccess) - OnCreateDepartmentSuccess({ dispatch }: StateContext, { payload }: OnCreateDepartmentSuccess): void { + OnCreateDepartmentSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDepartmentSuccess): void { dispatch(new MarkFormDirty(false)); + patchState({department: payload}); console.log('Department is created', payload); dispatch(new ShowMessageBar({ message: 'Напрямок успішно створенний', type: 'success' })); } + + @Action(CreateClass) + CreateClass({ dispatch }: StateContext, { payload }: CreateClass): Observable { + return this.categoriesService + .createClass(payload) + .pipe( + tap((res) => dispatch(new OnCreateClassSuccess(res))), + catchError((error: Error) => of(dispatch(new OnCreateClassFail(error)))) + ); + } + + @Action(OnCreateClassFail) + onCreateClassFail({ dispatch }: StateContext, { payload }: OnCreateClassFail): void { + throwError(payload); + dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); + } + + @Action(OnCreateClassSuccess) + onCreateChildrenSuccess({ dispatch }: StateContext, { payload }: OnCreateClassSuccess): void { + dispatch(new MarkFormDirty(false)); + console.log('Class is created', payload); + dispatch(new ShowMessageBar({ message: 'Дитина успішно зареєстрована', type: 'success' })); + this.router.navigate(['/personal-cabinet/parent/info']); + } @Action(GetDirectionById) getDirectionById({ patchState }: StateContext, { payload }: GetDirectionById): Observable { patchState({ isLoading: true }); diff --git a/src/app/shared/store/meta-data.state.ts b/src/app/shared/store/meta-data.state.ts index 56e1467ad5..8b309bb61b 100644 --- a/src/app/shared/store/meta-data.state.ts +++ b/src/app/shared/store/meta-data.state.ts @@ -145,6 +145,7 @@ export class MetaDataState { @Action(GetDepartments) getDepartments({ patchState }: StateContext, { payload }: GetDepartments): Observable { + patchState({ isLoading: true }) return this.categoriesService .getDepartmentsByDirectionId(payload) .pipe( diff --git a/src/app/shell/admin-tools/admin-tools.module.ts b/src/app/shell/admin-tools/admin-tools.module.ts index e1f6b0a2bc..8d0ecd9eab 100644 --- a/src/app/shell/admin-tools/admin-tools.module.ts +++ b/src/app/shell/admin-tools/admin-tools.module.ts @@ -4,7 +4,7 @@ import { AdminToolsRoutingModule } from './admin-tools-routing.module'; import { PlatformComponent } from './platform/platform.component'; import { SharedModule } from 'src/app/shared/shared.module'; import { FlexLayoutModule } from '@angular/flex-layout'; -import { DirectionsComponent } from './platform/directions/directions.component'; +import { DirectionsComponent } from './platform/create-direction/directions/directions.component'; @NgModule({ diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html index d2313af996..04bb5fc306 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -27,15 +27,4 @@ [invalid]="classFormGroup.get('title').invalid && classFormGroup.get('title').touched" [forbiddenCharacter]="classFormGroup.get('title').errors?.pattern?.requiredPattern"> -
- -
- - diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts index d824bc25b6..182c632e94 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -11,6 +11,7 @@ import { CreateFormComponent } from 'src/app/shell/personal-cabinet/create-form/ import { IClass } from 'src/app/shared/models/category.model'; import { takeUntil } from 'rxjs/operators'; import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; +import { Constants } from 'src/app/shared/constants/constants'; @Component({ @@ -20,43 +21,18 @@ import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; }) export class AddClassFormComponent implements OnInit { - classFormGroup: FormGroup; - isActiveClassInfoButton = false; - isActiveDepartmentInfoButton = false; - isActiveDirectionInfoButton = false; - editMode = false; + @Input() classFormGroup: FormGroup; - - @Input() admin: TechAdmin; - //@Output() passDirectionFormGroup = new EventEmitter(); + @Output() deleteForm = new EventEmitter(); constructor(private formBuilder: FormBuilder) { this.classFormGroup = this.formBuilder.group({ - className: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + title: new FormControl('', [Validators.maxLength(Constants.MAX_TEACHER_DESCRIPTION_LENGTH), Validators.required]) }); } - ngOnInit(): void { - (this.admin) && this.classFormGroup.patchValue(this.admin, { emitEvent: false }); - // this.passDirectionFormGroup.emit(this.classFormGroup); - } - - onSubmit(): void { } - - /** - * This method receives a form and marks each control of this form as touched - * @param FormGroup form - */ - //private checkValidation(form: FormGroup): void { - // Object.keys(form.controls).forEach(key => { - // form.get(key).markAsTouched(); - //}); - //} + ngOnInit(): void { } } - - - - diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts index 088dc706f8..5cbe24aabd 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -26,6 +26,7 @@ describe('AddClassFormComponent', () => { BrowserAnimationsModule, NgxsModule.forRoot([]), ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ AddDepartmentFormComponent, MockValidationHintForInputComponent, diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html index d5e6e40f9a..5700f44b29 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html @@ -24,12 +24,20 @@

{{(editMode) ? 'РЕДАГУВАТИ' : 'ДОДАТИ' - +

Клас

+ +
diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index c713421934..466d46f174 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -28,6 +28,7 @@ describe('CreateDirectionComponent', () => { RouterTestingModule, MatStepperModule, ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ CreateDirectionComponent, MockValidationHintForInputComponent, diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index c7edd88862..8ecf01193d 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -1,15 +1,23 @@ import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; import { MatStepper } from '@angular/material/stepper'; import { ActivatedRoute, Params } from '@angular/router'; -import { Store } from '@ngxs/store'; +import { Select, Store } from '@ngxs/store'; +import { Observable, Subject } from 'rxjs'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { createDirectionSteps } from 'src/app/shared/enum/provider'; +import { Department, Direction, IClass } from 'src/app/shared/models/category.model'; import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; +import { CreateClass, GetDepartmentByDirectionId, GetDirectionById } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; +import { GetDepartments, GetDirections } from 'src/app/shared/store/meta-data.actions'; +import { MetaDataState } from 'src/app/shared/store/meta-data.state'; import { AddNavPath, DeleteNavPath } from 'src/app/shared/store/navigation.actions'; @Component({ @@ -23,26 +31,65 @@ import { AddNavPath, DeleteNavPath } from 'src/app/shared/store/navigation.actio }) export class CreateDirectionComponent implements OnInit, OnDestroy { - techAdmin: TechAdmin; directionFormGroup: FormGroup; departmentFormGroup: FormGroup; classFormGroup: FormGroup; - editMode = false; @ViewChild('stepper') stepper: MatStepper; - constructor( + ClassFormArray: FormArray = new FormArray([]); + iClass: IClass; + + @Select(MetaDataState.classes) + iClasses$: Observable; + destroy$: Subject = new Subject(); + admin: TechAdmin; + @Input() department: Department; + direction: Direction; + + + constructor(private fb: FormBuilder, + private store: Store, private route: ActivatedRoute, - private store: Store,) { + private matDialog: MatDialog,) { } + ngOnInit(): void { + //this.store.dispatch(new GetDepartments()); + (this.admin) && this.classFormGroup.patchValue(this.admin, { emitEvent: false }); + //this.passDepartmentFormGroup.emit(this.departmentFormGroup); + } - ngOnInit(): void { + /** + * This method add new FormGroup to teh FormArray + */ + addClass(): void { + this.ClassFormArray.push(this.newForm()); + } + + /** + * This method create new FormGroup + * @param FormArray: array + */ + newForm(iClass?: IClass): FormGroup { + const classFormGroup = this.fb.group({ + title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + }); + iClass && classFormGroup.patchValue(iClass, { emitEvent: false }); + return classFormGroup; } - + + /** + * This method delete form from teh FormArray by index + * @param index: number + */ + onDeleteForm(index: number): void { + this.ClassFormArray.removeAt(index); + } + ngAfterViewInit(): void { if (this.editMode) { this.route.params.subscribe((params: Params) => { @@ -51,31 +98,30 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { } } - /** - * This method receives a form from create-info child component and assigns to the Info FormGroup - * @param FormGroup form - */ - //onReceiveDirectionFormGroup(form: FormGroup): void { - // this.directionFormGroup = form; - // } - - /** - * This method receives a form from create-info child component and assigns to the Info FormGroup - * @param FormGroup form - */ - // onReceiveDepartmentFormGroup(form: FormGroup): void { - // this.departmentFormGroup = form; - // } - - /** - * This method receives a form from create-info child component and assigns to the Info FormGroup - * @param FormGroup form - */ - // onReceiveClassFormGroup(form: FormGroup): void { - // this.classFormGroup = form; - // } + onSubmit(): void { + if (this.ClassFormArray.invalid) { + this.checkValidationClass(); + } else { + const department = this.store.selectSnapshot(AdminState.department); + this.ClassFormArray.controls.forEach((form: FormGroup) => { + const iClass: IClass = new IClass(form.value, department.id); + this.store.dispatch(new CreateClass(iClass)); + }); + } + + } + - onSubmit(): void { } + checkValidationClass(): void { + Object.keys(this.ClassFormArray.controls).forEach(key => { + this.checkValidation(this.ClassFormArray.get(key)); + }); + } + checkValidation(form: FormGroup): void { + Object.keys(form.controls).forEach(key => { + form.get(key).markAsTouched(); + }); + } ngOnDestroy(): void { this.store.dispatch(new DeleteNavPath()); diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html new file mode 100644 index 0000000000..f4d5b5efff --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -0,0 +1,25 @@ +
+ + +
+ +
+ + + + + +
+ + + + diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss new file mode 100644 index 0000000000..c341a1427c --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss @@ -0,0 +1,89 @@ + +@import "src/app/shared/styles/card-wrapper.scss"; +@import "src/app/shared/styles/config.scss"; +@import "src/app/shared/styles/navigation-tabs.scss"; +@import "src/app/shared/styles/buttons.scss"; +.wrapper{ + p { + font-family: Open Sans; + font-style: normal; + font-weight: normal; + font-size: 13px; + line-height: 18px; + } +} + +.link { + color: blue; + font-weight: 300!important; +} + +.support-title { + margin-bottom: 1rem; +} + +.config-button { + font-weight: 300; + font-family:Open Sans; +} + +.config-support p { + margin: 0; +} + +.header-wrapper{ + margin-bottom: 2rem; +} + +.title{ + margin-right: 1rem; +} + +@media(max-width: 750px) { + .header-wrapper{ + margin: 2rem 1rem; + } +} + +:host ::ng-deep .mat-form-field-wrapper { + padding: 0 0 0 10px; + width: 100%; +} + +:host ::ng-deep .mat-form-field-infix { + border: none; + display: flex; +} + +button { + border: none; + height: 100%; +} + +input { + font-weight: normal; + line-height: 22px; + color: #161414; + opacity: 0.4; + text-overflow: ellipsis; +} + +.icon { + margin: 0 1rem; + color: #AAAAAA; + line-height: 26px; + cursor: pointer; +} + +.search { + background: white; + margin: 1rem 0.5rem; + border-radius: 60px; + min-width: 300px; + max-width: 378px; + width: 100%; +} + +.shadow { + box-shadow: 0px 6px 16px rgb(0 0 0 / 8%); +} diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.spec.ts new file mode 100644 index 0000000000..312632b8e2 --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.spec.ts @@ -0,0 +1,47 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatStepperModule } from '@angular/material/stepper'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; +import { NgxsModule } from '@ngxs/store'; + +import { DirectionsComponent } from './directions.component'; + +describe('DirectionsComponent', () => { + let component: DirectionsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + MatIconModule, + NgxsModule.forRoot([]), + ReactiveFormsModule, + MatFormFieldModule, + MatInputModule, + BrowserAnimationsModule, + RouterTestingModule, + MatStepperModule, + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ + DirectionsComponent, + ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DirectionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts new file mode 100644 index 0000000000..7f221cb2ff --- /dev/null +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -0,0 +1,109 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; +import { MatTabChangeEvent } from '@angular/material/tabs'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Actions, ofAction, Select, Store } from '@ngxs/store'; +import { Observable, Subject } from 'rxjs'; +import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; +import { NoResultsTitle } from 'src/app/shared/enum/no-results'; +import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; +import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; +import { DeleteDirectionById, FilterChange, FilterClear, GetFilteredDirections, PageChange, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; +import { AdminState } from 'src/app/shared/store/admin.state'; + +@Component({ + selector: 'app-directions', + templateUrl: './directions.component.html', + styleUrls: ['./directions.component.scss'] +}) +export class DirectionsComponent implements OnInit { + + readonly noDirections = NoResultsTitle.noDirections; + searchValue = new FormControl('', [Validators.maxLength(200)]); + isResultPage = true; + searchedText: string; + + @Select(AdminState.filteredDirections) + filteredDirections$: Observable; + + @Select(AdminState.searchQuery) + searchQuery$: Observable; + + @Select(AdminState.isLoading) + isLoading$: Observable; + + destroy$: Subject = new Subject(); + + currentPage: PaginationElement = { + element: 1, + isActive: true + }; + + tabIndex: number; + + constructor( + private store: Store, + private route: ActivatedRoute, + private router: Router, + private actions$: Actions, + private matDialog: MatDialog) { } + + + ngOnInit(): void { + this.store.dispatch([new FilterClear(), new GetFilteredDirections(), ]); + + this.searchValue.valueChanges + .pipe(takeUntil(this.destroy$)) + .subscribe((val: string) => { + this.searchedText = val; + if (val.length === 0) { + this.store.dispatch(new SetSearchQueryValue('')); + } + }); + + this.searchQuery$ + .pipe(takeUntil(this.destroy$)) + .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); + + this.actions$.pipe(ofAction(FilterChange)) + .pipe( + debounceTime(1000), + distinctUntilChanged(), + takeUntil(this.destroy$)) + .subscribe(() => this.store.dispatch([ + new GetFilteredDirections(), + ])); + } + + onSearch(): void { + + this.store.dispatch(new SetSearchQueryValue(this.searchedText || '')); + } + + onPageChange(page: PaginationElement): void { + this.currentPage = page; + this.store.dispatch(new PageChange(page)); + } + + onDelete(direction: Direction): void { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.deleteDirection, + property: direction.title + } + }); + + dialogRef.afterClosed().subscribe((result: boolean) => { + result && this.store.dispatch(new DeleteDirectionById(direction.id)); + }); + } + + ngOnDestroy(): void { + this.destroy$.next(true); + this.destroy$.unsubscribe(); + } +} diff --git a/src/app/shell/admin-tools/platform/platform.component.spec.ts b/src/app/shell/admin-tools/platform/platform.component.spec.ts index c16d3e2e53..0c562c2d95 100644 --- a/src/app/shell/admin-tools/platform/platform.component.spec.ts +++ b/src/app/shell/admin-tools/platform/platform.component.spec.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatButtonModule } from '@angular/material/button'; import { MatDialogModule } from '@angular/material/dialog'; @@ -29,6 +29,7 @@ describe('PlatformComponent', () => { NoopAnimationsModule, MatDialogModule, ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ PlatformComponent, MockAllCategoriesCardComponent, diff --git a/src/app/shell/admin-tools/platform/platform.module.ts b/src/app/shell/admin-tools/platform/platform.module.ts index 398320aa71..d86e54a418 100644 --- a/src/app/shell/admin-tools/platform/platform.module.ts +++ b/src/app/shell/admin-tools/platform/platform.module.ts @@ -12,7 +12,7 @@ import { CreateDirectionComponent } from './create-direction/create-direction.co import { AddClassFormComponent } from './create-direction/add-class-form/add-class-form.component'; import { AddDepartmentFormComponent } from './create-direction/add-department-form/add-department-form.component'; import { AddDirectionFormComponent } from './create-direction/add-direction-form/add-direction-form.component'; -import { DirectionsComponent } from './directions/directions.component'; +import { DirectionsComponent } from './create-direction/directions/directions.component'; import { AdminToolsModule } from '../admin-tools.module'; import { NoResultCardComponent } from 'src/app/shared/components/no-result-card/no-result-card.component'; From 8df76e91e244a5dbf842a4395782d27576b00529 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Wed, 30 Mar 2022 16:31:10 +0300 Subject: [PATCH 08/20] Classes Classes --- .../image-form-control.component.html | 2 +- .../paginator/paginator.component.ts | 4 +- src/app/shared/constants/constants.ts | 1 + src/app/shared/models/category.model.ts | 12 +- .../services/categories/categories.service.ts | 6 +- src/app/shared/store/admin.actions.ts | 12 +- src/app/shared/store/admin.state.ts | 18 +-- src/app/shared/store/meta-data.actions.ts | 3 +- src/app/shared/store/meta-data.state.ts | 2 +- .../add-class-form.component.html | 27 ++--- .../add-class-form.component.scss | 9 +- .../add-class-form.component.spec.ts | 5 +- .../add-class-form.component.ts | 37 +++--- .../add-department-form.component.html | 8 +- .../add-department-form.component.ts | 38 +----- .../add-direction-form.component.html | 1 + .../add-direction-form.component.scss | 9 +- .../add-direction-form.component.ts | 25 +--- .../create-direction.component.html | 42 ++++--- .../create-direction.component.scss | 15 ++- .../create-direction.component.spec.ts | 5 - .../create-direction.component.ts | 114 +++++++++--------- .../directions/directions.component.html | 7 +- .../directions/directions.component.scss | 3 + .../directions/directions.component.ts | 4 - 25 files changed, 186 insertions(+), 223 deletions(-) diff --git a/src/app/shared/components/image-form-control/image-form-control.component.html b/src/app/shared/components/image-form-control/image-form-control.component.html index 184710cd3d..7f13108ebd 100644 --- a/src/app/shared/components/image-form-control/image-form-control.component.html +++ b/src/app/shared/components/image-form-control/image-form-control.component.html @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/src/app/shared/components/paginator/paginator.component.ts b/src/app/shared/components/paginator/paginator.component.ts index fd200047ce..3aa121e2ee 100644 --- a/src/app/shared/components/paginator/paginator.component.ts +++ b/src/app/shared/components/paginator/paginator.component.ts @@ -15,6 +15,8 @@ export class PaginatorComponent implements OnInit, OnChanges { @Input() currentPage: PaginationElement; @Input() totalEntities: number; + @Input() totalEntitiesDir: number; + @Output() pageChange = new EventEmitter(); constructor() { } @@ -91,7 +93,7 @@ export class PaginatorComponent implements OnInit, OnChanges { } private getTotalPageAmount(): number { - return Math.ceil(this.totalEntities / this.size); + return Math.ceil(this.totalEntities / this.size)|| Math.ceil(this.totalEntitiesDir / this.size); } private createDisplayedPageList(startPage: number): PaginationElement[] { diff --git a/src/app/shared/constants/constants.ts b/src/app/shared/constants/constants.ts index b83772a1d2..44f5278151 100644 --- a/src/app/shared/constants/constants.ts +++ b/src/app/shared/constants/constants.ts @@ -24,6 +24,7 @@ export class Constants { static readonly WORKSHOP_ENTITY_TYPE = 2; static readonly ITEMS_PER_PAGE = 8; + static readonly ITEMS_PER_PAGE_DIR = 10; static readonly RATE_ONE_STAR = 1; static readonly RATE_TWO_STAR = 2; diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index 64d236b384..4f36c54815 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -2,13 +2,13 @@ export class Direction { id: number; title: string; description: string; - + constructor(info, id?) { this.id = id; this.title = info.title; this.description = info.title; - + } } @@ -33,10 +33,10 @@ export class IClass { description: string; constructor(info, departmentId, id?) { - this.id = id; - this.departmentId = departmentId; - this.title = info.title; - this.description = info.title; + this.id = id, + this.departmentId = departmentId, + this.title = info.title, + this.description = info.title } } diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 422ce8459a..093fd63b3e 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -20,7 +20,7 @@ export class CategoriesService { } if (filters.currentPage) { - const size: number = Constants.ITEMS_PER_PAGE; + const size: number = Constants.ITEMS_PER_PAGE_DIR; const from: number = size * (+filters.currentPage.element - 1); params = params.set('Size', size.toString()); @@ -65,7 +65,7 @@ export class CategoriesService { getDirectionById(id: number): Observable { return this.http.get(`/api/v1/Direction/GetById/${id}`); } - createClass(iClass: IClass): Observable { - return this.http.post('/api/v1/Class/CreateMultiple', iClass); + createClass(classes: IClass[]): Observable { + return this.http.post('/api/v1/Class/CreateMultiple', classes); } } diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index 6d01151907..7513a14dfe 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -1,6 +1,6 @@ import { Direction } from "@angular/cdk/bidi"; import { AboutPortal } from "../models/aboutPortal.model"; -import { IClass } from "../models/category.model"; +import { Department, IClass } from "../models/category.model"; import { PaginationElement } from "../models/paginationElement.model"; export class GetInfoAboutPortal { @@ -57,7 +57,7 @@ export class OnUpdateDirectionSuccess { } export class CreateDepartment { static readonly type = '[admin] create Department'; - constructor(public payload) { } + constructor(public payload: Department) { } } export class OnCreateDepartmentFail { static readonly type = '[admin] create Department fail'; @@ -96,15 +96,15 @@ export class FilterClear { constructor() { } } export class CreateClass { - static readonly type = '[admin] create Children'; - constructor(public payload) { } + static readonly type = '[admin] create Class'; + constructor(public payload: IClass[]) { } } export class OnCreateClassFail { - static readonly type = '[admin] create Children fail'; + static readonly type = '[admin] create Class fail'; constructor(public payload: Error) { } } export class OnCreateClassSuccess { - static readonly type = '[admin] create Children success'; + static readonly type = '[admin] create Class success'; constructor(public payload) { } } diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 2f271cc7c6..5e083aed6e 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -15,9 +15,10 @@ export interface AdminStateModel { isLoading: boolean; direction: Direction; department: Department; + iClass: IClass[]; + classes: IClass[]; aboutPortal: AboutPortal; departments: Department[]; - classes: IClass[]; selectedDirection: Direction; currentPage: PaginationElement; searchQuery: string; @@ -29,8 +30,9 @@ export interface AdminStateModel { aboutPortal: null, direction: undefined, department: undefined, - departments: [], + iClass: [], classes: [], + departments: [], isLoading: false, selectedDirection: null, searchQuery: '', @@ -53,7 +55,7 @@ export class AdminState { @Selector() static departments(state: AdminStateModel): Department [] { return state.departments; } @Selector() - static classes(state: AdminStateModel): IClass [] { return state.classes; } + static class(state: AdminStateModel): IClass [] { return state.iClass; } @Selector() static searchQuery(state: AdminStateModel): string { return state.searchQuery } @Selector() @@ -123,7 +125,7 @@ export class AdminState { OnDeleteDirectionSuccess({ dispatch }: StateContext, { payload }: OnDeleteDirectionSuccess): void { console.log('Direction is deleted', payload); dispatch(new ShowMessageBar({ message: 'Напрямок видалено!', type: 'success' })); - this.router.navigate(['/admin-tools/platform/about']); + this.router.navigate(['/admin-tools/platform/directions']); } @Action(CreateDirection) @@ -211,11 +213,13 @@ export class AdminState { } @Action(OnCreateClassSuccess) - onCreateChildrenSuccess({ dispatch }: StateContext, { payload }: OnCreateClassSuccess): void { + onCreateClassSuccess({ dispatch,patchState }: StateContext, { payload }: OnCreateClassSuccess): void { dispatch(new MarkFormDirty(false)); + patchState({iClass: payload}); console.log('Class is created', payload); - dispatch(new ShowMessageBar({ message: 'Дитина успішно зареєстрована', type: 'success' })); - this.router.navigate(['/personal-cabinet/parent/info']); + dispatch(new ShowMessageBar({ message: 'Клас успішно створенний', type: 'success' })); + this.router.navigate(['/admin-tools/platform/directions']); + this.getFilteredDirections; } @Action(GetDirectionById) getDirectionById({ patchState }: StateContext, { payload }: GetDirectionById): Observable { diff --git a/src/app/shared/store/meta-data.actions.ts b/src/app/shared/store/meta-data.actions.ts index 6dcc3a53be..c745b5aee5 100644 --- a/src/app/shared/store/meta-data.actions.ts +++ b/src/app/shared/store/meta-data.actions.ts @@ -62,4 +62,5 @@ export class GetRateByEntityId { export class GetFeaturesList { static readonly type = '[meta-data] Get features list'; constructor() { } -} \ No newline at end of file +} + diff --git a/src/app/shared/store/meta-data.state.ts b/src/app/shared/store/meta-data.state.ts index 8b309bb61b..716cdec3d7 100644 --- a/src/app/shared/store/meta-data.state.ts +++ b/src/app/shared/store/meta-data.state.ts @@ -84,7 +84,7 @@ export class MetaDataState { @Selector() static classes(state: MetaDataStateModel): IClass[] { return state.classes; } - + @Selector() static socialGroups(state: MetaDataStateModel): SocialGroup[] { return state.socialGroups; } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html index 04bb5fc306..bf963c1c3e 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -1,16 +1,4 @@ -
-
- - info_outline -
-
Name
-
- - info_outline -
-
Name
+
+ [isEmptyCheck]="ClassFormGroup.get('title').errors?.required" + [invalid]="ClassFormGroup.get('title').invalid && ClassFormGroup.get('title').touched"> + [invalid]="ClassFormGroup.get('title').invalid && ClassFormGroup.get('title').touched" + [forbiddenCharacter]="ClassFormGroup.get('title').errors?.pattern?.requiredPattern"> +
+ +
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss index 1719c996fe..7cd27022a5 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss @@ -16,11 +16,4 @@ margin: auto 0.5rem; font-size: 16px; } -.direction{ - color: gray; - margin-bottom: 25px; -} -.department{ - color: gray; - margin-bottom: 25px; -} + diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts index b896fcc71d..8b9d209d6a 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -25,7 +25,8 @@ describe('AddClassFormComponent', () => { MatIconModule, BrowserAnimationsModule, NgxsModule.forRoot([]), - ], + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ AddClassFormComponent, MockValidationHintForInputComponent, diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts index 182c632e94..d380794fb1 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -1,18 +1,5 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { ActivatedRoute } from '@angular/router'; -import { Store } from '@ngxs/store'; -import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; -import { NavBarName } from 'src/app/shared/enum/navigation-bar'; -import { CategoriesService } from 'src/app/shared/services/categories/categories.service'; -import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; -import { AddNavPath } from 'src/app/shared/store/navigation.actions'; -import { CreateFormComponent } from 'src/app/shell/personal-cabinet/create-form/create-form.component'; -import { IClass } from 'src/app/shared/models/category.model'; -import { takeUntil } from 'rxjs/operators'; -import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; -import { Constants } from 'src/app/shared/constants/constants'; - +import { FormGroup } from '@angular/forms'; @Component({ selector: 'app-add-class-form', @@ -21,18 +8,24 @@ import { Constants } from 'src/app/shared/constants/constants'; }) export class AddClassFormComponent implements OnInit { - @Input() classFormGroup: FormGroup; - + @Input() ClassFormGroup: FormGroup; + @Input() indexClass: number; + @Input() classAmount: number; @Output() deleteForm = new EventEmitter(); - constructor(private formBuilder: FormBuilder) { - this.classFormGroup = this.formBuilder.group({ - title: new FormControl('', [Validators.maxLength(Constants.MAX_TEACHER_DESCRIPTION_LENGTH), Validators.required]) - }); - } + isActiveClassInfoButton = false; + isActiveDepartmentInfoButton = false; + isActiveDirectionInfoButton = false; + constructor() { } - ngOnInit(): void { } + ngOnInit(): void { + } + delete(): void { + this.deleteForm.emit(this.indexClass); + } } + + diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html index 848e4c9809..e13df0335c 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html @@ -1,12 +1,10 @@ -
+
- + info_outline
-
{{ direction?.title }}
- - +
{{ direction.title }}
; - destroy$: Subject = new Subject(); + @Input() direction: Direction; departmentFormGroup: FormGroup; directionFormGroup: FormGroup; isActiveDepartmentInfoButton = false; isActiveDirectionInfoButton = false; - department: Department; - @Input() admin: TechAdmin; - @Input() direction: Direction; - @Input() CategoryFormGroup: FormGroup; - - constructor( private store: Store, private matDialog: MatDialog, @@ -49,17 +35,12 @@ export class AddDepartmentFormComponent implements OnInit { } ngOnInit(): void { - this.store.dispatch(new GetDirections()); - (this.admin) && this.departmentFormGroup.patchValue(this.admin, { emitEvent: false }); - //this.passDepartmentFormGroup.emit(this.departmentFormGroup); - } onSubmit(): void { if (this.departmentFormGroup.invalid) { this.checkValidation(this.departmentFormGroup); } else { - const direction = this.store.selectSnapshot(AdminState.direction); const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { width: '330px', data: { @@ -67,24 +48,17 @@ export class AddDepartmentFormComponent implements OnInit { } }); dialogRef.afterClosed().subscribe((result: boolean) => { - const department = new Department(this.departmentFormGroup.value, direction.id); + const department = new Department(this.departmentFormGroup.value, this.direction.id); result && this.store.dispatch(new CreateDepartment(department)); this._stepper.next(); }) } } - ngOnDestroy(): void { - this.destroy$.next(true); - this.destroy$.unsubscribe(); - } - checkValidation(form: FormGroup): void { Object.keys(form.controls).forEach(key => { form.get(key).markAsTouched(); }); } - - - } + } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html index 842bbb7e6a..66fd7404b3 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html @@ -15,6 +15,7 @@ [invalid]="directionFormGroup.get('title').invalid && directionFormGroup.get('title').touched" [forbiddenCharacter]="directionFormGroup.get('title').errors?.pattern?.requiredPattern"> +
Додайте зображення натистувши на “+”.
diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss index dcc8afae33..87492b2f32 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss @@ -2,8 +2,9 @@ @import "src/app/shared/styles/validation-form.scss"; @import "src/app/shared/styles/create-form-wrapper.scss"; @import "src/app/shared/styles/buttons.scss"; + .wrapper{ - padding: 1rem 5rem; + padding: 0rem 0rem; margin-bottom: 2rem; &-title{ text-align: center; @@ -22,4 +23,14 @@ cursor: pointer; margin: auto 0.5rem; font-size: 16px; -} \ No newline at end of file +} + +.direction{ + color: gray; + margin-bottom: 25px; +} + +.department{ + color: gray; + margin-bottom: 25px; +} diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index 466d46f174..3951fd8ceb 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -9,7 +9,6 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; - import { CreateDirectionComponent } from './create-direction.component'; describe('CreateDirectionComponent', () => { @@ -56,7 +55,6 @@ describe('CreateDirectionComponent', () => { expect(component).toBeTruthy(); }); }); - @Component({ selector: 'app-validation-hint-for-input', template: '' @@ -76,7 +74,6 @@ class MockValidationHintForInputComponent { template: '' }) class MockAddDirectionFormComponent { - @Input() admin: TechAdmin; } @Component({ @@ -84,7 +81,6 @@ class MockAddDirectionFormComponent { template: '' }) class MockAddDepartmentFormComponent { - @Input() admin: TechAdmin; } @Component({ @@ -92,5 +88,4 @@ class MockAddDepartmentFormComponent { template: '' }) class MockAddClassFormComponent { - @Input() admin: TechAdmin; } diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index 8ecf01193d..ffbaf16045 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -6,19 +6,15 @@ import { MatStepper } from '@angular/material/stepper'; import { ActivatedRoute, Params } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; +import { filter, takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; -import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { createDirectionSteps } from 'src/app/shared/enum/provider'; import { Department, Direction, IClass } from 'src/app/shared/models/category.model'; -import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; -import { NavigationBarService } from 'src/app/shared/services/navigation-bar/navigation-bar.service'; -import { CreateClass, GetDepartmentByDirectionId, GetDirectionById } from 'src/app/shared/store/admin.actions'; +import { CreateClass } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; -import { GetDepartments, GetDirections } from 'src/app/shared/store/meta-data.actions'; -import { MetaDataState } from 'src/app/shared/store/meta-data.state'; -import { AddNavPath, DeleteNavPath } from 'src/app/shared/store/navigation.actions'; +import { DeleteNavPath } from 'src/app/shared/store/navigation.actions'; @Component({ selector: 'app-create-direction', @@ -32,63 +28,51 @@ import { AddNavPath, DeleteNavPath } from 'src/app/shared/store/navigation.actio export class CreateDirectionComponent implements OnInit, OnDestroy { - directionFormGroup: FormGroup; - departmentFormGroup: FormGroup; - classFormGroup: FormGroup; + @Select(AdminState.direction) + direction$: Observable; + direction: Direction; + @Select(AdminState.department) + department$: Observable; + department: Department; + destroy$: Subject = new Subject(); + + //directionFormGroup: FormGroup; + //departmentFormGroup: FormGroup; editMode = false; @ViewChild('stepper') stepper: MatStepper; - ClassFormArray: FormArray = new FormArray([]); - iClass: IClass; + ClassFormArray: FormArray = new FormArray([]); + iClass: IClass[]; + @Input() classes: IClass[]; - @Select(MetaDataState.classes) - iClasses$: Observable; - destroy$: Subject = new Subject(); - admin: TechAdmin; - @Input() department: Department; - direction: Direction; + isActiveDepartmentInfoButton = false; + isActiveDirectionInfoButton = false; + isActiveClassInfoButton = false; + + departmentFormGroup: FormGroup; + directionFormGroup: FormGroup; + ClassFormGroup: FormGroup; - constructor(private fb: FormBuilder, + constructor( + private fb: FormBuilder, private store: Store, private route: ActivatedRoute, private matDialog: MatDialog,) { } ngOnInit(): void { - //this.store.dispatch(new GetDepartments()); - (this.admin) && this.classFormGroup.patchValue(this.admin, { emitEvent: false }); - //this.passDepartmentFormGroup.emit(this.departmentFormGroup); - + this.ClassFormArray.push(this.newForm()); + this.direction$.pipe(takeUntil(this.destroy$),filter((direction: Direction)=>!!direction)).subscribe((direction: Direction)=>this.direction = direction); + this.department$.pipe(takeUntil(this.destroy$),filter((department: Department)=>!!department)).subscribe((department: Department)=>this.department = department); } - /** - * This method add new FormGroup to teh FormArray - */ - addClass(): void { - this.ClassFormArray.push(this.newForm()); - } - - /** - * This method create new FormGroup - * @param FormArray: array - */ - newForm(iClass?: IClass): FormGroup { - const classFormGroup = this.fb.group({ - title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), - }); - - iClass && classFormGroup.patchValue(iClass, { emitEvent: false }); - return classFormGroup; - } - - /** - * This method delete form from teh FormArray by index - * @param index: number - */ - onDeleteForm(index: number): void { - this.ClassFormArray.removeAt(index); - } + private newForm( ): FormGroup { + const ClassFormGroup = this.fb.group({ + title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), + }); + return ClassFormGroup; + } ngAfterViewInit(): void { if (this.editMode) { @@ -96,21 +80,37 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { this.stepper.selectedIndex = +createDirectionSteps[params.param]; }); } + } + + addClass(): void { + this.ClassFormArray.push(this.newForm()); + } + + onDeleteForm(indexClass: number): void { + this.ClassFormArray.removeAt(indexClass); } onSubmit(): void { if (this.ClassFormArray.invalid) { this.checkValidationClass(); } else { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.createClass, + } + }); + dialogRef.afterClosed().subscribe((result: boolean) => { + const classes: IClass[] = []; const department = this.store.selectSnapshot(AdminState.department); - this.ClassFormArray.controls.forEach((form: FormGroup) => { - const iClass: IClass = new IClass(form.value, department.id); - this.store.dispatch(new CreateClass(iClass)); - }); + + this.ClassFormArray.controls.forEach((form: FormGroup) => + classes.push(new IClass(form.value, department.id)) + ); + result && this.store.dispatch(new CreateClass(classes)); + }); } - } - checkValidationClass(): void { Object.keys(this.ClassFormArray.controls).forEach(key => { @@ -125,5 +125,7 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.store.dispatch(new DeleteNavPath()); + this.destroy$.next(true); + this.destroy$.unsubscribe(); } } diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index f4d5b5efff..0fcaa20250 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -9,17 +9,14 @@
-
- - + -
- diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss index c341a1427c..e687766d42 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.scss @@ -1,8 +1,11 @@ @import "src/app/shared/styles/card-wrapper.scss"; +@import "src/app/shared/styles/list-wrappers.scss"; @import "src/app/shared/styles/config.scss"; @import "src/app/shared/styles/navigation-tabs.scss"; @import "src/app/shared/styles/buttons.scss"; +@import "src/app/shared/styles/pagination.scss"; + .wrapper{ p { font-family: Open Sans; diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts index 7f221cb2ff..11f5bf4f27 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -1,8 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; -import { MatTabChangeEvent } from '@angular/material/tabs'; -import { ActivatedRoute, Router } from '@angular/router'; import { Actions, ofAction, Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; @@ -46,8 +44,6 @@ export class DirectionsComponent implements OnInit { constructor( private store: Store, - private route: ActivatedRoute, - private router: Router, private actions$: Actions, private matDialog: MatDialog) { } From 11515ebaddeb84e6e126fd3bdd888ea79e4e2f13 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 13:02:56 +0300 Subject: [PATCH 09/20] comments comments --- .../paginator/paginator.component.ts | 1 - src/app/shared/enum/provider-admin.ts | 5 +++ src/app/shared/enum/provider.ts | 5 --- src/app/shared/models/category.model.ts | 1 - .../services/categories/categories.service.ts | 4 +- src/app/shared/store/admin.actions.ts | 5 +-- src/app/shared/store/admin.state.ts | 44 ++++++++----------- src/app/shared/styles/buttons.scss | 11 +++++ .../shell/admin-tools/admin-tools.module.ts | 1 - .../add-class-form.component.html | 4 +- .../add-class-form.component.scss | 13 ------ .../add-class-form.component.ts | 2 +- .../add-department-form.component.scss | 13 ------ .../add-department-form.component.ts | 7 ++- .../add-direction-form.component.html | 1 - .../add-direction-form.component.scss | 19 +------- .../add-direction-form.component.ts | 6 +-- .../create-direction.component.html | 2 +- .../create-direction.component.scss | 14 ------ .../create-direction.component.ts | 31 ++++++------- .../directions/directions.component.ts | 11 ++--- 21 files changed, 67 insertions(+), 133 deletions(-) diff --git a/src/app/shared/components/paginator/paginator.component.ts b/src/app/shared/components/paginator/paginator.component.ts index a0b45932a4..45e7f92a61 100644 --- a/src/app/shared/components/paginator/paginator.component.ts +++ b/src/app/shared/components/paginator/paginator.component.ts @@ -11,7 +11,6 @@ export class PaginatorComponent implements OnInit, OnChanges { @Input() currentPage: PaginationElement; @Input() totalEntities: number; - @Input() totalEntitiesDir: number; @Output() pageChange = new EventEmitter(); diff --git a/src/app/shared/enum/provider-admin.ts b/src/app/shared/enum/provider-admin.ts index c70e56d48a..3b2046f37c 100644 --- a/src/app/shared/enum/provider-admin.ts +++ b/src/app/shared/enum/provider-admin.ts @@ -14,3 +14,8 @@ export enum ProviderAdminIcons { Accepted = 'fas fa-user-check', Blocked = 'fas fa-user-times', } +export enum createDirectionSteps { + 'direction', + 'department', + 'class' +} diff --git a/src/app/shared/enum/provider.ts b/src/app/shared/enum/provider.ts index 2b9945bda2..4edabb078c 100644 --- a/src/app/shared/enum/provider.ts +++ b/src/app/shared/enum/provider.ts @@ -46,8 +46,3 @@ export enum createProviderSteps { 'description' } -export enum createDirectionSteps { - 'direction', - 'department', - 'class' -} diff --git a/src/app/shared/models/category.model.ts b/src/app/shared/models/category.model.ts index 4f36c54815..880686f47f 100644 --- a/src/app/shared/models/category.model.ts +++ b/src/app/shared/models/category.model.ts @@ -3,7 +3,6 @@ export class Direction { title: string; description: string; - constructor(info, id?) { this.id = id; this.title = info.title; diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index 093fd63b3e..b171b9007f 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -44,8 +44,8 @@ export class CategoriesService { createDirection(direction: Direction): Observable { return this.http.post('/api/v1/Direction/Create', direction); } - createDepartment(department: Department): Observable { - return this.http.post('/api/v1/Department/Create', department); + createDepartment(department: Department): Observable { + return this.http.post('/api/v1/Department/Create', department); } updateDirection(direction: Direction): Observable { return this.http.put('/api/v1/Direction/Update', direction); diff --git a/src/app/shared/store/admin.actions.ts b/src/app/shared/store/admin.actions.ts index 7513a14dfe..d2634a9cf7 100644 --- a/src/app/shared/store/admin.actions.ts +++ b/src/app/shared/store/admin.actions.ts @@ -1,6 +1,5 @@ -import { Direction } from "@angular/cdk/bidi"; import { AboutPortal } from "../models/aboutPortal.model"; -import { Department, IClass } from "../models/category.model"; +import { Department, Direction, IClass } from "../models/category.model"; import { PaginationElement } from "../models/paginationElement.model"; export class GetInfoAboutPortal { @@ -45,7 +44,7 @@ export class OnCreateDirectionSuccess { } export class UpdateDirection { static readonly type = '[admin] update Direction'; - constructor(public payload) { } + constructor(public payload: Direction) { } } export class OnUpdateDirectionFail { static readonly type = '[admin] update Direction fail'; diff --git a/src/app/shared/store/admin.state.ts b/src/app/shared/store/admin.state.ts index 5e083aed6e..9552270b31 100644 --- a/src/app/shared/store/admin.state.ts +++ b/src/app/shared/store/admin.state.ts @@ -15,7 +15,6 @@ export interface AdminStateModel { isLoading: boolean; direction: Direction; department: Department; - iClass: IClass[]; classes: IClass[]; aboutPortal: AboutPortal; departments: Department[]; @@ -30,7 +29,6 @@ export interface AdminStateModel { aboutPortal: null, direction: undefined, department: undefined, - iClass: [], classes: [], departments: [], isLoading: false, @@ -55,13 +53,11 @@ export class AdminState { @Selector() static departments(state: AdminStateModel): Department [] { return state.departments; } @Selector() - static class(state: AdminStateModel): IClass [] { return state.iClass; } + static searchQuery(state: AdminStateModel): string { return state.searchQuery; } @Selector() - static searchQuery(state: AdminStateModel): string { return state.searchQuery } + static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections; } @Selector() - static filteredDirections(state: AdminStateModel): DirectionsFilter{ return state.filteredDirections } - @Selector() - static currentPage(state: AdminStateModel): {} { return state.currentPage }; + static currentPage(state: AdminStateModel): {} { return state.currentPage; }; @Selector() static isLoading(state: AdminStateModel): boolean { return state.isLoading }; @@ -93,20 +89,20 @@ export class AdminState { } @Action(OnUpdateInfoAboutPortalFail) - OnUpdateInfoAboutPortalFail({ dispatch }: StateContext, { payload }: OnUpdateInfoAboutPortalFail): void { + onUpdateInfoAboutPortalFail({ dispatch }: StateContext, { payload }: OnUpdateInfoAboutPortalFail): void { throwError(payload); dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); } @Action(OnUpdateInfoAboutPortalSuccess) - OnUpdateInfoAboutPortalSuccess({ dispatch }: StateContext, { payload }: OnUpdateInfoAboutPortalSuccess): void { + onUpdateInfoAboutPortalSuccess({ dispatch }: StateContext, { payload }: OnUpdateInfoAboutPortalSuccess): void { dispatch(new MarkFormDirty(false)); dispatch(new ShowMessageBar({ message: 'Інформація про портал успішно відредагована', type: 'success' })); this.router.navigate(['/admin-tools/platform/about']); } @Action(DeleteDirectionById) - DeleteDirectionById({ dispatch }: StateContext, { payload }: DeleteDirectionById): Observable { + deleteDirectionById({ dispatch }: StateContext, { payload }: DeleteDirectionById): Observable { return this.categoriesService .deleteDirection(payload) .pipe( @@ -116,20 +112,20 @@ export class AdminState { } @Action(OnDeleteDirectionFail) - OnDeleteDirectionFail({ dispatch }: StateContext, { payload }: OnDeleteDirectionFail): void { + onDeleteDirectionFail({ dispatch }: StateContext, { payload }: OnDeleteDirectionFail): void { throwError(payload); dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); } @Action(OnDeleteDirectionSuccess) - OnDeleteDirectionSuccess({ dispatch }: StateContext, { payload }: OnDeleteDirectionSuccess): void { + onDeleteDirectionSuccess({ dispatch }: StateContext, { payload }: OnDeleteDirectionSuccess): void { console.log('Direction is deleted', payload); dispatch(new ShowMessageBar({ message: 'Напрямок видалено!', type: 'success' })); this.router.navigate(['/admin-tools/platform/directions']); } @Action(CreateDirection) - CreateDirection({ dispatch }: StateContext, { payload }: CreateDirection): Observable { + createDirection({ dispatch }: StateContext, { payload }: CreateDirection): Observable { return this.categoriesService .createDirection(payload) .pipe( @@ -139,20 +135,20 @@ export class AdminState { } @Action(OnCreateDirectionFail) - OnCreateDirectionFail({ dispatch }: StateContext, { payload }: OnCreateDirectionFail): void { + onCreateDirectionFail({ dispatch }: StateContext, { payload }: OnCreateDirectionFail): void { throwError(payload); dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); } @Action(OnCreateDirectionSuccess) - OnCreateDirectionSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDirectionSuccess): void { + onCreateDirectionSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDirectionSuccess): void { dispatch(new MarkFormDirty(false)); patchState({direction: payload}); console.log('Direction is created', payload); dispatch(new ShowMessageBar({ message: 'Напрямок успішно створенний', type: 'success' })); } @Action(UpdateDirection) - updateChild({ dispatch }: StateContext, { payload }: UpdateDirection): Observable { + updateDirection({ dispatch }: StateContext, { payload }: UpdateDirection): Observable { return this.categoriesService .updateDirection(payload) .pipe( @@ -173,7 +169,7 @@ export class AdminState { this.router.navigate(['/admin-tools/platform/about']); } @Action(CreateDepartment) - CreateDepartment({ dispatch }: StateContext, { payload }: CreateDepartment): Observable { + createDepartment({ dispatch }: StateContext, { payload }: CreateDepartment): Observable { return this.categoriesService .createDepartment(payload) .pipe( @@ -183,13 +179,13 @@ export class AdminState { } @Action(OnCreateDepartmentFail) - OnCreateDepartmentFail({ dispatch }: StateContext, { payload }: OnCreateDepartmentFail): void { + onCreateDepartmentFail({ dispatch }: StateContext, { payload }: OnCreateDepartmentFail): void { throwError(payload); dispatch(new ShowMessageBar({ message: 'На жаль виникла помилка', type: 'error' })); } @Action(OnCreateDepartmentSuccess) - OnCreateDepartmentSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDepartmentSuccess): void { + onCreateDepartmentSuccess({ dispatch, patchState }: StateContext, { payload }: OnCreateDepartmentSuccess): void { dispatch(new MarkFormDirty(false)); patchState({department: payload}); console.log('Department is created', payload); @@ -197,7 +193,7 @@ export class AdminState { } @Action(CreateClass) - CreateClass({ dispatch }: StateContext, { payload }: CreateClass): Observable { + createClass({ dispatch }: StateContext, { payload }: CreateClass): Observable { return this.categoriesService .createClass(payload) .pipe( @@ -215,7 +211,7 @@ export class AdminState { @Action(OnCreateClassSuccess) onCreateClassSuccess({ dispatch,patchState }: StateContext, { payload }: OnCreateClassSuccess): void { dispatch(new MarkFormDirty(false)); - patchState({iClass: payload}); + patchState({classes: payload}); console.log('Class is created', payload); dispatch(new ShowMessageBar({ message: 'Клас успішно створенний', type: 'success' })); this.router.navigate(['/admin-tools/platform/directions']); @@ -242,7 +238,6 @@ export class AdminState { })); } - @Action(SetSearchQueryValue) setSearchQueryValue({ patchState, dispatch }: StateContext, { payload }: SetSearchQueryValue) { patchState({ searchQuery: payload }); @@ -257,7 +252,6 @@ export class AdminState { getFilteredDirections({ patchState, getState }: StateContext, { }: GetFilteredDirections) { patchState({ isLoading: true }); const state: AdminStateModel = getState(); - return this.categoriesService .getFilteredDirections( state) .pipe(tap((filterResult: DirectionsFilter) => patchState(filterResult ? { filteredDirections: filterResult, isLoading: false } : { filteredDirections: undefined, isLoading: false }), @@ -269,8 +263,9 @@ export class AdminState { patchState({ currentPage: payload }); dispatch(new GetFilteredDirections()); } + @Action(FilterClear) - FilterClear({ patchState }: StateContext, { }: FilterChange) { + filterClear({ patchState }: StateContext, { }: FilterChange) { patchState({ searchQuery: '', currentPage: { @@ -279,5 +274,4 @@ export class AdminState { } }); } - } diff --git a/src/app/shared/styles/buttons.scss b/src/app/shared/styles/buttons.scss index 56649eb918..a0556f36fd 100644 --- a/src/app/shared/styles/buttons.scss +++ b/src/app/shared/styles/buttons.scss @@ -63,3 +63,14 @@ button[disabled] { background-color: #cccccc; color: #666666; } +.activeInfoBtn { + color: #3849f9; +} +.inactiveInfoBtn { + color: #AAAAAA; +} +.status-info-icon { + cursor: pointer; + margin: auto 0.5rem; + font-size: 16px; +} diff --git a/src/app/shell/admin-tools/admin-tools.module.ts b/src/app/shell/admin-tools/admin-tools.module.ts index 8d0ecd9eab..246e57d2c5 100644 --- a/src/app/shell/admin-tools/admin-tools.module.ts +++ b/src/app/shell/admin-tools/admin-tools.module.ts @@ -11,7 +11,6 @@ import { DirectionsComponent } from './platform/create-direction/directions/dire declarations: [ PlatformComponent, DirectionsComponent, - ], imports: [ CommonModule, diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html index bf963c1c3e..069adc1999 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -1,4 +1,4 @@ - +
-
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss index 7cd27022a5..9856e3b813 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.scss @@ -3,17 +3,4 @@ @import "src/app/shared/styles/create-form-wrapper.scss"; @import "src/app/shared/styles/buttons.scss"; -.activeInfoBtn { - color: #3849f9; -} - -.inactiveInfoBtn { - color: #AAAAAA; -} - -.status-info-icon { - cursor: pointer; - margin: auto 0.5rem; - font-size: 16px; -} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts index d380794fb1..bb435ab2b9 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -22,7 +22,7 @@ export class AddClassFormComponent implements OnInit { ngOnInit(): void { } - delete(): void { + onDelete(): void { this.deleteForm.emit(this.indexClass); } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss index e4d387fb05..4bcee320e4 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.scss @@ -3,19 +3,6 @@ @import "src/app/shared/styles/create-form-wrapper.scss"; @import "src/app/shared/styles/buttons.scss"; -.activeInfoBtn { - color: #3849f9; -} - -.inactiveInfoBtn { - color: #AAAAAA; -} - -.status-info-icon { - cursor: pointer; - margin: auto 0.5rem; - font-size: 16px; -} .direction{ color: gray; margin-bottom: 25px; diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts index 8c22c49ad6..c3288a4575 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts @@ -34,8 +34,7 @@ export class AddDepartmentFormComponent implements OnInit { }); } - ngOnInit(): void { - } + ngOnInit(): void {} onSubmit(): void { if (this.departmentFormGroup.invalid) { @@ -48,8 +47,8 @@ export class AddDepartmentFormComponent implements OnInit { } }); dialogRef.afterClosed().subscribe((result: boolean) => { - const department = new Department(this.departmentFormGroup.value, this.direction.id); - result && this.store.dispatch(new CreateDepartment(department)); + const department = result && new Department(this.departmentFormGroup.value, this.direction.id); + this.store.dispatch(new CreateDepartment(department)); this._stepper.next(); }) } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html index 66fd7404b3..842bbb7e6a 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html @@ -15,7 +15,6 @@ [invalid]="directionFormGroup.get('title').invalid && directionFormGroup.get('title').touched" [forbiddenCharacter]="directionFormGroup.get('title').errors?.pattern?.requiredPattern"> -
Додайте зображення натистувши на “+”.
diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss index 87492b2f32..f61d1d62f4 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.scss @@ -11,20 +11,6 @@ } } -.activeInfoBtn { - color: #3849f9; -} - -.inactiveInfoBtn { - color: #AAAAAA; -} - -.status-info-icon { - cursor: pointer; - margin: auto 0.5rem; - font-size: 16px; -} - .direction{ color: gray; margin-bottom: 25px; diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index ffbaf16045..0353047cbb 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -6,11 +6,12 @@ import { MatStepper } from '@angular/material/stepper'; import { ActivatedRoute, Params } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; +import { dispatch } from 'rxjs/internal/observable/pairs'; import { filter, takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; -import { createDirectionSteps } from 'src/app/shared/enum/provider'; +import { createDirectionSteps } from 'src/app/shared/enum/provider-admin'; import { Department, Direction, IClass } from 'src/app/shared/models/category.model'; import { CreateClass } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; @@ -36,33 +37,29 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { department: Department; destroy$: Subject = new Subject(); - //directionFormGroup: FormGroup; - //departmentFormGroup: FormGroup; editMode = false; @ViewChild('stepper') stepper: MatStepper; - ClassFormArray: FormArray = new FormArray([]); - iClass: IClass[]; - @Input() classes: IClass[]; + ClassFormArray: FormArray = new FormArray([]); + @Input() classes: IClass[]; + isActiveDepartmentInfoButton = false; + isActiveDirectionInfoButton = false; + isActiveClassInfoButton = false; - isActiveDepartmentInfoButton = false; - isActiveDirectionInfoButton = false; - isActiveClassInfoButton = false; + departmentFormGroup: FormGroup; + directionFormGroup: FormGroup; + ClassFormGroup: FormGroup; - departmentFormGroup: FormGroup; - directionFormGroup: FormGroup; - ClassFormGroup: FormGroup; - - constructor( + constructor( private fb: FormBuilder, private store: Store, private route: ActivatedRoute, private matDialog: MatDialog,) { } ngOnInit(): void { - this.ClassFormArray.push(this.newForm()); + this.addClass(); this.direction$.pipe(takeUntil(this.destroy$),filter((direction: Direction)=>!!direction)).subscribe((direction: Direction)=>this.direction = direction); this.department$.pipe(takeUntil(this.destroy$),filter((department: Department)=>!!department)).subscribe((department: Department)=>this.department = department); } @@ -102,12 +99,12 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { }); dialogRef.afterClosed().subscribe((result: boolean) => { const classes: IClass[] = []; - const department = this.store.selectSnapshot(AdminState.department); + const department = result && this.store.selectSnapshot(AdminState.department); this.ClassFormArray.controls.forEach((form: FormGroup) => classes.push(new IClass(form.value, department.id)) ); - result && this.store.dispatch(new CreateClass(classes)); + this.store.dispatch(new CreateClass(classes)); }); } } diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts index 11f5bf4f27..2c0734ed0f 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -1,9 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormControl, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Actions, ofAction, Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged, startWith, takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { NoResultsTitle } from 'src/app/shared/enum/no-results'; @@ -17,7 +17,7 @@ import { AdminState } from 'src/app/shared/store/admin.state'; templateUrl: './directions.component.html', styleUrls: ['./directions.component.scss'] }) -export class DirectionsComponent implements OnInit { +export class DirectionsComponent implements OnInit, OnDestroy { readonly noDirections = NoResultsTitle.noDirections; searchValue = new FormControl('', [Validators.maxLength(200)]); @@ -26,10 +26,8 @@ export class DirectionsComponent implements OnInit { @Select(AdminState.filteredDirections) filteredDirections$: Observable; - @Select(AdminState.searchQuery) searchQuery$: Observable; - @Select(AdminState.isLoading) isLoading$: Observable; @@ -50,7 +48,6 @@ export class DirectionsComponent implements OnInit { ngOnInit(): void { this.store.dispatch([new FilterClear(), new GetFilteredDirections(), ]); - this.searchValue.valueChanges .pipe(takeUntil(this.destroy$)) .subscribe((val: string) => { @@ -68,6 +65,7 @@ export class DirectionsComponent implements OnInit { .pipe( debounceTime(1000), distinctUntilChanged(), + startWith(''), takeUntil(this.destroy$)) .subscribe(() => this.store.dispatch([ new GetFilteredDirections(), @@ -75,7 +73,6 @@ export class DirectionsComponent implements OnInit { } onSearch(): void { - this.store.dispatch(new SetSearchQueryValue(this.searchedText || '')); } From a1ed496268b92ce58b99e8d4f14566cefa4e7db9 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 13:11:21 +0300 Subject: [PATCH 10/20] test test --- .../directions/directions.component.html | 25 ---- .../directions/directions.component.scss | 89 -------------- .../directions/directions.component.spec.ts | 25 ---- .../directions/directions.component.ts | 110 ------------------ 4 files changed, 249 deletions(-) delete mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.html delete mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.scss delete mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.spec.ts delete mode 100644 src/app/shell/admin-tools/platform/directions/directions.component.ts diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.html b/src/app/shell/admin-tools/platform/directions/directions.component.html deleted file mode 100644 index f4d5b5efff..0000000000 --- a/src/app/shell/admin-tools/platform/directions/directions.component.html +++ /dev/null @@ -1,25 +0,0 @@ -
- - -
- -
- - - - - -
- - - - diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.scss b/src/app/shell/admin-tools/platform/directions/directions.component.scss deleted file mode 100644 index c341a1427c..0000000000 --- a/src/app/shell/admin-tools/platform/directions/directions.component.scss +++ /dev/null @@ -1,89 +0,0 @@ - -@import "src/app/shared/styles/card-wrapper.scss"; -@import "src/app/shared/styles/config.scss"; -@import "src/app/shared/styles/navigation-tabs.scss"; -@import "src/app/shared/styles/buttons.scss"; -.wrapper{ - p { - font-family: Open Sans; - font-style: normal; - font-weight: normal; - font-size: 13px; - line-height: 18px; - } -} - -.link { - color: blue; - font-weight: 300!important; -} - -.support-title { - margin-bottom: 1rem; -} - -.config-button { - font-weight: 300; - font-family:Open Sans; -} - -.config-support p { - margin: 0; -} - -.header-wrapper{ - margin-bottom: 2rem; -} - -.title{ - margin-right: 1rem; -} - -@media(max-width: 750px) { - .header-wrapper{ - margin: 2rem 1rem; - } -} - -:host ::ng-deep .mat-form-field-wrapper { - padding: 0 0 0 10px; - width: 100%; -} - -:host ::ng-deep .mat-form-field-infix { - border: none; - display: flex; -} - -button { - border: none; - height: 100%; -} - -input { - font-weight: normal; - line-height: 22px; - color: #161414; - opacity: 0.4; - text-overflow: ellipsis; -} - -.icon { - margin: 0 1rem; - color: #AAAAAA; - line-height: 26px; - cursor: pointer; -} - -.search { - background: white; - margin: 1rem 0.5rem; - border-radius: 60px; - min-width: 300px; - max-width: 378px; - width: 100%; -} - -.shadow { - box-shadow: 0px 6px 16px rgb(0 0 0 / 8%); -} diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts b/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts deleted file mode 100644 index 55def506a4..0000000000 --- a/src/app/shell/admin-tools/platform/directions/directions.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { DirectionsComponent } from './directions.component'; - -describe('DirectionsComponent', () => { - let component: DirectionsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ DirectionsComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(DirectionsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/shell/admin-tools/platform/directions/directions.component.ts b/src/app/shell/admin-tools/platform/directions/directions.component.ts deleted file mode 100644 index e81931bf1c..0000000000 --- a/src/app/shell/admin-tools/platform/directions/directions.component.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { FormControl, Validators } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatTabChangeEvent } from '@angular/material/tabs'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Actions, ofAction, Select, Store } from '@ngxs/store'; -import { Observable, Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; -import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; -import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; -import { NoResultsTitle } from 'src/app/shared/enum/no-results'; -import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; -import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; -import { DeleteDirectionById, FilterChange, FilterClear, GetFilteredDirections, PageChange, ResetSelectedDirection, SetFirstPage, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; -import { AdminState } from 'src/app/shared/store/admin.state'; -import { ResetSelectedWorkshop } from 'src/app/shared/store/user.actions'; - -@Component({ - selector: 'app-directions', - templateUrl: './directions.component.html', - styleUrls: ['./directions.component.scss'] -}) -export class DirectionsComponent implements OnInit { - - readonly noDirections = NoResultsTitle.noDirections; - searchValue = new FormControl('', [Validators.maxLength(200)]); - isResultPage = true; - searchedText: string; - - @Select(AdminState.filteredDirections) - filteredDirections$: Observable; - - @Select(AdminState.searchQuery) - searchQuery$: Observable; - - @Select(AdminState.isLoading) - isLoading$: Observable; - - destroy$: Subject = new Subject(); - - currentPage: PaginationElement = { - element: 1, - isActive: true - }; - - tabIndex: number; - - constructor( - private store: Store, - private route: ActivatedRoute, - private router: Router, - private actions$: Actions, - private matDialog: MatDialog) { } - - - ngOnInit(): void { - this.store.dispatch([new FilterClear(), new GetFilteredDirections(), ]); - - this.searchValue.valueChanges - .pipe(takeUntil(this.destroy$)) - .subscribe((val: string) => { - this.searchedText = val; - if (val.length === 0) { - this.store.dispatch(new SetSearchQueryValue('')); - } - }); - - this.searchQuery$ - .pipe(takeUntil(this.destroy$)) - .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); - - this.actions$.pipe(ofAction(FilterChange)) - .pipe( - debounceTime(1000), - distinctUntilChanged(), - takeUntil(this.destroy$)) - .subscribe(() => this.store.dispatch([ - new GetFilteredDirections(), - ])); - } - - onSearch(): void { - - this.store.dispatch(new SetSearchQueryValue(this.searchedText || '')); - } - - onPageChange(page: PaginationElement): void { - this.currentPage = page; - this.store.dispatch(new PageChange(page)); - } - - onDelete(direction: Direction): void { - const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { - width: '330px', - data: { - type: ModalConfirmationType.deleteDirection, - property: direction.title - } - }); - - dialogRef.afterClosed().subscribe((result: boolean) => { - result && this.store.dispatch(new DeleteDirectionById(direction.id)); - }); - } - - ngOnDestroy(): void { - this.destroy$.next(true); - this.destroy$.unsubscribe(); - } -} From 4754f22ff31213e6b02b2c0802c2c2aa5712dcc0 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 13:44:01 +0300 Subject: [PATCH 11/20] test --- .../add-class-form/add-class-form.component.spec.ts | 2 ++ .../add-department-form.component.spec.ts | 7 ++++++- .../add-direction-form.component.spec.ts | 2 ++ .../create-direction/create-direction.component.spec.ts | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts index 8b9d209d6a..094167c9f0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts @@ -1,6 +1,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -23,6 +24,7 @@ describe('AddClassFormComponent', () => { MatFormFieldModule, MatInputModule, MatIconModule, + MatDialogModule, BrowserAnimationsModule, NgxsModule.forRoot([]), ], diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts index 5cbe24aabd..1c8bdf547f 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -1,6 +1,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -24,6 +25,7 @@ describe('AddClassFormComponent', () => { MatInputModule, MatIconModule, BrowserAnimationsModule, + MatDialogModule, NgxsModule.forRoot([]), ], schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -38,6 +40,9 @@ describe('AddClassFormComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(AddDepartmentFormComponent); component = fixture.componentInstance; + component.departmentFormGroup = new FormGroup({ + title: new FormControl(''), + }); fixture.detectChanges(); }); diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts index 9c52710968..ad7f5a9c76 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -23,6 +24,7 @@ describe('AddDirectionFormComponent', () => { MatFormFieldModule, MatInputModule, MatIconModule, + MatDialogModule, BrowserAnimationsModule, NgxsModule.forRoot([]), ], diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index 3951fd8ceb..c68e285593 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -1,6 +1,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; @@ -26,6 +27,7 @@ describe('CreateDirectionComponent', () => { BrowserAnimationsModule, RouterTestingModule, MatStepperModule, + MatDialogModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ From e2d7676c399545645e959a3ad45f3931690e0a7d Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 15:26:55 +0300 Subject: [PATCH 12/20] test --- .../add-class-form.component.spec.ts | 12 +++++++-- .../add-department-form.component.spec.ts | 17 +++++++++--- .../add-direction-form.component.spec.ts | 27 +++++++++++++++---- .../create-direction.component.spec.ts | 3 ++- .../directions/directions.component.html | 2 +- .../directions/directions.component.spec.ts | 23 +++++++++++++++- 6 files changed, 71 insertions(+), 13 deletions(-) diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts index 094167c9f0..1598e7537a 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.spec.ts @@ -1,11 +1,13 @@ +import { CdkStepperModule } from '@angular/cdk/stepper'; import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MatStepper, MatStepperModule } from '@angular/material/stepper'; +import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; @@ -27,6 +29,9 @@ describe('AddClassFormComponent', () => { MatDialogModule, BrowserAnimationsModule, NgxsModule.forRoot([]), + MatStepperModule, + NoopAnimationsModule, + CdkStepperModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ @@ -40,6 +45,9 @@ describe('AddClassFormComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(AddClassFormComponent); component = fixture.componentInstance; + component.ClassFormGroup = new FormGroup({ + title: new FormControl(''), + }); fixture.detectChanges(); }); diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts index 1c8bdf547f..21b7cbaca0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -1,3 +1,4 @@ +import { CdkStepperModule } from '@angular/cdk/stepper'; import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -5,9 +6,11 @@ import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MatStepper, MatStepperModule } from '@angular/material/stepper'; +import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; +import { Department, Direction } from 'src/app/shared/models/category.model'; import { AddDepartmentFormComponent } from './add-department-form.component'; @@ -24,10 +27,13 @@ describe('AddClassFormComponent', () => { MatFormFieldModule, MatInputModule, MatIconModule, - BrowserAnimationsModule, MatDialogModule, + BrowserAnimationsModule, NgxsModule.forRoot([]), - ], + MatStepperModule, + NoopAnimationsModule, + CdkStepperModule, + ], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ AddDepartmentFormComponent, @@ -62,4 +68,9 @@ class MockValidationHintForInputComponent { @Input() minCharachters: number; @Input() forbiddenCharacter: string; @Input() isEmptyCheck: boolean; + @Input() direction: Direction; + @Input() department: Department; + @Input() directionFormGroup: FormGroup; + @Input() classFormGroup: FormGroup; + @Input() departmentFormGroup: FormGroup; } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts index ad7f5a9c76..1a93a637b7 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts @@ -1,17 +1,20 @@ -import { Component, Input } from '@angular/core'; +import { CdkStepperModule } from '@angular/cdk/stepper'; +import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MatStepperModule } from '@angular/material/stepper'; +import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; +import { Department, Direction } from 'src/app/shared/models/category.model'; import { AddDirectionFormComponent } from './add-direction-form.component'; -describe('AddDirectionFormComponent', () => { +describe('AddClassFormComponent', () => { let component: AddDirectionFormComponent; let fixture: ComponentFixture; @@ -27,7 +30,11 @@ describe('AddDirectionFormComponent', () => { MatDialogModule, BrowserAnimationsModule, NgxsModule.forRoot([]), - ], + MatStepperModule, + NoopAnimationsModule, + CdkStepperModule, + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ AddDirectionFormComponent, MockValidationHintForInputComponent, @@ -39,6 +46,9 @@ describe('AddDirectionFormComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(AddDirectionFormComponent); component = fixture.componentInstance; + component.directionFormGroup = new FormGroup({ + title: new FormControl(''), + }); fixture.detectChanges(); }); @@ -58,4 +68,11 @@ class MockValidationHintForInputComponent { @Input() minCharachters: number; @Input() forbiddenCharacter: string; @Input() isEmptyCheck: boolean; + @Input() direction: Direction; + @Input() department: Department; + @Input() directionFormGroup: FormGroup; + @Input() classFormGroup: FormGroup; + @Input() departmentFormGroup: FormGroup; } + + diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index c68e285593..e68e101597 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -6,7 +6,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatStepperModule } from '@angular/material/stepper'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; @@ -28,6 +28,7 @@ describe('CreateDirectionComponent', () => { RouterTestingModule, MatStepperModule, MatDialogModule, + NoopAnimationsModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index 08e8d909c7..d6ad9dedcb 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -11,7 +11,7 @@
+ (deleteDirection)="onDelete($event)">
{ BrowserAnimationsModule, RouterTestingModule, MatStepperModule, + MatDialogModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ DirectionsComponent, + MockListChildCardPaginatorComponent, + MockAllCategoriesCardComponent, ] }) .compileComponents(); @@ -45,3 +51,18 @@ describe('DirectionsComponent', () => { expect(component).toBeTruthy(); }); }); +@Component({ + selector: 'app-category-card', + template: '' +}) +class MockAllCategoriesCardComponent { + @Input() direction: Direction; +} +@Component({ + selector: 'app-paginator', + template: '' +}) +class MockListChildCardPaginatorComponent { + @Input() totalEntities: number; + @Input() currentPage: PaginationElement; +} From cb8d2ec2d9e117f14da59c9b3de6f16ac69fbdc7 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 19:21:25 +0300 Subject: [PATCH 13/20] tests --- .../components/paginator/paginator.component.ts | 3 ++- src/app/shared/constants/constants.ts | 6 +++--- .../add-department-form.component.spec.ts | 8 ++++++-- .../add-direction-form.component.spec.ts | 7 +++++-- .../directions/directions.component.html | 14 +++++++++----- .../directions/directions.component.ts | 5 ++--- .../admin-tools/platform/platform.component.html | 2 +- .../admin-tools/platform/platform.component.ts | 13 ++++--------- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/app/shared/components/paginator/paginator.component.ts b/src/app/shared/components/paginator/paginator.component.ts index 45e7f92a61..93114063ff 100644 --- a/src/app/shared/components/paginator/paginator.component.ts +++ b/src/app/shared/components/paginator/paginator.component.ts @@ -11,6 +11,7 @@ export class PaginatorComponent implements OnInit, OnChanges { @Input() currentPage: PaginationElement; @Input() totalEntities: number; + @Input() totalEntitiesDir: number; @Output() pageChange = new EventEmitter(); @@ -58,7 +59,7 @@ export class PaginatorComponent implements OnInit, OnChanges { } private getTotalPageAmount(): number { - return Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE)|| Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE_DIR); + return Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE) || Math.ceil(this.totalEntitiesDir / Constants.ITEMS_PER_PAGE_DIR); } private createDisplayedPageList(): PaginationElement[] { diff --git a/src/app/shared/constants/constants.ts b/src/app/shared/constants/constants.ts index 4382257d05..2957c23e9d 100644 --- a/src/app/shared/constants/constants.ts +++ b/src/app/shared/constants/constants.ts @@ -1,3 +1,4 @@ +import { Input } from '@angular/core'; import { MatDateFormats } from '@angular/material/core'; import { WorkingDays } from '../enum/enumUA/working-hours'; import { City } from '../models/city.model'; @@ -25,8 +26,7 @@ export class Constants { static readonly PHONE_PREFIX = '+380'; static readonly PROVIDER_ENTITY_TYPE = 1; static readonly WORKSHOP_ENTITY_TYPE = 2; - - static readonly ITEMS_PER_PAGE_DIR = 10; + static readonly ITEMS_PER_PAGE_DIR =10; static readonly ITEMS_PER_PAGE = 2 * Math.floor(window.innerWidth / (332)); static readonly RATE_ONE_STAR = 1; @@ -107,4 +107,4 @@ export const WorkingDaysValues: WorkingDaysToggleValue[] = [ export class NotificationsConstants { static readonly NO_MESSAGE = 'У вас немає нових повідомлень'; -} \ No newline at end of file +} diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts index 21b7cbaca0..793e7222f9 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -1,4 +1,4 @@ -import { CdkStepperModule } from '@angular/cdk/stepper'; +import { CdkStepper, CdkStepperModule } from '@angular/cdk/stepper'; import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -38,7 +38,10 @@ describe('AddClassFormComponent', () => { declarations: [ AddDepartmentFormComponent, MockValidationHintForInputComponent, - ] + ], + providers: [ + { provide: CdkStepper, } + ], }) .compileComponents(); }); @@ -73,4 +76,5 @@ class MockValidationHintForInputComponent { @Input() directionFormGroup: FormGroup; @Input() classFormGroup: FormGroup; @Input() departmentFormGroup: FormGroup; + @Input() _stepper: CdkStepper; } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts index 1a93a637b7..698850899e 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts @@ -1,4 +1,4 @@ -import { CdkStepperModule } from '@angular/cdk/stepper'; +import { CdkStepper, CdkStepperModule } from '@angular/cdk/stepper'; import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -38,7 +38,10 @@ describe('AddClassFormComponent', () => { declarations: [ AddDirectionFormComponent, MockValidationHintForInputComponent, - ] + ], + providers: [ + { provide: CdkStepper, } + ], }) .compileComponents(); }); diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index d6ad9dedcb..4567b11b48 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -1,4 +1,4 @@ -
+
-
+ +
- - + + +
+ + diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts index 2c0734ed0f..3b8c584490 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -11,6 +11,7 @@ import { Direction, DirectionsFilter } from 'src/app/shared/models/category.mode import { PaginationElement } from 'src/app/shared/models/paginationElement.model'; import { DeleteDirectionById, FilterChange, FilterClear, GetFilteredDirections, PageChange, SetSearchQueryValue } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; +import { FilterState } from 'src/app/shared/store/filter.state'; @Component({ selector: 'app-directions', @@ -21,15 +22,13 @@ export class DirectionsComponent implements OnInit, OnDestroy { readonly noDirections = NoResultsTitle.noDirections; searchValue = new FormControl('', [Validators.maxLength(200)]); - isResultPage = true; + DirectionsPage = true; searchedText: string; @Select(AdminState.filteredDirections) filteredDirections$: Observable; @Select(AdminState.searchQuery) searchQuery$: Observable; - @Select(AdminState.isLoading) - isLoading$: Observable; destroy$: Subject = new Subject(); diff --git a/src/app/shell/admin-tools/platform/platform.component.html b/src/app/shell/admin-tools/platform/platform.component.html index 69391d85aa..b88d8bf015 100644 --- a/src/app/shell/admin-tools/platform/platform.component.html +++ b/src/app/shell/admin-tools/platform/platform.component.html @@ -16,7 +16,7 @@

{{portalItem.description}}

-
+
diff --git a/src/app/shell/admin-tools/platform/platform.component.ts b/src/app/shell/admin-tools/platform/platform.component.ts index 5729fa56d7..064d87544d 100644 --- a/src/app/shell/admin-tools/platform/platform.component.ts +++ b/src/app/shell/admin-tools/platform/platform.component.ts @@ -10,10 +10,8 @@ import { AdminTabs, AdminTabsUkr } from 'src/app/shared/enum/enumUA/admin-tabs'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; import { AboutPortal } from 'src/app/shared/models/aboutPortal.model'; -import { GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; +import { GetFilteredDirections, GetInfoAboutPortal } from 'src/app/shared/store/admin.actions'; import { AdminState } from 'src/app/shared/store/admin.state'; -import { GetDirections } from 'src/app/shared/store/meta-data.actions'; -import { MetaDataState } from 'src/app/shared/store/meta-data.state'; @Component({ @@ -26,24 +24,21 @@ export class PlatformComponent implements OnInit, OnDestroy { readonly adminTabs = AdminTabs; readonly adminTabsUkr = AdminTabsUkr; + @Select(AdminState.aboutPortal) + aboutPortal$: Observable; @Select(AdminState.filteredDirections) filteredDirections$: Observable; destroy$: Subject = new Subject(); - @Select(AdminState.aboutPortal) - aboutPortal$: Observable; - - + @Input() direction: Direction; tabIndex: number; - constructor( private store: Store, private route: ActivatedRoute, private router: Router, private matDialog: MatDialog) { } - ngOnInit(): void { this.store.dispatch(new GetInfoAboutPortal()); this.route.params.pipe( From 6b2c944db3454ae34e95353ba21bf212bd6c5425 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Thu, 31 Mar 2022 19:25:23 +0300 Subject: [PATCH 14/20] test --- .../create-direction/directions/directions.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts index 3b8c584490..797e0086e5 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { FormControl, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Actions, ofAction, Select, Store } from '@ngxs/store'; @@ -24,7 +24,8 @@ export class DirectionsComponent implements OnInit, OnDestroy { searchValue = new FormControl('', [Validators.maxLength(200)]); DirectionsPage = true; searchedText: string; - + + @Input() direction: Direction; @Select(AdminState.filteredDirections) filteredDirections$: Observable; @Select(AdminState.searchQuery) From 984c579834b9536fd729d6b0b4a9a7f97c4e73cc Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Mon, 4 Apr 2022 14:39:39 +0300 Subject: [PATCH 15/20] commens commens --- .../category-card/category-card.component.ts | 2 +- .../paginator/paginator.component.ts | 4 +-- src/app/shared/constants/constants.ts | 6 ++-- src/app/shared/enum/no-results.ts | 2 +- .../services/categories/categories.service.ts | 4 +-- .../app-workshop/app-workshops.service.ts | 6 ++-- .../add-class-form.component.ts | 6 +--- .../add-department-form.component.ts | 8 ++--- .../add-direction-form.component.ts | 9 ++---- .../create-direction.component.ts | 2 +- .../directions/directions.component.html | 6 ++-- .../directions/directions.component.ts | 29 ++++++++----------- .../parent/children/children.component.html | 18 ++++++------ .../favorite-workshops.component.html | 4 +-- .../workshop-cards-list.component.html | 4 +-- .../workshop-map-view-list.component.html | 4 +-- 16 files changed, 50 insertions(+), 64 deletions(-) diff --git a/src/app/shared/components/category-card/category-card.component.ts b/src/app/shared/components/category-card/category-card.component.ts index 10b25d932c..24f6c4eb63 100644 --- a/src/app/shared/components/category-card/category-card.component.ts +++ b/src/app/shared/components/category-card/category-card.component.ts @@ -11,7 +11,7 @@ import { SetDirections } from '../../store/filter.actions'; }) export class CategoryCardComponent implements OnInit { @Input() workshopsCount: number; - @Input() isEditMode: boolean; + @Input() isEditMode: true; @Input() direction: Direction; @Input() icons: {}; @Output() deleteDirection = new EventEmitter(); diff --git a/src/app/shared/components/paginator/paginator.component.ts b/src/app/shared/components/paginator/paginator.component.ts index 93114063ff..a37ec6c695 100644 --- a/src/app/shared/components/paginator/paginator.component.ts +++ b/src/app/shared/components/paginator/paginator.component.ts @@ -11,7 +11,7 @@ export class PaginatorComponent implements OnInit, OnChanges { @Input() currentPage: PaginationElement; @Input() totalEntities: number; - @Input() totalEntitiesDir: number; + @Input() itemsPerPage: number = this.constants.ITEMS_PER_PAGE_DEFAULT; @Output() pageChange = new EventEmitter(); @@ -59,7 +59,7 @@ export class PaginatorComponent implements OnInit, OnChanges { } private getTotalPageAmount(): number { - return Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE) || Math.ceil(this.totalEntitiesDir / Constants.ITEMS_PER_PAGE_DIR); + return Math.ceil(this.totalEntities / this.itemsPerPage); } private createDisplayedPageList(): PaginationElement[] { diff --git a/src/app/shared/constants/constants.ts b/src/app/shared/constants/constants.ts index 2957c23e9d..68fbc8c411 100644 --- a/src/app/shared/constants/constants.ts +++ b/src/app/shared/constants/constants.ts @@ -26,8 +26,6 @@ export class Constants { static readonly PHONE_PREFIX = '+380'; static readonly PROVIDER_ENTITY_TYPE = 1; static readonly WORKSHOP_ENTITY_TYPE = 2; - static readonly ITEMS_PER_PAGE_DIR =10; - static readonly ITEMS_PER_PAGE = 2 * Math.floor(window.innerWidth / (332)); static readonly RATE_ONE_STAR = 1; static readonly RATE_TWO_STAR = 2; @@ -60,7 +58,9 @@ export class PaginationConstants { static readonly MAX_PAGE_PAGINATOR_DISPLAY = 7; static readonly PAGINATION_DOTS = '...'; static readonly PAGINATION_SHIFT_DELTA = 3; -} + static readonly ITEMS_PER_PAGE_TEN = 10; + static readonly ITEMS_PER_PAGE_DEFAULT = 2 * Math.floor(window.innerWidth / (332)) +}; export const MOMENT_DATE_FORMATS: MatDateFormats = { parse: { diff --git a/src/app/shared/enum/no-results.ts b/src/app/shared/enum/no-results.ts index 6d3eeea459..96170d0b34 100644 --- a/src/app/shared/enum/no-results.ts +++ b/src/app/shared/enum/no-results.ts @@ -1,7 +1,7 @@ export enum NoResultsTitle { noApplication = 'Заявок поки немає', noResultWorkshops = 'За результатами нічого не знайдено', - noParentWorkshops = 'Тут буде відображатися інформація про гуртки, секцію фбо школу для навчання. Ще жодної заяви на гурток не подано.', + noParentWorkshops = 'Тут буде відображатися інформація про гуртки, секцію або школу для навчання. Ще жодної заяви на гурток не подано.', noFavoriteWorkshops = 'Улюблених гуртків поки немає', noDirections = 'За результатами нічого не знайдено', noProviderAdmins = 'Користувачів поки немає', diff --git a/src/app/shared/services/categories/categories.service.ts b/src/app/shared/services/categories/categories.service.ts index b171b9007f..49b098280c 100644 --- a/src/app/shared/services/categories/categories.service.ts +++ b/src/app/shared/services/categories/categories.service.ts @@ -1,7 +1,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { Constants } from '../../constants/constants'; +import { Constants, PaginationConstants } from '../../constants/constants'; import { IClass, Department, Direction, DirectionsFilter } from '../../models/category.model'; import { AdminStateModel } from '../../store/admin.state'; @@ -20,7 +20,7 @@ export class CategoriesService { } if (filters.currentPage) { - const size: number = Constants.ITEMS_PER_PAGE_DIR; + const size: number = PaginationConstants.ITEMS_PER_PAGE_TEN; const from: number = size * (+filters.currentPage.element - 1); params = params.set('Size', size.toString()); diff --git a/src/app/shared/services/workshops/app-workshop/app-workshops.service.ts b/src/app/shared/services/workshops/app-workshop/app-workshops.service.ts index 10ea737799..94d983776d 100644 --- a/src/app/shared/services/workshops/app-workshop/app-workshops.service.ts +++ b/src/app/shared/services/workshops/app-workshop/app-workshops.service.ts @@ -1,7 +1,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { Constants } from 'src/app/shared/constants/constants'; +import { Constants, PaginationConstants } from 'src/app/shared/constants/constants'; import { Ordering } from 'src/app/shared/enum/ordering'; import { Direction } from 'src/app/shared/models/category.model'; @@ -13,7 +13,7 @@ import { FilterStateModel } from '../../../store/filter.state'; export class AppWorkshopsService { dataUrlMock = '/assets/mock-org-cards.json'; - size: number = Constants.ITEMS_PER_PAGE; + size: number = PaginationConstants.ITEMS_PER_PAGE_DEFAULT; constructor(private http: HttpClient) { } @@ -84,7 +84,7 @@ export class AppWorkshopsService { params = params.set('Size', '100'); params = params.set('From', '0'); } else if (filters.currentPage) { - const size: number = Constants.ITEMS_PER_PAGE; + const size: number = PaginationConstants.ITEMS_PER_PAGE_DEFAULT; const from: number = size * (+filters.currentPage.element - 1); params = params.set('Size', size.toString()); diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts index bb435ab2b9..1b1c943ef2 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -6,7 +6,7 @@ import { FormGroup } from '@angular/forms'; templateUrl: './add-class-form.component.html', styleUrls: ['./add-class-form.component.scss'] }) -export class AddClassFormComponent implements OnInit { +export class AddClassFormComponent { @Input() ClassFormGroup: FormGroup; @Input() indexClass: number; @@ -19,13 +19,9 @@ export class AddClassFormComponent implements OnInit { constructor() { } - ngOnInit(): void { - } - onDelete(): void { this.deleteForm.emit(this.indexClass); } - } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts index c3288a4575..68a9a35ebb 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts @@ -14,7 +14,7 @@ import { CreateDepartment } from 'src/app/shared/store/admin.actions'; templateUrl: './add-department-form.component.html', styleUrls: ['./add-department-form.component.scss'] }) -export class AddDepartmentFormComponent implements OnInit { +export class AddDepartmentFormComponent { @Input() direction: Direction; @@ -34,8 +34,6 @@ export class AddDepartmentFormComponent implements OnInit { }); } - ngOnInit(): void {} - onSubmit(): void { if (this.departmentFormGroup.invalid) { this.checkValidation(this.departmentFormGroup); @@ -51,13 +49,13 @@ export class AddDepartmentFormComponent implements OnInit { this.store.dispatch(new CreateDepartment(department)); this._stepper.next(); }) - } + } } checkValidation(form: FormGroup): void { Object.keys(form.controls).forEach(key => { form.get(key).markAsTouched(); }); - } + } } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts index b7f39272b1..19e7c5385c 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts @@ -20,9 +20,8 @@ import { AdminStateModel } from 'src/app/shared/store/admin.state'; useValue: { displayDefaultIndicatorType: false } }] }) -export class AddDirectionFormComponent implements OnInit { +export class AddDirectionFormComponent { - @Input() admin: TechAdmin; isActiveDirectionInfoButton = false; AdminStateModel: AdminStateModel; directionFormGroup: FormGroup; @@ -37,8 +36,6 @@ export class AddDirectionFormComponent implements OnInit { }); } - ngOnInit(): void { } - onSubmit(): void { if (this.directionFormGroup.invalid) { this.checkValidation(this.directionFormGroup); @@ -54,10 +51,10 @@ export class AddDirectionFormComponent implements OnInit { result && this.store.dispatch(new CreateDirection(direction)); this._stepper.next(); }) - } + } } - checkValidation(form: FormGroup): void { + private checkValidation(form: FormGroup): void { Object.keys(form.controls).forEach(key => { form.get(key).markAsTouched(); }); diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index 0353047cbb..9d367e686f 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -37,7 +37,7 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { department: Department; destroy$: Subject = new Subject(); - editMode = false; + editMode = true; @ViewChild('stepper') stepper: MatStepper; diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index 4567b11b48..01f0a53f0b 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -1,4 +1,4 @@ -
+
- +
-
diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts index 797e0086e5..a43a6b068e 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.ts @@ -5,6 +5,7 @@ import { Actions, ofAction, Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, startWith, takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { PaginationConstants } from 'src/app/shared/constants/constants'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { NoResultsTitle } from 'src/app/shared/enum/no-results'; import { Direction, DirectionsFilter } from 'src/app/shared/models/category.model'; @@ -19,36 +20,32 @@ import { FilterState } from 'src/app/shared/store/filter.state'; styleUrls: ['./directions.component.scss'] }) export class DirectionsComponent implements OnInit, OnDestroy { - - readonly noDirections = NoResultsTitle.noDirections; - searchValue = new FormControl('', [Validators.maxLength(200)]); - DirectionsPage = true; - searchedText: string; - @Input() direction: Direction; @Select(AdminState.filteredDirections) filteredDirections$: Observable; @Select(AdminState.searchQuery) searchQuery$: Observable; - destroy$: Subject = new Subject(); + readonly noDirections = NoResultsTitle.noDirections; + readonly itemsPerPage = PaginationConstants.ITEMS_PER_PAGE_TEN; + + searchValue = new FormControl('', [Validators.maxLength(200)]); + searchedText: string; + isEditMode: true; currentPage: PaginationElement = { element: 1, isActive: true }; - tabIndex: number; - constructor( private store: Store, private actions$: Actions, private matDialog: MatDialog) { } - ngOnInit(): void { - this.store.dispatch([new FilterClear(), new GetFilteredDirections(), ]); - this.searchValue.valueChanges + this.store.dispatch([new FilterClear(), new GetFilteredDirections()]); + this.searchValue.valueChanges .pipe(takeUntil(this.destroy$)) .subscribe((val: string) => { this.searchedText = val; @@ -61,15 +58,13 @@ export class DirectionsComponent implements OnInit, OnDestroy { .pipe(takeUntil(this.destroy$)) .subscribe((text: string) => this.searchValue.setValue(text, {emitEvent: false})); - this.actions$.pipe(ofAction(FilterChange)) + this.actions$.pipe(ofAction(FilterChange)) .pipe( debounceTime(1000), distinctUntilChanged(), startWith(''), - takeUntil(this.destroy$)) - .subscribe(() => this.store.dispatch([ - new GetFilteredDirections(), - ])); + takeUntil(this.destroy$) + ).subscribe(() => this.store.dispatch(new GetFilteredDirections())); } onSearch(): void { diff --git a/src/app/shell/personal-cabinet/parent/children/children.component.html b/src/app/shell/personal-cabinet/parent/children/children.component.html index c68b36f46e..c744f57cb0 100644 --- a/src/app/shell/personal-cabinet/parent/children/children.component.html +++ b/src/app/shell/personal-cabinet/parent/children/children.component.html @@ -1,14 +1,14 @@
-

Тут ви можете додати інформацію про дитину, щоб записати її у гурток, секцію чи школу

+

Тут ви можете додати інформацію про дитину, щоб записати її у гурток, секцію чи школу

Можливо додати не більш, ніж 20 дітей
- - - @@ -23,8 +23,8 @@ (deleteChild)="onDelete($event)" [applications]="childApplications(applications$ |async, child)">
-
- \ No newline at end of file + diff --git a/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html b/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html index 5e53fcf7dd..3e7438fddc 100644 --- a/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html +++ b/src/app/shell/personal-cabinet/parent/favorite-workshops/favorite-workshops.component.html @@ -4,7 +4,7 @@ [isMainPage]="false" [userRoleView]="Role.unauthorized">
- @@ -13,4 +13,4 @@

{{noFavoriteWorkshops}}

- \ No newline at end of file + diff --git a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html index 8e581cd171..9677c5c082 100644 --- a/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html +++ b/src/app/shell/result/workshop-cards-list/workshop-cards-list.component.html @@ -8,11 +8,11 @@ - - \ No newline at end of file + diff --git a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html index a139b3314b..6589f18bab 100644 --- a/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html +++ b/src/app/shell/result/workshop-map-view-list/workshop-map-view-list.component.html @@ -5,7 +5,7 @@ [workshop]="workshop" [isMainPage]="true" #WorkshopsWrap>
- @@ -44,4 +44,4 @@
- \ No newline at end of file + From ad41bcc833492fc1fe9cc99a65b8b9a2eec63ba2 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Tue, 5 Apr 2022 11:57:31 +0300 Subject: [PATCH 16/20] comment --- .../services/children/children.service.ts | 4 +-- .../add-department-form.component.spec.ts | 2 ++ .../add-department-form.component.ts | 12 +++++-- .../add-direction-form.component.spec.ts | 2 ++ .../add-direction-form.component.ts | 33 +++++++++++-------- .../create-direction.component.spec.ts | 2 ++ .../create-direction.component.ts | 14 +++++--- .../directions/directions.component.html | 2 +- .../directions/directions.component.ts | 1 - src/app/shell/main/main.component.ts | 6 ++-- 10 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/app/shared/services/children/children.service.ts b/src/app/shared/services/children/children.service.ts index 2185ae8a0a..922fa295fa 100644 --- a/src/app/shared/services/children/children.service.ts +++ b/src/app/shared/services/children/children.service.ts @@ -1,7 +1,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { Constants } from '../../constants/constants'; +import { PaginationConstants } from '../../constants/constants'; import { Child, ChildCards } from '../../models/child.model'; import { SocialGroup } from '../../models/socialGroup.model'; import { UserStateModel } from '../../store/user.state'; @@ -17,7 +17,7 @@ export class ChildrenService { let params = new HttpParams(); if (state.currentPage) { - const size: number = Constants.ITEMS_PER_PAGE; + const size: number = PaginationConstants.ITEMS_PER_PAGE_DEFAULT; const from: number = size * (+state.currentPage.element - 1); params = params.set('Size', (size).toString()); diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts index 793e7222f9..314aeff3e0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.spec.ts @@ -8,6 +8,7 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatStepper, MatStepperModule } from '@angular/material/stepper'; import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; import { Department, Direction } from 'src/app/shared/models/category.model'; @@ -77,4 +78,5 @@ class MockValidationHintForInputComponent { @Input() classFormGroup: FormGroup; @Input() departmentFormGroup: FormGroup; @Input() _stepper: CdkStepper; + @Input() router: Router; } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts index 68a9a35ebb..87a8be0dc2 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts @@ -1,7 +1,8 @@ import { CdkStepper } from '@angular/cdk/stepper'; -import { Component, EventEmitter, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; +import { Router } from '@angular/router'; import { Store } from '@ngxs/store'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; @@ -28,6 +29,7 @@ export class AddDepartmentFormComponent { private store: Store, private matDialog: MatDialog, private _stepper: CdkStepper, + private router: Router, private formBuilder: FormBuilder) { this.departmentFormGroup = this.formBuilder.group({ title: new FormControl('', [Validators.required, Validators.pattern(TEXT_REGEX)]), @@ -45,12 +47,16 @@ export class AddDepartmentFormComponent { } }); dialogRef.afterClosed().subscribe((result: boolean) => { + if (result) { const department = result && new Department(this.departmentFormGroup.value, this.direction.id); this.store.dispatch(new CreateDepartment(department)); this._stepper.next(); - }) - } + } else { + this.router.navigate([`/admin-tools/platform/directions`]); + } + }); } + } checkValidation(form: FormGroup): void { Object.keys(form.controls).forEach(key => { diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts index 698850899e..9334c8dec1 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.spec.ts @@ -8,6 +8,7 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatStepperModule } from '@angular/material/stepper'; import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; import { Department, Direction } from 'src/app/shared/models/category.model'; @@ -76,6 +77,7 @@ class MockValidationHintForInputComponent { @Input() directionFormGroup: FormGroup; @Input() classFormGroup: FormGroup; @Input() departmentFormGroup: FormGroup; + @Input() router: Router; } diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts index 19e7c5385c..40820003db 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts @@ -1,13 +1,13 @@ import { CdkStepper, STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; -import { Component, Input, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; +import { Router } from '@angular/router'; import { Store } from '@ngxs/store'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; import { ModalConfirmationType } from 'src/app/shared/enum/modal-confirmation'; import { Direction } from 'src/app/shared/models/category.model'; -import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; import { CreateDirection } from 'src/app/shared/store/admin.actions'; import { AdminStateModel } from 'src/app/shared/store/admin.state'; @@ -29,6 +29,7 @@ export class AddDirectionFormComponent { constructor( private store: Store, private matDialog: MatDialog, + private router: Router, private _stepper: CdkStepper, private formBuilder: FormBuilder){ this.directionFormGroup = this.formBuilder.group({ @@ -37,20 +38,24 @@ export class AddDirectionFormComponent { } onSubmit(): void { - if (this.directionFormGroup.invalid) { - this.checkValidation(this.directionFormGroup); - } else { - const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { - width: '330px', - data: { - type: ModalConfirmationType.createDirection, + if (this.directionFormGroup.invalid) { + this.checkValidation(this.directionFormGroup); + } else { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: '330px', + data: { + type: ModalConfirmationType.createDirection, + } + }); + dialogRef.afterClosed().subscribe((result: boolean) => { + if (result) { + const direction = new Direction(this.directionFormGroup.value); + this.store.dispatch(new CreateDirection(direction)); + this._stepper.next(); + } else { + this.router.navigate([`/admin-tools/platform/directions`]); } }); - dialogRef.afterClosed().subscribe((result: boolean) => { - const direction = new Direction(this.directionFormGroup.value); - result && this.store.dispatch(new CreateDirection(direction)); - this._stepper.next(); - }) } } diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts index e68e101597..23d0b7fbfd 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.spec.ts @@ -7,6 +7,7 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatStepperModule } from '@angular/material/stepper'; import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; import { TechAdmin } from 'src/app/shared/models/techAdmin.model'; @@ -71,6 +72,7 @@ class MockValidationHintForInputComponent { @Input() directionFormGroup: FormGroup; @Input() classFormGroup: FormGroup; @Input() departmentFormGroup: FormGroup; + @Input() router: Router; } @Component({ selector: 'app-add-direction-form', diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index 9d367e686f..ab15459a5d 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -3,10 +3,9 @@ import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatStepper } from '@angular/material/stepper'; -import { ActivatedRoute, Params } from '@angular/router'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { Observable, Subject } from 'rxjs'; -import { dispatch } from 'rxjs/internal/observable/pairs'; import { filter, takeUntil } from 'rxjs/operators'; import { ConfirmationModalWindowComponent } from 'src/app/shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { TEXT_REGEX } from 'src/app/shared/constants/regex-constants'; @@ -56,6 +55,7 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { private fb: FormBuilder, private store: Store, private route: ActivatedRoute, + private router: Router, private matDialog: MatDialog,) { } ngOnInit(): void { @@ -98,6 +98,7 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { } }); dialogRef.afterClosed().subscribe((result: boolean) => { + if (result) { const classes: IClass[] = []; const department = result && this.store.selectSnapshot(AdminState.department); @@ -105,10 +106,13 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { classes.push(new IClass(form.value, department.id)) ); this.store.dispatch(new CreateClass(classes)); - }); + } else { + this.router.navigate([`/admin-tools/platform/directions`]); + } + }); } - } - + } + checkValidationClass(): void { Object.keys(this.ClassFormArray.controls).forEach(key => { this.checkValidation(this.ClassFormArray.get(key)); diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index 01f0a53f0b..2eeeced6dd 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -12,7 +12,7 @@
+ (deleteDirection)="onDelete($event)" [isEditMode]="true">
(!!city && !!favorite?.length) || (favorite === null)), takeUntil(this.destroy$)) - .subscribe(() => this.store.dispatch(new GetTopWorkshops(Constants.ITEMS_PER_PAGE))); + .subscribe(() => this.store.dispatch(new GetTopWorkshops(PaginationConstants.ITEMS_PER_PAGE_DEFAULT))); } else { this.city$ .pipe( filter(city => !!city), takeUntil(this.destroy$)) - .subscribe(() => this.store.dispatch(new GetTopWorkshops(Constants.ITEMS_PER_PAGE))); + .subscribe(() => this.store.dispatch(new GetTopWorkshops(PaginationConstants.ITEMS_PER_PAGE_DEFAULT))); } } From af21c27c009515039dbbf165f004889fea5e5867 Mon Sep 17 00:00:00 2001 From: LeraKornienko Date: Tue, 5 Apr 2022 12:47:57 +0300 Subject: [PATCH 17/20] info info --- .../add-class-form/add-class-form.component.html | 2 -- .../add-class-form/add-class-form.component.ts | 4 ---- .../add-department-form.component.html | 4 ---- .../add-department-form.component.ts | 2 -- .../add-direction-form.component.html | 2 -- .../add-direction-form.component.ts | 1 - .../create-direction/create-direction.component.html | 4 ---- .../create-direction/create-direction.component.ts | 12 ------------ .../directions/directions.component.html | 2 +- 9 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html index 069adc1999..30cc21d0f0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.html @@ -1,8 +1,6 @@
- info_outline
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts index 1b1c943ef2..488e3e6e93 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-class-form/add-class-form.component.ts @@ -13,10 +13,6 @@ export class AddClassFormComponent { @Input() classAmount: number; @Output() deleteForm = new EventEmitter(); - isActiveClassInfoButton = false; - isActiveDepartmentInfoButton = false; - isActiveDirectionInfoButton = false; - constructor() { } onDelete(): void { diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html index e13df0335c..e93296713c 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.html @@ -1,14 +1,10 @@
- info_outline
{{ direction.title }}
- info_outline
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts index 87a8be0dc2..eb94a06193 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-department-form/add-department-form.component.ts @@ -21,8 +21,6 @@ export class AddDepartmentFormComponent { departmentFormGroup: FormGroup; directionFormGroup: FormGroup; - isActiveDepartmentInfoButton = false; - isActiveDirectionInfoButton = false; department: Department; constructor( diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html index 842bbb7e6a..daab711188 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.html @@ -1,8 +1,6 @@
- info_outline
diff --git a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts index 40820003db..a0cd7660f7 100644 --- a/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/add-direction-form/add-direction-form.component.ts @@ -22,7 +22,6 @@ import { AdminStateModel } from 'src/app/shared/store/admin.state'; }) export class AddDirectionFormComponent { - isActiveDirectionInfoButton = false; AdminStateModel: AdminStateModel; directionFormGroup: FormGroup; diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html index 2e54ef7b68..a68bab3cd0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.html @@ -25,14 +25,10 @@

{{(editMode) ? 'РЕДАГУВАТИ' : 'ДОДАТИ'
- info_outline
{{direction.title}}
- info_outline
{{department.title}}
diff --git a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts index ab15459a5d..23be6193f0 100644 --- a/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts +++ b/src/app/shell/admin-tools/platform/create-direction/create-direction.component.ts @@ -43,10 +43,6 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { ClassFormArray: FormArray = new FormArray([]); @Input() classes: IClass[]; - isActiveDepartmentInfoButton = false; - isActiveDirectionInfoButton = false; - isActiveClassInfoButton = false; - departmentFormGroup: FormGroup; directionFormGroup: FormGroup; ClassFormGroup: FormGroup; @@ -71,14 +67,6 @@ export class CreateDirectionComponent implements OnInit, OnDestroy { return ClassFormGroup; } - ngAfterViewInit(): void { - if (this.editMode) { - this.route.params.subscribe((params: Params) => { - this.stepper.selectedIndex = +createDirectionSteps[params.param]; - }); - } - } - addClass(): void { this.ClassFormArray.push(this.newForm()); } diff --git a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html index 2eeeced6dd..030ca06ef2 100644 --- a/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html +++ b/src/app/shell/admin-tools/platform/create-direction/directions/directions.component.html @@ -1,4 +1,4 @@ -
+