Squashed commit of the following: commit 5b427cdd62b881cc32d408beaf92f8e3c22a9bd4 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Fri Nov 12 09:24:18 2021 +0100 refactor commit b51af1b25b573a3203f3dd7e8e1c3e1401f0d228 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Fri Nov 12 09:20:58 2021 +0100 add yrke names commit 1ed3a33fb997669bf1af0be52347b371af0177ba Merge: 4d9d25220235f1f9Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Fri Nov 12 07:40:48 2021 +0100 Merge branch 'develop' into feature/tv-533-Skapa-slutredovisning-2 # Conflicts: # apps/mina-sidor-fa/src/app/shared/enums/feature.enum.ts commit 4d9d25226fc3b91386832b1367edcf016d336c03 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Thu Nov 11 16:34:24 2021 +0100 Fixed switch functionality inside slutredovisning model commit cce93c169e39bba681e4e25f511fa42686134f97 Merge: b56ce52f 51ed2e84 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Thu Nov 11 16:15:46 2021 +0100 Fixed conflicts and added deltid percent commit 51ed2e841e00e8d7cea9225bd9cfeab8b783efbd Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 14:49:40 2021 +0100 hide description on step 1 and 2 commit 269708be2f7fec84815b3e7f91e33d4c305b0846 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 14:04:59 2021 +0100 cleanup commit 05df3acf97f6115ec15cd295c1ed12721592f867 Merge: 3c803f38c6adc71fAuthor: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 13:47:22 2021 +0100 Merge branch 'develop' into feature/tv-533-Skapa-slutredovisning-2 commit 3c803f3883b23065c2e0c15f6946213e5972576b Merge: c2724aa6f332dd41Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 12:38:53 2021 +0100 Merge branch 'develop' into feature/tv-533-Skapa-slutredovisning-2 # Conflicts: # apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-details/pages/deltagare-card/components/deltagare-tab-reports/components/reports-list/reports-list.component.ts # apps/mina-sidor-fa/src/app/shared/enums/report-type.enum.ts commit c2724aa654483001d48ca1c2d0a5bfc1b2552c89 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 12:22:05 2021 +0100 add loader commit b97b45fb22260dbdc9f9792e027b7bda68150ead Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 12:09:09 2021 +0100 move formgroups to parent to persist stat commit 37feaab19309777ef96fb70be62ede9e26498b89 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 10:43:53 2021 +0100 fix radiobuttons commit 644b9fd6288589cc3a66ceb8beefb623345e4308 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 09:30:31 2021 +0100 . commit 28875f21a381a966054523ff7ccb7df126b30120 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 08:20:07 2021 +0100 move submit logic to step3 commit eef52c39dd970abbedc413b4c348098e07abe036 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Thu Nov 11 07:40:56 2021 +0100 submit button commit 4d732240e0ff6196d827572ff865392d6aaa0a9c Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Nov 10 12:47:43 2021 +0100 fix some bugs commit 642cc2b24fd3a5def8abb9ae45595d101ccdcfb7 Merge: c4d534072dc56685Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Nov 10 12:24:18 2021 +0100 Merge branch 'develop' into feature/tv-533-Skapa-slutredovisning-2 commit c4d53407399d695f58e5a0be074d81bbc1b1cb21 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Nov 10 12:24:09 2021 +0100 wip commit 808810699850e611ead2ee7ed1b728acc3d93dd5 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Nov 10 12:02:01 2021 +0100 slutredovisning commit fa446717acc66e779ecdb87ba7a5b2224eeca9fe Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Nov 10 11:00:44 2021 +0100 view for utbildning done ... and 64 more commits
101 lines
2.5 KiB
TypeScript
101 lines
2.5 KiB
TypeScript
import {
|
|
AfterViewInit,
|
|
ChangeDetectionStrategy,
|
|
ChangeDetectorRef,
|
|
Component,
|
|
EventEmitter,
|
|
Injector,
|
|
Input,
|
|
OnChanges,
|
|
Output,
|
|
} from '@angular/core';
|
|
import { ControlValueAccessor, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
import { uuid } from '@utils/uuid.util';
|
|
import { UiInputType } from './input-type.enum';
|
|
import { UiInputVariation } from './input-variation.enum';
|
|
|
|
/**
|
|
* A input input. Implemented with control value accessor
|
|
*
|
|
* ## Usage
|
|
* ``import {UiInputModule} from '@ui/input/input.module';``
|
|
*/
|
|
@Component({
|
|
selector: 'ui-input',
|
|
templateUrl: './input.component.html',
|
|
styleUrls: ['./input.component.scss'],
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: InputComponent,
|
|
multi: true,
|
|
},
|
|
],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class InputComponent implements AfterViewInit, ControlValueAccessor, OnChanges {
|
|
@Input() uiId: string = uuid();
|
|
@Input() uiName: string;
|
|
@Input() uiLabel: string = '';
|
|
@Input() uiDescription: string;
|
|
@Input() uiVariation: UiInputVariation = UiInputVariation.M;
|
|
@Input() uiRequired: boolean;
|
|
@Input() uiAnnounceIfOptional: boolean = false;
|
|
@Input() uiMin: number;
|
|
@Input() uiMax: number;
|
|
@Input() uiType: UiInputType = UiInputType.TEXT;
|
|
@Input() uiInvalid: boolean;
|
|
@Input() uiValidationMessage: string;
|
|
@Output() uiOnChange: EventEmitter<any> = new EventEmitter();
|
|
|
|
name: string | number;
|
|
|
|
onTouched: () => {};
|
|
private onChange: (value: any) => {};
|
|
private _value: any;
|
|
|
|
constructor(private injector: Injector, private changeDetectorRef: ChangeDetectorRef) {}
|
|
|
|
get currentValue(): string {
|
|
return this._value || '';
|
|
}
|
|
|
|
ngAfterViewInit(): void {
|
|
const ngControl: NgControl = this.injector.get(NgControl, null);
|
|
if (ngControl) {
|
|
this.name = this.uiName || ngControl.name;
|
|
}
|
|
}
|
|
|
|
ngOnChanges(): void {
|
|
const ngControl: NgControl = this.injector.get(NgControl, null);
|
|
if (ngControl) {
|
|
this.name = this.uiName || ngControl.name;
|
|
}
|
|
}
|
|
|
|
checkForChange(rawValue: string): void {
|
|
const value = this.uiType === UiInputType.NUMBER ? +rawValue : rawValue;
|
|
if (this._value !== value) {
|
|
if (this.onChange) {
|
|
this.onChange(value);
|
|
}
|
|
this._value = value;
|
|
this.uiOnChange.emit(value);
|
|
}
|
|
}
|
|
|
|
writeValue(value: any): void {
|
|
this._value = value;
|
|
this.changeDetectorRef.detectChanges();
|
|
}
|
|
|
|
registerOnChange(fn: (value: string) => {}) {
|
|
this.onChange = fn;
|
|
}
|
|
|
|
registerOnTouched(fn: () => {}) {
|
|
this.onTouched = fn;
|
|
}
|
|
}
|