@unicef-polymer/etools-form-builder 1.0.3 → 2.1.0-rc.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/dist/form-attachments-popup/form-attachments-popup.d.ts +10 -2
- package/dist/form-attachments-popup/form-attachments-popup.js +53 -48
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -5
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +79 -85
- package/dist/form-fields/abstract-field-base.class.d.ts +28 -0
- package/dist/form-fields/{base-field.js → abstract-field-base.class.js} +133 -112
- package/dist/form-fields/custom-elements.define.js +17 -5
- package/dist/form-fields/field-renderer-component.d.ts +20 -0
- package/dist/form-fields/field-renderer-component.js +245 -0
- package/dist/form-fields/index.d.ts +9 -5
- package/dist/form-fields/index.js +9 -5
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -0
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +198 -0
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -0
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +123 -0
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -0
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +56 -0
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -0
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +104 -0
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -0
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +43 -0
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -0
- package/dist/form-fields/single-fields/attachment-field.js +87 -0
- package/dist/form-fields/single-fields/base-field.d.ts +11 -0
- package/dist/form-fields/single-fields/base-field.js +57 -0
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -0
- package/dist/form-fields/single-fields/boolean-field.js +39 -0
- package/dist/form-fields/{number-field.d.ts → single-fields/number-field.d.ts} +1 -0
- package/dist/form-fields/{number-field.js → single-fields/number-field.js} +34 -21
- package/dist/form-fields/{scale-field.d.ts → single-fields/scale-field.d.ts} +4 -2
- package/dist/form-fields/{scale-field.js → single-fields/scale-field.js} +66 -54
- package/dist/form-fields/{text-field.d.ts → single-fields/text-field.d.ts} +0 -0
- package/dist/form-fields/{text-field.js → single-fields/text-field.js} +26 -21
- package/dist/form-fields/wide-field.d.ts +1 -1
- package/dist/form-fields/wide-field.js +3 -3
- package/dist/form-groups/form-abstract-group.d.ts +12 -12
- package/dist/form-groups/form-abstract-group.js +189 -166
- package/dist/form-groups/form-card.d.ts +1 -0
- package/dist/form-groups/form-card.js +35 -10
- package/dist/form-groups/form-collapsed-card.d.ts +3 -1
- package/dist/form-groups/form-collapsed-card.js +45 -25
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/lib/additional-components/confirmation-dialog.d.ts +16 -0
- package/dist/lib/additional-components/confirmation-dialog.js +61 -0
- package/dist/lib/additional-components/etools-fb-card.js +135 -128
- package/dist/lib/styles/attachments.styles.js +69 -66
- package/dist/lib/styles/form-builder-card.styles.js +46 -41
- package/dist/lib/styles/input-styles.js +53 -64
- package/dist/lib/styles/page-layout-styles.js +198 -198
- package/dist/lib/types/form-builder.interfaces.d.ts +2 -2
- package/dist/lib/types/form-builder.types.d.ts +8 -2
- package/dist/lib/utils/validations.helper.d.ts +3 -3
- package/dist/lib/utils/validations.helper.js +7 -7
- package/package.json +53 -52
- package/dist/form-fields/base-field.d.ts +0 -20
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import '@unicef-polymer/etools-dialog/etools-dialog';
|
|
2
|
+
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
3
|
+
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
4
|
+
import '@polymer/paper-button/paper-button';
|
|
5
|
+
import '@polymer/iron-icons/iron-icons';
|
|
1
6
|
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
7
|
import { GenericObject } from '../lib/types/global.types';
|
|
3
8
|
import { BlueprintMetadata } from '../lib/types/form-builder.types';
|
|
@@ -33,10 +38,14 @@ export declare type OfflineSavedAttachment = {
|
|
|
33
38
|
extraInfo: string[];
|
|
34
39
|
unsynced: boolean;
|
|
35
40
|
};
|
|
36
|
-
declare type UploadFinishedDetails = {
|
|
41
|
+
export declare type UploadFinishedDetails = {
|
|
37
42
|
success: (UploadedAttachment | OfflineSavedAttachment)[];
|
|
38
43
|
error: any[];
|
|
39
44
|
};
|
|
45
|
+
export declare type SingleUploadFinishedDetails = {
|
|
46
|
+
success: UploadedAttachment | OfflineSavedAttachment;
|
|
47
|
+
error: any[];
|
|
48
|
+
};
|
|
40
49
|
export declare class FormAttachmentsPopup extends LitElement {
|
|
41
50
|
dialogOpened: boolean;
|
|
42
51
|
saveBtnClicked: boolean;
|
|
@@ -74,4 +83,3 @@ export declare class FormAttachmentsPopup extends LitElement {
|
|
|
74
83
|
private isOfflineSavedAttachment;
|
|
75
84
|
static get styles(): CSSResultArray;
|
|
76
85
|
}
|
|
77
|
-
export {};
|
|
@@ -4,6 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
import '@unicef-polymer/etools-dialog/etools-dialog';
|
|
8
|
+
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
9
|
+
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
10
|
+
import '@polymer/paper-button/paper-button';
|
|
11
|
+
import '@polymer/iron-icons/iron-icons';
|
|
7
12
|
import { css, LitElement, property, query } from 'lit-element';
|
|
8
13
|
import { clone, equals } from 'ramda';
|
|
9
14
|
import { template } from './form-attachments-popup.tpl';
|
|
@@ -170,54 +175,54 @@ export class FormAttachmentsPopup extends LitElement {
|
|
|
170
175
|
return [
|
|
171
176
|
SharedStyles,
|
|
172
177
|
AttachmentsStyles,
|
|
173
|
-
css `
|
|
174
|
-
.file-selector__type-dropdown {
|
|
175
|
-
flex-basis: 25%;
|
|
176
|
-
padding-left: 8px;
|
|
177
|
-
padding-right: 8px;
|
|
178
|
-
}
|
|
179
|
-
.file-selector__filename {
|
|
180
|
-
flex-basis: 35%;
|
|
181
|
-
}
|
|
182
|
-
.file-selector__download {
|
|
183
|
-
flex-basis: 10%;
|
|
184
|
-
}
|
|
185
|
-
.file-selector__delete {
|
|
186
|
-
flex-basis: 10%;
|
|
187
|
-
}
|
|
188
|
-
.file-selector-container.with-type-dropdown {
|
|
189
|
-
flex-wrap: nowrap;
|
|
190
|
-
}
|
|
191
|
-
.popup-container {
|
|
192
|
-
padding: 12px 12px 0;
|
|
193
|
-
}
|
|
194
|
-
@media (max-width: 380px) {
|
|
195
|
-
.file-selector-container.with-type-dropdown {
|
|
196
|
-
justify-content: center;
|
|
197
|
-
}
|
|
198
|
-
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
199
|
-
flex-basis: 90%;
|
|
200
|
-
}
|
|
201
|
-
.file-selector__filename {
|
|
202
|
-
flex-basis: 90%;
|
|
203
|
-
}
|
|
204
|
-
.file-selector__download {
|
|
205
|
-
flex-basis: 5%;
|
|
206
|
-
}
|
|
207
|
-
.file-selector__delete {
|
|
208
|
-
flex-basis: 5%;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
@media (max-width: 600px) {
|
|
212
|
-
etools-dropdown {
|
|
213
|
-
padding: 0;
|
|
214
|
-
}
|
|
215
|
-
.file-selector-container.with-type-dropdown {
|
|
216
|
-
border-bottom: 1px solid lightgrey;
|
|
217
|
-
flex-wrap: wrap;
|
|
218
|
-
padding-bottom: 10px;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
178
|
+
css `
|
|
179
|
+
.file-selector__type-dropdown {
|
|
180
|
+
flex-basis: 25%;
|
|
181
|
+
padding-left: 8px;
|
|
182
|
+
padding-right: 8px;
|
|
183
|
+
}
|
|
184
|
+
.file-selector__filename {
|
|
185
|
+
flex-basis: 35%;
|
|
186
|
+
}
|
|
187
|
+
.file-selector__download {
|
|
188
|
+
flex-basis: 10%;
|
|
189
|
+
}
|
|
190
|
+
.file-selector__delete {
|
|
191
|
+
flex-basis: 10%;
|
|
192
|
+
}
|
|
193
|
+
.file-selector-container.with-type-dropdown {
|
|
194
|
+
flex-wrap: nowrap;
|
|
195
|
+
}
|
|
196
|
+
.popup-container {
|
|
197
|
+
padding: 12px 12px 0;
|
|
198
|
+
}
|
|
199
|
+
@media (max-width: 380px) {
|
|
200
|
+
.file-selector-container.with-type-dropdown {
|
|
201
|
+
justify-content: center;
|
|
202
|
+
}
|
|
203
|
+
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
204
|
+
flex-basis: 90%;
|
|
205
|
+
}
|
|
206
|
+
.file-selector__filename {
|
|
207
|
+
flex-basis: 90%;
|
|
208
|
+
}
|
|
209
|
+
.file-selector__download {
|
|
210
|
+
flex-basis: 5%;
|
|
211
|
+
}
|
|
212
|
+
.file-selector__delete {
|
|
213
|
+
flex-basis: 5%;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
@media (max-width: 600px) {
|
|
217
|
+
etools-dropdown {
|
|
218
|
+
padding: 0;
|
|
219
|
+
}
|
|
220
|
+
.file-selector-container.with-type-dropdown {
|
|
221
|
+
border-bottom: 1px solid lightgrey;
|
|
222
|
+
flex-wrap: wrap;
|
|
223
|
+
padding-bottom: 10px;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
221
226
|
`
|
|
222
227
|
];
|
|
223
228
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { FormAttachmentsPopup } from './form-attachments-popup';
|
|
2
2
|
import { TemplateResult } from 'lit-html';
|
|
3
|
-
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
4
|
-
import '@unicef-polymer/etools-dialog/etools-dialog';
|
|
5
|
-
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
6
|
-
import '@polymer/paper-button/paper-button';
|
|
7
|
-
import '@polymer/iron-icons/iron-icons';
|
|
8
3
|
export declare function template(this: FormAttachmentsPopup): TemplateResult;
|
|
@@ -1,95 +1,89 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
3
|
-
import '@unicef-polymer/etools-dialog/etools-dialog';
|
|
4
|
-
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
5
|
-
import '@polymer/paper-button/paper-button';
|
|
6
|
-
import '@polymer/iron-icons/iron-icons';
|
|
7
2
|
import { InputStyles } from '../lib/styles/input-styles';
|
|
8
3
|
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
9
4
|
export function template() {
|
|
10
5
|
var _a;
|
|
11
|
-
return html `
|
|
12
|
-
${InputStyles} ${DialogStyles}
|
|
13
|
-
<etools-dialog
|
|
14
|
-
id="form-attachments-dialog"
|
|
15
|
-
size="md"
|
|
16
|
-
no-padding
|
|
17
|
-
keep-dialog-open
|
|
18
|
-
?opened="${this.dialogOpened}"
|
|
19
|
-
.okBtnText="Save"
|
|
20
|
-
.hideConfirmBtn="${this.readonly}"
|
|
21
|
-
dialog-title="${this.popupTitle}"
|
|
22
|
-
@close="${this.onClose}"
|
|
23
|
-
@confirm-btn-clicked="${() => this.saveChanges()}"
|
|
24
|
-
>
|
|
25
|
-
<!-- Link is used to download attachments -->
|
|
26
|
-
<a id="link" target="_blank" hidden></a>
|
|
27
|
-
|
|
28
|
-
<div class="popup-container">
|
|
6
|
+
return html `
|
|
7
|
+
${InputStyles} ${DialogStyles}
|
|
8
|
+
<etools-dialog
|
|
9
|
+
id="form-attachments-dialog"
|
|
10
|
+
size="md"
|
|
11
|
+
no-padding
|
|
12
|
+
keep-dialog-open
|
|
13
|
+
?opened="${this.dialogOpened}"
|
|
14
|
+
.okBtnText="Save"
|
|
15
|
+
.hideConfirmBtn="${this.readonly}"
|
|
16
|
+
dialog-title="${this.popupTitle}"
|
|
17
|
+
@close="${this.onClose}"
|
|
18
|
+
@confirm-btn-clicked="${() => this.saveChanges()}"
|
|
19
|
+
>
|
|
20
|
+
<!-- Link is used to download attachments -->
|
|
21
|
+
<a id="link" target="_blank" hidden></a>
|
|
22
|
+
|
|
23
|
+
<div class="popup-container">
|
|
29
24
|
${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
|
|
30
25
|
var _a, _b;
|
|
31
|
-
return html `
|
|
32
|
-
<div class="file-selector-container with-type-dropdown">
|
|
33
|
-
<!-- Type select Dropdown -->
|
|
34
|
-
<etools-dropdown
|
|
35
|
-
class="type-dropdown
|
|
36
|
-
.selected="${attachment.file_type}"
|
|
37
|
-
@etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
|
|
38
|
-
trigger-value-change-event
|
|
39
|
-
label="Document Type"
|
|
40
|
-
placeholder="Select Document Type"
|
|
41
|
-
required
|
|
42
|
-
?readonly="${this.readonly}"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
option-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</div>
|
|
26
|
+
return html `
|
|
27
|
+
<div class="file-selector-container with-type-dropdown">
|
|
28
|
+
<!-- Type select Dropdown -->
|
|
29
|
+
<etools-dropdown
|
|
30
|
+
class="type-dropdown file-selector__type-dropdown"
|
|
31
|
+
.selected="${attachment.file_type}"
|
|
32
|
+
@etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
|
|
33
|
+
trigger-value-change-event
|
|
34
|
+
label="Document Type"
|
|
35
|
+
placeholder="Select Document Type"
|
|
36
|
+
required
|
|
37
|
+
?readonly="${this.readonly}"
|
|
38
|
+
hide-search
|
|
39
|
+
.options="${(_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.options.target_attachments_file_types) === null || _b === void 0 ? void 0 : _b.values}"
|
|
40
|
+
option-label="label"
|
|
41
|
+
option-value="value"
|
|
42
|
+
?invalid="${this.checkFileType(index)}"
|
|
43
|
+
.errorMessage="${this.retrieveErrorMessage(index)}"
|
|
44
|
+
allow-outside-scroll
|
|
45
|
+
dynamic-align
|
|
46
|
+
></etools-dropdown>
|
|
47
|
+
|
|
48
|
+
<!-- File name component -->
|
|
49
|
+
<div class="filename-container file-selector__filename">
|
|
50
|
+
<iron-icon class="file-icon" icon="attachment"></iron-icon>
|
|
51
|
+
<span class="filename" title="${attachment.filename}">${attachment.filename}</span>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<!-- Download Button -->
|
|
55
|
+
<paper-button
|
|
56
|
+
?hidden="${!attachment.url}"
|
|
57
|
+
class="download-button file-selector__download"
|
|
58
|
+
@tap="${() => this.downloadFile(attachment)}"
|
|
59
|
+
>
|
|
60
|
+
<iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
|
|
61
|
+
Download
|
|
62
|
+
</paper-button>
|
|
63
|
+
|
|
64
|
+
<!-- Delete Button -->
|
|
65
|
+
<paper-button
|
|
66
|
+
class="delete-button file-selector__delete"
|
|
67
|
+
?hidden="${this.readonly}"
|
|
68
|
+
@tap="${() => this.deleteAttachment(index)}"
|
|
69
|
+
>
|
|
70
|
+
Delete
|
|
71
|
+
</paper-button>
|
|
72
|
+
</div>
|
|
79
73
|
`;
|
|
80
|
-
})}
|
|
81
|
-
|
|
82
|
-
<!-- Upload button -->
|
|
83
|
-
<etools-upload-multi
|
|
84
|
-
class="with-padding"
|
|
85
|
-
activate-offline
|
|
86
|
-
?hidden="${this.readonly}"
|
|
87
|
-
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
88
|
-
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
89
|
-
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
90
|
-
>
|
|
91
|
-
</etools-upload-multi>
|
|
92
|
-
</div>
|
|
93
|
-
</etools-dialog>
|
|
74
|
+
})}
|
|
75
|
+
|
|
76
|
+
<!-- Upload button -->
|
|
77
|
+
<etools-upload-multi
|
|
78
|
+
class="with-padding"
|
|
79
|
+
activate-offline
|
|
80
|
+
?hidden="${this.readonly}"
|
|
81
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
82
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
83
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
84
|
+
>
|
|
85
|
+
</etools-upload-multi>
|
|
86
|
+
</div>
|
|
87
|
+
</etools-dialog>
|
|
94
88
|
`;
|
|
95
89
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
|
+
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
3
|
+
/**
|
|
4
|
+
* Class that contains common properties and methods for single and repeatable fields
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
|
|
7
|
+
questionText: string;
|
|
8
|
+
set isReadonly(readonly: boolean);
|
|
9
|
+
get isReadonly(): boolean;
|
|
10
|
+
required: boolean;
|
|
11
|
+
placeholder: string;
|
|
12
|
+
value: T | null;
|
|
13
|
+
validators: FieldValidator[];
|
|
14
|
+
touched: boolean;
|
|
15
|
+
set defaultValue(value: any);
|
|
16
|
+
private _defaultValue;
|
|
17
|
+
private _readonly;
|
|
18
|
+
protected render(): TemplateResult;
|
|
19
|
+
protected questionTemplate(): TemplateResult;
|
|
20
|
+
protected metaValidation(value: unknown): string | null;
|
|
21
|
+
private setDefaultValue;
|
|
22
|
+
protected abstract valueChanged(...args: any): void;
|
|
23
|
+
protected abstract customValidation(value: unknown): string | null;
|
|
24
|
+
protected abstract controlTemplate(...args: any): TemplateResult;
|
|
25
|
+
protected abstract setValue(value: T): void;
|
|
26
|
+
protected abstract validateField(value: T): void;
|
|
27
|
+
static get styles(): CSSResultArray;
|
|
28
|
+
}
|
|
@@ -4,151 +4,172 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
9
|
-
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
7
|
+
import { LitElement, property, css, html } from 'lit-element';
|
|
10
8
|
import { validate } from '../lib/utils/validations.helper';
|
|
11
|
-
|
|
9
|
+
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
10
|
+
/**
|
|
11
|
+
* Class that contains common properties and methods for single and repeatable fields
|
|
12
|
+
*/
|
|
13
|
+
export class AbstractFieldBaseClass extends LitElement {
|
|
12
14
|
constructor() {
|
|
13
15
|
super(...arguments);
|
|
14
16
|
this.questionText = '';
|
|
15
|
-
this.isReadonly = false;
|
|
16
17
|
this.required = false;
|
|
18
|
+
this.placeholder = '';
|
|
17
19
|
this.value = null;
|
|
18
|
-
this._errorMessage = null;
|
|
19
20
|
this.validators = [];
|
|
21
|
+
this.touched = false;
|
|
22
|
+
this._readonly = false;
|
|
23
|
+
}
|
|
24
|
+
set isReadonly(readonly) {
|
|
25
|
+
this._readonly = readonly;
|
|
26
|
+
this.setDefaultValue(readonly, this._defaultValue);
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
this.
|
|
28
|
+
get isReadonly() {
|
|
29
|
+
return this._readonly;
|
|
23
30
|
}
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
set defaultValue(value) {
|
|
32
|
+
this._defaultValue = value;
|
|
33
|
+
this.setDefaultValue(this._readonly, value);
|
|
34
|
+
this.requestUpdate();
|
|
26
35
|
}
|
|
27
36
|
render() {
|
|
28
|
-
return html `
|
|
29
|
-
<div class="finding-container">
|
|
30
|
-
<div class="question"><slot>${this.questionTemplate()}</slot></div>
|
|
31
|
-
<div class="question-control">${this.controlTemplate()}</div>
|
|
32
|
-
</div>
|
|
37
|
+
return html `
|
|
38
|
+
<div class="finding-container">
|
|
39
|
+
<div class="question"><slot>${this.questionTemplate()}</slot></div>
|
|
40
|
+
<div class="question-control">${this.controlTemplate()}</div>
|
|
41
|
+
</div>
|
|
33
42
|
`;
|
|
34
43
|
}
|
|
35
44
|
questionTemplate() {
|
|
36
|
-
return html
|
|
37
|
-
}
|
|
38
|
-
valueChanged(newValue) {
|
|
39
|
-
this.validateField(newValue);
|
|
40
|
-
if (newValue !== this.value) {
|
|
41
|
-
this.value = newValue;
|
|
42
|
-
fireEvent(this, 'value-changed', { value: newValue });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
validateField(value) {
|
|
46
|
-
let errorMessage;
|
|
47
|
-
if (this.required && !value) {
|
|
48
|
-
errorMessage = 'This field is required!';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
errorMessage = this.metaValidation(value);
|
|
52
|
-
}
|
|
53
|
-
if (this._errorMessage !== errorMessage) {
|
|
54
|
-
fireEvent(this, 'error-changed', { error: errorMessage });
|
|
55
|
-
this._errorMessage = errorMessage;
|
|
56
|
-
this.requestUpdate();
|
|
57
|
-
}
|
|
45
|
+
return html `<span class="question-text">${this.questionText}</span>`;
|
|
58
46
|
}
|
|
59
47
|
metaValidation(value) {
|
|
60
48
|
const message = validate(this.validators, value);
|
|
61
49
|
return message ? message : this.customValidation(value);
|
|
62
50
|
}
|
|
51
|
+
setDefaultValue(readonly, defaultValue) {
|
|
52
|
+
if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.getUpdateComplete().then(() => {
|
|
56
|
+
if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
|
|
57
|
+
this.setValue(defaultValue);
|
|
58
|
+
this.validateField(defaultValue);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
63
62
|
static get styles() {
|
|
64
63
|
// language=CSS
|
|
65
64
|
return [
|
|
66
65
|
FlexLayoutClasses,
|
|
67
|
-
css `
|
|
68
|
-
:host {
|
|
69
|
-
display: block;
|
|
70
|
-
width: 100%;
|
|
71
|
-
padding: 0 25px 0 45px;
|
|
72
|
-
box-sizing: border-box;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.finding-container {
|
|
76
|
-
width: 100%;
|
|
77
|
-
display: flex;
|
|
78
|
-
}
|
|
79
|
-
.flex-wrapping {
|
|
80
|
-
flex-wrap: wrap;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.question-control
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
66
|
+
css `
|
|
67
|
+
:host {
|
|
68
|
+
display: block;
|
|
69
|
+
width: 100%;
|
|
70
|
+
padding: 0 25px 0 45px;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.finding-container {
|
|
75
|
+
width: 100%;
|
|
76
|
+
display: flex;
|
|
77
|
+
}
|
|
78
|
+
.flex-wrapping {
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:host(.wide) .finding-container {
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host(.wide) .question {
|
|
87
|
+
margin-bottom: -8px;
|
|
88
|
+
min-height: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.question-control,
|
|
92
|
+
.question {
|
|
93
|
+
min-width: 0;
|
|
94
|
+
min-height: 57px;
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
}
|
|
98
|
+
.question {
|
|
99
|
+
flex: 2;
|
|
100
|
+
}
|
|
101
|
+
.question-control {
|
|
102
|
+
flex: 3;
|
|
103
|
+
}
|
|
104
|
+
.add-button {
|
|
105
|
+
padding: 3px;
|
|
106
|
+
margin: 10px;
|
|
107
|
+
background: transparent;
|
|
108
|
+
color: var(--primary-color);
|
|
109
|
+
border: 1px solid;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.full-width,
|
|
113
|
+
paper-input,
|
|
114
|
+
paper-textarea {
|
|
115
|
+
width: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.question-text {
|
|
119
|
+
font-weight: 500;
|
|
120
|
+
font-size: 13px;
|
|
121
|
+
color: var(--primary-text-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
paper-input,
|
|
125
|
+
paper-textarea {
|
|
126
|
+
outline: none !important;
|
|
127
|
+
}
|
|
128
|
+
paper-input[required],
|
|
129
|
+
paper-textarea[required] {
|
|
130
|
+
--paper-input-container-label_-_background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221235%22%20height%3D%221175%22%3E%3Cpath%20fill%3D%22%23de0000%22%20d%3D%22M0%2C449h1235l-999%2C726%20382-1175%20382%2C1175z%22%2F%3E%3C%2Fsvg%3E')
|
|
131
|
+
no-repeat 98% 14%/7px;
|
|
132
|
+
--paper-input-container-label_-_max-width: max-content;
|
|
133
|
+
--paper-input-container-label_-_padding-right: 15px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
iron-icon[icon='close'] {
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.error-text {
|
|
141
|
+
color: var(--error-color);
|
|
142
|
+
font-size: 12px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@media (max-width: 1080px) {
|
|
146
|
+
:host {
|
|
147
|
+
padding: 0 15px;
|
|
148
|
+
}
|
|
149
|
+
.finding-container {
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
}
|
|
152
|
+
.question,
|
|
153
|
+
.question-control {
|
|
154
|
+
flex: 0 1 auto;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
136
157
|
`
|
|
137
158
|
];
|
|
138
159
|
}
|
|
139
160
|
}
|
|
140
161
|
__decorate([
|
|
141
162
|
property({ type: String })
|
|
142
|
-
],
|
|
163
|
+
], AbstractFieldBaseClass.prototype, "questionText", void 0);
|
|
143
164
|
__decorate([
|
|
144
165
|
property({ type: Boolean, attribute: 'is-readonly' })
|
|
145
|
-
],
|
|
166
|
+
], AbstractFieldBaseClass.prototype, "isReadonly", null);
|
|
146
167
|
__decorate([
|
|
147
|
-
property({ type: Boolean, attribute: 'required'
|
|
148
|
-
],
|
|
168
|
+
property({ type: Boolean, attribute: 'required' })
|
|
169
|
+
], AbstractFieldBaseClass.prototype, "required", void 0);
|
|
149
170
|
__decorate([
|
|
150
171
|
property()
|
|
151
|
-
],
|
|
172
|
+
], AbstractFieldBaseClass.prototype, "placeholder", void 0);
|
|
152
173
|
__decorate([
|
|
153
174
|
property()
|
|
154
|
-
],
|
|
175
|
+
], AbstractFieldBaseClass.prototype, "value", void 0);
|