onshore-forms 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/esm2020/lib/components/form-autocomplete-item/form-autocomplete-item.component.mjs +11 -0
  2. package/esm2020/lib/components/form-checkbox-item/form-checkbox-item.component.mjs +62 -0
  3. package/esm2020/lib/components/form-colorpicker-item/form-colorpicker-item.component.mjs +69 -0
  4. package/esm2020/lib/components/form-dropdown-item/form-dropdown-item.component.mjs +65 -0
  5. package/esm2020/lib/components/form-image-item/form-image-item.component.mjs +160 -0
  6. package/esm2020/lib/components/form-input-item/form-input-item.component.mjs +63 -0
  7. package/esm2020/lib/components/form-switch-item/form-switch-item.component.mjs +65 -0
  8. package/esm2020/lib/components/form-textarea-item/form-textarea-item.component.mjs +61 -0
  9. package/esm2020/lib/components/form-validation-output/form-validation-output.component.mjs +41 -0
  10. package/esm2020/lib/enums/form.enums.mjs +26 -0
  11. package/esm2020/lib/models/form.models.mjs +2 -0
  12. package/esm2020/lib/onshore-forms.component.mjs +22 -0
  13. package/esm2020/lib/onshore-forms.module.mjs +134 -0
  14. package/esm2020/lib/onshore-forms.service.mjs +151 -0
  15. package/esm2020/onshore-forms.mjs +5 -0
  16. package/esm2020/public-api.mjs +18 -0
  17. package/fesm2015/onshore-forms.mjs +921 -0
  18. package/fesm2015/onshore-forms.mjs.map +1 -0
  19. package/fesm2020/onshore-forms.mjs +877 -0
  20. package/fesm2020/onshore-forms.mjs.map +1 -0
  21. package/index.d.ts +5 -0
  22. package/lib/components/form-autocomplete-item/form-autocomplete-item.component.d.ts +5 -0
  23. package/lib/components/form-checkbox-item/form-checkbox-item.component.d.ts +21 -0
  24. package/lib/components/form-colorpicker-item/form-colorpicker-item.component.d.ts +23 -0
  25. package/lib/components/form-dropdown-item/form-dropdown-item.component.d.ts +22 -0
  26. package/lib/components/form-image-item/form-image-item.component.d.ts +40 -0
  27. package/lib/components/form-input-item/form-input-item.component.d.ts +23 -0
  28. package/lib/components/form-switch-item/form-switch-item.component.d.ts +21 -0
  29. package/lib/components/form-textarea-item/form-textarea-item.component.d.ts +22 -0
  30. package/lib/components/form-validation-output/form-validation-output.component.d.ts +17 -0
  31. package/lib/enums/form.enums.d.ts +23 -0
  32. package/lib/models/form.models.d.ts +61 -0
  33. package/lib/onshore-forms.component.d.ts +8 -0
  34. package/lib/onshore-forms.module.d.ts +31 -0
  35. package/lib/onshore-forms.service.d.ts +32 -0
  36. package/package.json +21 -10
  37. package/{src/public-api.ts → public-api.d.ts} +0 -4
  38. package/karma.conf.js +0 -44
  39. package/ng-package.json +0 -11
  40. package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.html +0 -46
  41. package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.scss +0 -0
  42. package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.ts +0 -133
  43. package/src/lib/components/form-checkbox-item/form-checkbox-item.component.html +0 -23
  44. package/src/lib/components/form-checkbox-item/form-checkbox-item.component.scss +0 -0
  45. package/src/lib/components/form-checkbox-item/form-checkbox-item.component.ts +0 -65
  46. package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.html +0 -30
  47. package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.scss +0 -0
  48. package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.ts +0 -71
  49. package/src/lib/components/form-dropdown-item/form-dropdown-item.component.html +0 -44
  50. package/src/lib/components/form-dropdown-item/form-dropdown-item.component.scss +0 -0
  51. package/src/lib/components/form-dropdown-item/form-dropdown-item.component.ts +0 -68
  52. package/src/lib/components/form-image-item/form-image-item.component.html +0 -79
  53. package/src/lib/components/form-image-item/form-image-item.component.scss +0 -3
  54. package/src/lib/components/form-image-item/form-image-item.component.ts +0 -155
  55. package/src/lib/components/form-input-item/form-input-item.component.html +0 -81
  56. package/src/lib/components/form-input-item/form-input-item.component.scss +0 -3
  57. package/src/lib/components/form-input-item/form-input-item.component.ts +0 -66
  58. package/src/lib/components/form-switch-item/form-switch-item.component.html +0 -8
  59. package/src/lib/components/form-switch-item/form-switch-item.component.scss +0 -0
  60. package/src/lib/components/form-switch-item/form-switch-item.component.ts +0 -72
  61. package/src/lib/components/form-textarea-item/form-textarea-item.component.html +0 -39
  62. package/src/lib/components/form-textarea-item/form-textarea-item.component.scss +0 -0
  63. package/src/lib/components/form-textarea-item/form-textarea-item.component.ts +0 -64
  64. package/src/lib/components/form-validation-output/form-validation-output.component.html +0 -2
  65. package/src/lib/components/form-validation-output/form-validation-output.component.scss +0 -1
  66. package/src/lib/components/form-validation-output/form-validation-output.component.ts +0 -43
  67. package/src/lib/enums/form.enums.ts +0 -24
  68. package/src/lib/models/form.models.ts +0 -70
  69. package/src/lib/onshore-forms.component.ts +0 -20
  70. package/src/lib/onshore-forms.module.ts +0 -78
  71. package/src/lib/onshore-forms.service.ts +0 -172
  72. package/src/test.ts +0 -27
  73. package/styles/css/main.css +0 -1
  74. package/styles/css/theme1.css +0 -1
  75. package/tsconfig.lib.json +0 -24
  76. package/tsconfig.lib.prod.json +0 -20
  77. package/tsconfig.spec.json +0 -17
