-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add institution type data #1290
Changes from 2 commits
acb54cd
a2f72a9
61b6afd
e9104df
1b4c9ba
55f9656
81fbb3d
7985741
ca172c3
d090176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core'; | ||
import { Constants } from 'src/app/shared/constants/constants'; | ||
import { MatTabChangeEvent } from '@angular/material/tabs'; | ||
import { | ||
CreateProviderSteps, | ||
InstitutionTypes, | ||
OwnershipType, | ||
OwnershipTypeUkr, | ||
ProviderType, | ||
ProviderTypeUkr, | ||
} from '../../enum/provider'; | ||
import { Provider } from '../../models/provider.model'; | ||
import { Select, Store } from '@ngxs/store'; | ||
import { GetInstitutionStatus } from '../../store/meta-data.actions'; | ||
import { NgxsOnInit, Select, Store } from '@ngxs/store'; | ||
import { MetaDataState } from '../../store/meta-data.state'; | ||
import { Observable, Subject } from 'rxjs'; | ||
import { InstitutionStatus } from '../../models/institutionStatus.model'; | ||
import { ActivateEditMode } from 'src/app/shared/store/app.actions'; | ||
import { GetInstitutionStatus } from '../../store/meta-data.actions'; | ||
import { filter, takeUntil } from 'rxjs/operators'; | ||
import { RegistrationState } from '../../store/registration.state'; | ||
import { ActivateEditMode } from 'src/app/shared/store/app.actions'; | ||
|
||
@Component({ | ||
selector: 'app-provider-info', | ||
|
@@ -29,6 +30,7 @@ export class ProviderInfoComponent implements OnInit { | |
readonly ownershipType: typeof OwnershipType = OwnershipType; | ||
readonly ownershipTypeUkr = OwnershipTypeUkr; | ||
readonly providerTypeUkr = ProviderTypeUkr; | ||
readonly institutionTypes = InstitutionTypes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add empty row after readonly fields |
||
editLink: string = CreateProviderSteps[0]; | ||
|
||
@Input() provider: Provider; | ||
|
@@ -50,13 +52,13 @@ export class ProviderInfoComponent implements OnInit { | |
.pipe( | ||
filter((institutionStatuses) => !!institutionStatuses.length), | ||
takeUntil(this.destroy$) | ||
).subscribe((institutionStatuses) => { | ||
const provider = this.store.selectSnapshot(RegistrationState.provider); | ||
this.currentStatus = | ||
institutionStatuses | ||
.find((item) => +item.id === provider?.institutionStatusId) | ||
?.name.toString() ?? 'Відсутній'; | ||
}); | ||
).subscribe((institutionStatuses) => { | ||
const provider = this.store.selectSnapshot(RegistrationState.provider); | ||
this.currentStatus = | ||
institutionStatuses | ||
.find((item) => +item.id === provider?.institutionStatusId) | ||
?.name.toString() ?? 'Відсутній'; | ||
}); | ||
} | ||
|
||
onTabChanged(tabChangeEvent: MatTabChangeEvent): void { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,17 @@ | |
</mat-select> | ||
</mat-form-field> | ||
|
||
<label class="step-label">Тип закладу</label> | ||
<mat-form-field floatLabel="never" appearance="none"> | ||
<mat-select disableOptionCentering panelClass="dropdown-panel" class="step-input" | ||
formControlName="institutionType"> | ||
<mat-option *ngFor="let type of (institutionTypes | keyvalue)" [value]="type.key" class="dropdown-option"> | ||
{{type.value}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty row please |
||
<div class="step-label-combined"> | ||
<label class="step-label"> Опис<span class="step-required">*</span></label> | ||
<label class="step-characters-count"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { Select, Store } from '@ngxs/store'; | |
import { Observable, Subject } from 'rxjs'; | ||
import { Constants } from 'src/app/shared/constants/constants'; | ||
import { ValidationConstants } from 'src/app/shared/constants/validation'; | ||
import { InstitutionTypes } from 'src/app/shared/enum/provider'; | ||
import { InstitutionStatus } from 'src/app/shared/models/institutionStatus.model'; | ||
import { Provider } from 'src/app/shared/models/provider.model'; | ||
import { GetInstitutionStatus } from 'src/app/shared/store/meta-data.actions'; | ||
|
@@ -16,38 +17,43 @@ import { MetaDataState } from 'src/app/shared/store/meta-data.state'; | |
}) | ||
export class CreatePhotoFormComponent implements OnInit { | ||
readonly validationConstants = ValidationConstants; | ||
readonly institutionTypes = InstitutionTypes; | ||
|
||
@Select(MetaDataState.institutionStatuses) | ||
institutionStatuses$: Observable<InstitutionStatus[]>; | ||
destroy$: Subject<boolean> = new Subject<boolean>(); | ||
|
||
@Input() provider: Provider; | ||
|
||
@Output() passPhotoFormGroup = new EventEmitter(); | ||
|
||
PhotoFormGroup: FormGroup; | ||
descriptionFormGroup: FormControl = new FormControl('', [ | ||
Validators.required, | ||
Validators.minLength(ValidationConstants.INPUT_LENGTH_3), | ||
Validators.maxLength(ValidationConstants.MAX_DESCRIPTION_LENGTH_2000) | ||
]); | ||
@Input() provider: Provider; | ||
|
||
@Output() passPhotoFormGroup = new EventEmitter(); | ||
|
||
constructor(private formBuilder: FormBuilder, private store: Store ) { | ||
this.PhotoFormGroup = this.formBuilder.group({ | ||
image: new FormControl(''), | ||
description: this.descriptionFormGroup, | ||
institutionStatusId: new FormControl(Constants.INSTITUTION_STATUS_ID_ABSENT_VALUE), | ||
institutionStatusId: new FormControl(Constants.INSTITUTION_STATUS_ID_ABSENT_VALUE, Validators.required), | ||
institutionType: new FormControl('', Validators.required), | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.store.dispatch(new GetInstitutionStatus()); | ||
this.provider && this.activateEditMode(); | ||
this.passPhotoFormGroup.emit(this.PhotoFormGroup); | ||
console.log(this.PhotoFormGroup) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove console |
||
} | ||
|
||
private activateEditMode(): void { | ||
this.PhotoFormGroup.patchValue(this.provider, { emitEvent: false }); | ||
this.provider.institutionStatusId = this.provider.institutionStatusId || Constants.SOCIAL_GROUP_ID_ABSENT_VALUE; | ||
} | ||
this.provider.institutionStatusId = this.provider.institutionStatusId || Constants.SOCIAL_GROUP_ID_ABSENT_VALUE; | ||
this.PhotoFormGroup.patchValue(this.provider, { emitEvent: false }); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.destroy$.next(true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused imports (output as I see)