@unicef-polymer/etools-form-builder 3.0.0-rc.8 → 3.1.0
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.js +70 -2
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +4 -0
- package/dist/form-attachments-popup/form-attachments-popup.js +156 -53
- package/dist/form-fields/abstract-field-base.class.d.ts +1 -0
- package/dist/form-fields/abstract-field-base.class.js +106 -116
- package/dist/form-fields/field-renderer-component.d.ts +7 -3
- package/dist/form-fields/field-renderer-component.js +185 -154
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +112 -112
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -21
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -59
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -24
- package/dist/form-fields/single-fields/attachment-field.js +13 -13
- package/dist/form-fields/single-fields/boolean-field.js +16 -21
- package/dist/form-fields/single-fields/number-field.js +21 -23
- package/dist/form-fields/single-fields/scale-field.js +58 -60
- package/dist/form-fields/single-fields/text-field.js +24 -25
- package/dist/form-groups/form-abstract-group.d.ts +2 -1
- package/dist/form-groups/form-abstract-group.js +129 -127
- package/dist/form-groups/form-card.js +30 -24
- package/dist/form-groups/form-collapsed-card.js +34 -34
- package/dist/lib/additional-components/confirmation-dialog.js +21 -21
- package/dist/lib/additional-components/etools-fb-card.js +136 -135
- package/dist/lib/styles/attachments.styles.js +61 -66
- package/dist/lib/styles/card-styles.js +147 -151
- package/dist/lib/styles/dialog.styles.js +83 -83
- package/dist/lib/styles/elevation-styles.d.ts +2 -2
- package/dist/lib/styles/elevation-styles.js +35 -35
- package/dist/lib/styles/flex-layout-classes.js +316 -316
- package/dist/lib/styles/form-builder-card.styles.js +53 -46
- package/dist/lib/styles/page-layout-styles.js +198 -198
- package/dist/lib/styles/shared-styles.js +61 -67
- package/package.json +55 -55
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -7
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +0 -102
- package/dist/lib/styles/input-styles.d.ts +0 -2
- package/dist/lib/styles/input-styles.js +0 -143
|
@@ -4,6 +4,9 @@ import { property, customElement } from 'lit/decorators.js';
|
|
|
4
4
|
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
5
5
|
import { FieldTypes, StructureTypes } from '../form-groups';
|
|
6
6
|
import { FormBuilderCardStyles } from '../lib/styles/form-builder-card.styles';
|
|
7
|
+
import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
|
|
8
|
+
import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
|
|
9
|
+
import { getTranslation } from '../lib/utils/translate';
|
|
7
10
|
let FieldRendererComponent = class FieldRendererComponent extends LitElement {
|
|
8
11
|
constructor() {
|
|
9
12
|
super(...arguments);
|
|
@@ -20,179 +23,194 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
|
|
|
20
23
|
return this.renderField(this.field);
|
|
21
24
|
}
|
|
22
25
|
renderField(blueprintField) {
|
|
23
|
-
|
|
24
|
-
?
|
|
25
|
-
:
|
|
26
|
+
let additionalClass = blueprintField.styling.includes(StructureTypes.ADDITIONAL)
|
|
27
|
+
? `additional-field ${blueprintField.name} `
|
|
28
|
+
: `${blueprintField.name} `;
|
|
26
29
|
const wideClass = blueprintField.styling.includes(StructureTypes.WIDE) ? 'wide-field-container ' : '';
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const mandatoryClass = blueprintField.styling.includes(StructureTypes.MANDATORY_WARNING)
|
|
31
|
+
? 'mandatory_warning '
|
|
32
|
+
: '';
|
|
33
|
+
return html `
|
|
34
|
+
<div class="${`${additionalClass}${wideClass}${mandatoryClass}finding-container`}">
|
|
29
35
|
${blueprintField.repeatable
|
|
30
|
-
? this.renderRepeatableField(blueprintField)
|
|
31
|
-
: this.renderStandardField(blueprintField)}
|
|
32
|
-
</div>
|
|
36
|
+
? this.renderRepeatableField(blueprintField, !!mandatoryClass)
|
|
37
|
+
: this.renderStandardField(blueprintField, !!mandatoryClass)}
|
|
38
|
+
</div>
|
|
33
39
|
`;
|
|
34
40
|
}
|
|
35
|
-
renderStandardField({ input_type, label, help_text, required, placeholder, styling }) {
|
|
41
|
+
renderStandardField({ input_type, label, help_text, required, placeholder, styling, name }, isMandatory = false) {
|
|
36
42
|
var _a, _b, _c, _d;
|
|
37
43
|
const isWide = styling.includes(StructureTypes.WIDE);
|
|
38
44
|
switch (input_type) {
|
|
39
45
|
case FieldTypes.TEXT_TYPE:
|
|
40
|
-
return html `
|
|
41
|
-
<text-field
|
|
42
|
-
class="${isWide ? 'wide' : ''}"
|
|
43
|
-
?is-readonly="${this.readonly}"
|
|
44
|
-
?required="${required}"
|
|
45
|
-
.placeholder="${placeholder}"
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
return html `
|
|
47
|
+
<text-field
|
|
48
|
+
class="${isWide ? 'wide' : ''}"
|
|
49
|
+
?is-readonly="${this.readonly}"
|
|
50
|
+
?required="${required}"
|
|
51
|
+
.placeholder="${placeholder}"
|
|
52
|
+
.name="${name}"
|
|
53
|
+
.value="${this.value}"
|
|
54
|
+
.validators="${this.validations}"
|
|
55
|
+
.errorMessage="${this.errorMessage}"
|
|
56
|
+
.defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
|
|
57
|
+
>
|
|
58
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
59
|
+
</text-field>
|
|
53
60
|
`;
|
|
54
61
|
case FieldTypes.NUMBER_TYPE:
|
|
55
62
|
case FieldTypes.NUMBER_FLOAT_TYPE:
|
|
56
63
|
case FieldTypes.NUMBER_INTEGER_TYPE:
|
|
57
|
-
return html `
|
|
58
|
-
<number-field
|
|
59
|
-
?is-readonly="${this.readonly}"
|
|
60
|
-
?required="${required}"
|
|
61
|
-
.placeholder="${placeholder}"
|
|
62
|
-
.value="${this.value}"
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
return html `
|
|
65
|
+
<number-field
|
|
66
|
+
?is-readonly="${this.readonly}"
|
|
67
|
+
?required="${required}"
|
|
68
|
+
.placeholder="${placeholder}"
|
|
69
|
+
.value="${this.value}"
|
|
70
|
+
.name="${name}"
|
|
71
|
+
.validators="${this.validations}"
|
|
72
|
+
.errorMessage="${this.errorMessage}"
|
|
73
|
+
.isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
|
|
74
|
+
.defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
|
|
75
|
+
>
|
|
76
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
77
|
+
</number-field>
|
|
70
78
|
`;
|
|
71
79
|
case FieldTypes.BOOL_TYPE:
|
|
72
|
-
return html `
|
|
73
|
-
<boolean-field
|
|
74
|
-
?is-readonly="${this.readonly}"
|
|
75
|
-
?required="${required}"
|
|
76
|
-
.value="${this.value}"
|
|
77
|
-
.
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
return html `
|
|
81
|
+
<boolean-field
|
|
82
|
+
?is-readonly="${this.readonly}"
|
|
83
|
+
?required="${required}"
|
|
84
|
+
.value="${this.value}"
|
|
85
|
+
.name="${name}"
|
|
86
|
+
.validators="${this.validations}"
|
|
87
|
+
.errorMessage="${this.errorMessage}"
|
|
88
|
+
.defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
|
|
89
|
+
>
|
|
90
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
91
|
+
</boolean-field>
|
|
83
92
|
`;
|
|
84
93
|
case FieldTypes.SCALE_TYPE:
|
|
85
|
-
return html `
|
|
86
|
-
<scale-field
|
|
87
|
-
.options="${this.options}"
|
|
88
|
-
?is-readonly="${this.readonly}"
|
|
89
|
-
?required="${required}"
|
|
90
|
-
.placeholder="${placeholder}"
|
|
91
|
-
.value="${this.value}"
|
|
92
|
-
.
|
|
93
|
-
.
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
return html `
|
|
95
|
+
<scale-field
|
|
96
|
+
.options="${this.options}"
|
|
97
|
+
?is-readonly="${this.readonly}"
|
|
98
|
+
?required="${required}"
|
|
99
|
+
.placeholder="${placeholder}"
|
|
100
|
+
.value="${this.value}"
|
|
101
|
+
.name="${name}"
|
|
102
|
+
.validators="${this.validations}"
|
|
103
|
+
.errorMessage="${this.errorMessage}"
|
|
104
|
+
.defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
|
|
105
|
+
>
|
|
106
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
107
|
+
</scale-field>
|
|
98
108
|
`;
|
|
99
109
|
case FieldTypes.FILE_TYPE:
|
|
100
|
-
return html `
|
|
101
|
-
<attachments-field
|
|
102
|
-
?is-readonly="${this.readonly}"
|
|
103
|
-
?required="${required}"
|
|
104
|
-
.placeholder="${placeholder}"
|
|
105
|
-
.value="${this.value}"
|
|
106
|
-
.
|
|
107
|
-
.
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
return html `
|
|
111
|
+
<attachments-field
|
|
112
|
+
?is-readonly="${this.readonly}"
|
|
113
|
+
?required="${required}"
|
|
114
|
+
.placeholder="${placeholder}"
|
|
115
|
+
.value="${this.value}"
|
|
116
|
+
.name="${name}"
|
|
117
|
+
.validators="${this.validations}"
|
|
118
|
+
.errorMessage="${this.errorMessage}"
|
|
119
|
+
.computedPath="${this.computedPath}"
|
|
120
|
+
>
|
|
121
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
122
|
+
</attachments-field>
|
|
112
123
|
`;
|
|
113
124
|
default:
|
|
114
125
|
console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
|
|
115
126
|
return html ``;
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
|
-
|
|
129
|
+
renderTooltip(isMandatory) {
|
|
130
|
+
return isMandatory
|
|
131
|
+
? html ` <sl-tooltip placement="top" content="${getTranslation(this.language, 'PLEASE_ANSWER')}">
|
|
132
|
+
<etools-icon id="users-icon" name="info-outline"></etools-icon>
|
|
133
|
+
</sl-tooltip>`
|
|
134
|
+
: ``;
|
|
135
|
+
}
|
|
136
|
+
renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }, isMandatory = false) {
|
|
119
137
|
var _a, _b, _c;
|
|
120
138
|
const isWide = styling.includes(StructureTypes.WIDE);
|
|
121
139
|
switch (input_type) {
|
|
122
140
|
case FieldTypes.TEXT_TYPE:
|
|
123
|
-
return html `
|
|
124
|
-
<repeatable-text-field
|
|
125
|
-
class="${isWide ? 'wide' : ''}"
|
|
126
|
-
?is-readonly="${this.readonly}"
|
|
127
|
-
?required="${required}"
|
|
128
|
-
.placeholder="${placeholder}"
|
|
129
|
-
.value="${this.value}"
|
|
130
|
-
.validators="${this.validations}"
|
|
131
|
-
.errorMessage="${this.errorMessage}"
|
|
132
|
-
.defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
|
|
133
|
-
>
|
|
134
|
-
${this.renderFieldLabel(label, help_text)}
|
|
135
|
-
</repeatable-text-field>
|
|
141
|
+
return html `
|
|
142
|
+
<repeatable-text-field
|
|
143
|
+
class="${isWide ? 'wide' : ''}"
|
|
144
|
+
?is-readonly="${this.readonly}"
|
|
145
|
+
?required="${required}"
|
|
146
|
+
.placeholder="${placeholder}"
|
|
147
|
+
.value="${this.value}"
|
|
148
|
+
.validators="${this.validations}"
|
|
149
|
+
.errorMessage="${this.errorMessage}"
|
|
150
|
+
.defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
|
|
151
|
+
>
|
|
152
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
153
|
+
</repeatable-text-field>
|
|
136
154
|
`;
|
|
137
155
|
case FieldTypes.NUMBER_TYPE:
|
|
138
156
|
case FieldTypes.NUMBER_FLOAT_TYPE:
|
|
139
157
|
case FieldTypes.NUMBER_INTEGER_TYPE:
|
|
140
|
-
return html `
|
|
141
|
-
<repeatable-number-field
|
|
142
|
-
class="${isWide ? 'wide' : ''}"
|
|
143
|
-
?is-readonly="${this.readonly}"
|
|
144
|
-
?required="${required}"
|
|
145
|
-
.placeholder="${placeholder}"
|
|
146
|
-
.value="${this.value}"
|
|
147
|
-
.validators="${this.validations}"
|
|
148
|
-
.errorMessage="${this.errorMessage}"
|
|
149
|
-
.isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
|
|
150
|
-
.defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
|
|
151
|
-
>
|
|
152
|
-
${this.renderFieldLabel(label, help_text)}
|
|
153
|
-
</repeatable-number-field>
|
|
158
|
+
return html `
|
|
159
|
+
<repeatable-number-field
|
|
160
|
+
class="${isWide ? 'wide' : ''}"
|
|
161
|
+
?is-readonly="${this.readonly}"
|
|
162
|
+
?required="${required}"
|
|
163
|
+
.placeholder="${placeholder}"
|
|
164
|
+
.value="${this.value}"
|
|
165
|
+
.validators="${this.validations}"
|
|
166
|
+
.errorMessage="${this.errorMessage}"
|
|
167
|
+
.isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
|
|
168
|
+
.defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
|
|
169
|
+
>
|
|
170
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
171
|
+
</repeatable-number-field>
|
|
154
172
|
`;
|
|
155
173
|
case FieldTypes.SCALE_TYPE:
|
|
156
|
-
return html `
|
|
157
|
-
<repeatable-scale-field
|
|
158
|
-
class="${isWide ? 'wide' : ''}"
|
|
159
|
-
.options="${this.options}"
|
|
160
|
-
?is-readonly="${this.readonly}"
|
|
161
|
-
?required="${required}"
|
|
162
|
-
.placeholder="${placeholder}"
|
|
163
|
-
.value="${this.value}"
|
|
164
|
-
.validators="${this.validations}"
|
|
165
|
-
.errorMessage="${this.errorMessage}"
|
|
166
|
-
.defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
|
|
167
|
-
>
|
|
168
|
-
${this.renderFieldLabel(label, help_text)}
|
|
169
|
-
</repeatable-scale-field>
|
|
174
|
+
return html `
|
|
175
|
+
<repeatable-scale-field
|
|
176
|
+
class="${isWide ? 'wide' : ''}"
|
|
177
|
+
.options="${this.options}"
|
|
178
|
+
?is-readonly="${this.readonly}"
|
|
179
|
+
?required="${required}"
|
|
180
|
+
.placeholder="${placeholder}"
|
|
181
|
+
.value="${this.value}"
|
|
182
|
+
.validators="${this.validations}"
|
|
183
|
+
.errorMessage="${this.errorMessage}"
|
|
184
|
+
.defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
|
|
185
|
+
>
|
|
186
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
187
|
+
</repeatable-scale-field>
|
|
170
188
|
`;
|
|
171
189
|
case FieldTypes.FILE_TYPE:
|
|
172
|
-
return html `
|
|
173
|
-
<repeatable-attachments-field
|
|
174
|
-
?is-readonly="${this.readonly}"
|
|
175
|
-
?required="${required}"
|
|
176
|
-
.placeholder="${placeholder}"
|
|
177
|
-
.value="${this.value}"
|
|
178
|
-
.validators="${this.validations}"
|
|
179
|
-
.errorMessage="${this.errorMessage}"
|
|
180
|
-
.computedPath="${this.computedPath}"
|
|
181
|
-
>
|
|
182
|
-
${this.renderFieldLabel(label, help_text)}
|
|
183
|
-
</repeatable-attachments-field>
|
|
190
|
+
return html `
|
|
191
|
+
<repeatable-attachments-field
|
|
192
|
+
?is-readonly="${this.readonly}"
|
|
193
|
+
?required="${required}"
|
|
194
|
+
.placeholder="${placeholder}"
|
|
195
|
+
.value="${this.value}"
|
|
196
|
+
.validators="${this.validations}"
|
|
197
|
+
.errorMessage="${this.errorMessage}"
|
|
198
|
+
.computedPath="${this.computedPath}"
|
|
199
|
+
>
|
|
200
|
+
${this.renderFieldLabel(label, help_text, isMandatory)}
|
|
201
|
+
</repeatable-attachments-field>
|
|
184
202
|
`;
|
|
185
203
|
default:
|
|
186
204
|
console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
|
|
187
205
|
return html ``;
|
|
188
206
|
}
|
|
189
207
|
}
|
|
190
|
-
renderFieldLabel(label, helperText) {
|
|
191
|
-
return html `
|
|
192
|
-
<div class="layout vertical question-container">
|
|
193
|
-
<div class="question-text">${label}</div>
|
|
194
|
-
<div class="question-details">${helperText}</div>
|
|
195
|
-
</div>
|
|
208
|
+
renderFieldLabel(label, helperText, isMandatory = false) {
|
|
209
|
+
return html `
|
|
210
|
+
<div class="layout vertical question-container">
|
|
211
|
+
<div class="question-text">${this.renderTooltip(isMandatory)}${label}</div>
|
|
212
|
+
<div class="question-details">${helperText}</div>
|
|
213
|
+
</div>
|
|
196
214
|
`;
|
|
197
215
|
}
|
|
198
216
|
static get styles() {
|
|
@@ -200,29 +218,39 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
|
|
|
200
218
|
return [
|
|
201
219
|
FlexLayoutClasses,
|
|
202
220
|
FormBuilderCardStyles,
|
|
203
|
-
css `
|
|
204
|
-
.additional-field {
|
|
205
|
-
padding-top: 15px;
|
|
206
|
-
padding-bottom: 20px;
|
|
207
|
-
background-color: var(--secondary-background-color);
|
|
208
|
-
}
|
|
209
|
-
.wide-field-container {
|
|
210
|
-
padding-bottom: 10px;
|
|
211
|
-
}
|
|
212
|
-
.wide-field-container .question-container {
|
|
213
|
-
min-height: 0;
|
|
214
|
-
padding: 7px 0 0;
|
|
215
|
-
}
|
|
216
|
-
.wide-field-container .question-text {
|
|
217
|
-
color: var(--secondary-text-color);
|
|
218
|
-
font-weight: 400;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
css `
|
|
222
|
+
.additional-field {
|
|
223
|
+
padding-top: 15px;
|
|
224
|
+
padding-bottom: 20px;
|
|
225
|
+
background-color: var(--secondary-background-color);
|
|
226
|
+
}
|
|
227
|
+
.wide-field-container {
|
|
228
|
+
padding-bottom: 10px;
|
|
229
|
+
}
|
|
230
|
+
.wide-field-container .question-container {
|
|
231
|
+
min-height: 0;
|
|
232
|
+
padding: 7px 0 0;
|
|
233
|
+
}
|
|
234
|
+
.wide-field-container .question-text {
|
|
235
|
+
color: var(--secondary-text-color);
|
|
236
|
+
font-weight: 400;
|
|
237
|
+
}
|
|
238
|
+
.mandatory_warning etools-icon {
|
|
239
|
+
--etools-icon-fill-color: #f59e0b !important;
|
|
240
|
+
}
|
|
241
|
+
:host(:not([readonly])) {
|
|
242
|
+
.overall {
|
|
243
|
+
background-color: #ffffff;
|
|
244
|
+
border-style: inset;
|
|
245
|
+
border-width: 0 1px 1px 1px;
|
|
246
|
+
border-color: var(--dark-divider-color);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
@media print {
|
|
250
|
+
:host {
|
|
251
|
+
break-inside: avoid;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
226
254
|
`
|
|
227
255
|
];
|
|
228
256
|
}
|
|
@@ -233,6 +261,9 @@ __decorate([
|
|
|
233
261
|
__decorate([
|
|
234
262
|
property()
|
|
235
263
|
], FieldRendererComponent.prototype, "value", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
property()
|
|
266
|
+
], FieldRendererComponent.prototype, "language", void 0);
|
|
236
267
|
__decorate([
|
|
237
268
|
property()
|
|
238
269
|
], FieldRendererComponent.prototype, "errorMessage", void 0);
|
|
@@ -24,55 +24,55 @@ let RepeatableAttachmentField = class RepeatableAttachmentField extends Repeatab
|
|
|
24
24
|
render() {
|
|
25
25
|
var _a;
|
|
26
26
|
const values = this.getValues();
|
|
27
|
-
return html `
|
|
28
|
-
<div class="finding-container">
|
|
29
|
-
<div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
|
|
30
|
-
<div class="question-control layout vertical center-justified start">
|
|
27
|
+
return html `
|
|
28
|
+
<div class="finding-container">
|
|
29
|
+
<div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
|
|
30
|
+
<div class="question-control layout vertical center-justified start">
|
|
31
31
|
${values.map((value, index) => value
|
|
32
|
-
? html `
|
|
33
|
-
<div class="layout horizontal file-container">
|
|
34
|
-
<!-- File name component -->
|
|
35
|
-
<div class="filename-container file-selector__filename">
|
|
36
|
-
<etools-icon class="file-icon" name="attachment"></etools-icon>
|
|
37
|
-
<span class="filename" title="${value.filename}">${value.filename}</span>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<!-- Download Button -->
|
|
41
|
-
<etools-button
|
|
42
|
-
class="neutral download-button file-selector__download"
|
|
43
|
-
variant="text"
|
|
44
|
-
?hidden="${!value.url}"
|
|
45
|
-
@click="${() => this.downloadFile(value)}"
|
|
46
|
-
>
|
|
47
|
-
<etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
|
|
48
|
-
${getTranslation(this.language, 'DOWNLOAD')}
|
|
49
|
-
</etools-button>
|
|
50
|
-
|
|
51
|
-
<!-- Delete Button -->
|
|
52
|
-
<etools-button
|
|
53
|
-
variant="danger"
|
|
54
|
-
class="file-selector__delete"
|
|
55
|
-
?hidden="${this.isReadonly}"
|
|
56
|
-
@click="${() => this.removeControl(index)}"
|
|
57
|
-
>
|
|
58
|
-
${getTranslation(this.language, 'DELETE')}
|
|
59
|
-
</etools-button>
|
|
60
|
-
</div>
|
|
32
|
+
? html `
|
|
33
|
+
<div class="layout horizontal file-container">
|
|
34
|
+
<!-- File name component -->
|
|
35
|
+
<div class="filename-container file-selector__filename">
|
|
36
|
+
<etools-icon class="file-icon" name="attachment"></etools-icon>
|
|
37
|
+
<span class="filename" title="${value.filename}">${value.filename}</span>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Download Button -->
|
|
41
|
+
<etools-button
|
|
42
|
+
class="neutral download-button file-selector__download"
|
|
43
|
+
variant="text"
|
|
44
|
+
?hidden="${!value.url}"
|
|
45
|
+
@click="${() => this.downloadFile(value)}"
|
|
46
|
+
>
|
|
47
|
+
<etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
|
|
48
|
+
${getTranslation(this.language, 'DOWNLOAD')}
|
|
49
|
+
</etools-button>
|
|
50
|
+
|
|
51
|
+
<!-- Delete Button -->
|
|
52
|
+
<etools-button
|
|
53
|
+
variant="danger"
|
|
54
|
+
class="file-selector__delete"
|
|
55
|
+
?hidden="${this.isReadonly}"
|
|
56
|
+
@click="${() => this.removeControl(index)}"
|
|
57
|
+
>
|
|
58
|
+
${getTranslation(this.language, 'DELETE')}
|
|
59
|
+
</etools-button>
|
|
60
|
+
</div>
|
|
61
61
|
`
|
|
62
|
-
: '')}
|
|
63
|
-
<!-- Upload button -->
|
|
64
|
-
<etools-upload-multi
|
|
65
|
-
class="with-padding"
|
|
66
|
-
activate-offline
|
|
67
|
-
?hidden="${this.isReadonly}"
|
|
68
|
-
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
69
|
-
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
70
|
-
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
71
|
-
>
|
|
72
|
-
</etools-upload-multi>
|
|
73
|
-
<div ?hidden="${!this.isReadonly || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length)}">—</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
62
|
+
: '')}
|
|
63
|
+
<!-- Upload button -->
|
|
64
|
+
<etools-upload-multi
|
|
65
|
+
class="with-padding"
|
|
66
|
+
activate-offline
|
|
67
|
+
?hidden="${this.isReadonly}"
|
|
68
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
69
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
70
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
71
|
+
>
|
|
72
|
+
</etools-upload-multi>
|
|
73
|
+
<div ?hidden="${!this.isReadonly || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length)}">—</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
76
|
`;
|
|
77
77
|
}
|
|
78
78
|
controlTemplate() {
|
|
@@ -107,7 +107,7 @@ let RepeatableAttachmentField = class RepeatableAttachmentField extends Repeatab
|
|
|
107
107
|
});
|
|
108
108
|
if (error && error.length) {
|
|
109
109
|
console.error(error);
|
|
110
|
-
fireEvent(this, 'toast', { text:
|
|
110
|
+
fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
downloadFile(attachment) {
|
|
@@ -135,70 +135,70 @@ let RepeatableAttachmentField = class RepeatableAttachmentField extends Repeatab
|
|
|
135
135
|
...RepeatableBaseField.styles,
|
|
136
136
|
SharedStyles,
|
|
137
137
|
AttachmentsStyles,
|
|
138
|
-
css `
|
|
139
|
-
.file-selector__type-dropdown {
|
|
140
|
-
flex-basis: 25%;
|
|
141
|
-
padding-left: 8px;
|
|
142
|
-
padding-right: 8px;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.file-selector__filename {
|
|
146
|
-
flex-basis: 35%;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.file-selector__download {
|
|
150
|
-
flex-basis: 10%;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.file-selector__delete {
|
|
154
|
-
flex-basis: 10%;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.file-selector-container.with-type-dropdown {
|
|
158
|
-
flex-wrap: nowrap;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.popup-container {
|
|
162
|
-
padding: 12px 12px 0;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.file-container {
|
|
166
|
-
padding: 8px 0;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@media (max-width: 380px) {
|
|
170
|
-
.file-selector-container.with-type-dropdown {
|
|
171
|
-
justify-content: center;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
175
|
-
flex-basis: 90%;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.file-selector__filename {
|
|
179
|
-
flex-basis: 90%;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.file-selector__download {
|
|
183
|
-
flex-basis: 5%;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.file-selector__delete {
|
|
187
|
-
flex-basis: 5%;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@media (max-width: 600px) {
|
|
192
|
-
etools-dropdown {
|
|
193
|
-
padding: 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.file-selector-container.with-type-dropdown {
|
|
197
|
-
border-bottom: 1px solid lightgrey;
|
|
198
|
-
flex-wrap: wrap;
|
|
199
|
-
padding-bottom: 10px;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
138
|
+
css `
|
|
139
|
+
.file-selector__type-dropdown {
|
|
140
|
+
flex-basis: 25%;
|
|
141
|
+
padding-left: 8px;
|
|
142
|
+
padding-right: 8px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.file-selector__filename {
|
|
146
|
+
flex-basis: 35%;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.file-selector__download {
|
|
150
|
+
flex-basis: 10%;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.file-selector__delete {
|
|
154
|
+
flex-basis: 10%;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.file-selector-container.with-type-dropdown {
|
|
158
|
+
flex-wrap: nowrap;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.popup-container {
|
|
162
|
+
padding: 12px 12px 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.file-container {
|
|
166
|
+
padding: 8px 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@media (max-width: 380px) {
|
|
170
|
+
.file-selector-container.with-type-dropdown {
|
|
171
|
+
justify-content: center;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
175
|
+
flex-basis: 90%;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.file-selector__filename {
|
|
179
|
+
flex-basis: 90%;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.file-selector__download {
|
|
183
|
+
flex-basis: 5%;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.file-selector__delete {
|
|
187
|
+
flex-basis: 5%;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@media (max-width: 600px) {
|
|
192
|
+
etools-dropdown {
|
|
193
|
+
padding: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.file-selector-container.with-type-dropdown {
|
|
197
|
+
border-bottom: 1px solid lightgrey;
|
|
198
|
+
flex-wrap: wrap;
|
|
199
|
+
padding-bottom: 10px;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
202
|
`
|
|
203
203
|
];
|
|
204
204
|
}
|