onshore-forms 0.0.1
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.
- package/README.md +1 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +11 -0
- package/package.json +39 -0
- package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.html +46 -0
- package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.scss +0 -0
- package/src/lib/components/form-autocomplete-item/form-autocomplete-item.component.ts +133 -0
- package/src/lib/components/form-checkbox-item/form-checkbox-item.component.html +23 -0
- package/src/lib/components/form-checkbox-item/form-checkbox-item.component.scss +0 -0
- package/src/lib/components/form-checkbox-item/form-checkbox-item.component.ts +65 -0
- package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.html +30 -0
- package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.scss +0 -0
- package/src/lib/components/form-colorpicker-item/form-colorpicker-item.component.ts +71 -0
- package/src/lib/components/form-dropdown-item/form-dropdown-item.component.html +44 -0
- package/src/lib/components/form-dropdown-item/form-dropdown-item.component.scss +0 -0
- package/src/lib/components/form-dropdown-item/form-dropdown-item.component.ts +68 -0
- package/src/lib/components/form-image-item/form-image-item.component.html +79 -0
- package/src/lib/components/form-image-item/form-image-item.component.scss +3 -0
- package/src/lib/components/form-image-item/form-image-item.component.ts +155 -0
- package/src/lib/components/form-input-item/form-input-item.component.html +81 -0
- package/src/lib/components/form-input-item/form-input-item.component.scss +3 -0
- package/src/lib/components/form-input-item/form-input-item.component.ts +66 -0
- package/src/lib/components/form-switch-item/form-switch-item.component.html +8 -0
- package/src/lib/components/form-switch-item/form-switch-item.component.scss +0 -0
- package/src/lib/components/form-switch-item/form-switch-item.component.ts +72 -0
- package/src/lib/components/form-textarea-item/form-textarea-item.component.html +39 -0
- package/src/lib/components/form-textarea-item/form-textarea-item.component.scss +0 -0
- package/src/lib/components/form-textarea-item/form-textarea-item.component.ts +64 -0
- package/src/lib/components/form-validation-output/form-validation-output.component.html +2 -0
- package/src/lib/components/form-validation-output/form-validation-output.component.scss +1 -0
- package/src/lib/components/form-validation-output/form-validation-output.component.ts +43 -0
- package/src/lib/enums/form.enums.ts +24 -0
- package/src/lib/models/form.models.ts +70 -0
- package/src/lib/onshore-forms.component.ts +20 -0
- package/src/lib/onshore-forms.module.ts +78 -0
- package/src/lib/onshore-forms.service.ts +172 -0
- package/src/public-api.ts +18 -0
- package/src/test.ts +27 -0
- package/styles/css/main.css +1 -0
- package/styles/css/theme1.css +1 -0
- package/styles/scss/main.scss +4 -0
- package/styles/scss/theme1.scss +8 -0
- package/tsconfig.lib.json +16 -0
- package/tsconfig.lib.prod.json +12 -0
- package/tsconfig.spec.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# OnShore FormBuilder
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.0.1",
|
|
3
|
+
"name": "onshore-forms",
|
|
4
|
+
"description": "OnShore Angular Form Builder",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Michael Bösken",
|
|
7
|
+
"email": "mboesken@onshore.tv"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://onshore.tv",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/OnShore-Development/onshore_libs.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/OnShore-Development/onshore_libs.git/issues"
|
|
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
|
+
"peerDependencies": {
|
|
25
|
+
"@angular/common": "^14.2.0",
|
|
26
|
+
"@angular/core": "^14.2.0",
|
|
27
|
+
"primeicons": "^6.0.1",
|
|
28
|
+
"primeng": "^14.1.2",
|
|
29
|
+
"primeflex": "^3.2.1"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"tslib": "^2.3.0"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
"./theme1": {
|
|
36
|
+
"sass": "./styles/theme1/style.scss"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
-->
|
|
File without changes
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
}*/
|
|
@@ -0,0 +1,23 @@
|
|
|
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>
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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>
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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>
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
-->
|