@@ -1,79 +0,0 @@
1
- <div class="flex flex-column mb-3" style="max-width: 500px">
2
- <div class="flex justify-content-between align-items-center">
3
- <b [class.text-muted]="disabled" class="mb-1 white-space-nowrap">
4
- {{formTemplate.label}}
5
- <span *ngIf="formTemplate.required" class="tl-color-danger">*</span>
6
- </b>
7
- <i *ngIf="formTemplate.tooltip" class="fa fa-info-circle tl-color-black" [pTooltip]="formTemplate.tooltip" tooltipPosition="left" [escape]="false"></i>
8
- </div>
9
-
10
- <div class="w-100">
11
-
12
- <div class="position-relative flex justify-content-center align-items-center" style="background-color: white">
13
- <!--<app-image-placeholder class="w-100" [image]="image" imageStyle="position: absolut; height: 250px; width: 250px" [placeholder]="formSettings?.imagePlaceholder ? formSettings?.imagePlaceholder + ' fa-10x' : 'fa-image fa-10x'" placeholderStyle="width: 250px; height: 250px"></app-image-placeholder>-->
14
- </div>
15
-
16
- <div class="flex flex-column mt-4 w-100">
17
- <button pButton pRipple type="button"
18
- [hidden]="formSettings?.disableImageSelection"
19
- icon="fa fa-image"
20
- label="Bild hochladen"
21
- class="p-button-rounded p-button-outlined text-secondary mb-2"
22
- [disabled]="disabled"
23
- (click)="imageChooserDialogVisible = true">
24
- </button>
25
-
26
- <button pButton pRipple type="button"
27
- [hidden]="formSettings?.disableWebcamSelection"
28
- icon="fa fa-camera"
29
- label="Foto aufnehmen"
30
- class="p-button-rounded p-button-outlined text-secondary mb-2"
31
- [disabled]="disabled"
32
- (click)="webcamDialogVisible = true">
33
- </button>
34
-
35
- <!--<button pButton pRipple type="button"
36
- [hidden]="formSettings?.disableMediaSelection"
37
- icon="fa fa-photo-video"
38
- label="Medienverwaltung"
39
- class="p-button-rounded p-button-outlined text-secondary mb-2"
40
- [disabled]="disabled"
41
- (click)="searchMedia()">
42
- </button>-->
43
-
44
- <button pButton pRipple type="button"
45
- [hidden]="formSettings?.disableDelete"
46
- icon="fa fa-eraser"
47
- label="Entfernen"
48
- (click)="removeImage()"
49
- [disabled]="!image || disabled"
50
- class="p-button-rounded p-button-outlined text-secondary">
51
- </button>
52
-
53
- </div>
54
-
55
- </div>
56
-
57
- <small *ngIf="formTemplate.description"><i class="fa fa-info-circle"></i> {{formTemplate.description}}</small>
58
-
59
- </div>
60
-
61
- <!--
62
- <p-dialog [header]="'Bild auswählen'" [(visible)]="imageChooserDialogVisible" [modal]="true" [style]="{'max-width': '50vw'}">
63
- <app-image-chooser buttonLabel="Auswählen"
64
- (choosen)="getFileImage($event)"
65
- (canceled)="imageChooserDialogVisible = false"
66
- [inverseColor]="inverseColor"
67
- [resizeToWidth]="imageWidth"
68
- [resizeToHeight]="imageHeight"
69
- [containWithinAspectRatio]="containWithinAspectRatio"
70
- [aspectRatio]="aspectRatio"
71
- backgroundColor="transparent"></app-image-chooser>
72
- </p-dialog>
73
- -->
74
-
75
- <!--
76
- <p-dialog [header]="'Foto aufnehmen'" [(visible)]="webcamDialogVisible" [modal]="true" [style]="{'max-width': '50vw'}">
77
- <app-webcam *ngIf="webcamDialogVisible" buttonLabel="Smile" (shot)="getWebcamImage($event)" (canceled)="webcamDialogVisible = false" [inverseColor]="inverseColor"></app-webcam>
78
- </p-dialog>
79
- -->
@@ -1,3 +0,0 @@
1
- app-form-image-item {
2
-
3
- }
@@ -1,155 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- ChangeDetectorRef,
4
- Component, EventEmitter, Input, OnDestroy, OnInit,
5
- Optional, Output,
6
- Self
7
- } from '@angular/core';
8
- import { ControlValueAccessor, NgControl } from '@angular/forms';
9
- import { Subscription } from 'rxjs';
10
- import { DialogService } from 'primeng/dynamicdialog';
11
- import { TranslateService } from '@ngx-translate/core';
12
- import { OnshoreFormTemplateItem, OnshoreImageItemSettings } from '../../models/form.models';
13
-
14
- @Component({
15
- selector: 'onshore-form-image-item',
16
- templateUrl: './form-image-item.component.html',
17
- changeDetection: ChangeDetectionStrategy.OnPush,
18
- })
19
- export class OnshoreFormImageItemComponent implements ControlValueAccessor, OnInit, OnDestroy {
20
- @Input() formTemplate!: OnshoreFormTemplateItem;
21
- @Input() inverseColor: boolean = false;
22
-
23
- // Image updload params
24
- @Input() imageWidth: number = 400;
25
- @Input() imageHeight: number = 400;
26
- @Input() public containWithinAspectRatio = false;
27
- @Input() public aspectRatio: number = 1 / 1;
28
- @Output() imageDeleted: EventEmitter<string> = new EventEmitter();
29
- @Output() imageCleared: EventEmitter<any> = new EventEmitter();
30
- @Output() imageSelectedFromMedia: EventEmitter<any> = new EventEmitter();
31
-
32
- image = '';
33
- disabled = false;
34
- webcamDialogVisible: boolean = false;
35
- imageChooserDialogVisible: boolean = false;
36
- formSettings: OnshoreImageItemSettings;
37
-
38
- subscriptions: Array<Subscription> = [];
39
-
40
- getFileImage(image: any) {
41
- this.imageChooserDialogVisible = false;
42
- if(image) {
43
- this.image = image;
44
- setTimeout(() => {
45
- this.cdr.markForCheck();
46
- this.ngControl?.control?.setValue(this.image);
47
- this.ngControl?.control?.markAsDirty();
48
- }, 500);
49
- }
50
- }
51
-
52
- getWebcamImage(image: any) {
53
- this.webcamDialogVisible = false;
54
- if(image) {
55
- this.image = image;
56
- setTimeout(() => {
57
- this.cdr.markForCheck();
58
- this.ngControl?.control?.setValue(this.image);
59
- this.ngControl?.control?.markAsDirty();
60
- }, 500);
61
- }
62
- }
63
-
64
- /*searchMedia() {
65
- this.dialogService.open(SearchMediaComponent,{
66
- styleClass: 'p-dialog-background-white',
67
- modal: true,
68
- header: this.translate.instant('search.media.dialogTitle'),
69
- data: { targetType: this.formSettings.mediaType }
70
- }).onClose.subscribe((result) => {
71
- if(result) {
72
- this.image = result.url;
73
- setTimeout(() => {
74
- this.cdr.markForCheck();
75
- this.ngControl?.control?.setValue(this.image);
76
- this.ngControl?.control?.markAsDirty();
77
- this.imageSelectedFromMedia.next(result);
78
- }, 500);
79
- }
80
- });
81
- }*/
82
-
83
- removeImage() {
84
- if(this.image && !this.image.includes('base64')) {
85
- this.imageDeleted.emit(this.image);
86
- } else {
87
- this.imageCleared.emit();
88
- }
89
-
90
- this.ngControl?.control?.setValue(null);
91
- this.ngControl?.control?.markAsDirty();
92
- this.image = '';
93
- }
94
-
95
- public writeValue(obj: any): void {
96
- if(obj && !obj.includes('base64')) {
97
- this.image = obj;
98
- }
99
- if(obj == null) {
100
- this.image = '';
101
- }
102
- this.cdr.markForCheck();
103
- }
104
-
105
- public registerOnChange(fn: any): void {
106
- if(this.ngControl.value) {
107
- this.image = this.ngControl.value;
108
- this.cdr.markForCheck();
109
- }
110
- }
111
-
112
- public registerOnTouched(fn: any): void {}
113
-
114
- public setDisabledState?(isDisabled: boolean): void {
115
- this.disabled = isDisabled;
116
- this.cdr.markForCheck();
117
- }
118
-
119
- ngOnInit(): void {
120
- this.ngControl.control.valueChanges.subscribe((value) => {
121
- this.cdr.markForCheck();
122
- });
123
- this.ngControl.control.statusChanges.subscribe((status) => {
124
- this.cdr.markForCheck();
125
- });
126
-
127
- if(this.ngControl.control.value == '' && this.formTemplate.default != undefined) {
128
- this.ngControl.control.setValue(this.formTemplate.default);
129
- this.cdr.markForCheck();
130
- }
131
- if(this.formTemplate.enabled) {
132
- this.ngControl.control.enable();
133
- } else {
134
- this.ngControl.control.disable();
135
- }
136
- if(this.formTemplate.settings) {
137
- this.formSettings = this.formTemplate.settings as OnshoreImageItemSettings;
138
- }
139
- }
140
-
141
- ngOnDestroy() {
142
- this.subscriptions.forEach((subscription: Subscription) => {
143
- subscription.unsubscribe();
144
- });
145
- this.ngControl.control.disable();
146
- this.image = null;
147
- }
148
-
149
- constructor(private cdr: ChangeDetectorRef,
150
- @Self() @Optional() public ngControl: NgControl,
151
- public dialogService: DialogService,
152
- private translate: TranslateService) {
153
- this.ngControl.valueAccessor = this;
154
- }
155
- }
@@ -1,81 +0,0 @@
1
- <div class="flex flex-column mb-3">
2
- <div class="flex justify-content-between align-items-center">
3
- <b [class.text-muted]="disabled" class="mb-1 white-space-nowrap">
4
- {{formTemplate.label}}
5
- <span *ngIf="formTemplate.required" class="tl-color-danger">*</span>
6
- </b>
7
- <i *ngIf="formTemplate.tooltip" class="fa fa-info-circle tl-color-black" [pTooltip]="formTemplate.tooltip" tooltipPosition="left" [escape]="false"></i>
8
- </div>
9
-
10
- <span class="p-inputgroup w-100">
11
-
12
- <container-element [ngSwitch]="formTemplate.type" class="w-100" style="width: 100%">
13
-
14
- <input *ngSwitchDefault
15
- class="w-100"
16
- type="text"
17
- [name]="formTemplate.name"
18
- [placeholder]="formTemplate.placeholder ?? ''"
19
- pInputText
20
- [formControl]="ngControl.control"
21
- [class.p-invalid]="ngControl.control.touched && ngControl.control.invalid"
22
- [autocomplete]="'prevent-template-' + formTemplate.name"/>
23
-
24
- <input *ngSwitchCase="'password'"
25
- class="w-100"
26
- [type]="passwordVisible ? 'text' : formTemplate.type"
27
- [name]="formTemplate.name"
28
- [placeholder]="formTemplate.placeholder ?? ''"
29
- pInputText
30
- [formControl]="ngControl.control"
31
- [class.p-invalid]="ngControl.control.touched && ngControl.control.invalid"
32
- [autocomplete]="'prevent-template-' + formTemplate.name"/>
33
-
34
- <p-inputNumber *ngSwitchCase="'number'"
35
- class="w-100"
36
- [name]="formTemplate.name"
37
- [placeholder]="formTemplate.placeholder ?? 0"
38
- [formControl]="ngControl.control"
39
- [class.p-invalid]="ngControl.control.touched && ngControl.control.invalid"
40
- [autocomplete]="'prevent-template-' + formTemplate.name"
41
- [step]="formTemplate.settings?.step ?? 1"
42
- [min]="formTemplate.settings?.min ?? null"
43
- [max]="formTemplate.settings?.max ?? null">
44
- </p-inputNumber>
45
- <!--
46
- [showButtons]="true"
47
- buttonLayout="horizontal"
48
- spinnerMode="horizontal"
49
- decrementButtonClass="p-button-outlined text-black-50"
50
- incrementButtonClass="p-button-outlined text-black-50"
51
- -->
52
- </container-element>
53
-
54
- <span class="p-inputgroup-addon">
55
- <i *ngIf="formTemplate.type != FormTemplateItemType.password" class="fa"
56
- [class.tl-color-black]="ngControl.control.untouched"
57
- [class.fa-check]="formTemplate.required && ngControl.control.valid"
58
- [class.tl-color-primary1]="ngControl.control.touched && ngControl.control.valid"
59
- [class.fa-exclamation-triangle]="ngControl.control.touched && ngControl.control.invalid"
60
- [class.tl-color-danger]="ngControl.control.touched && ngControl.control.invalid"
61
- ></i>
62
- <i *ngIf="formTemplate.type == FormTemplateItemType.password" class="fa tl-color-black"
63
- [class.fa-eye-slash]="passwordVisible"
64
- [class.fa-eye]="!passwordVisible"
65
- (click)="passwordVisible = !passwordVisible"
66
- ></i>
67
- </span>
68
-
69
- </span>
70
-
71
- <small *ngIf="formTemplate.description"><i class="fa fa-info-circle"></i> {{formTemplate.description}}</small>
72
-
73
- <div *ngIf="ngControl.control.touched">
74
- <onshore-form-validation-output
75
- [validationItems]="formTemplate.validationItems"
76
- [validationErrors]="ngControl.control.errors"
77
- [externValidationPattern]="formTemplate.validationPatternTranslation">
78
- </onshore-form-validation-output>
79
- </div>
80
-
81
- </div>
@@ -1,3 +0,0 @@
1
- .p-inputtext {
2
- border-color: var(--color-primary) !important;
3
- }
@@ -1,66 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- ChangeDetectorRef,
4
- Component,
5
- Input, OnChanges, OnDestroy,
6
- OnInit, Optional,
7
- Self, SimpleChanges
8
- } from '@angular/core';
9
- import { ControlValueAccessor, NgControl } from '@angular/forms';
10
- import { OnshoreFormTemplateItem } from '../../models/form.models';
11
- import { OnshoreFormTemplateType } from '../../enums/form.enums';
12
-
13
- @Component({
14
- selector: 'onshore-form-input-item',
15
- templateUrl: './form-input-item.component.html',
16
- styleUrls: ['./form-input-item.component.scss'],
17
- changeDetection: ChangeDetectionStrategy.OnPush,
18
- })
19
- export class OnshoreFormInputItemComponent implements OnInit, ControlValueAccessor, OnChanges, OnDestroy {
20
- @Input() formTemplate!: OnshoreFormTemplateItem;
21
-
22
- FormTemplateItemType = OnshoreFormTemplateType;
23
-
24
- passwordVisible: boolean = false;
25
- disabled: boolean = false;
26
-
27
- // ControlValueAccessor interface
28
- writeValue(obj: any): void {}
29
- registerOnChange(fn: any): void {}
30
- registerOnTouched(fn: any): void {}
31
- setDisabledState?(isDisabled: boolean): void {
32
- this.disabled = isDisabled;
33
- }
34
-
35
-
36
- ngOnInit(): void {
37
- this.ngControl.control?.valueChanges.subscribe(() => {
38
- this.cdr.markForCheck();
39
- });
40
- this.ngControl.control?.statusChanges.subscribe(() => {
41
- this.cdr.markForCheck();
42
- });
43
- if(this.ngControl.control?.value == '' && this.formTemplate.default != undefined) {
44
- this.ngControl.control?.setValue(this.formTemplate.default);
45
- this.cdr.markForCheck();
46
- }
47
- if(this.formTemplate.enabled) {
48
- this.ngControl.control?.enable();
49
- } else {
50
- this.ngControl.control?.disable();
51
- }
52
- }
53
-
54
- ngOnChanges(changes: SimpleChanges) {
55
- this.cdr.markForCheck();
56
- }
57
-
58
- ngOnDestroy() {
59
- this.ngControl.control?.disable();
60
- }
61
-
62
- constructor(@Self() @Optional() public ngControl: NgControl,
63
- private cdr: ChangeDetectorRef) {
64
- this.ngControl.valueAccessor = this;
65
- }
66
- }
@@ -1,8 +0,0 @@
1
- <div class="flex flex-column pt-1">
2
- <div class="flex justify-content-between align-items-center">
3
- <i *ngIf="formTemplate.tooltip" class="fa fa-info-circle tl-color-black" [pTooltip]="formTemplate.tooltip" tooltipPosition="left" [escape]="false"></i>
4
- </div>
5
-
6
- <p-inputSwitch [name]="formTemplate.name" [formControl]="ngControl.control" [inputId]="formTemplate.name"></p-inputSwitch>
7
-
8
- </div>
@@ -1,72 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- ChangeDetectorRef,
4
- Component, EventEmitter,
5
- Input, OnChanges, OnDestroy,
6
- OnInit, Optional, Output,
7
- Self, SimpleChanges
8
- } from '@angular/core';
9
- import { ControlValueAccessor, NgControl } from '@angular/forms';
10
- import { debounceTime, distinctUntilChanged, skip } from 'rxjs';
11
- import { OnshoreFormTemplateItem } from '../../models/form.models';
12
-
13
- @Component({
14
- selector: 'onshore-form-switch-item',
15
- templateUrl: './form-switch-item.component.html',
16
- changeDetection: ChangeDetectionStrategy.OnPush,
17
- })
18
- export class OnshoreFormSwitchItemComponent implements OnInit, ControlValueAccessor, OnDestroy, OnChanges {
19
- @Input() formTemplate!: OnshoreFormTemplateItem;
20
- @Output() valueChange: EventEmitter<boolean> = new EventEmitter();
21
-
22
- disabled: boolean = false;
23
-
24
- // ControlValueAccessor interface
25
- writeValue(obj: any): void {}
26
- registerOnChange(fn: any): void {}
27
- registerOnTouched(fn: any): void {}
28
- setDisabledState?(isDisabled: boolean): void {
29
- this.disabled = isDisabled;
30
- }
31
-
32
-
33
- ngOnInit(): void {
34
- this.ngControl.control?.valueChanges.pipe(
35
- debounceTime(100),
36
- distinctUntilChanged(),
37
- skip(1)
38
- ).subscribe(newValue => {
39
- this.valueChange.emit(this.ngControl.control?.value);
40
- });
41
-
42
- this.ngControl.control?.valueChanges.subscribe(() => {
43
- this.cdr.markForCheck();
44
- });
45
- this.ngControl.control?.statusChanges.subscribe(() => {
46
- this.cdr.markForCheck();
47
- });
48
-
49
- if(this.ngControl.control?.value == undefined && this.formTemplate.default != undefined) {
50
- this.ngControl.control?.setValue(this.formTemplate.default);
51
- this.cdr.markForCheck();
52
- }
53
- if(this.formTemplate.enabled) {
54
- this.ngControl.control?.enable();
55
- } else {
56
- this.ngControl.control?.disable();
57
- }
58
- }
59
-
60
- ngOnChanges(changes: SimpleChanges) {
61
- this.cdr.markForCheck();
62
- }
63
-
64
- ngOnDestroy() {
65
- this.ngControl.control?.disable();
66
- }
67
-
68
- constructor(@Self() @Optional() public ngControl: NgControl,
69
- private cdr: ChangeDetectorRef) {
70
- this.ngControl.valueAccessor = this;
71
- }
72
- }
@@ -1,39 +0,0 @@
1
- <div class="flex flex-column mb-3">
2
- <div class="flex justify-content-between align-items-center">
3
- <b [class.text-muted]="disabled" class="mb-1 white-space-nowrap">
4
- {{formTemplate.label}}
5
- <span *ngIf="formTemplate.required" class="tl-color-danger">*</span>
6
- </b>
7
- <i *ngIf="formTemplate.tooltip" class="fa fa-info-circle tl-color-black" [pTooltip]="formTemplate.tooltip" tooltipPosition="left" [escape]="false"></i>
8
- </div>
9
-
10
- <span class="p-input-icon-right">
11
- <i class="fa"
12
- [class.tl-color-black]="ngControl.control?.untouched"
13
- [class.fa-check]="ngControl.control?.touched && ngControl.control?.valid"
14
- [class.text-primary]="ngControl.control?.touched && ngControl.control?.valid"
15
- [class.fa-exclamation-triangle]="ngControl.control?.touched && ngControl.control?.invalid"
16
- [class.tl-color-danger]="ngControl.control?.touched && ngControl.control?.invalid"
17
- ></i>
18
- <textarea class="w-100"
19
- [name]="formTemplate.name"
20
- [placeholder]="formTemplate.label"
21
- [rows]="3"
22
- [cols]="30"
23
- pInputTextarea
24
- [autoResize]="true"
25
- [formControl]="ngControl.control"
26
- [class.p-invalid]="ngControl.control?.touched && ngControl.control?.invalid"></textarea>
27
- </span>
28
-
29
- <small *ngIf="formTemplate.description"><i class="fa fa-info-circle"></i> {{formTemplate.description}}</small>
30
-
31
- <div *ngIf="ngControl.control?.touched">
32
- <onshore-form-validation-output
33
- [validationItems]="formTemplate.validationItems"
34
- [validationErrors]="ngControl.control?.errors"
35
- [externValidationPattern]="formTemplate.validationPatternTranslation">
36
- </onshore-form-validation-output>
37
- </div>
38
-
39
- </div>
@@ -1,64 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- ChangeDetectorRef,
4
- Component,
5
- Input, OnChanges, OnDestroy,
6
- OnInit, Optional,
7
- Self, SimpleChanges
8
- } from '@angular/core';
9
- import { ControlValueAccessor, NgControl } from '@angular/forms';
10
- import { OnshoreFormTemplateItem } from '../../models/form.models';
11
- import { OnshoreFormTemplateType } from '../../enums/form.enums';
12
-
13
- @Component({
14
- selector: 'onshore-form-textarea-item',
15
- templateUrl: './form-textarea-item.component.html',
16
- changeDetection: ChangeDetectionStrategy.OnPush,
17
- })
18
- export class OnshoreFormTextareaItemComponent implements OnInit, ControlValueAccessor, OnChanges, OnChanges, OnDestroy {
19
- @Input() formTemplate!: OnshoreFormTemplateItem;
20
-
21
- FormTemplateItemType = OnshoreFormTemplateType;
22
-
23
- disabled: boolean = false;
24
-
25
- // ControlValueAccessor interface
26
- writeValue(obj: any): void {}
27
- registerOnChange(fn: any): void {}
28
- registerOnTouched(fn: any): void {}
29
- setDisabledState?(isDisabled: boolean): void {
30
- this.disabled = isDisabled;
31
- }
32
-
33
- ngOnInit(): void {
34
- this.ngControl.control?.valueChanges.subscribe(() => {
35
- this.cdr.markForCheck();
36
- });
37
- this.ngControl.control?.statusChanges.subscribe(() => {
38
- this.cdr.markForCheck();
39
- });
40
-
41
- if(this.ngControl.control?.value == '' && this.formTemplate.default != undefined) {
42
- this.ngControl.control?.setValue(this.formTemplate.default);
43
- this.cdr.markForCheck();
44
- }
45
- if(this.formTemplate.enabled) {
46
- this.ngControl.control?.enable();
47
- } else {
48
- this.ngControl.control?.disable();
49
- }
50
- }
51
-
52
- ngOnDestroy() {
53
- this.ngControl.control?.disable();
54
- }
55
-
56
- ngOnChanges(changes: SimpleChanges) {
57
- this.cdr.markForCheck();
58
- }
59
-
60
- constructor(@Self() @Optional() public ngControl: NgControl,
61
- private cdr: ChangeDetectorRef) {
62
- this.ngControl.valueAccessor = this;
63
- }
64
- }
@@ -1,2 +0,0 @@
1
- <small *ngIf="validationErrors && validationErrors['pattern']" [innerHTML]="externValidationPattern"></small>
2
- <small *ngIf="validationTranslation" [innerHTML]="validationTranslation"></small>
@@ -1,43 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- ChangeDetectorRef,
4
- Component,
5
- Input, OnChanges, SimpleChanges
6
- } from '@angular/core';
7
- import { ValidationErrors } from '@angular/forms';
8
- import { TranslateService } from '@ngx-translate/core';
9
- import { OnshoreFormValidationItem } from '../../models/form.models';
10
-
11
- @Component({
12
- selector: 'onshore-form-validation-output',
13
- templateUrl: './form-validation-output.component.html',
14
- changeDetection: ChangeDetectionStrategy.OnPush,
15
- })
16
- export class OnshoreFormValidationOutputComponent implements OnChanges {
17
- @Input() validationErrors!: ValidationErrors | null;
18
- @Input() externValidationPattern: string = "";
19
- @Input() validationItems!: OnshoreFormValidationItem[];
20
-
21
- validationTranslation: string = '';
22
-
23
- ngOnChanges(changes: SimpleChanges) {
24
- this.validationTranslation = '';
25
- if(changes['validationErrors'].currentValue) {
26
- Object.keys(this.validationErrors!).forEach(error => {
27
- const exists = Object.values(this.validationItems).filter( validationItem => validationItem.key == error);
28
- if(exists && exists.length > 0) {
29
- this.validationTranslation += this.translate.instant('request.error.' + error) + '<br>';
30
- } else {
31
- const errorValues = this.validationErrors![error];
32
- this.validationTranslation += this.translate.instant('form.validation.' + error, errorValues) + '<br>';
33
- }
34
- });
35
- }
36
- this.cdr.markForCheck();
37
- }
38
-
39
- constructor(private cdr: ChangeDetectorRef,
40
- private translate: TranslateService,) {
41
-
42
- }
43
- }
@@ -1,24 +0,0 @@
1
- export enum OnshoreFormTemplateType {
2
- text = 'text',
3
- textarea = 'textarea',
4
- editor = 'editor',
5
- password = 'password',
6
- number = 'number',
7
- email = 'email',
8
- phone = 'phone',
9
- regexp = 'regexp',
10
- select = 'select',
11
- check = 'check',
12
- radio = 'radio',
13
- image = 'image',
14
- autocomplete = 'autocomplete',
15
- color = 'color',
16
- subform = 'subform'
17
- }
18
-
19
- export enum OnshoreImageError {
20
- none = '',
21
- fileType = 'fileType',
22
- ratio = 'ratio',
23
- size = 'size',
24
- }