diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index 684426d5b6..d56d9bf2df 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -1,9 +1,7 @@
-
+
@@ -63,7 +60,7 @@

{{ headerSubtitle }}

- + @@ -88,9 +84,7 @@

{{ headerSubtitle }}

- + - + @@ -128,10 +120,7 @@

{{ headerSubtitle }}

{{ 'ENUM.NAV_BAR_NAME.PERSONAL_INFORMATION' | translate }}
- + diff --git a/src/app/shared/components/sidenav-menu/sidenav-menu.component.html b/src/app/shared/components/sidenav-menu/sidenav-menu.component.html index e5725428cc..60096a26b2 100644 --- a/src/app/shared/components/sidenav-menu/sidenav-menu.component.html +++ b/src/app/shared/components/sidenav-menu/sidenav-menu.component.html @@ -26,7 +26,7 @@
-
+
@@ -35,12 +35,7 @@
-
+
{{ 'ENUM.NAV_BAR_NAME.PERSONAL_INFORMATION' | translate @@ -48,30 +43,22 @@ {{ 'ENUM.NAV_BAR_NAME.INFORMATION_ABOUT' | translate }} {{ RoleLinks[user.role] | translate }} - {{ 'ENUM.NAV_BAR_NAME.MY_WORKSHOPS' | translate }} + {{ + 'ENUM.NAV_BAR_NAME.MY_WORKSHOPS' | translate + }} {{ 'ENUM.NAV_BAR_NAME.APPLICATIONS' | translate }} - {{ - 'ENUM.NAV_BAR_NAME.MESSAGES' | translate - }} + {{ 'ENUM.NAV_BAR_NAME.MESSAGES' | translate }} {{ 'ENUM.NAV_BAR_NAME.ADMINISTRATION' | translate }} - {{ 'ENUM.NAV_BAR_NAME.FAVORITE' | translate }} + {{ + 'ENUM.NAV_BAR_NAME.FAVORITE' | translate + }} {{ @@ -84,10 +71,7 @@ (click)="changeView()"> {{ 'ENUM.NAV_BAR_NAME.ADMINISTRATION' | translate }} - + {{ 'ENUM.NAV_BAR_NAME.ADMINISTRATION' | translate }} diff --git a/src/app/shared/services/provider/provider.service.ts b/src/app/shared/services/provider/provider.service.ts index 8f4b0e4167..3879445deb 100644 --- a/src/app/shared/services/provider/provider.service.ts +++ b/src/app/shared/services/provider/provider.service.ts @@ -1,11 +1,15 @@ -import { PaginationElement } from './../../models/paginationElement.model'; +import { Observable } from 'rxjs'; + import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Store } from '@ngxs/store'; -import { Observable } from 'rxjs'; -import { BlockProviderData, LicenseStatusData, Provider, ProviderParameters, ProviderStatusUpdateData } from '../../models/provider.model'; -import { SearchResponse } from '../../models/search.model'; + import { DataItem } from '../../models/item.model'; +import { PaginationElement } from '../../models/paginationElement.model'; +import { + BlockProviderData, LicenseStatusData, Provider, ProviderParameters, ProviderStatusUpdateData +} from '../../models/provider.model'; +import { SearchResponse } from '../../models/search.model'; @Injectable({ providedIn: 'root' @@ -13,23 +17,11 @@ import { DataItem } from '../../models/item.model'; export class ProviderService { constructor(private http: HttpClient, private store: Store) {} - private setParams(providerParameters: ProviderParameters): HttpParams { - let params = new HttpParams(); - - if (providerParameters.searchString) { - params = params.set('SearchString', providerParameters.searchString); - } - - params = params.set('Size', providerParameters.size.toString()).set('From', providerParameters.from.toString()); - - return params; - } - /** * This method get Provider by id * @param id string */ - getProviderById(id: string): Observable { + public getProviderById(id: string): Observable { return this.http.get(`/api/v1/Provider/GetById/${id}`); } @@ -37,7 +29,7 @@ export class ProviderService { * This method get filtered Providers from the database * @param */ - getFilteredProviders(providerParameters: ProviderParameters): Observable> { + public getFilteredProviders(providerParameters: ProviderParameters): Observable> { const options = { params: this.setParams(providerParameters) }; return this.http.get>('/api/v1/Provider/GetByFilter', options); @@ -47,23 +39,14 @@ export class ProviderService { * This method create Provider * @param Provider */ - createProvider(provider: Provider, isRelease3: boolean): Observable { - return isRelease3 ? this.createProviderV2(provider) : this.createProviderV1(provider); - } - - createProviderV1(provider: Provider): Observable { - return this.http.post('/api/v1/Provider/Create', provider); - } - - createProviderV2(provider: Provider): Observable { - const formData = Provider.createFormData(provider); - return this.http.post('/api/v2/Provider/Create', formData); + public createProvider(provider: Provider, isImagesFeature: boolean): Observable { + return isImagesFeature ? this.createProviderV2(provider) : this.createProviderV1(provider); } /** * This method get Provider by User id */ - getProfile(): Observable { + public getProfile(): Observable { return this.http.get('/api/v1/Provider/GetProfile'); } @@ -71,58 +54,79 @@ export class ProviderService { * This method update Provider * @param Provider */ - updateProvider(provider: Provider, isRelease3: boolean): Observable { - return isRelease3 ? this.updateProviderV2(provider) : this.updateProviderV1(provider); - } - - updateProviderV1(provider: Provider): Observable { - return this.http.put('/api/v1/Provider/Update', provider); - } - - updateProviderV2(provider: Provider): Observable { - const formData = Provider.createFormData(provider); - return this.http.put('/api/v2/Provider/Update', formData); + public updateProvider(provider: Provider, isImagesFeature: boolean): Observable { + return isImagesFeature ? this.updateProviderV2(provider) : this.updateProviderV1(provider); } /** * This method update Provider status */ - updateProviderStatus(updateStatus: ProviderStatusUpdateData): Observable { + public updateProviderStatus(updateStatus: ProviderStatusUpdateData): Observable { return this.http.put('/api/v1/Provider/StatusUpdate', updateStatus); } /** * This method update Provider status */ - updateProviderLicenseStatus(licenseStatusData: LicenseStatusData): Observable { + public updateProviderLicenseStatus(licenseStatusData: LicenseStatusData): Observable { return this.http.put('/api/v1/Provider/LicenseStatusUpdate', licenseStatusData); } /** * This method get all institution statuses */ - getInstitutionStatuses(): Observable { + public getInstitutionStatuses(): Observable { return this.http.get('/api/v1/InstitutionStatus/Get'); } /** * This method get all provider types */ - getProviderTypes(): Observable { + public getProviderTypes(): Observable { return this.http.get('/api/v1/ProviderType/Get'); } /** * This method delete a specific Provider from the database */ - deleteProviderById(id: string): Observable { + public deleteProviderById(id: string): Observable { return this.http.delete(`/api/v1/Provider/Delete/${id}`); } /** * This method block a specific Provider from the database */ - blockProvider(provider: BlockProviderData): Observable { - return this.http.put(`/api/v1/Provider/Block`, provider); + public blockProvider(provider: BlockProviderData): Observable { + return this.http.put('/api/v1/Provider/Block', provider); + } + + private setParams(providerParameters: ProviderParameters): HttpParams { + let params = new HttpParams(); + + if (providerParameters.searchString) { + params = params.set('SearchString', providerParameters.searchString); + } + + params = params.set('Size', providerParameters.size.toString()).set('From', providerParameters.from.toString()); + + return params; + } + + private createProviderV1(provider: Provider): Observable { + return this.http.post('/api/v1/Provider/Create', provider); + } + + private createProviderV2(provider: Provider): Observable { + const formData = Provider.createFormData(provider); + return this.http.post('/api/v2/Provider/Create', formData); + } + + private updateProviderV1(provider: Provider): Observable { + return this.http.put('/api/v1/Provider/Update', provider); + } + + private updateProviderV2(provider: Provider): Observable { + const formData = Provider.createFormData(provider); + return this.http.put('/api/v2/Provider/Update', formData); } } diff --git a/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts b/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts index 32b9771c24..26ce836aba 100644 --- a/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts +++ b/src/app/shared/services/workshops/user-workshop/user-workshop.service.ts @@ -10,14 +10,16 @@ import { FeaturesList } from '../../../models/featuresList.model'; import { TruncatedItem } from '../../../models/item.model'; import { PaginationElement } from '../../../models/paginationElement.model'; import { SearchResponse } from '../../../models/search.model'; -import { ProviderWorkshopCard, Workshop, WorkshopCard, WorkshopCardParameters, WorkshopStatus } from '../../../models/workshop.model'; +import { + ProviderWorkshopCard, Workshop, WorkshopCard, WorkshopCardParameters, WorkshopStatus +} from '../../../models/workshop.model'; import { MetaDataState } from '../../../store/meta-data.state'; @Injectable({ providedIn: 'root' }) export class UserWorkshopService { - private isRelease3: boolean; + private isImagesFeature: boolean; constructor(private http: HttpClient, private store: Store) {} @@ -78,8 +80,8 @@ export class UserWorkshopService { * @param workshop: Workshop */ public createWorkshop(workshop: Workshop): Observable { - this.isRelease3 = this.store.selectSnapshot(MetaDataState.featuresList).release3; - return this.isRelease3 ? this.createWorkshopV2(workshop) : this.createWorkshopV1(workshop); + this.isImagesFeature = this.store.selectSnapshot(MetaDataState.featuresList).images; + return this.isImagesFeature ? this.createWorkshopV2(workshop) : this.createWorkshopV1(workshop); } public createWorkshopV1(workshop: Workshop): Observable { @@ -96,8 +98,8 @@ export class UserWorkshopService { * @param workshop: Workshop */ public updateWorkshop(workshop: Workshop): Observable { - this.isRelease3 = this.store.selectSnapshot(MetaDataState.featuresList).release2; - return this.isRelease3 ? this.updateWorkshopV2(workshop) : this.updateWorkshopV1(workshop); + this.isImagesFeature = this.store.selectSnapshot(MetaDataState.featuresList).images; + return this.isImagesFeature ? this.updateWorkshopV2(workshop) : this.updateWorkshopV1(workshop); } public updateWorkshopV1(workshop: Workshop): Observable { diff --git a/src/app/shared/store/provider.actions.ts b/src/app/shared/store/provider.actions.ts index ab361acef6..f104ec999d 100644 --- a/src/app/shared/store/provider.actions.ts +++ b/src/app/shared/store/provider.actions.ts @@ -144,7 +144,7 @@ export class OnDeleteWorkshopFail { export class CreateProvider { static readonly type = '[provider] create Provider'; - constructor(public payload: Provider, public isRelease3: boolean) {} + constructor(public payload: Provider, public isImagesFeature: boolean) {} } export class OnCreateProviderFail { @@ -159,7 +159,7 @@ export class OnCreateProviderSuccess { export class UpdateProvider { static readonly type = '[provider] update Provider'; - constructor(public payload: Provider, public isRelease3: boolean) {} + constructor(public payload: Provider, public isImagesFeature: boolean) {} } export class OnUpdateProviderFail { diff --git a/src/app/shared/store/provider.state.ts b/src/app/shared/store/provider.state.ts index 45b1ab076f..41849c0ee9 100644 --- a/src/app/shared/store/provider.state.ts +++ b/src/app/shared/store/provider.state.ts @@ -382,9 +382,9 @@ export class ProviderState { @Action(CreateProvider) createProvider( { dispatch }: StateContext, - { payload, isRelease3 }: CreateProvider + { payload, isImagesFeature }: CreateProvider ): Observable> { - return this.providerService.createProvider(payload, isRelease3).pipe( + return this.providerService.createProvider(payload, isImagesFeature).pipe( tap((res: Provider) => dispatch(new OnCreateProviderSuccess(res))), catchError((error) => of(dispatch(new OnCreateProviderFail(error)))) ); @@ -414,9 +414,9 @@ export class ProviderState { @Action(UpdateProvider) updateProvider( { dispatch }: StateContext, - { payload, isRelease3 }: UpdateProvider + { payload, isImagesFeature }: UpdateProvider ): Observable> { - return this.providerService.updateProvider(payload, isRelease3).pipe( + return this.providerService.updateProvider(payload, isImagesFeature).pipe( tap(() => dispatch(new OnUpdateProviderSuccess())), catchError((error: HttpErrorResponse) => of(dispatch(new OnUpdateProviderFail(error)))) ); diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-info-form/create-info-form.component.html b/src/app/shell/personal-cabinet/provider/create-provider/create-info-form/create-info-form.component.html index 240d641ed1..9cdbc929a6 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-info-form/create-info-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-info-form/create-info-form.component.html @@ -1,6 +1,6 @@
; @Input() public provider: Provider; - @Input() public isRelease3: boolean; + @Input() public isImagesFeature: boolean; @Output() public passInfoFormGroup = new EventEmitter(); diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html b/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html index b4e819c9d1..03458f44f0 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html @@ -1,6 +1,6 @@

{{ 'TITLES.ABOUT_THE_PROVIDER_INFO' | translate }}

@@ -21,12 +21,7 @@

-

@@ -62,7 +57,7 @@

{{ 'TITLES.DESCRIPTION' | translate }}

@@ -85,9 +80,7 @@

mat-button type="submit" (click)="onSubmit()" - [disabled]=" - !isAgreed || !isNotRobot || PhotoFormGroup.invalid || ContactsFormGroup.invalid || InfoFormGroup.invalid - "> + [disabled]="!isAgreed || !isNotRobot || PhotoFormGroup.invalid || ContactsFormGroup.invalid || InfoFormGroup.invalid"> {{ 'BUTTONS.SAVE' | translate }}

diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.spec.ts b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.spec.ts index fc5c108071..5755dc7312 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.spec.ts +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.spec.ts @@ -1,14 +1,15 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { CreateProviderComponent } from './create-provider.component'; import { Component, Input } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatStepperModule } from '@angular/material/stepper'; -import { RouterTestingModule } from '@angular/router/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; import { NgxsModule } from '@ngxs/store'; -import { MatCheckboxModule } from '@angular/material/checkbox'; -import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms'; -import { MatDialogModule } from '@angular/material/dialog'; + import { Provider } from '../../../../shared/models/provider.model'; +import { CreateProviderComponent } from './create-provider.component'; fdescribe('CreateProviderComponent', () => { let component: CreateProviderComponent; @@ -68,7 +69,7 @@ class MockCreateContactsFormComponent { class MockCreateInfoComponent { @Input() provider: Provider; @Input() InfoFormGroup; - @Input() isRelease3: boolean; + @Input() isImagesFeature: boolean; } @Component({ @@ -77,5 +78,5 @@ class MockCreateInfoComponent { }) class MockCreatePhotoFormComponent { @Input() provider: Provider; - @Input() isRelease3: boolean; + @Input() isImagesFeature: boolean; } diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts index 2a7396e113..2855035503 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-provider.component.ts @@ -1,5 +1,20 @@ -import { ConfirmationModalWindowComponent } from '../../../../shared/components/confirmation-modal-window/confirmation-modal-window.component'; +import { takeUntil } from 'rxjs/operators'; + +import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; +import { + AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild +} from '@angular/core'; +import { FormControl, FormGroup } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; +import { MatStepper } from '@angular/material/stepper'; +import { ActivatedRoute, Params, Router } from '@angular/router'; +import { Store } from '@ngxs/store'; + +import { + ConfirmationModalWindowComponent +} from '../../../../shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { Constants } from '../../../../shared/constants/constants'; +import { NavBarName } from '../../../../shared/enum/enumUA/navigation-bar'; import { ModalConfirmationType } from '../../../../shared/enum/modal-confirmation'; import { CreateProviderSteps } from '../../../../shared/enum/provider'; import { Role } from '../../../../shared/enum/role'; @@ -7,23 +22,16 @@ import { Address } from '../../../../shared/models/address.model'; import { FeaturesList } from '../../../../shared/models/featuresList.model'; import { Provider } from '../../../../shared/models/provider.model'; import { User } from '../../../../shared/models/user.model'; -import { NavigationBarService } from '../../../../shared/services/navigation-bar/navigation-bar.service'; +import { + NavigationBarService +} from '../../../../shared/services/navigation-bar/navigation-bar.service'; import { MetaDataState } from '../../../../shared/store/meta-data.state'; import { AddNavPath } from '../../../../shared/store/navigation.actions'; +import { CreateProvider, UpdateProvider } from '../../../../shared/store/provider.actions'; +import { Logout } from '../../../../shared/store/registration.actions'; import { RegistrationState } from '../../../../shared/store/registration.state'; import { Util } from '../../../../shared/utils/utils'; -import { Logout } from './../../../../shared/store/registration.actions'; -import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; -import { AfterViewInit, Component, OnInit, ViewChild, OnDestroy, AfterViewChecked, ChangeDetectorRef } from '@angular/core'; -import { FormGroup, FormControl } from '@angular/forms'; -import { MatStepper } from '@angular/material/stepper'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { Store } from '@ngxs/store'; -import { takeUntil } from 'rxjs/operators'; -import { NavBarName } from '../../../../shared/enum/enumUA/navigation-bar'; import { CreateFormComponent } from '../../shared-cabinet/create-form/create-form.component'; -import { MatDialog } from '@angular/material/dialog'; -import { CreateProvider, UpdateProvider } from '../../../../shared/store/provider.actions'; @Component({ selector: 'app-create-provider', @@ -37,20 +45,21 @@ import { CreateProvider, UpdateProvider } from '../../../../shared/store/provide ] }) export class CreateProviderComponent extends CreateFormComponent implements OnInit, AfterViewInit, OnDestroy, AfterViewChecked { - provider: Provider; - isAgreed: boolean; - isNotRobot: boolean; + @ViewChild('stepper') public stepper: MatStepper; - InfoFormGroup: FormGroup; - ActualAddressFormGroup: FormGroup; - LegalAddressFormGroup: FormGroup; - PhotoFormGroup: FormGroup; + public provider: Provider; + public isAgreed: boolean; + public isNotRobot: boolean; - ContactsFormGroup: FormGroup = new FormGroup({}); - RobotFormControl = new FormControl(false); - AgreementFormControl = new FormControl(false); + public InfoFormGroup: FormGroup; + public ActualAddressFormGroup: FormGroup; + public LegalAddressFormGroup: FormGroup; + public PhotoFormGroup: FormGroup; - @ViewChild('stepper') stepper: MatStepper; + public ContactsFormGroup: FormGroup = new FormGroup({}); + public RobotFormControl = new FormControl(false); + public AgreementFormControl = new FormControl(false); + public isImagesFeature: boolean; constructor( protected store: Store, @@ -63,7 +72,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn super(store, route, navigationBarService); } - ngOnInit(): void { + public ngOnInit(): void { this.determineEditMode(); this.RobotFormControl.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((val: boolean) => (this.isNotRobot = val)); @@ -71,26 +80,26 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn this.AgreementFormControl.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((val: boolean) => (this.isAgreed = val)); } - ngAfterViewInit(): void { + public ngAfterViewInit(): void { if (this.editMode) { this.route.params.subscribe((params: Params) => { this.stepper.selectedIndex = +CreateProviderSteps[params.param]; }); } } - - ngAfterViewChecked(): void { + + public ngAfterViewChecked(): void { this.changeDetector.detectChanges(); } - setEditMode(): void { + public setEditMode(): void { this.provider = this.store.selectSnapshot(RegistrationState.provider); this.addNavPath(); this.isAgreed = true; this.isNotRobot = true; } - addNavPath(): void { + public addNavPath(): void { const userRole = this.store.selectSnapshot(RegistrationState.role); const subRole = this.store.selectSnapshot(RegistrationState.subrole); const personalCabinetTitle = Util.getPersonalCabinetTitle(userRole, subRole); @@ -108,12 +117,12 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn /** * This method dispatch store action to create a Provider with Form Groups values */ - onSubmit(): void { + public onSubmit(): void { if (this.PhotoFormGroup.invalid) { this.checkValidation(this.PhotoFormGroup); } else { const user: User = this.store.selectSnapshot(RegistrationState.user); - const isRelease3 = this.store.selectSnapshot(MetaDataState.featuresList).release3; + this.isImagesFeature = this.store.selectSnapshot(MetaDataState.featuresList).images; let legalAddress: Address; let actulaAdress: Address; let provider: Provider; @@ -124,12 +133,12 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn ? null : new Address(this.ActualAddressFormGroup.value, this.provider.actualAddress); provider = new Provider(this.InfoFormGroup.value, legalAddress, actulaAdress, this.PhotoFormGroup.value, user, this.provider); - this.store.dispatch(new UpdateProvider(provider, isRelease3)); + this.store.dispatch(new UpdateProvider(provider, this.isImagesFeature)); } else { legalAddress = new Address(this.LegalAddressFormGroup.value); actulaAdress = this.ActualAddressFormGroup.disabled ? null : new Address(this.ActualAddressFormGroup.value); provider = new Provider(this.InfoFormGroup.value, legalAddress, actulaAdress, this.PhotoFormGroup.value, user); - this.store.dispatch(new CreateProvider(provider, isRelease3)); + this.store.dispatch(new CreateProvider(provider, this.isImagesFeature)); } } } @@ -138,7 +147,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn * This method receives a form from create-info child component and assigns to the Info FormGroup * @param FormGroup form */ - onReceiveInfoFormGroup(form: FormGroup): void { + public onReceiveInfoFormGroup(form: FormGroup): void { this.InfoFormGroup = form; this.subscribeOnDirtyForm(form); } @@ -147,13 +156,13 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn * These methods receive froms from create-contacts child component and assigns to the Actual and Legal FormGroup * @param FormGroup form */ - onReceiveActualAddressFormGroup(form: FormGroup): void { + public onReceiveActualAddressFormGroup(form: FormGroup): void { this.ActualAddressFormGroup = form; this.subscribeOnDirtyForm(form); this.ContactsFormGroup.addControl('actual', form); } - onReceiveLegalAddressFormGroup(form: FormGroup): void { + public onReceiveLegalAddressFormGroup(form: FormGroup): void { this.LegalAddressFormGroup = form; this.subscribeOnDirtyForm(form); this.ContactsFormGroup.addControl('legal', form); @@ -163,7 +172,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn * This method receives a from from create-photo child component and assigns to the Info FormGroup * @param FormGroup form */ - onReceivePhotoFormGroup(form: FormGroup): void { + public onReceivePhotoFormGroup(form: FormGroup): void { this.PhotoFormGroup = form; this.subscribeOnDirtyForm(form); } @@ -172,7 +181,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn * This method receives a form and marks each control of this form as touched * @param FormGroup form */ - checkValidation(form: FormGroup): void { + public checkValidation(form: FormGroup): void { Object.keys(form.controls).forEach((key) => { form.get(key).markAsTouched(); }); @@ -181,7 +190,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn /** * This method marks each control of form in the array of forms in ContactsFormGroup as touched */ - checkValidationContacts(): void { + public checkValidationContacts(): void { Object.keys(this.ContactsFormGroup.controls).forEach((key) => { if ((this.ContactsFormGroup.get(key) as FormGroup).enabled) { this.checkValidation(this.ContactsFormGroup.get(key) as FormGroup); @@ -189,7 +198,7 @@ export class CreateProviderComponent extends CreateFormComponent implements OnIn }); } - onCancel(): void { + public onCancel(): void { const isRegistered = this.store.selectSnapshot(RegistrationState.user).isRegistered; if (!isRegistered) { diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.html index 809c989d7a..3aaf37a560 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.html @@ -4,13 +4,12 @@ + [imageIdsFormControl]="AboutFormGroup.get('coverImageId')"> @@ -19,8 +18,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_60"> @@ -36,15 +34,13 @@ appTrimValue ui-number-mask ui-hide-group-sep - maxlength="{{ validationConstants.PHONE_LENGTH }}" - /> + maxlength="{{ validationConstants.PHONE_LENGTH }}" />
+ [isPhoneNumber]="true"> @@ -60,8 +56,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_256"> @@ -71,8 +66,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_256"> @@ -82,8 +76,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_256">
@@ -105,8 +98,7 @@ [directiveFormControl]="AboutFormGroup.get('minAge')" [min]="validationConstants.AGE_MIN" [max]="AboutFormGroup.get('maxAge').value ? AboutFormGroup.get('maxAge').value - 1 : validationConstants.AGE_MAX" - autocomplete="none" - /> + autocomplete="none" />
@@ -126,8 +118,7 @@ [directiveFormControl]="AboutFormGroup.get('maxAge')" appMinMax [min]="AboutFormGroup.get('minAge').value ? AboutFormGroup.get('minAge').value + 1 : validationConstants.AGE_MIN" - autocomplete="none" - /> + autocomplete="none" />
@@ -152,8 +143,7 @@ type="number" [directiveFormControl]="priceControl" [min]="validationConstants.MIN_PRICE" - [max]="validationConstants.MAX_PRICE" - /> + [max]="validationConstants.MAX_PRICE" />
@@ -164,8 +154,7 @@ class="step-input" formControlName="payRate" name="payRate" - placeholder="{{ 'FORMS.PLACEHOLDERS.PAYMENT_TYPE' | translate }}" - > + placeholder="{{ 'FORMS.PLACEHOLDERS.PAYMENT_TYPE' | translate }}"> {{ PayRateTypeEnum[type.key] | translate }} @@ -206,13 +195,11 @@ type="number" [directiveFormControl]="availableSeatsControl" [min]="MIN_SEATS" - [max]="UNLIMITED_SEATS" - /> + [max]="UNLIMITED_SEATS" />
- - + diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.ts index 1630274fc2..375cdf64f7 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-about-form/create-about-form.component.ts @@ -1,9 +1,15 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; -import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { Store } from '@ngxs/store'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { Constants, CropperConfigurationConstants } from '../../../../../shared/constants/constants'; + +import { + ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, OnInit, Output +} from '@angular/core'; +import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Store } from '@ngxs/store'; + +import { + Constants, CropperConfigurationConstants +} from '../../../../../shared/constants/constants'; import { ValidationConstants } from '../../../../../shared/constants/validation'; import { PayRateTypeEnum } from '../../../../../shared/enum/enumUA/workshop'; import { OwnershipTypes, ProviderWorkshopSameValues } from '../../../../../shared/enum/provider'; @@ -18,15 +24,15 @@ import { Workshop } from '../../../../../shared/models/workshop.model'; changeDetection: ChangeDetectionStrategy.OnPush }) export class CreateAboutFormComponent implements OnInit, OnDestroy { - readonly validationConstants = ValidationConstants; - readonly phonePrefix = Constants.PHONE_PREFIX; - readonly MIN_SEATS = Constants.WORKSHOP_MIN_SEATS; - readonly UNLIMITED_SEATS = Constants.WORKSHOP_UNLIMITED_SEATS; - readonly mailFormPlaceholder = Constants.MAIL_FORMAT_PLACEHOLDER; - readonly PayRateType = PayRateType; - readonly PayRateTypeEnum = PayRateTypeEnum; - readonly ownershipType = OwnershipTypes; - readonly cropperConfig = { + public readonly validationConstants = ValidationConstants; + public readonly phonePrefix = Constants.PHONE_PREFIX; + public readonly MIN_SEATS = Constants.WORKSHOP_MIN_SEATS; + public readonly UNLIMITED_SEATS = Constants.WORKSHOP_UNLIMITED_SEATS; + public readonly mailFormPlaceholder = Constants.MAIL_FORMAT_PLACEHOLDER; + public readonly PayRateType = PayRateType; + public readonly PayRateTypeEnum = PayRateTypeEnum; + public readonly ownershipType = OwnershipTypes; + public readonly cropperConfig = { cropperMinWidth: CropperConfigurationConstants.cropperMinWidth, cropperMaxWidth: CropperConfigurationConstants.cropperMaxWidth, cropperMinHeight: CropperConfigurationConstants.cropperMinHeight, @@ -37,44 +43,44 @@ export class CreateAboutFormComponent implements OnInit, OnDestroy { croppedQuality: CropperConfigurationConstants.croppedQuality }; - @Input() workshop: Workshop; - @Input() provider: Provider; - @Input() isRelease3: boolean; - @Output() PassAboutFormGroup = new EventEmitter(); + @Input() public workshop: Workshop; + @Input() public provider: Provider; + @Input() public isImagesFeature: boolean; + @Output() public PassAboutFormGroup = new EventEmitter(); - AboutFormGroup: FormGroup; - workingHoursFormArray: FormArray = new FormArray([], [Validators.required]); - destroy$: Subject = new Subject(); + private destroy$: Subject = new Subject(); - priceRadioBtn: FormControl = new FormControl(false); - useProviderInfoCtrl: FormControl = new FormControl(false); - availableSeatsRadioBtnControl: FormControl = new FormControl(true); + public AboutFormGroup: FormGroup; + public workingHoursFormArray: FormArray = new FormArray([], [Validators.required]); + public priceRadioBtn: FormControl = new FormControl(false); + public useProviderInfoCtrl: FormControl = new FormControl(false); + public availableSeatsRadioBtnControl: FormControl = new FormControl(true); // competitiveSelectionRadioBtn: FormControl = new FormControl(false); TODO: add to the second release constructor(private formBuilder: FormBuilder, private store: Store) {} - ngOnInit(): void { + public ngOnInit(): void { this.initForm(); this.PassAboutFormGroup.emit(this.AboutFormGroup); this.workshop && this.activateEditMode(); this.initListeners(); } - ngOnDestroy(): void { + public ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); } - get priceControl(): FormControl { + public get priceControl(): FormControl { return this.AboutFormGroup.get('price') as FormControl; } - get payRateControl(): FormControl { + public get payRateControl(): FormControl { return this.AboutFormGroup.get('payRate') as FormControl; } - get availableSeatsControl(): FormControl { + public get availableSeatsControl(): FormControl { return this.AboutFormGroup.get('availableSeats') as FormControl; } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html index 1d51a042b4..fd8c8e2565 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html @@ -1,12 +1,11 @@ + [imageIdsFormControl]="DescriptionFormGroup.get('imageIds')"> + (deleteForm)="onDeleteForm($event)"> @@ -40,21 +37,18 @@ placeholder="{{ 'FORMS.PLACEHOLDERS.SPECIAL_EQUIPMENT' | translate }}" formControlName="disabilityOptionsDesc" autocomplete="none" - appTrimValue - /> + appTrimValue /> + [maxCharachters]="validationConstants.INPUT_LENGTH_256"> + [provider]="provider">
@@ -83,8 +77,7 @@ (keyup.enter)="onKeyWordsInput()" [(ngModel)]="keyWord" autocomplete="none" - appTrimValue - /> + appTrimValue />
diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts index 85fbd6106b..18f9e73ed9 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts @@ -1,7 +1,11 @@ -import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; -import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; + +import { + Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild +} from '@angular/core'; +import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; + import { CropperConfigurationConstants } from '../../../../../shared/constants/constants'; import { ValidationConstants } from '../../../../../shared/constants/validation'; import { Provider } from '../../../../../shared/models/provider.model'; @@ -13,8 +17,8 @@ import { Workshop, WorkshopSectionItem } from '../../../../../shared/models/work styleUrls: ['./create-description-form.component.scss'] }) export class CreateDescriptionFormComponent implements OnInit, OnDestroy { - readonly validationConstants = ValidationConstants; - readonly cropperConfig = { + public readonly validationConstants = ValidationConstants; + public readonly cropperConfig = { cropperMinWidth: CropperConfigurationConstants.cropperMinWidth, cropperMaxWidth: CropperConfigurationConstants.cropperMaxWidth, cropperMinHeight: CropperConfigurationConstants.cropperMinHeight, @@ -25,25 +29,26 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { croppedQuality: CropperConfigurationConstants.croppedQuality }; - @Input() workshop: Workshop; - @Input() isRelease3: boolean; - @Input() provider: Provider; + @Input() public workshop: Workshop; + @Input() public isImagesFeature: boolean; + @Input() public provider: Provider; + + @Output() public passDescriptionFormGroup = new EventEmitter(); - @Output() passDescriptionFormGroup = new EventEmitter(); + @ViewChild('keyWordsInput') public keyWordsInputElement: ElementRef; - @ViewChild('keyWordsInput') keyWordsInputElement: ElementRef; + private destroy$: Subject = new Subject(); - DescriptionFormGroup: FormGroup; - EditFormGroup: FormGroup; - SectionItemsFormArray = new FormArray([]); - keyWordsCtrl: FormControl = new FormControl('', Validators.required); + public DescriptionFormGroup: FormGroup; + public EditFormGroup: FormGroup; + public SectionItemsFormArray = new FormArray([]); + public keyWordsCtrl: FormControl = new FormControl('', Validators.required); - keyWords: string[] = []; - keyWord: string; - destroy$: Subject = new Subject(); + public keyWords: string[] = []; + public keyWord: string; - disabilityOptionRadioBtn: FormControl = new FormControl(false); - disabledKeyWordsInput = false; + public disabilityOptionRadioBtn: FormControl = new FormControl(false); + public disabledKeyWordsInput = false; constructor(private formBuilder: FormBuilder) { this.DescriptionFormGroup = this.formBuilder.group({ @@ -60,7 +65,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { }); } - ngOnInit(): void { + public ngOnInit(): void { this.onDisabilityOptionCtrlInit(); this.workshop ? this.activateEditMode() : this.onAddForm(); this.passDescriptionFormGroup.emit(this.DescriptionFormGroup); @@ -70,7 +75,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { * This method remove already added key words from the list of key words * @param string word */ - onRemoveKeyWord(word: string): void { + public onRemoveKeyWord(word: string): void { if (this.keyWords.indexOf(word) >= 0) { this.disabledKeyWordsInput = false; this.keyWords.splice(this.keyWords.indexOf(word), 1); @@ -82,7 +87,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { } } - onKeyWordsInput(isEditMode: boolean = true): void { + public onKeyWordsInput(isEditMode: boolean = true): void { this.DescriptionFormGroup.get('keyWords').markAsTouched(); if (this.keyWord) { const inputKeyWord = this.keyWord.trim().toLowerCase(); @@ -98,7 +103,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { } } - ngOnDestroy(): void { + public ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); } @@ -106,7 +111,7 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { /** * This method makes input enable if radiobutton value is true and sets the value to teh formgroup */ - onDisabilityOptionCtrlInit(): void { + public onDisabilityOptionCtrlInit(): void { const setAction = (action: string) => this.DescriptionFormGroup.get('disabilityOptionsDesc')[action](); this.disabilityOptionRadioBtn.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((isDisabilityOptionsDesc: boolean) => { @@ -114,6 +119,30 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { }); } + /** + * This method puts keyWordsInput field in focus + */ + public setFocus(): void { + this.keyWordsInputElement.nativeElement.focus(); + } + + /** + * This method creates new FormGroup adds new FormGroup to the FormArray + */ + public onAddForm(): void { + if (this.DescriptionFormGroup.get('workshopDescriptionItems')) { + (this.DescriptionFormGroup.get('workshopDescriptionItems') as FormArray).push(this.newForm()); + } + } + + /** + * This method delete FormGroup from the FormArray by index + * @param index + */ + public onDeleteForm(index: number): void { + this.SectionItemsFormArray.removeAt(index); + } + /** * This method fills inputs with information of edited workshop */ @@ -141,13 +170,6 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { } } - /** - * This method puts keyWordsInput field in focus - */ - setFocus(): void { - this.keyWordsInputElement.nativeElement.focus(); - } - /** * This method creates new FormGroup */ @@ -175,21 +197,4 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { return this.EditFormGroup; } - - /** - * This method creates new FormGroup adds new FormGroup to the FormArray - */ - onAddForm(): void { - if (this.DescriptionFormGroup.get('workshopDescriptionItems')) { - (this.DescriptionFormGroup.get('workshopDescriptionItems') as FormArray).push(this.newForm()); - } - } - - /** - * This method delete FormGroup from the FormArray by index - * @param index - */ - onDeleteForm(index: number): void { - this.SectionItemsFormArray.removeAt(index); - } } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.html index 3e3fdd4af0..f76f9aba57 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.html @@ -7,9 +7,8 @@ [TeacherFormGroup]="form" [index]="TeacherFormArray.controls.indexOf(form)" [teacherAmount]="TeacherFormArray.controls.length" - [isRelease3]="isRelease3" - (deleteForm)="onDeleteForm($event)" - > + [isImagesFeature]="isImagesFeature" + (deleteForm)="onDeleteForm($event)">
diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.spec.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.spec.ts index a5c416312e..851e07ed88 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.spec.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.spec.ts @@ -1,13 +1,14 @@ +import { Component, Input } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { CreateTeacherComponent } from './create-teacher.component'; -import { MatIconModule } from '@angular/material/icon'; -import { MatFormFieldModule } from '@angular/material/form-field'; import { FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { Component, Input } from '@angular/core'; -import { MatGridListModule } from '@angular/material/grid-list'; import { MatDialogModule } from '@angular/material/dialog'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatGridListModule } from '@angular/material/grid-list'; +import { MatIconModule } from '@angular/material/icon'; import { TranslateModule } from '@ngx-translate/core'; +import { CreateTeacherComponent } from './create-teacher.component'; + describe('CreateTeacherComponent', () => { let component: CreateTeacherComponent; let fixture: ComponentFixture; @@ -38,7 +39,7 @@ class MockTeacherFormComponent { @Input() TeacherFormGroup: FormGroup; @Input() teacherAmount: number; @Input() index: number; - @Input() isRelease3: boolean; + @Input() isImagesFeature: boolean; } @Component({ diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.ts index be5ffd89ed..34d10ffad9 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/create-teacher.component.ts @@ -1,7 +1,12 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { AbstractControl, FormControl, Validators, FormArray, FormBuilder, FormGroup } from '@angular/forms'; +import { + AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, Validators +} from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; -import { ConfirmationModalWindowComponent } from '../../../../../shared/components/confirmation-modal-window/confirmation-modal-window.component'; + +import { + ConfirmationModalWindowComponent +} from '../../../../../shared/components/confirmation-modal-window/confirmation-modal-window.component'; import { Constants } from '../../../../../shared/constants/constants'; import { NAME_REGEX } from '../../../../../shared/constants/regex-constants'; import { ValidationConstants } from '../../../../../shared/constants/validation'; @@ -14,16 +19,16 @@ import { Teacher } from '../../../../../shared/models/teacher.model'; styleUrls: ['./create-teacher.component.scss'] }) export class CreateTeacherComponent implements OnInit { - TeacherFormArray: FormArray = new FormArray([]); + public TeacherFormArray: FormArray = new FormArray([]); - @Input() teachers: Teacher[]; - @Input() isRelease3: boolean; + @Input() public teachers: Teacher[]; + @Input() public isImagesFeature: boolean; - @Output() passTeacherFormArray = new EventEmitter(); + @Output() public passTeacherFormArray = new EventEmitter(); constructor(private fb: FormBuilder, private matDialog: MatDialog) {} - ngOnInit(): void { + public ngOnInit(): void { if (this.teachers?.length) { this.teachers.forEach((teahcer: Teacher) => this.onAddTeacher(teahcer)); } @@ -32,13 +37,36 @@ export class CreateTeacherComponent implements OnInit { /** * This method add new FormGroup to teh FormArray */ - onAddTeacher(teacher?: Teacher): void { + public onAddTeacher(teacher?: Teacher): void { const formGroup = this.createNewForm(teacher); this.TeacherFormArray.controls.push(formGroup); this.TeacherFormArray['_registerControl'](formGroup); // for preventing emitting value changes in edit mode on initial value set this.passTeacherFormArray.emit(this.TeacherFormArray); } + /** + * This method delete form from teh FormArray by index + * @param index: number + */ + public onDeleteForm(index: number): void { + const teacherFormGroup: AbstractControl = this.TeacherFormArray.controls[index]; + const isPristine = teacherFormGroup.pristine; + + if (teacherFormGroup.status === 'VALID' || !isPristine) { + const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { + width: Constants.MODAL_SMALL, + data: { + type: ModalConfirmationType.deleteTeacher, + property: '' + } + }); + + dialogRef.afterClosed().subscribe((result: boolean) => result && this.TeacherFormArray.removeAt(index)); + } else { + this.TeacherFormArray.removeAt(index); + } + } + /** * This method create new FormGroup * @param FormArray: array @@ -89,27 +117,4 @@ export class CreateTeacherComponent implements OnInit { teacherFormGroup.get('coverImageId').setValue([teacher.coverImageId], { emitEvent: false }); } } - - /** - * This method delete form from teh FormArray by index - * @param index: number - */ - onDeleteForm(index: number): void { - const teacherFormGroup: AbstractControl = this.TeacherFormArray.controls[index]; - const isPristine = teacherFormGroup.pristine; - - if (teacherFormGroup.status === 'VALID' || !isPristine) { - const dialogRef = this.matDialog.open(ConfirmationModalWindowComponent, { - width: Constants.MODAL_SMALL, - data: { - type: ModalConfirmationType.deleteTeacher, - property: '' - } - }); - - dialogRef.afterClosed().subscribe((result: boolean) => result && this.TeacherFormArray.removeAt(index)); - } else { - this.TeacherFormArray.removeAt(index); - } - } } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.html index f8adf21713..ce6676002c 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.html @@ -3,16 +3,14 @@ fxLayout="column" fxLayoutAlign="center space-between" class="step" - [class.step-border]="(teacherAmount > 1) && (index !== teacherAmount - 1)" -> + [class.step-border]="teacherAmount > 1 && index !== teacherAmount - 1"> + [imageIdsFormControl]="TeacherFormGroup.get('coverImageId')"> @@ -22,8 +20,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_60"> @@ -33,8 +30,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_60"> @@ -44,8 +40,7 @@ + [maxCharachters]="validationConstants.INPUT_LENGTH_60"> @@ -63,16 +58,11 @@ matInput [matDatepicker]="picker" formControlName="dateOfBirth" - placeholder="{{ 'FORMS.PLACEHOLDERS.SHORT_DATE_FORMAT' | translate }}" - /> + placeholder="{{ 'FORMS.PLACEHOLDERS.SHORT_DATE_FORMAT' | translate }}" /> - - +
@@ -89,14 +79,12 @@ }}" formControlName="description" maxlength="{{ validationConstants.MAX_DESCRIPTION_LENGTH_300 }}" - appTrimValue - > + appTrimValue> + [maxCharachters]="validationConstants.MAX_DESCRIPTION_LENGTH_300">
diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.ts index 282a8c7bfe..451a91a2be 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-teacher/teacher-form/teacher-form.component.ts @@ -1,6 +1,6 @@ -import { Component, Input } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { Output, EventEmitter } from '@angular/core'; + import { CropperConfigurationConstants } from '../../../../../../shared/constants/constants'; import { ValidationConstants } from '../../../../../../shared/constants/validation'; import { Util } from '../../../../../../shared/utils/utils'; @@ -11,8 +11,8 @@ import { Util } from '../../../../../../shared/utils/utils'; styleUrls: ['./teacher-form.component.scss'] }) export class TeacherFormComponent { - readonly validationConstants = ValidationConstants; - readonly cropperConfig = { + public readonly validationConstants = ValidationConstants; + public readonly cropperConfig = { cropperMinWidth: CropperConfigurationConstants.cropperMinWidth, cropperMaxWidth: CropperConfigurationConstants.cropperMaxWidth, cropperMinHeight: CropperConfigurationConstants.cropperMinHeight, @@ -23,19 +23,19 @@ export class TeacherFormComponent { croppedQuality: CropperConfigurationConstants.croppedQuality }; - today: Date = new Date(); - minDate: Date = Util.getMinBirthDate(ValidationConstants.BIRTH_AGE_MAX); + public today: Date = new Date(); + public minDate: Date = Util.getMinBirthDate(ValidationConstants.BIRTH_AGE_MAX); - @Input() index: number; - @Input() TeacherFormGroup: FormGroup; - @Input() teacherAmount: number; - @Input() isRelease3: boolean; + @Input() public index: number; + @Input() public TeacherFormGroup: FormGroup; + @Input() public teacherAmount: number; + @Input() public isImagesFeature: boolean; - @Output() deleteForm = new EventEmitter(); + @Output() public deleteForm = new EventEmitter(); constructor() {} - onDeleteTeacher(): void { + public onDeleteTeacher(): void { this.deleteForm.emit(this.index); } } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.html index 5fa6c47a1c..4b2350a4f5 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-workshop.component.html @@ -6,10 +6,7 @@

{{ (editMode ? 'FORMS.HEADERS.EDIT_WORKSHOP' : 'FORMS.HEADERS.NEW_WORKSHOP') | translate }}

- {{ - (editMode ? 'FORMS.HEADERS.EDIT_WORKSHOP_DESCRIPTION_PATH' : 'FORMS.HEADERS.NEW_WORKSHOP_DESCRIPTION_PATH') - | translate - }} + {{ (editMode ? 'FORMS.HEADERS.EDIT_WORKSHOP_DESCRIPTION_PATH' : 'FORMS.HEADERS.NEW_WORKSHOP_DESCRIPTION_PATH') | translate }} {{ 'FORMS.HEADERS.WORKSHOP_FORM_DESCRIPTION' | translate }}

@@ -23,7 +20,7 @@

fxLayout="row" fxLayoutAlign="center center" [workshop]="workshop" - [isRelease3]="isRelease3" + [isImagesFeature]="isImagesFeature" [provider]="provider" (PassAboutFormGroup)="onReceiveAboutFormGroup($event)"> @@ -37,9 +34,7 @@

- +

{{ 'TITLES.DESCRIPTION' | translate }}

@@ -48,7 +43,7 @@

fxLayoutAlign="center center" [workshop]="workshop" [provider]="provider" - [isRelease3]="isRelease3" + [isImagesFeature]="isImagesFeature" (passDescriptionFormGroup)="onReceiveDescriptionFormGroup($event)">