Skip to content

Commit

Permalink
#38 - Fix Solution form for 'Confiscare' stage
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanconstantinescu committed Mar 12, 2019
1 parent 8fda083 commit f816e10
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ <h3>Stare actuala bun: [ {{ getCurrentStage() }} ]</h3>
</mat-form-field>
</div>

<div class="column" *ngIf="solutionForm.controls.recoveryBeneficiaryId">
<mat-form-field>
<mat-select placeholder="Autoritatea catre care se fac despagubirile" name="recoveryBeneficiaryId"
formControlName="recoveryBeneficiaryId"
required
>
<mat-option *ngFor="let theBeneficiary of recoveryBeneficiaries" [value]="theBeneficiary.id">
{{ theBeneficiary.name }}
</mat-option>
</mat-select>
</mat-form-field>
</div>

<div class="separator"></div>

<mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Decision,
Institution,
PrecautionaryMeasure,
RecoveryBeneficiary,
RecoveryDetails,
Solution,
SolutionDetails,
Expand Down Expand Up @@ -46,6 +47,7 @@ export class EditSolutionComponent implements OnInit {
@Input() decisions: Decision[];
@Input() stages: Stage[];
@Input() precautionaryMeasures: PrecautionaryMeasure[];
@Input() recoveryBeneficiaries: RecoveryBeneficiary[];
@Output() onUpdate: EventEmitter<Solution> = new EventEmitter<Solution>();
@Output() onCancel: EventEmitter<Solution> = new EventEmitter<Solution>();
@Output() onSave: EventEmitter<Solution> = new EventEmitter<Solution>();
Expand Down Expand Up @@ -156,6 +158,13 @@ export class EditSolutionComponent implements OnInit {
}
break;
}

case 'confiscare': {
if (!this.solutionForm.contains('recoveryBeneficiaryId')) {
this.solutionForm.addControl('recoveryBeneficiaryId', new FormControl('', [Validators.required]));
}
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h2>Adauga proprietati</h2>
[decisions]="decisions$ | async"
[stages]="stages$ | async"
[precautionaryMeasures]="(precautionaryMeasures$ | async)"
[recoveryBeneficiaries]="(recoveryBeneficiaries$ | async)"
(onUpdate)="onPropertyUpdate($event)"
(onCancel)="onPropertyCancel($event)"
(onSave)="onPropertySave($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Defendant,
Institution,
PrecautionaryMeasure,
RecoveryBeneficiary,
Solution,
Stage,
StorageSpace
Expand Down Expand Up @@ -45,6 +46,7 @@ export class AssetDetailComponent implements OnInit {
private decisions$: Observable<Decision[]>;
private stages$: Observable<Stage[]>;
private precautionaryMeasures$: Observable<PrecautionaryMeasure[]>;
private recoveryBeneficiaries$: Observable<RecoveryBeneficiary[]>;
private assetProperty$: Observable<AssetProperty>;

private categories$: Observable<Category[]> = this.store.pipe(select(fromStore.getAssetParentCategories));
Expand Down Expand Up @@ -79,6 +81,7 @@ export class AssetDetailComponent implements OnInit {
this.decisions$ = this.store.pipe(select(fromStore.getAllDecisions));
this.stages$ = this.store.pipe(select(fromStore.getAllStages));
this.precautionaryMeasures$ = this.store.pipe(select(fromStore.getAllPrecautionaryMeasures));
this.recoveryBeneficiaries$ = this.store.pipe(select(fromStore.getAllRecoveryBeneficiaries));
});

this.asset$.pipe(take(1))
Expand Down
14 changes: 13 additions & 1 deletion src/app/assets/guards/assets.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ export class AssetsGuard implements CanActivate {
this.store.pipe(select(fromStore.getInstitutionsLoaded)),
this.store.pipe(select(fromStore.getDecisionsLoaded)),
this.store.pipe(select(fromStore.getPrecautionaryMeasuresLoaded)),
(aAssetsLoaded: boolean, aInstitutionsLoaded: boolean, aDecisionsLoaded: boolean, aMeasuresLoaded: boolean) => {
this.store.pipe(select(fromStore.getRecoveryBeneficiariesLoaded)),
(
aAssetsLoaded: boolean,
aInstitutionsLoaded: boolean,
aDecisionsLoaded: boolean,
aMeasuresLoaded: boolean,
aBeneficiariesLoaded: boolean
) => {
let allLoaded = true;
if (!aAssetsLoaded) {
this.store.dispatch(new fromStore.LoadAssets());
Expand All @@ -60,6 +67,11 @@ export class AssetsGuard implements CanActivate {
allLoaded = false;
}

if (!aBeneficiariesLoaded) {
this.store.dispatch(new fromStore.LoadRecoveryBeneficiaries());
allLoaded = false;
}

return allLoaded;
}
).pipe(
Expand Down

0 comments on commit f816e10

Please sign in to comment.