From d1f7a66f15e90c639fce3c18ae9e5f1f2402e3c7 Mon Sep 17 00:00:00 2001 From: Daniel Appelgren Date: Wed, 17 Nov 2021 16:08:06 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Pull=20request=20#270:=20Feature/TV-565=20f?= =?UTF-8?q?ormul=C3=A4r=20signal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge in TEA/mina-sidor-fa-web from feature/TV-565-formulär-signal to develop Squashed commit of the following: commit 4c17164caafd4c530e9a1dad7bd960c7a39b79ac Author: Daniel Appelgren Date: Wed Nov 17 12:09:05 2021 +0100 Update signal-form.validator.ts commit bd9437f70e312e5b6685faf8339cb12e5970fa32 Author: Daniel Appelgren Date: Wed Nov 17 12:08:18 2021 +0100 omfattnign i procent matchar nu slutredovsining commit 913e22e02d9c2afa67caec6f747ee2cc4c61d487 Author: Daniel Appelgren Date: Wed Nov 17 11:54:11 2021 +0100 Update signal-form.module.ts commit 3ca50a7f46124e6386e45c78c56b31a2af3a3a76 Author: Daniel Appelgren Date: Wed Nov 17 11:52:49 2021 +0100 change type of form to conform with other reports commit 7313e8e4e9a86c08a5d885a9474f5e57d250269a Author: Daniel Appelgren Date: Wed Nov 17 11:38:22 2021 +0100 Replaced digi ng and replace slider with input --- .../signal-form/signal-form.component.html | 92 +++++++------------ .../signal-form/signal-form.component.scss | 6 ++ .../signal-form/signal-form.component.ts | 21 +++-- .../signal-form/signal-form.model.ts | 17 ++++ .../signal-form/signal-form.module.ts | 10 +- .../signal-form/signal-form.validator.ts | 13 ++- .../src/app/shared/models/signal.model.ts | 8 +- 7 files changed, 83 insertions(+), 84 deletions(-) create mode 100644 apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model.ts diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.html b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.html index 5a48fe2..6d1b9dc 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.html +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.html @@ -22,63 +22,39 @@
-
- -
- -
-
-
- - - -
- -
-
-
- -
- -
-
+ + + + +
(false); confirmDialogOpen$ = new BehaviorSubject(false); signalFormGroup = new FormGroup( @@ -50,8 +55,8 @@ export class SignalFormComponent { ]; omfattningRadioButtons: Radiobutton[] = [ - { label: 'Heltid', value: 'heltid' }, - { label: 'Deltid', value: 'deltid' }, + { label: 'Heltid', value: SignalOmfattning.Heltid }, + { label: 'Deltid', value: SignalOmfattning.Deltid }, ]; constructor(private signalFormService: SignalFormService, private activatedRoute: ActivatedRoute) {} @@ -61,16 +66,16 @@ export class SignalFormComponent { } get typeFormControl(): FormControl { - return this.signalFormGroup.get('type') as FormControl; + return this.signalFormGroup.get(this.typeFormName) as FormControl; } get omfattningFormControl(): FormControl { - return this.signalFormGroup.get('omfattning') as FormControl; + return this.signalFormGroup.get(this.omfattningFormName) as FormControl; } get percentFormControl(): FormControl { - return this.signalFormGroup.get('percent') as FormControl; + return this.signalFormGroup.get(this.percentFormName) as FormControl; } get startDateFormControl(): FormControl { - return this.signalFormGroup.get('startDate') as FormControl; + return this.signalFormGroup.get(this.startDateFormName) as FormControl; } get showPercentFormControl(): boolean { @@ -106,7 +111,7 @@ export class SignalFormComponent { submitAndCloseConfirmDialog(genomforandeReferens: number): void { this.submitLoading$.next(true); - const { type, omfattning, startDate, percent } = this.signalFormGroup.value as Signal; + const { type, omfattning, startDate, percent } = this.signalFormGroup.value as SignalFormData; const postRequest: SignalRequest = { genomforandeReferens: +genomforandeReferens, diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model.ts new file mode 100644 index 0000000..121142d --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model.ts @@ -0,0 +1,17 @@ +export enum SignalOmfattning { + Heltid = 'heltid', + Deltid = 'deltid', +} +export enum SignalType { + Arbete = 'arbete', + Utbildning = 'utbildning', +} + +export interface SignalFormData { + type: SignalType; + omfattning: SignalOmfattning; + percent: number; + startDate: Date; +} + +export type SignalFormKeys = keyof SignalFormData; diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.module.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.module.ts index 981f294..460bdcb 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.module.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.module.ts @@ -1,7 +1,5 @@ import { DigiNgDialogModule } from '@af/digi-ng/_dialog/dialog'; import { DigiNgFormDatepickerModule } from '@af/digi-ng/_form/form-datepicker'; -import { DigiNgFormRangeModule } from '@af/digi-ng/_form/form-range'; -import { DigiNgFormSelectModule } from '@af/digi-ng/_form/form-select'; import { DigiNgFormValidationMessageModule } from '@af/digi-ng/_form/form-validation-message'; import { CommonModule } from '@angular/common'; import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; @@ -16,6 +14,9 @@ import { ReportDescriptionListModule } from '../../../components/report-descript import { ReportLayoutModule } from '../../../components/report-layout/report-layout.module'; import { SignalFormComponent } from './signal-form.component'; import { SignalFormService } from './signal-form.service'; +import { UiInputModule } from '@ui/input/input.module'; +import { UiSelectModule } from '@ui/select/select.module'; +import { UiLoaderModule } from '@ui/loader/loader.module'; @NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -31,11 +32,12 @@ import { SignalFormService } from './signal-form.service'; UiRadiobuttonGroupModule, DigiNgFormDatepickerModule, UiSkeletonModule, + UiSelectModule, + UiLoaderModule, DigiNgDialogModule, - DigiNgFormRangeModule, DigiNgFormValidationMessageModule, - DigiNgFormSelectModule, ReportDescriptionListModule, + UiInputModule, ], providers: [SignalFormService], exports: [SignalFormComponent], diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.validator.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.validator.ts index c2fc948..1c81b5d 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.validator.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.validator.ts @@ -1,11 +1,11 @@ import { AbstractControl, ValidatorFn } from '@angular/forms'; -import { Signal } from '@msfa-models/signal.model'; +import { SignalFormData } from './signal-form.model'; export class SignalFormValidator { static isSignalValid(): ValidatorFn { return (c: AbstractControl): { [key: string]: string } => { let errors: { [key: string]: string } = null; - const { type, omfattning, percent, startDate } = c.value as Signal; + const { type, omfattning, percent, startDate } = c.value as SignalFormData; if (!type) { errors = { @@ -14,16 +14,15 @@ export class SignalFormValidator { }; } if (type && omfattning === 'deltid') { - if (percent < 5) { + if (percent < 1) { errors = { ...errors, - percent: 'Antal procent måste vara högre än 5%', + percent: 'Omfattning i procent får inte vara mindre än 1% om deltid har valts', }; - } - if (percent > 100) { + } else if (percent > 99) { errors = { ...errors, - percent: 'Antal procent måste vara lägre än 100%', + percent: 'Omfattning i procent får inte vara mer än 99% om deltid har valts', }; } } diff --git a/apps/mina-sidor-fa/src/app/shared/models/signal.model.ts b/apps/mina-sidor-fa/src/app/shared/models/signal.model.ts index 6c60151..acd6069 100644 --- a/apps/mina-sidor-fa/src/app/shared/models/signal.model.ts +++ b/apps/mina-sidor-fa/src/app/shared/models/signal.model.ts @@ -1,11 +1,5 @@ import { SignalResponse } from './api/signal.response.model'; - -export interface Signal { - type: 'arbete' | 'utbildning'; - omfattning: 'heltid' | 'deltid'; - percent: number; - startDate: Date; -} +import { Signal } from '../../pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model'; export function mapResponseToSignal(data: SignalResponse): Signal { const { typ, startdatum, omfattning, omfattning_procent } = data; From ef9289d72e46ca48f79e5e9cb7f89edfec5a8f4b Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Thu, 18 Nov 2021 12:25:18 +0100 Subject: [PATCH 2/3] Fixed issue with hours inside Periodisk redovisning form --- .../periodisk-redovisning-form.component.html | 31 +++++++------------ .../periodisk-redovisning-form.model.ts | 2 +- .../periodisk-redovisning-form.module.ts | 2 ++ .../periodisk-redovisning.validator.ts | 2 +- libs/ui/src/input/input.component.ts | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/periodisk-redovisning-form/periodisk-redovisning-form.component.html b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/periodisk-redovisning-form/periodisk-redovisning-form.component.html index 92e4853..cc46089 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/periodisk-redovisning-form/periodisk-redovisning-form.component.html +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/periodisk-redovisning-form/periodisk-redovisning-form.component.html @@ -127,25 +127,18 @@ [afLabel]="activitiesFormArrayMetadata[i].name" >
-
- -
- - {{activityFormGroup.errors.hours}} - -
-
+
0 && Number.isInteger(+hours) && +hours >= 0 && +hours <= 200; + const isValidHours = Number.isInteger(hours) && hours >= 0 && hours <= 200; if (isSelected && !isValidHours) { errors = { diff --git a/libs/ui/src/input/input.component.ts b/libs/ui/src/input/input.component.ts index fa4f200..f423b59 100644 --- a/libs/ui/src/input/input.component.ts +++ b/libs/ui/src/input/input.component.ts @@ -75,7 +75,7 @@ export class InputComponent implements AfterViewInit, ControlValueAccessor, OnCh } checkForChange(rawValue: string): void { - const value = this.uiType === UiInputType.NUMBER ? +rawValue : rawValue; + const value = this.uiType === UiInputType.NUMBER ? (rawValue !== '' ? +rawValue : null) : rawValue; if (this._value !== value) { if (this.onChange) { this.onChange(value); From fbd04112fba34243219766543b663dfb11dff0ea Mon Sep 17 00:00:00 2001 From: Daniel Appelgren Date: Fri, 19 Nov 2021 09:34:00 +0100 Subject: [PATCH 3/3] update signal model --- .../pages/report-forms/signal-form/signal-form.component.ts | 6 +++--- .../src/app/shared/models/api/signal.request.model.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.ts index 1d1e555..36d2635 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.component.ts @@ -115,10 +115,10 @@ export class SignalFormComponent { const postRequest: SignalRequest = { genomforandeReferens: +genomforandeReferens, - typ: type, + type, omfattning, - omfattning_procent: omfattning === 'deltid' ? percent : null, - startdatum: formatDate(startDate), + omfattningPercent: omfattning === 'deltid' ? percent : null, + startDate: formatDate(startDate), }; this.signalFormService diff --git a/apps/mina-sidor-fa/src/app/shared/models/api/signal.request.model.ts b/apps/mina-sidor-fa/src/app/shared/models/api/signal.request.model.ts index f1b1787..1458347 100644 --- a/apps/mina-sidor-fa/src/app/shared/models/api/signal.request.model.ts +++ b/apps/mina-sidor-fa/src/app/shared/models/api/signal.request.model.ts @@ -1,7 +1,7 @@ export interface SignalRequest { genomforandeReferens: number; - typ: 'arbete' | 'utbildning'; + type: 'arbete' | 'utbildning'; omfattning: 'heltid' | 'deltid'; - omfattning_procent: number; - startdatum: string; + omfattningPercent: number; + startDate: string; }