fix(informativ-rapport): Added file-upload inside informativ-rapport to feature toggling

This commit is contained in:
Erik Tiekstra
2021-12-15 10:45:43 +01:00
parent a158b4ac21
commit 92cf04e802
4 changed files with 18 additions and 7 deletions

View File

@@ -61,7 +61,7 @@
></ui-select> ></ui-select>
<ng-container *ngIf="formData$ | async as formData"> <ng-container *ngIf="formData$ | async as formData">
<ui-file-upload <ui-file-upload
*ngIf="formData.category === 'dokument'" *ngIf="fileUploadActive && formData.category === 'dokument'"
ngDefaultControl ngDefaultControl
[formControl]="fileFormControl" [formControl]="fileFormControl"
uiId="informativRapportFileUpload" uiId="informativRapportFileUpload"

View File

@@ -1,8 +1,10 @@
import { SelectOption } from '@ui/select/select-option.model';
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Feature } from '@msfa-enums/feature.enum';
import { InformativRapportCategory, InformativRapportCategoryKey } from '@msfa-enums/informativ-rapport-category.enum'; import { InformativRapportCategory, InformativRapportCategoryKey } from '@msfa-enums/informativ-rapport-category.enum';
import { environment } from '@msfa-environment';
import { import {
InformativRapportRequest, InformativRapportRequest,
InformativRapportWithFileRequest, InformativRapportWithFileRequest,
@@ -10,11 +12,11 @@ import {
import { DeltagareAvrop } from '@msfa-models/avrop.model'; import { DeltagareAvrop } from '@msfa-models/avrop.model';
import { CustomError } from '@msfa-models/error/custom-error'; import { CustomError } from '@msfa-models/error/custom-error';
import { RequiredValidator } from '@msfa-utils/validators/required.validator'; import { RequiredValidator } from '@msfa-utils/validators/required.validator';
import { SelectOption } from '@ui/select/select-option.model';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { map, shareReplay, switchMap, take } from 'rxjs/operators'; import { map, shareReplay, switchMap, take } from 'rxjs/operators';
import { InformativRapportFormData } from './informativ-rapport-form.model'; import { InformativRapportFormData } from './informativ-rapport-form.model';
import { InformativRapportFormService } from './informativ-rapport-form.service'; import { InformativRapportFormService } from './informativ-rapport-form.service';
import { DomSanitizer } from '@angular/platform-browser';
@Component({ @Component({
selector: 'msfa-informativ-rapport-form', selector: 'msfa-informativ-rapport-form',
@@ -23,6 +25,7 @@ import { DomSanitizer } from '@angular/platform-browser';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class InformativRapportFormComponent { export class InformativRapportFormComponent {
private _activeFeatures = environment.activeFeatures;
categoryDocumentSelected = false; categoryDocumentSelected = false;
shouldValidate$ = new BehaviorSubject<boolean>(false); shouldValidate$ = new BehaviorSubject<boolean>(false);
confirmDialogOpen$ = new BehaviorSubject<boolean>(false); confirmDialogOpen$ = new BehaviorSubject<boolean>(false);
@@ -43,7 +46,9 @@ export class InformativRapportFormComponent {
comment: new FormControl('', [RequiredValidator('Kompletterande information är obligatoriskt')]), comment: new FormControl('', [RequiredValidator('Kompletterande information är obligatoriskt')]),
file: new FormControl(null), file: new FormControl(null),
}); });
categorySelectItems: SelectOption[] = Object.entries(InformativRapportCategory).map(([value, name]) => ({ categorySelectItems: SelectOption[] = Object.entries(InformativRapportCategory)
.filter(([_, name]) => (name === InformativRapportCategory.dokument ? this.fileUploadActive : true))
.map(([value, name]) => ({
name, name,
value, value,
})); }));
@@ -71,6 +76,10 @@ export class InformativRapportFormComponent {
return this.informativRapportFormGroup.get('file') as FormControl; return this.informativRapportFormGroup.get('file') as FormControl;
} }
get fileUploadActive(): boolean {
return this._activeFeatures.includes(Feature.REPORTING_INFORMATIV_RAPPORT_FILE);
}
private _formDataToSubmitData( private _formDataToSubmitData(
genomforandeReferens: number, genomforandeReferens: number,
formData: InformativRapportFormData formData: InformativRapportFormData

View File

@@ -15,6 +15,7 @@ export enum Feature {
REPORTING_SIGNAL, REPORTING_SIGNAL,
REPORTING_PERIODISK_REDOVISNING, REPORTING_PERIODISK_REDOVISNING,
REPORTING_INFORMATIV_RAPPORT, REPORTING_INFORMATIV_RAPPORT,
REPORTING_INFORMATIV_RAPPORT_FILE,
REPORTING_SLUTREDOVISNING, REPORTING_SLUTREDOVISNING,
EXPORTS, EXPORTS,
NEWS, NEWS,

View File

@@ -29,6 +29,7 @@ export const ACTIVE_FEATURES_TEST: Feature[] = [
Feature.VERSION_INFO, Feature.VERSION_INFO,
Feature.REPORTING_PERIODISK_REDOVISNING, Feature.REPORTING_PERIODISK_REDOVISNING,
Feature.REPORTING_INFORMATIV_RAPPORT, Feature.REPORTING_INFORMATIV_RAPPORT,
Feature.REPORTING_INFORMATIV_RAPPORT_FILE,
Feature.REPORTING_SLUTREDOVISNING, Feature.REPORTING_SLUTREDOVISNING,
Feature.REPORTING_SIGNAL, Feature.REPORTING_SIGNAL,
Feature.EXPORTS, Feature.EXPORTS,