@unicef-polymer/etools-form-builder 0.1.25 → 1.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/dist/form-attachments-popup/form-attachments-popup.d.ts +77 -77
- package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
- package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
- package/dist/form-attachments-popup/form-attachments-popup.js +191 -191
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +8 -8
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +15 -15
- package/dist/form-attachments-popup/index.d.ts +2 -2
- package/dist/form-attachments-popup/index.js +2 -2
- package/dist/form-fields/base-field.d.ts +20 -20
- package/dist/form-fields/base-field.js +80 -80
- package/dist/form-fields/custom-elements.define.d.ts +1 -1
- package/dist/form-fields/custom-elements.define.js +11 -11
- package/dist/form-fields/index.d.ts +5 -5
- package/dist/form-fields/index.js +5 -5
- package/dist/form-fields/number-field.d.ts +9 -9
- package/dist/form-fields/number-field.js +24 -24
- package/dist/form-fields/scale-field.d.ts +16 -16
- package/dist/form-fields/scale-field.js +38 -38
- package/dist/form-fields/text-field.d.ts +8 -8
- package/dist/form-fields/text-field.js +19 -19
- package/dist/form-fields/wide-field.d.ts +11 -11
- package/dist/form-fields/wide-field.js +36 -36
- package/dist/form-groups/custom-elements.define.d.ts +1 -1
- package/dist/form-groups/custom-elements.define.js +9 -9
- package/dist/form-groups/form-abstract-group.d.ts +60 -60
- package/dist/form-groups/form-abstract-group.js +199 -199
- package/dist/form-groups/form-card.d.ts +31 -31
- package/dist/form-groups/form-card.js +69 -69
- package/dist/form-groups/form-collapsed-card.d.ts +68 -68
- package/dist/form-groups/form-collapsed-card.js +208 -207
- package/dist/form-groups/index.d.ts +3 -3
- package/dist/form-groups/index.js +3 -3
- package/dist/index.d.ts +14 -14
- package/dist/index.js +19 -19
- package/dist/lib/additional-components/etools-fb-card.d.ts +16 -16
- package/dist/lib/additional-components/etools-fb-card.js +80 -80
- package/dist/lib/styles/attachments.styles.d.ts +2 -2
- package/dist/lib/styles/attachments.styles.js +3 -3
- package/dist/lib/styles/card-styles.d.ts +2 -2
- package/dist/lib/styles/card-styles.js +3 -3
- package/dist/lib/styles/dialog.styles.d.ts +2 -2
- package/dist/lib/styles/dialog.styles.js +3 -3
- package/dist/lib/styles/elevation-styles.d.ts +9 -9
- package/dist/lib/styles/elevation-styles.js +10 -10
- package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
- package/dist/lib/styles/flex-layout-classes.js +3 -3
- package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
- package/dist/lib/styles/form-builder-card.styles.js +3 -3
- package/dist/lib/styles/input-styles.d.ts +2 -2
- package/dist/lib/styles/input-styles.js +5 -5
- package/dist/lib/styles/page-layout-styles.d.ts +2 -2
- package/dist/lib/styles/page-layout-styles.js +3 -3
- package/dist/lib/styles/shared-styles.d.ts +2 -2
- package/dist/lib/styles/shared-styles.js +3 -3
- package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
- package/dist/lib/types/form-builder.types.d.ts +53 -53
- package/dist/lib/types/global.types.d.ts +4 -4
- package/dist/lib/utils/dialog.d.ts +10 -10
- package/dist/lib/utils/dialog.js +21 -21
- package/dist/lib/utils/fire-custom-event.d.ts +1 -1
- package/dist/lib/utils/fire-custom-event.js +7 -7
- package/dist/lib/utils/validations.helper.d.ts +26 -26
- package/dist/lib/utils/validations.helper.js +35 -35
- package/package.json +7 -7
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { LitElement, property, html, css } from 'lit-element';
|
|
8
|
-
import '../form-fields/text-field';
|
|
9
|
-
import '../form-fields/number-field';
|
|
10
|
-
import '../form-fields/scale-field';
|
|
11
|
-
import '../form-fields/wide-field';
|
|
12
|
-
import '@polymer/paper-input/paper-textarea';
|
|
13
|
-
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
14
|
-
import { pageLayoutStyles } from '../lib/styles/page-layout-styles';
|
|
15
|
-
import { elevationStyles } from '../lib/styles/elevation-styles';
|
|
16
|
-
import { CardStyles } from '../lib/styles/card-styles';
|
|
17
|
-
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
18
|
-
import { FormBuilderCardStyles } from '..';
|
|
19
|
-
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
20
|
-
import { clone } from 'ramda';
|
|
21
|
-
export var FieldTypes;
|
|
22
|
-
(function (FieldTypes) {
|
|
23
|
-
FieldTypes["FILE_TYPE"] = "file";
|
|
24
|
-
FieldTypes["TEXT_TYPE"] = "text";
|
|
25
|
-
FieldTypes["NUMBER_TYPE"] = "number";
|
|
26
|
-
FieldTypes["BOOL_TYPE"] = "bool";
|
|
27
|
-
FieldTypes["SCALE_TYPE"] = "likert_scale";
|
|
28
|
-
FieldTypes["NUMBER_INTEGER_TYPE"] = "number-integer";
|
|
29
|
-
FieldTypes["NUMBER_FLOAT_TYPE"] = "number-float";
|
|
30
|
-
})(FieldTypes || (FieldTypes = {}));
|
|
31
|
-
export var StructureTypes;
|
|
32
|
-
(function (StructureTypes) {
|
|
33
|
-
StructureTypes["WIDE"] = "wide";
|
|
34
|
-
StructureTypes["ADDITIONAL"] = "additional";
|
|
35
|
-
StructureTypes["CARD"] = "card";
|
|
36
|
-
StructureTypes["ABSTRACT"] = "abstract";
|
|
37
|
-
StructureTypes["COLLAPSED"] = "collapse";
|
|
38
|
-
StructureTypes["ATTACHMENTS_BUTTON"] = "floating_attachments";
|
|
39
|
-
})(StructureTypes || (StructureTypes = {}));
|
|
40
|
-
export class FormAbstractGroup extends LitElement {
|
|
41
|
-
constructor() {
|
|
42
|
-
super(...arguments);
|
|
43
|
-
this.parentGroupName = '';
|
|
44
|
-
this.readonly = true;
|
|
45
|
-
this._errors = {};
|
|
46
|
-
this._value = {};
|
|
47
|
-
this.computedPath = [];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Make value property immutable
|
|
51
|
-
* @param value
|
|
52
|
-
*/
|
|
53
|
-
set value(value) {
|
|
54
|
-
this._value = this.groupStructure.name === 'root' ? clone(value) : value;
|
|
55
|
-
}
|
|
56
|
-
get value() {
|
|
57
|
-
return this._value;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Setter for handling error.
|
|
61
|
-
* Normally we wouldn't have errors as string or string[] for FormGroups.
|
|
62
|
-
* In cases they appear - show toast with error text and reset it.
|
|
63
|
-
* Otherwise it will be impossible to clear that error from field elements
|
|
64
|
-
* @param errors
|
|
65
|
-
*/
|
|
66
|
-
set errors(errors) {
|
|
67
|
-
if (Array.isArray(errors)) {
|
|
68
|
-
fireEvent(this, 'toast', { text: errors[0] });
|
|
69
|
-
fireEvent(this, 'error-changed', { error: null });
|
|
70
|
-
}
|
|
71
|
-
else if (errors) {
|
|
72
|
-
this._errors = errors;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
render() {
|
|
76
|
-
if (!this.groupStructure || !this.metadata) {
|
|
77
|
-
return html ``;
|
|
78
|
-
}
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, property, html, css } from 'lit-element';
|
|
8
|
+
import '../form-fields/text-field';
|
|
9
|
+
import '../form-fields/number-field';
|
|
10
|
+
import '../form-fields/scale-field';
|
|
11
|
+
import '../form-fields/wide-field';
|
|
12
|
+
import '@polymer/paper-input/paper-textarea';
|
|
13
|
+
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
14
|
+
import { pageLayoutStyles } from '../lib/styles/page-layout-styles';
|
|
15
|
+
import { elevationStyles } from '../lib/styles/elevation-styles';
|
|
16
|
+
import { CardStyles } from '../lib/styles/card-styles';
|
|
17
|
+
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
18
|
+
import { FormBuilderCardStyles } from '..';
|
|
19
|
+
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
20
|
+
import { clone } from 'ramda';
|
|
21
|
+
export var FieldTypes;
|
|
22
|
+
(function (FieldTypes) {
|
|
23
|
+
FieldTypes["FILE_TYPE"] = "file";
|
|
24
|
+
FieldTypes["TEXT_TYPE"] = "text";
|
|
25
|
+
FieldTypes["NUMBER_TYPE"] = "number";
|
|
26
|
+
FieldTypes["BOOL_TYPE"] = "bool";
|
|
27
|
+
FieldTypes["SCALE_TYPE"] = "likert_scale";
|
|
28
|
+
FieldTypes["NUMBER_INTEGER_TYPE"] = "number-integer";
|
|
29
|
+
FieldTypes["NUMBER_FLOAT_TYPE"] = "number-float";
|
|
30
|
+
})(FieldTypes || (FieldTypes = {}));
|
|
31
|
+
export var StructureTypes;
|
|
32
|
+
(function (StructureTypes) {
|
|
33
|
+
StructureTypes["WIDE"] = "wide";
|
|
34
|
+
StructureTypes["ADDITIONAL"] = "additional";
|
|
35
|
+
StructureTypes["CARD"] = "card";
|
|
36
|
+
StructureTypes["ABSTRACT"] = "abstract";
|
|
37
|
+
StructureTypes["COLLAPSED"] = "collapse";
|
|
38
|
+
StructureTypes["ATTACHMENTS_BUTTON"] = "floating_attachments";
|
|
39
|
+
})(StructureTypes || (StructureTypes = {}));
|
|
40
|
+
export class FormAbstractGroup extends LitElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.parentGroupName = '';
|
|
44
|
+
this.readonly = true;
|
|
45
|
+
this._errors = {};
|
|
46
|
+
this._value = {};
|
|
47
|
+
this.computedPath = [];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Make value property immutable
|
|
51
|
+
* @param value
|
|
52
|
+
*/
|
|
53
|
+
set value(value) {
|
|
54
|
+
this._value = this.groupStructure.name === 'root' ? clone(value) : value;
|
|
55
|
+
}
|
|
56
|
+
get value() {
|
|
57
|
+
return this._value;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Setter for handling error.
|
|
61
|
+
* Normally we wouldn't have errors as string or string[] for FormGroups.
|
|
62
|
+
* In cases they appear - show toast with error text and reset it.
|
|
63
|
+
* Otherwise it will be impossible to clear that error from field elements
|
|
64
|
+
* @param errors
|
|
65
|
+
*/
|
|
66
|
+
set errors(errors) {
|
|
67
|
+
if (Array.isArray(errors)) {
|
|
68
|
+
fireEvent(this, 'toast', { text: errors[0] });
|
|
69
|
+
fireEvent(this, 'error-changed', { error: null });
|
|
70
|
+
}
|
|
71
|
+
else if (errors) {
|
|
72
|
+
this._errors = errors;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
if (!this.groupStructure || !this.metadata) {
|
|
77
|
+
return html ``;
|
|
78
|
+
}
|
|
79
79
|
return html `
|
|
80
80
|
${this.groupStructure.children.map((child) => this.renderChild(child))}
|
|
81
|
-
`;
|
|
82
|
-
}
|
|
83
|
-
renderChild(child) {
|
|
84
|
-
const type = child.type;
|
|
85
|
-
switch (child.type) {
|
|
86
|
-
case 'field':
|
|
87
|
-
return this.renderField(child);
|
|
88
|
-
case 'group':
|
|
89
|
-
return this.renderGroup(child);
|
|
90
|
-
default:
|
|
91
|
-
console.warn(`FormBuilderGroup: Unknown group type ${type}. Please, specify rendering method`);
|
|
92
|
-
return html ``;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
renderField(blueprintField) {
|
|
96
|
-
const isWide = blueprintField.styling.includes(StructureTypes.WIDE);
|
|
97
|
-
const isAdditional = blueprintField.styling.includes(StructureTypes.ADDITIONAL);
|
|
98
|
-
if (isWide) {
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
renderChild(child) {
|
|
84
|
+
const type = child.type;
|
|
85
|
+
switch (child.type) {
|
|
86
|
+
case 'field':
|
|
87
|
+
return this.renderField(child);
|
|
88
|
+
case 'group':
|
|
89
|
+
return this.renderGroup(child);
|
|
90
|
+
default:
|
|
91
|
+
console.warn(`FormBuilderGroup: Unknown group type ${type}. Please, specify rendering method`);
|
|
92
|
+
return html ``;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
renderField(blueprintField) {
|
|
96
|
+
const isWide = blueprintField.styling.includes(StructureTypes.WIDE);
|
|
97
|
+
const isAdditional = blueprintField.styling.includes(StructureTypes.ADDITIONAL);
|
|
98
|
+
if (isWide) {
|
|
99
99
|
return html `
|
|
100
100
|
<div class="${isAdditional ? 'additional-field' : ''}">${this.renderWideField(blueprintField)}</div>
|
|
101
|
-
`;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
104
|
return html `
|
|
105
105
|
<div class="${isAdditional ? 'additional-field finding-container' : 'finding-container'}">
|
|
106
106
|
${this.renderStandardField(blueprintField)}
|
|
107
107
|
</div>
|
|
108
|
-
`;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
renderWideField({ name, label, placeholder, required, validations }) {
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
renderWideField({ name, label, placeholder, required, validations }) {
|
|
112
112
|
return html `
|
|
113
113
|
<wide-field
|
|
114
114
|
?is-readonly="${this.readonly}"
|
|
@@ -121,12 +121,12 @@ export class FormAbstractGroup extends LitElement {
|
|
|
121
121
|
@value-changed="${(event) => this.valueChanged(event, name)}"
|
|
122
122
|
@error-changed="${(event) => this.errorChanged(event, name)}"
|
|
123
123
|
></wide-field>
|
|
124
|
-
`;
|
|
125
|
-
}
|
|
126
|
-
renderStandardField({ input_type, name, label, help_text, options_key, required, validations }) {
|
|
127
|
-
var _a;
|
|
128
|
-
switch (input_type) {
|
|
129
|
-
case FieldTypes.TEXT_TYPE:
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
renderStandardField({ input_type, name, label, help_text, options_key, required, validations }) {
|
|
127
|
+
var _a;
|
|
128
|
+
switch (input_type) {
|
|
129
|
+
case FieldTypes.TEXT_TYPE:
|
|
130
130
|
return html `
|
|
131
131
|
<text-field
|
|
132
132
|
?is-readonly="${this.readonly}"
|
|
@@ -139,10 +139,10 @@ export class FormAbstractGroup extends LitElement {
|
|
|
139
139
|
>
|
|
140
140
|
${this.renderFieldLabel(label, help_text)}
|
|
141
141
|
</text-field>
|
|
142
|
-
`;
|
|
143
|
-
case FieldTypes.NUMBER_TYPE:
|
|
144
|
-
case FieldTypes.NUMBER_FLOAT_TYPE:
|
|
145
|
-
case FieldTypes.NUMBER_INTEGER_TYPE:
|
|
142
|
+
`;
|
|
143
|
+
case FieldTypes.NUMBER_TYPE:
|
|
144
|
+
case FieldTypes.NUMBER_FLOAT_TYPE:
|
|
145
|
+
case FieldTypes.NUMBER_INTEGER_TYPE:
|
|
146
146
|
return html `
|
|
147
147
|
<number-field
|
|
148
148
|
?is-readonly="${this.readonly}"
|
|
@@ -155,9 +155,9 @@ export class FormAbstractGroup extends LitElement {
|
|
|
155
155
|
>
|
|
156
156
|
${this.renderFieldLabel(label, help_text)}
|
|
157
157
|
</number-field>
|
|
158
|
-
`;
|
|
159
|
-
case FieldTypes.BOOL_TYPE:
|
|
160
|
-
case FieldTypes.SCALE_TYPE:
|
|
158
|
+
`;
|
|
159
|
+
case FieldTypes.BOOL_TYPE:
|
|
160
|
+
case FieldTypes.SCALE_TYPE:
|
|
161
161
|
return html `
|
|
162
162
|
<scale-field
|
|
163
163
|
.options="${((_a = this.metadata.options[options_key || '']) === null || _a === void 0 ? void 0 : _a.values) || []}"
|
|
@@ -171,25 +171,25 @@ export class FormAbstractGroup extends LitElement {
|
|
|
171
171
|
>
|
|
172
172
|
${this.renderFieldLabel(label, help_text)}
|
|
173
173
|
</scale-field>
|
|
174
|
-
`;
|
|
175
|
-
default:
|
|
176
|
-
console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
|
|
177
|
-
return html ``;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
renderFieldLabel(label, helperText) {
|
|
174
|
+
`;
|
|
175
|
+
default:
|
|
176
|
+
console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
|
|
177
|
+
return html ``;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
renderFieldLabel(label, helperText) {
|
|
181
181
|
return html `
|
|
182
182
|
<div class="layout vertical question-container">
|
|
183
183
|
<div class="question-text">${label}</div>
|
|
184
184
|
<div class="question-details">${helperText}</div>
|
|
185
185
|
</div>
|
|
186
|
-
`;
|
|
187
|
-
}
|
|
188
|
-
renderGroup(groupStructure) {
|
|
189
|
-
const isAbstract = groupStructure.styling.includes(StructureTypes.ABSTRACT);
|
|
190
|
-
const isCard = groupStructure.styling.includes(StructureTypes.CARD);
|
|
191
|
-
const isCollapsed = groupStructure.styling.includes(StructureTypes.COLLAPSED);
|
|
192
|
-
if (isAbstract) {
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
renderGroup(groupStructure) {
|
|
189
|
+
const isAbstract = groupStructure.styling.includes(StructureTypes.ABSTRACT);
|
|
190
|
+
const isCard = groupStructure.styling.includes(StructureTypes.CARD);
|
|
191
|
+
const isCollapsed = groupStructure.styling.includes(StructureTypes.COLLAPSED);
|
|
192
|
+
if (isAbstract) {
|
|
193
193
|
return html `
|
|
194
194
|
<form-abstract-group
|
|
195
195
|
.groupStructure="${groupStructure}"
|
|
@@ -202,9 +202,9 @@ export class FormAbstractGroup extends LitElement {
|
|
|
202
202
|
@value-changed="${(event) => this.valueChanged(event, groupStructure.name)}"
|
|
203
203
|
@error-changed="${(event) => this.errorChanged(event, groupStructure.name)}"
|
|
204
204
|
></form-abstract-group>
|
|
205
|
-
`;
|
|
206
|
-
}
|
|
207
|
-
else if (isCard && isCollapsed) {
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
else if (isCard && isCollapsed) {
|
|
208
208
|
return html `
|
|
209
209
|
<form-collapsed-card
|
|
210
210
|
.groupStructure="${groupStructure}"
|
|
@@ -217,9 +217,9 @@ export class FormAbstractGroup extends LitElement {
|
|
|
217
217
|
@value-changed="${(event) => this.valueChanged(event, groupStructure.name)}"
|
|
218
218
|
@error-changed="${(event) => this.errorChanged(event, groupStructure.name)}"
|
|
219
219
|
></form-collapsed-card>
|
|
220
|
-
`;
|
|
221
|
-
}
|
|
222
|
-
else if (isCard) {
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
else if (isCard) {
|
|
223
223
|
return html `
|
|
224
224
|
<form-card
|
|
225
225
|
.groupStructure="${groupStructure}"
|
|
@@ -232,47 +232,47 @@ export class FormAbstractGroup extends LitElement {
|
|
|
232
232
|
@value-changed="${(event) => this.valueChanged(event, groupStructure.name)}"
|
|
233
233
|
@error-changed="${(event) => this.errorChanged(event, groupStructure.name)}"
|
|
234
234
|
></form-card>
|
|
235
|
-
`;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
console.warn(`FormBuilderGroup: Unknown group type: ${groupStructure.styling}`);
|
|
239
|
-
return html ``;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
valueChanged(event, name) {
|
|
243
|
-
if (!this.value) {
|
|
244
|
-
this.value = {};
|
|
245
|
-
}
|
|
246
|
-
this.value[name] = event.detail.value;
|
|
247
|
-
event.stopPropagation();
|
|
248
|
-
fireEvent(this, 'value-changed', { value: this.value });
|
|
249
|
-
this.requestUpdate();
|
|
250
|
-
}
|
|
251
|
-
errorChanged(event, name) {
|
|
252
|
-
const errorMessage = event.detail.error;
|
|
253
|
-
if (errorMessage) {
|
|
254
|
-
this._errors[name] = errorMessage;
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
delete this._errors[name];
|
|
258
|
-
}
|
|
259
|
-
event.stopPropagation();
|
|
260
|
-
const errors = Object.keys(this._errors).length ? this._errors : null;
|
|
261
|
-
fireEvent(this, 'error-changed', { error: errors });
|
|
262
|
-
}
|
|
263
|
-
getErrorMessage(fieldName) {
|
|
264
|
-
const error = this._errors && this._errors[fieldName];
|
|
265
|
-
return Array.isArray(error) ? error[0] : error || null;
|
|
266
|
-
}
|
|
267
|
-
static get styles() {
|
|
268
|
-
// language=CSS
|
|
269
|
-
return [
|
|
270
|
-
SharedStyles,
|
|
271
|
-
pageLayoutStyles,
|
|
272
|
-
elevationStyles,
|
|
273
|
-
CardStyles,
|
|
274
|
-
FlexLayoutClasses,
|
|
275
|
-
FormBuilderCardStyles,
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
console.warn(`FormBuilderGroup: Unknown group type: ${groupStructure.styling}`);
|
|
239
|
+
return html ``;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
valueChanged(event, name) {
|
|
243
|
+
if (!this.value) {
|
|
244
|
+
this.value = {};
|
|
245
|
+
}
|
|
246
|
+
this.value[name] = event.detail.value;
|
|
247
|
+
event.stopPropagation();
|
|
248
|
+
fireEvent(this, 'value-changed', { value: this.value });
|
|
249
|
+
this.requestUpdate();
|
|
250
|
+
}
|
|
251
|
+
errorChanged(event, name) {
|
|
252
|
+
const errorMessage = event.detail.error;
|
|
253
|
+
if (errorMessage) {
|
|
254
|
+
this._errors[name] = errorMessage;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
delete this._errors[name];
|
|
258
|
+
}
|
|
259
|
+
event.stopPropagation();
|
|
260
|
+
const errors = Object.keys(this._errors).length ? this._errors : null;
|
|
261
|
+
fireEvent(this, 'error-changed', { error: errors });
|
|
262
|
+
}
|
|
263
|
+
getErrorMessage(fieldName) {
|
|
264
|
+
const error = this._errors && this._errors[fieldName];
|
|
265
|
+
return Array.isArray(error) ? error[0] : error || null;
|
|
266
|
+
}
|
|
267
|
+
static get styles() {
|
|
268
|
+
// language=CSS
|
|
269
|
+
return [
|
|
270
|
+
SharedStyles,
|
|
271
|
+
pageLayoutStyles,
|
|
272
|
+
elevationStyles,
|
|
273
|
+
CardStyles,
|
|
274
|
+
FlexLayoutClasses,
|
|
275
|
+
FormBuilderCardStyles,
|
|
276
276
|
css `
|
|
277
277
|
.save-button {
|
|
278
278
|
margin-top: 8px;
|
|
@@ -302,25 +302,25 @@ export class FormAbstractGroup extends LitElement {
|
|
|
302
302
|
.attachments-warning {
|
|
303
303
|
color: red;
|
|
304
304
|
}
|
|
305
|
-
`
|
|
306
|
-
];
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
__decorate([
|
|
310
|
-
property({ type: Object })
|
|
311
|
-
], FormAbstractGroup.prototype, "groupStructure", void 0);
|
|
312
|
-
__decorate([
|
|
313
|
-
property({ type: Object })
|
|
314
|
-
], FormAbstractGroup.prototype, "metadata", void 0);
|
|
315
|
-
__decorate([
|
|
316
|
-
property({ type: String })
|
|
317
|
-
], FormAbstractGroup.prototype, "parentGroupName", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
property({ type: Boolean, attribute: 'readonly', reflect: true })
|
|
320
|
-
], FormAbstractGroup.prototype, "readonly", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
property()
|
|
323
|
-
], FormAbstractGroup.prototype, "_errors", void 0);
|
|
324
|
-
__decorate([
|
|
325
|
-
property()
|
|
326
|
-
], FormAbstractGroup.prototype, "_value", void 0);
|
|
305
|
+
`
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
__decorate([
|
|
310
|
+
property({ type: Object })
|
|
311
|
+
], FormAbstractGroup.prototype, "groupStructure", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Object })
|
|
314
|
+
], FormAbstractGroup.prototype, "metadata", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: String })
|
|
317
|
+
], FormAbstractGroup.prototype, "parentGroupName", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: Boolean, attribute: 'readonly', reflect: true })
|
|
320
|
+
], FormAbstractGroup.prototype, "readonly", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property()
|
|
323
|
+
], FormAbstractGroup.prototype, "_errors", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property()
|
|
326
|
+
], FormAbstractGroup.prototype, "_value", void 0);
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit-element';
|
|
2
|
-
import { IFormBuilderCard } from '../lib/types/form-builder.interfaces';
|
|
3
|
-
import { FormAbstractGroup } from './form-abstract-group';
|
|
4
|
-
import { GenericObject } from '../lib/types/global.types';
|
|
5
|
-
import '@polymer/iron-collapse';
|
|
6
|
-
export declare class FormCard extends FormAbstractGroup implements IFormBuilderCard {
|
|
7
|
-
protected _value: GenericObject;
|
|
8
|
-
/**
|
|
9
|
-
* Show save button only if value was changed by user
|
|
10
|
-
*/
|
|
11
|
-
private showSaveButton;
|
|
12
|
-
/**
|
|
13
|
-
* Overrides value property. Saves originalValue.
|
|
14
|
-
* We need to update inner _value only if it wasn't change
|
|
15
|
-
* @param value
|
|
16
|
-
*/
|
|
17
|
-
set value(value: GenericObject);
|
|
18
|
-
get value(): GenericObject;
|
|
19
|
-
protected originalValue: GenericObject;
|
|
20
|
-
/**
|
|
21
|
-
* Extends parent render method,
|
|
22
|
-
* adds card-container html wrapper and dynamic save button
|
|
23
|
-
*/
|
|
24
|
-
render(): TemplateResult;
|
|
25
|
-
/**
|
|
26
|
-
* Updates value property, stops event propagation.
|
|
27
|
-
* We need to fire value-changed event only after save button click
|
|
28
|
-
*/
|
|
29
|
-
valueChanged(event: CustomEvent, name: string): void;
|
|
30
|
-
saveChanges(): void;
|
|
31
|
-
}
|
|
1
|
+
import { TemplateResult } from 'lit-element';
|
|
2
|
+
import { IFormBuilderCard } from '../lib/types/form-builder.interfaces';
|
|
3
|
+
import { FormAbstractGroup } from './form-abstract-group';
|
|
4
|
+
import { GenericObject } from '../lib/types/global.types';
|
|
5
|
+
import '@polymer/iron-collapse';
|
|
6
|
+
export declare class FormCard extends FormAbstractGroup implements IFormBuilderCard {
|
|
7
|
+
protected _value: GenericObject;
|
|
8
|
+
/**
|
|
9
|
+
* Show save button only if value was changed by user
|
|
10
|
+
*/
|
|
11
|
+
private showSaveButton;
|
|
12
|
+
/**
|
|
13
|
+
* Overrides value property. Saves originalValue.
|
|
14
|
+
* We need to update inner _value only if it wasn't change
|
|
15
|
+
* @param value
|
|
16
|
+
*/
|
|
17
|
+
set value(value: GenericObject);
|
|
18
|
+
get value(): GenericObject;
|
|
19
|
+
protected originalValue: GenericObject;
|
|
20
|
+
/**
|
|
21
|
+
* Extends parent render method,
|
|
22
|
+
* adds card-container html wrapper and dynamic save button
|
|
23
|
+
*/
|
|
24
|
+
render(): TemplateResult;
|
|
25
|
+
/**
|
|
26
|
+
* Updates value property, stops event propagation.
|
|
27
|
+
* We need to fire value-changed event only after save button click
|
|
28
|
+
*/
|
|
29
|
+
valueChanged(event: CustomEvent, name: string): void;
|
|
30
|
+
saveChanges(): void;
|
|
31
|
+
}
|