onshore-forms 0.0.6 → 0.0.8

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
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.6",
2
+ "version": "0.0.8",
3
3
  "name": "onshore-forms",
4
4
  "description": "OnShore Angular Form Builder",
5
5
  "author": {
@@ -14,13 +14,6 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/OnShore-Development/onshore_libs.git/issues"
16
16
  },
17
- "scripts": {
18
- "sass:dev": "sass --watch --update --style=expanded styles/scss:styles/css",
19
- "sass:prod": "sass --no-source-map --style=compressed styles/scss:styles/css",
20
- "build": "npm run sass:prod && ng build onshore-forms",
21
- "serve": "npm run sass:dev && ng build onshore-forms --watch",
22
- "publish": "npm publish"
23
- },
24
17
  "peerDependencies": {
25
18
  "@angular/common": "^14.2.0",
26
19
  "@angular/core": "^14.2.0",
@@ -34,6 +27,24 @@
34
27
  "exports": {
35
28
  "./theme1": {
36
29
  "sass": "./styles/theme1/style.scss"
30
+ },
31
+ "./package.json": {
32
+ "default": "./package.json"
33
+ },
34
+ ".": {
35
+ "types": "./index.d.ts",
36
+ "esm2020": "./esm2020/onshore-forms.mjs",
37
+ "es2020": "./fesm2020/onshore-forms.mjs",
38
+ "es2015": "./fesm2015/onshore-forms.mjs",
39
+ "node": "./fesm2015/onshore-forms.mjs",
40
+ "default": "./fesm2020/onshore-forms.mjs"
37
41
  }
38
- }
39
- }
42
+ },
43
+ "module": "fesm2015/onshore-forms.mjs",
44
+ "es2020": "fesm2020/onshore-forms.mjs",
45
+ "esm2020": "esm2020/onshore-forms.mjs",
46
+ "fesm2020": "fesm2020/onshore-forms.mjs",
47
+ "fesm2015": "fesm2015/onshore-forms.mjs",
48
+ "typings": "index.d.ts",
49
+ "sideEffects": false
50
+ }
@@ -1,7 +1,3 @@
1
- /*
2
- * Public API Surface of onshore-forms
3
- */
4
-
5
1
  export * from './lib/onshore-forms.service';
6
2
  export * from './lib/onshore-forms.component';
7
3
  export * from './lib/onshore-forms.module';
