@unicef-polymer/etools-form-builder 2.1.0 → 2.1.2
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/LICENSE +674 -674
- package/README.md +1 -1
- package/dist/assets/translations.d.ts +6 -0
- package/dist/assets/translations.js +67 -0
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +86 -85
- 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 +255 -248
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +91 -89
- package/dist/form-attachments-popup/index.d.ts +2 -2
- package/dist/form-attachments-popup/index.js +2 -2
- package/dist/form-fields/abstract-field-base.class.d.ts +33 -28
- package/dist/form-fields/abstract-field-base.class.js +194 -176
- package/dist/form-fields/field-renderer-component.d.ts +20 -20
- package/dist/form-fields/field-renderer-component.js +249 -249
- package/dist/form-fields/index.d.ts +12 -12
- package/dist/form-fields/index.js +12 -12
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +209 -208
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +124 -123
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +67 -66
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
- package/dist/form-fields/single-fields/attachment-field.js +98 -97
- package/dist/form-fields/single-fields/base-field.d.ts +11 -11
- package/dist/form-fields/single-fields/base-field.js +58 -57
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
- package/dist/form-fields/single-fields/boolean-field.js +49 -49
- package/dist/form-fields/single-fields/number-field.d.ts +10 -10
- package/dist/form-fields/single-fields/number-field.js +67 -66
- package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
- package/dist/form-fields/single-fields/scale-field.js +108 -107
- package/dist/form-fields/single-fields/text-field.d.ts +8 -8
- package/dist/form-fields/single-fields/text-field.js +54 -54
- package/dist/form-groups/form-abstract-group.d.ts +65 -60
- package/dist/form-groups/form-abstract-group.js +375 -353
- package/dist/form-groups/form-card.d.ts +32 -32
- package/dist/form-groups/form-card.js +113 -108
- package/dist/form-groups/form-collapsed-card.d.ts +70 -70
- package/dist/form-groups/form-collapsed-card.js +254 -253
- package/dist/form-groups/index.d.ts +3 -3
- package/dist/form-groups/index.js +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/lib/additional-components/confirmation-dialog.d.ts +18 -16
- package/dist/lib/additional-components/confirmation-dialog.js +72 -65
- package/dist/lib/additional-components/etools-fb-card.d.ts +21 -16
- package/dist/lib/additional-components/etools-fb-card.js +238 -215
- package/dist/lib/styles/attachments.styles.d.ts +2 -2
- package/dist/lib/styles/attachments.styles.js +72 -72
- package/dist/lib/styles/card-styles.d.ts +2 -2
- package/dist/lib/styles/card-styles.js +154 -154
- package/dist/lib/styles/dialog.styles.d.ts +2 -2
- package/dist/lib/styles/dialog.styles.js +85 -85
- package/dist/lib/styles/elevation-styles.d.ts +9 -9
- package/dist/lib/styles/elevation-styles.js +43 -43
- package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
- package/dist/lib/styles/flex-layout-classes.js +319 -319
- package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
- package/dist/lib/styles/form-builder-card.styles.js +49 -49
- package/dist/lib/styles/input-styles.d.ts +2 -2
- package/dist/lib/styles/input-styles.js +138 -138
- package/dist/lib/styles/page-layout-styles.d.ts +2 -2
- package/dist/lib/styles/page-layout-styles.js +201 -201
- package/dist/lib/styles/shared-styles.d.ts +2 -2
- package/dist/lib/styles/shared-styles.js +70 -70
- package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
- package/dist/lib/types/form-builder.interfaces.js +0 -0
- package/dist/lib/types/form-builder.types.d.ts +59 -59
- package/dist/lib/types/form-builder.types.js +0 -0
- package/dist/lib/types/global.types.d.ts +4 -4
- package/dist/lib/types/global.types.js +0 -0
- 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/translate.d.ts +1 -0
- package/dist/lib/utils/translate.js +9 -0
- package/dist/lib/utils/validations.helper.d.ts +26 -26
- package/dist/lib/utils/validations.helper.js +42 -35
- package/package.json +56 -56
|
@@ -1,253 +1,254 @@
|
|
|
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 { html, property, customElement } from 'lit-element';
|
|
8
|
-
import { clone } from 'ramda';
|
|
9
|
-
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
10
|
-
import { openDialog } from '../lib/utils/dialog';
|
|
11
|
-
import { FormAbstractGroup, StructureTypes } from './form-abstract-group';
|
|
12
|
-
import '../lib/additional-components/etools-fb-card';
|
|
13
|
-
import '../lib/additional-components/confirmation-dialog';
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
fireEvent(this, '
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
79
|
-
?
|
|
80
|
-
|
|
81
|
-
@
|
|
82
|
-
@
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<div slot="
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
fireEvent(this, '
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
tmp
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
FormCollapsedCard
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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 { html, property, customElement } from 'lit-element';
|
|
8
|
+
import { clone } from 'ramda';
|
|
9
|
+
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
10
|
+
import { openDialog } from '../lib/utils/dialog';
|
|
11
|
+
import { FormAbstractGroup, StructureTypes } from './form-abstract-group';
|
|
12
|
+
import '../lib/additional-components/etools-fb-card';
|
|
13
|
+
import '../lib/additional-components/confirmation-dialog';
|
|
14
|
+
import { getTranslation } from '../lib/utils/translate';
|
|
15
|
+
const PARTNER_KEY = 'partner';
|
|
16
|
+
const OUTPUT_KEY = 'output';
|
|
17
|
+
const INTERVENTION_KEY = 'intervention';
|
|
18
|
+
let FormCollapsedCard = class FormCollapsedCard extends FormAbstractGroup {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.isEditMode = false;
|
|
22
|
+
this._readonly = true;
|
|
23
|
+
this._value = {};
|
|
24
|
+
this.originalValue = {};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Overrides readonly property
|
|
28
|
+
* In collapsed card it must consider isEditMode property,
|
|
29
|
+
* components inside card are readonly if isEditMode is off or if card is readonly
|
|
30
|
+
*/
|
|
31
|
+
set readonly(state) {
|
|
32
|
+
this._readonly = state;
|
|
33
|
+
}
|
|
34
|
+
get readonly() {
|
|
35
|
+
return this._readonly || !this.isEditMode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Overrides errors setter
|
|
39
|
+
* In collapsed card it must consider isEditMode property,
|
|
40
|
+
* We must to enable isEditMode if errors comes from backend
|
|
41
|
+
*/
|
|
42
|
+
set errors(errors) {
|
|
43
|
+
if (Array.isArray(errors)) {
|
|
44
|
+
fireEvent(this, 'toast', { text: errors[0] });
|
|
45
|
+
fireEvent(this, 'error-changed', { error: null });
|
|
46
|
+
}
|
|
47
|
+
else if (errors) {
|
|
48
|
+
this._errors = errors;
|
|
49
|
+
}
|
|
50
|
+
if (errors) {
|
|
51
|
+
this.isEditMode = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Overrides value property
|
|
56
|
+
* We need to save originalValue to have Cancel possibility in collapsed card.
|
|
57
|
+
* Don't override current edited value if isEditMode enabled
|
|
58
|
+
* (It can be happened if other sibling card or component updates their value during current card edition)
|
|
59
|
+
*/
|
|
60
|
+
set value(value) {
|
|
61
|
+
this.originalValue = value;
|
|
62
|
+
if (!this.isEditMode) {
|
|
63
|
+
this._value = clone(value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
get value() {
|
|
67
|
+
return this._value;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Extends parent render method for handling additional types (StructureTypes.ATTACHMENTS_BUTTON in our case)
|
|
71
|
+
* and adds etools-card as container wrapper
|
|
72
|
+
*/
|
|
73
|
+
render() {
|
|
74
|
+
return html `
|
|
75
|
+
<section class="elevation page-content card-container" elevation="1">
|
|
76
|
+
<etools-fb-card
|
|
77
|
+
card-title="${this.retrieveTitle(this.parentGroupName) + this.groupStructure.title}"
|
|
78
|
+
is-collapsible
|
|
79
|
+
?is-editable="${!this._readonly}"
|
|
80
|
+
?edit="${this.isEditMode}"
|
|
81
|
+
@start-edit="${() => this.startEdit()}"
|
|
82
|
+
@save="${() => this.saveChanges()}"
|
|
83
|
+
@cancel="${() => this.cancelEdit()}"
|
|
84
|
+
>
|
|
85
|
+
<!-- Open Attachments popup button -->
|
|
86
|
+
<div slot="actions" class="layout horizontal center">${this.getAdditionalButtons()}</div>
|
|
87
|
+
<div slot="postfix" class="layout horizontal center" ?hidden="${!this.groupStructure.repeatable}">
|
|
88
|
+
<paper-icon-button
|
|
89
|
+
icon="close"
|
|
90
|
+
class="attachments-warning"
|
|
91
|
+
@click="${() => this.confirmRemove(this.groupStructure.title || getTranslation(this.language, 'THIS_GROUP'))}"
|
|
92
|
+
></paper-icon-button>
|
|
93
|
+
</div>
|
|
94
|
+
<div slot="content">${this.renderGroupChildren()}</div>
|
|
95
|
+
</etools-fb-card>
|
|
96
|
+
</section>
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Filters StructureTypes.ATTACHMENTS_BUTTON type. It will be rendered as button,
|
|
101
|
+
* allows parent renderChild method to render other types
|
|
102
|
+
*/
|
|
103
|
+
renderGroupChildren() {
|
|
104
|
+
return this.groupStructure.children
|
|
105
|
+
.filter(({ styling }) => !styling.includes(StructureTypes.ATTACHMENTS_BUTTON))
|
|
106
|
+
.map((child) => super.renderChild(child));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Generate open Attachments popup button.
|
|
110
|
+
* It is hidden if tab is readonly and no attachments uploaded
|
|
111
|
+
*/
|
|
112
|
+
getAdditionalButtons() {
|
|
113
|
+
var _a, _b, _c, _d, _e, _f;
|
|
114
|
+
const hideAttachmentsButton = (this._readonly && !((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.attachments) === null || _b === void 0 ? void 0 : _b.length)) ||
|
|
115
|
+
!this.groupStructure.children.some(({ styling }) => styling.includes(StructureTypes.ATTACHMENTS_BUTTON));
|
|
116
|
+
return hideAttachmentsButton
|
|
117
|
+
? html ``
|
|
118
|
+
: html `
|
|
119
|
+
<iron-icon icon="warning" class="attachments-warning" ?hidden="${!this._errors.attachments}"></iron-icon>
|
|
120
|
+
<paper-button @click="${() => this.openAttachmentsPopup()}" class="attachments-button">
|
|
121
|
+
<iron-icon icon="${((_d = (_c = this.value) === null || _c === void 0 ? void 0 : _c.attachments) === null || _d === void 0 ? void 0 : _d.length) ? 'file-download' : 'file-upload'}"></iron-icon>
|
|
122
|
+
${this.getAttachmentsBtnText((_f = (_e = this.value) === null || _e === void 0 ? void 0 : _e.attachments) === null || _f === void 0 ? void 0 : _f.length)}
|
|
123
|
+
</paper-button>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
retrieveTitle(target) {
|
|
127
|
+
switch (target) {
|
|
128
|
+
case PARTNER_KEY:
|
|
129
|
+
return `${getTranslation(this.language, 'PARTNER')}: `;
|
|
130
|
+
case OUTPUT_KEY:
|
|
131
|
+
return `${getTranslation(this.language, 'CP_OUTPUT')}: `;
|
|
132
|
+
case INTERVENTION_KEY:
|
|
133
|
+
return `${getTranslation(this.language, 'PD_SSFA')}: `;
|
|
134
|
+
default:
|
|
135
|
+
return '';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
startEdit() {
|
|
139
|
+
if (this._readonly) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.isEditMode = true;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* We need to rerender view to update all changes that was happen,
|
|
146
|
+
* because only fields are updating during @value-change event.
|
|
147
|
+
* Only then we can reset all changed values to their original
|
|
148
|
+
*/
|
|
149
|
+
cancelEdit() {
|
|
150
|
+
this.requestUpdate().then(() => {
|
|
151
|
+
this._value = clone(this.originalValue);
|
|
152
|
+
this.isEditMode = false;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Updates value property, stops event propagation.
|
|
157
|
+
* We need to fire value-changed event only after save button click
|
|
158
|
+
*/
|
|
159
|
+
valueChanged(event, name) {
|
|
160
|
+
event.stopPropagation();
|
|
161
|
+
if (!this._value) {
|
|
162
|
+
this._value = {};
|
|
163
|
+
}
|
|
164
|
+
if (this._value[name] !== event.detail.value) {
|
|
165
|
+
this._value[name] = event.detail.value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
saveChanges() {
|
|
169
|
+
if (Object.keys(this._errors).length) {
|
|
170
|
+
fireEvent(this, 'toast', { text: getTranslation(this.language, 'CHECK_FIELDS_TRY_AGAIN') });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
this.isEditMode = false;
|
|
174
|
+
fireEvent(this, 'value-changed', { value: this.value });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Tries to save changed attachments on popup confirm
|
|
178
|
+
* Generates value-changed event with originalValue clone if isEditMode enabled.
|
|
179
|
+
* In this case it will take only attachments changes and ignore other changes that may happen during card edit
|
|
180
|
+
*/
|
|
181
|
+
openAttachmentsPopup() {
|
|
182
|
+
var _a;
|
|
183
|
+
if (!customElements.get('form-attachments-popup')) {
|
|
184
|
+
throw new Error('Please define "form-attachments-popup" custom element!');
|
|
185
|
+
}
|
|
186
|
+
openDialog({
|
|
187
|
+
dialog: 'form-attachments-popup',
|
|
188
|
+
dialogData: {
|
|
189
|
+
attachments: (_a = this.value) === null || _a === void 0 ? void 0 : _a.attachments,
|
|
190
|
+
metadata: this.metadata,
|
|
191
|
+
title: `${getTranslation(this.language, 'ATTACHMENTS_FOR')} ${this.retrieveTitle(this.parentGroupName) + ': ' + this.groupStructure.title}`,
|
|
192
|
+
computedPath: this.computedPath.concat([this.groupStructure.name, 'attachments']),
|
|
193
|
+
errors: this._errors.attachments
|
|
194
|
+
},
|
|
195
|
+
readonly: this._readonly
|
|
196
|
+
}).then((response) => {
|
|
197
|
+
if (!response.confirmed) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!this._value) {
|
|
201
|
+
this._value = {};
|
|
202
|
+
}
|
|
203
|
+
this._value.attachments = response.attachments;
|
|
204
|
+
delete this._errors.attachments;
|
|
205
|
+
fireEvent(this, 'error-changed', { error: Object.keys(this._errors).length ? this._errors : null });
|
|
206
|
+
fireEvent(this, 'attachments-changed', { attachments: this._value.attachments });
|
|
207
|
+
if (this.isEditMode) {
|
|
208
|
+
const tmp = clone(this.originalValue) || {};
|
|
209
|
+
tmp.attachments = response.attachments;
|
|
210
|
+
fireEvent(this, 'value-changed', { value: tmp });
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.saveChanges();
|
|
214
|
+
}
|
|
215
|
+
this.requestUpdate();
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
confirmRemove(groupName) {
|
|
219
|
+
openDialog({
|
|
220
|
+
dialog: 'confirmation-popup',
|
|
221
|
+
dialogData: {
|
|
222
|
+
text: `${getTranslation(this.language, 'CONFIRM_DELETE')} ${groupName}`
|
|
223
|
+
}
|
|
224
|
+
}).then((response) => {
|
|
225
|
+
if (response.confirmed) {
|
|
226
|
+
fireEvent(this, 'remove-group');
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
getAttachmentsBtnText(attachmentsCount = 0) {
|
|
231
|
+
if (attachmentsCount === 1) {
|
|
232
|
+
return `${attachmentsCount} ${getTranslation(this.language, 'FILE')}`;
|
|
233
|
+
}
|
|
234
|
+
else if (attachmentsCount > 1) {
|
|
235
|
+
return `${attachmentsCount} ${getTranslation(this.language, 'FILES')}`;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
return getTranslation(this.language, 'UPLOAD_FILES');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
__decorate([
|
|
243
|
+
property()
|
|
244
|
+
], FormCollapsedCard.prototype, "isEditMode", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
property({ type: Boolean, attribute: 'readonly', reflect: true })
|
|
247
|
+
], FormCollapsedCard.prototype, "_readonly", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
property()
|
|
250
|
+
], FormCollapsedCard.prototype, "_value", void 0);
|
|
251
|
+
FormCollapsedCard = __decorate([
|
|
252
|
+
customElement('form-collapsed-card')
|
|
253
|
+
], FormCollapsedCard);
|
|
254
|
+
export { FormCollapsedCard };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './form-abstract-group';
|
|
2
|
-
export * from './form-card';
|
|
3
|
-
export * from './form-collapsed-card';
|
|
1
|
+
export * from './form-abstract-group';
|
|
2
|
+
export * from './form-card';
|
|
3
|
+
export * from './form-collapsed-card';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './form-abstract-group';
|
|
2
|
-
export * from './form-card';
|
|
3
|
-
export * from './form-collapsed-card';
|
|
1
|
+
export * from './form-abstract-group';
|
|
2
|
+
export * from './form-card';
|
|
3
|
+
export * from './form-collapsed-card';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './form-fields';
|
|
2
|
-
export * from './form-groups';
|
|
3
|
-
export * from './form-attachments-popup';
|
|
1
|
+
export * from './form-fields';
|
|
2
|
+
export * from './form-groups';
|
|
3
|
+
export * from './form-attachments-popup';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './form-fields';
|
|
2
|
-
export * from './form-groups';
|
|
3
|
-
export * from './form-attachments-popup';
|
|
1
|
+
export * from './form-fields';
|
|
2
|
+
export * from './form-groups';
|
|
3
|
+
export * from './form-attachments-popup';
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { LitElement, CSSResultArray } from 'lit-element';
|
|
2
|
-
export declare class ConfirmationDialog extends LitElement {
|
|
3
|
-
dialogOpened: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { LitElement, CSSResultArray } from 'lit-element';
|
|
2
|
+
export declare class ConfirmationDialog extends LitElement {
|
|
3
|
+
dialogOpened: boolean;
|
|
4
|
+
language: string;
|
|
5
|
+
text: string;
|
|
6
|
+
dialogTitle: string;
|
|
7
|
+
hideConfirmBtn: boolean;
|
|
8
|
+
set dialogData({ text, dialogTitle, hideConfirmBtn }: {
|
|
9
|
+
text: string;
|
|
10
|
+
dialogTitle: string;
|
|
11
|
+
hideConfirmBtn: boolean;
|
|
12
|
+
});
|
|
13
|
+
constructor();
|
|
14
|
+
render(): unknown;
|
|
15
|
+
onClose(): void;
|
|
16
|
+
confirm(): void;
|
|
17
|
+
static get styles(): CSSResultArray;
|
|
18
|
+
}
|