package/karma.conf.js DELETED
@@ -1,44 +0,0 @@
1
- // Karma configuration file, see link for more information
2
- // https://karma-runner.github.io/1.0/config/configuration-file.html
3
-
4
- module.exports = function (config) {
5
- config.set({
6
- basePath: '',
7
- frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
- plugins: [
9
- require('karma-jasmine'),
10
- require('karma-chrome-launcher'),
11
- require('karma-jasmine-html-reporter'),
12
- require('karma-coverage'),
13
- require('@angular-devkit/build-angular/plugins/karma')
14
- ],
15
- client: {
16
- jasmine: {
17
- // you can add configuration options for Jasmine here
18
- // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
- // for example, you can disable the random execution with `random: false`
20
- // or set a specific seed with `seed: 4321`
21
- },
22
- clearContext: false // leave Jasmine Spec Runner output visible in browser
23
- },
24
- jasmineHtmlReporter: {
25
- suppressAll: true // removes the duplicated traces
26
- },
27
- coverageReporter: {
28
- dir: require('path').join(__dirname, '../../coverage/onshore-forms'),
29
- subdir: '.',
30
- reporters: [
31
- { type: 'html' },
32
- { type: 'text-summary' }
33
- ]
34
- },
35
- reporters: ['progress', 'kjhtml'],
36
- port: 9876,
37
- colors: true,
38
- logLevel: config.LOG_INFO,
39
- autoWatch: true,
40
- browsers: ['Chrome'],
41
- singleRun: false,
42
- restartOnFileChange: true
43
- });
44
- };
package/ng-package.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/onshore-forms",
4
- "lib": {
5
- "entryFile": "src/public-api.ts"
6
- },
7
- "assets": [
8
- "./styles/scss/*.*",
9
- "./src/lib/components/*.*"
10
- ]
11
- }
@@ -1,46 +0,0 @@
1
- <!--<div class="flex flex-column mb-3">
2
- <div *ngIf="formTemplate.label" 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
- <p-autoComplete [placeholder]="formTemplate.placeholder"
11
- appendTo="body"
12
- [formControl]="this.ngControl.control"
13
- (onSelect)="selected($event)"
14
- (onUnselect)="selected($event)"
15
- (onClear)="searchClear()"
16
- [suggestions]="dataSearch"
17
- (completeMethod)="searchPrepare($event)"
18
- [size]="30"
19
- [minLength]="2"
20
- [multiple]="multiple"
21
- [delay]="1000"
22
- [unique]="true"
23
- [field]="selectedField"
24
- class="w-100">
25
- <ng-template let-item pTemplate="item">
26
- <div *ngIf="suggestionsHighlightedField">
27
- <span class="mr-1">
28
- <b>{{item[suggestionsHighlightedField]}}</b><br>
29
- </span>
30
- </div>
31
- <div [hidden]="suggestionsLineOneFields.length <= 0"><span *ngFor="let field of suggestionsLineOneFields">{{item[field]}} </span></div>
32
- <div [hidden]="suggestionsLineTwoFields.length <= 0"><span *ngFor="let field of suggestionsLineTwoFields">{{item[field]}} </span></div>
33
- </ng-template>
34
- </p-autoComplete>
35
-
36
- <small *ngIf="formTemplate.description"><i class="fa fa-info-circle"></i> {{formTemplate.description}}</small>
37
-
38
- <div *ngIf="ngControl.control.touched">
39
- <onshore-form-validation-output
40
- [validationErrors]="ngControl.control.errors"
41
- [externValidationPattern]="formTemplate.validationPatternTranslation">
42
- </onshore-form-validation-output>
43
- </div>
44
-
45
- </div>
46
- -->
@@ -1,133 +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 { OnshoreFormTemplateItem } from '../../models/form.models';
10
-
11
- @Component({
12
- selector: 'onshore-form-autocomplete-item',
13
- templateUrl: './form-autocomplete-item.component.html',
14
- changeDetection: ChangeDetectionStrategy.OnPush,
15
- })
16
- export class OnshoreFormAutocompleteItemComponent {
17
-
18
- }
19
- /*export class OnshoreFormAutocompleteItemComponent implements ControlValueAccessor, OnDestroy, OnInit {
20
- @Input() formTemplate: OnshoreFormTemplateItem;
21
- @Output() onSelect: EventEmitter<UnionDataType> = new EventEmitter();
22
- @Output() onClear: EventEmitter<boolean> = new EventEmitter();
23
-
24
- @Input() public dataType: DataType = DataType.user;
25
- @Input() public searchFields: string[] = [];
26
- @Input() public selectedField: string = '';
27
- @Input() public preventDuplicatesField: string = '';
28
- @Input() public suggestionsHighlightedField: string = '';
29
- @Input() public suggestionsLineOneFields: string[] = [];
30
- @Input() public suggestionsLineTwoFields: string[] = [];
31
- @Input() public multiple: boolean = false;
32
-
33
- disabled: boolean = false;
34
- dataSearch: UnionDataType[];
35
- selectedData: UnionDataType;
36
-
37
- selected(data: UnionDataType) {
38
- this.onSelect.emit(data);
39
- this.cdr.markForCheck();
40
- }
41
-
42
- searchClear() {
43
- this.dataSearch = [];
44
- this.ngControl.reset();
45
- this.onClear.emit();
46
- }
47
-
48
- searchPrepare(term: any) {
49
- if(term.query != '') {
50
- this.search(term.query);
51
- }else{
52
- this.dataSearch = [];
53
- this.ngControl.reset();
54
- this.onClear.emit();
55
- }
56
- }
57
-
58
- async search(searchTerm: string) {
59
- let filterParams = {};
60
-
61
- this.searchFields.forEach(field => {
62
- // @ts-ignore
63
- filterParams[field + '[regex]'] = searchTerm;
64
- });
65
-
66
- if(this.searchFields.length > 1) {
67
- // @ts-ignore
68
- filterParams['condition'] = 'or';
69
- }
70
-
71
- const data: UnionDataType[] = await this.apiService.getWithQuery(this.dataType, filterParams);
72
-
73
- if(this.preventDuplicatesField != '') {
74
- this.dataSearch = data.filter(item => {
75
- // @ts-ignore
76
- return !(this.ngControl?.value || []).find(value => value[this.preventDuplicatesField] === item[this.preventDuplicatesField]);
77
- });
78
- } else {
79
- this.dataSearch = data;
80
- }
81
- this.cdr.markForCheck();
82
- }
83
-
84
- public writeValue(obj: any): void {
85
- if(obj) {
86
- this.selectedData = obj;
87
- this.cdr.markForCheck();
88
- }
89
- }
90
-
91
- public registerOnChange(fn: any): void {
92
- if(this.ngControl.value) {
93
- this.selectedData = this.ngControl.value;
94
- this.cdr.markForCheck();
95
- }
96
- }
97
-
98
- public registerOnTouched(fn: any): void {}
99
-
100
- public setDisabledState?(isDisabled: boolean): void {
101
- this.disabled = isDisabled;
102
- }
103
-
104
- ngOnInit(): void {
105
- this.ngControl.control?.valueChanges.subscribe(() => {
106
- this.cdr.markForCheck();
107
- });
108
- this.ngControl.control?.statusChanges.subscribe(() => {
109
- this.cdr.markForCheck();
110
- });
111
- if(this.ngControl.control?.value == '' && this.formTemplate.default != undefined) {
112
- this.ngControl.control?.setValue(this.formTemplate.default);
113
- this.cdr.markForCheck();
114
- }
115
- if(this.formTemplate.enabled) {
116
- this.ngControl.control?.enable();
117
- } else {
118
- this.ngControl.control?.disable();
119
- }
120
- }
121
-
122
- ngOnDestroy() {
123
- this.ngControl.control?.disable();
124
- }
125
-
126
- constructor(private cdr: ChangeDetectorRef,
127
- private apiService: ApiService,
128
- @Self() @Optional() public ngControl: NgControl) {
129
-
130
- this.ngControl.valueAccessor = this;
131
- }
132
-
133
- }*/
@@ -1,23 +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
- <div class="p-field-checkbox flex">
11
- <p-checkbox class="align-self-start mt-1" [name]="formTemplate.name" [formControl]="ngControl.control" [binary]="true" [inputId]="formTemplate.name" [value]="ngControl.control.value" (onChange)="changeCheck($event)"></p-checkbox>
12
- <label class="mb-0 ml-2" [for]="formTemplate.name">{{formTemplate.description}}</label>
13
- </div>
14
-
15
- <div *ngIf="ngControl.control.touched">
16
- <onshore-form-validation-output
17
- [validationItems]="formTemplate.validationItems"
18
- [validationErrors]="ngControl.control.errors"
19
- [externValidationPattern]="formTemplate.validationPatternTranslation">
20
- </onshore-form-validation-output>
21
- </div>
22
-
23
- </div>
@@ -1,65 +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
-
12
- @Component({
13
- selector: 'onshore-form-checkbox-item',
14
- templateUrl: './form-checkbox-item.component.html',
15
- changeDetection: ChangeDetectionStrategy.OnPush,
16
- })
17
- export class OnshoreFormCheckboxItemComponent implements OnInit, ControlValueAccessor, OnChanges, OnDestroy {
18
- @Input() formTemplate!: OnshoreFormTemplateItem;
19
-
20
- disabled: boolean = false;
21
-
22
- // ControlValueAccessor interface
23
- writeValue(obj: any): void {}
24
- registerOnChange(fn: any): void {}
25
- registerOnTouched(fn: any): void {}
26
- setDisabledState?(isDisabled: boolean): void {
27
- this.disabled = isDisabled;
28
- }
29
-
30
- changeCheck(value: any) {
31
- this.ngControl.control?.setValue(value.checked);
32
- }
33
-
34
- ngOnInit(): void {
35
- this.ngControl.control?.valueChanges.subscribe(() => {
36
- this.cdr.markForCheck();
37
- });
38
- this.ngControl.control?.statusChanges.subscribe(() => {
39
- this.cdr.markForCheck();
40
- });
41
-
42
- if(this.ngControl.control?.value !== true && this.ngControl.control?.value !== false && this.formTemplate.default != undefined) {
43
- this.ngControl.control?.setValue(this.formTemplate.default);
44
- this.cdr.markForCheck();
45
- }
46
- if(this.formTemplate.enabled) {
47
- this.ngControl.control?.enable();
48
- } else {
49
- this.ngControl.control?.disable();
50
- }
51
- }
52
-
53
- ngOnChanges(changes: SimpleChanges) {
54
- this.cdr.markForCheck();
55
- }
56
-
57
- ngOnDestroy() {
58
- this.ngControl.control?.disable();
59
- }
60
-
61
- constructor(@Self() @Optional() public ngControl: NgControl,
62
- private cdr: ChangeDetectorRef) {
63
- this.ngControl.valueAccessor = this;
64
- }
65
- }
@@ -1,30 +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
- <div class="flex w-100">
11
- <p-colorPicker [(ngModel)]="colorPickerValue" format="hex" [inline]="false" appendTo="body" [baseZIndex]="99999" (onChange)="changeColor()"></p-colorPicker>
12
- <input class="w-100 ml-2"
13
- type="text"
14
- [name]="formTemplate.name"
15
- [placeholder]="formTemplate.label"
16
- [formControl]="ngControl.control"
17
- pInputText
18
- [value]="ngControl.control.value"
19
- (input)="changeInput($event)"/>
20
- </div>
21
-
22
- <div *ngIf="ngControl.control.touched">
23
- <onshore-form-validation-output
24
- [validationItems]="formTemplate.validationItems"
25
- [validationErrors]="ngControl.control.errors"
26
- [externValidationPattern]="formTemplate.validationPatternTranslation">
27
- </onshore-form-validation-output>
28
- </div>
29
-
30
- </div>
@@ -1,71 +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
- @Component({
12
- selector: 'onshore-form-colorpicker-item',
13
- templateUrl: './form-colorpicker-item.component.html',
14
- changeDetection: ChangeDetectionStrategy.OnPush,
15
- })
16
- export class OnshoreFormColorpickerItemComponent implements OnInit, OnChanges, ControlValueAccessor, OnDestroy {
17
- @Input() formTemplate!: OnshoreFormTemplateItem;
18
-
19
- disabled: boolean = false;
20
- colorPickerValue = '';
21
-
22
- // ControlValueAccessor interface
23
- writeValue(obj: any): void {}
24
- registerOnChange(fn: any): void {}
25
- registerOnTouched(fn: any): void {}
26
- setDisabledState?(isDisabled: boolean): void {
27
- this.disabled = isDisabled;
28
- }
29
-
30
- changeColor() {
31
- this.ngControl.control?.setValue(this.colorPickerValue);
32
- }
33
-
34
- changeInput(input: any) {
35
- this.colorPickerValue = input.target?.value;
36
- }
37
-
38
- ngOnInit(): void {
39
- this.ngControl.control?.valueChanges.subscribe(() => {
40
- this.cdr.markForCheck();
41
- });
42
- this.ngControl.control?.statusChanges.subscribe(() => {
43
- this.cdr.markForCheck();
44
- });
45
-
46
- if(this.ngControl.control?.value == '' && this.formTemplate.default != undefined) {
47
- this.ngControl.control?.setValue(this.formTemplate.default);
48
- this.colorPickerValue = this.formTemplate.default;
49
- this.cdr.markForCheck();
50
- }
51
- if(this.formTemplate.enabled) {
52
- this.ngControl.control?.enable();
53
- } else {
54
- this.ngControl.control?.disable();
55
- }
56
- }
57
-
58
- ngOnDestroy() {
59
- this.ngControl.control?.disable();
60
- }
61
-
62
- ngOnChanges(changes: SimpleChanges) {
63
- this.colorPickerValue = this.ngControl.control?.value;
64
- this.cdr.markForCheck();
65
- }
66
-
67
- constructor(@Self() @Optional() public ngControl: NgControl,
68
- private cdr: ChangeDetectorRef) {
69
- this.ngControl.valueAccessor = this;
70
- }
71
- }
@@ -1,44 +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
- <p-dropdown *ngIf="!multiple"
11
- class="w-100"
12
- [options]="formTemplate?.options"
13
- [formControl]="ngControl.control"
14
- [name]="formTemplate?.name"
15
- [placeholder]="formTemplate?.placeholder"
16
- [disabled]="disabled"
17
- [dataKey]="formTemplate?.optionDataKey"
18
- [showClear]="formTemplate?.settings?.showClear"
19
- (onClear)="clearSelection()"
20
- optionDisabled="disabled"
21
- appendTo="body">
22
- </p-dropdown>
23
-
24
- <p-multiSelect *ngIf="multiple"
25
- class="w-100"
26
- [options]="formTemplate?.options"
27
- [formControl]="ngControl.control"
28
- [name]="formTemplate?.name"
29
- [placeholder]="formTemplate?.placeholder"
30
- [disabled]="disabled"
31
- [dataKey]="formTemplate?.optionDataKey"
32
- display="chip"
33
- optionDisabled="disabled"
34
- appendTo="body"></p-multiSelect>
35
-
36
- <div *ngIf="ngControl.control.touched">
37
- <onshore-form-validation-output
38
- [validationItems]="formTemplate.validationItems"
39
- [validationErrors]="ngControl.control.errors"
40
- [externValidationPattern]="formTemplate?.validationPatternTranslation">
41
- </onshore-form-validation-output>
42
- </div>
43
-
44
- </div>
@@ -1,68 +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 { OnshoreDropdownSettings, OnshoreFormTemplateItem } from '../../models/form.models';
11
-
12
- @Component({
13
- selector: 'onshore-form-dropdown-item',
14
- templateUrl: './form-dropdown-item.component.html',
15
- changeDetection: ChangeDetectionStrategy.OnPush,
16
- })
17
- export class OnshoreFormDropdownItemComponent implements OnInit, OnChanges, ControlValueAccessor, OnChanges, OnDestroy {
18
- @Input() formTemplate!: OnshoreFormTemplateItem;
19
-
20
- disabled: boolean | undefined = false;
21
- multiple: boolean | undefined = false;
22
-
23
- // ControlValueAccessor interface
24
- writeValue(obj: any): void {}
25
- registerOnChange(fn: any): void {}
26
- registerOnTouched(fn: any): void {}
27
- setDisabledState?(isDisabled: boolean): void {
28
- this.disabled = isDisabled;
29
- }
30
-
31
- clearSelection() {
32
- this.ngControl.control?.setValue(null);
33
- }
34
-
35
- ngOnInit(): void {
36
- this.ngControl.control?.valueChanges.subscribe(() => {
37
- this.cdr.markForCheck();
38
- });
39
- this.ngControl.control?.statusChanges.subscribe(() => {
40
- this.cdr.markForCheck();
41
- });
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
- this.multiple = (this.formTemplate.settings as OnshoreDropdownSettings)?.multiple;
54
- }
55
-
56
- ngOnDestroy() {
57
- this.ngControl.control?.disable();
58
- }
59
-
60
- ngOnChanges(changes: SimpleChanges) {
61
- this.cdr.markForCheck();
62
- }
63
-
64
- constructor(@Self() @Optional() public ngControl: NgControl,
65
- private cdr: ChangeDetectorRef) {
66
- this.ngControl.valueAccessor = this;
67
- }
68
- }