@unicef-polymer/etools-form-builder 3.0.0-rc.9 → 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
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# Etools FM Form Builder Components
|
|
1
|
+
# Etools FM Form Builder Components
|
|
@@ -29,7 +29,8 @@ const translations = {
|
|
|
29
29
|
NUMBER_MUST_BE_GREATER_THAN: 'Number must be greater than {0}',
|
|
30
30
|
NUMBER_MUST_BE_LOWER_THAN: 'Number must be lower than {0}',
|
|
31
31
|
DOCUMENT_TYPE: 'Document type',
|
|
32
|
-
SELECT_DOCUMENT_TYPE: 'Select Document Type'
|
|
32
|
+
SELECT_DOCUMENT_TYPE: 'Select Document Type',
|
|
33
|
+
PLEASE_ANSWER: 'Important: Please provide the answer if available'
|
|
33
34
|
},
|
|
34
35
|
fr: {
|
|
35
36
|
SAVE: 'Sauvegarder',
|
|
@@ -61,7 +62,74 @@ const translations = {
|
|
|
61
62
|
NUMBER_MUST_BE_GREATER_THAN: 'Le nombre doit être supérieur à {0}',
|
|
62
63
|
NUMBER_MUST_BE_LOWER_THAN: 'Le nombre doit être inférieur à {0}',
|
|
63
64
|
DOCUMENT_TYPE: 'Type de document',
|
|
64
|
-
SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document'
|
|
65
|
+
SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document',
|
|
66
|
+
PLEASE_ANSWER: 'Important : veuillez fournir la réponse si disponible'
|
|
67
|
+
},
|
|
68
|
+
ar: {
|
|
69
|
+
SAVE: 'يحفظ',
|
|
70
|
+
DOWNLOAD: 'تحميل',
|
|
71
|
+
CHANGE: 'يتغير',
|
|
72
|
+
DELETE: 'يمسح',
|
|
73
|
+
CANCEL: 'يلغي',
|
|
74
|
+
OK: 'نعم',
|
|
75
|
+
ADD: 'يضيف',
|
|
76
|
+
UPLOAD_ATTACHMENTS_FAILED: 'لا يمكن تحميل المرفقات. الرجاء معاودة المحاولة في وقت لاحق',
|
|
77
|
+
REQUIRED_FIELD: 'هذه الخانة مطلوبه',
|
|
78
|
+
MUST_BE_INTEGER: 'يجب أن يكون صحيحا',
|
|
79
|
+
MUST_BE_NUMBER: 'يجب أن يكون رقما',
|
|
80
|
+
CLEAR: 'واضح',
|
|
81
|
+
GROUP_REQUIRED: 'المجموعة مطلوبة. يجب أن تكون هناك مجموعة واحدة على الأقل',
|
|
82
|
+
GROUP: 'مجموعة',
|
|
83
|
+
THIS_GROUP: 'هذه المجموعة',
|
|
84
|
+
CHECK_FIELDS_TRY_AGAIN: 'يرجى التحقق من كافة الحقول والمحاولة مرة أخرى',
|
|
85
|
+
CONFIRM_DELETE: 'هل أنت متأكد أنك تريد حذف',
|
|
86
|
+
UPLOAD_FILES: 'تحميل الملفات',
|
|
87
|
+
FILE: 'ملف',
|
|
88
|
+
FILES: 'ملفات',
|
|
89
|
+
ATTACHMENTS_FOR: 'المرفقات ل',
|
|
90
|
+
PARTNER: 'شريك',
|
|
91
|
+
CP_OUTPUT: 'إخراج سي بي',
|
|
92
|
+
PD_SPD: 'بي دي/SPD',
|
|
93
|
+
TEXT_MUST_BE_LESS_CHARS: 'يجب أن يكون النص أقل من {0} حرف',
|
|
94
|
+
DOES_NOT_MATCH_PATTERN: 'لا يتطابق مع النمط المسموح به',
|
|
95
|
+
NUMBER_MUST_BE_GREATER_THAN: 'يجب أن يكون الرقم أكبر من {0}',
|
|
96
|
+
NUMBER_MUST_BE_LOWER_THAN: 'يجب أن يكون الرقم أقل من {0}',
|
|
97
|
+
DOCUMENT_TYPE: 'نوع الوثيقة',
|
|
98
|
+
SELECT_DOCUMENT_TYPE: 'حدد نوع المستند',
|
|
99
|
+
PLEASE_ANSWER: 'هام: يرجى تقديم الإجابة إذا كانت متوفرة'
|
|
100
|
+
},
|
|
101
|
+
es: {
|
|
102
|
+
SAVE: 'Guardar',
|
|
103
|
+
DOWNLOAD: 'Descargar',
|
|
104
|
+
CHANGE: 'Cambia',
|
|
105
|
+
DELETE: 'Eliminar',
|
|
106
|
+
CANCEL: 'Cancelar',
|
|
107
|
+
OK: 'Biean',
|
|
108
|
+
ADD: 'Añadir',
|
|
109
|
+
UPLOAD_ATTACHMENTS_FAILED: 'No se pueden cargar archivos adjuntos. Por favor, inténtelo de nuevo más tarde',
|
|
110
|
+
REQUIRED_FIELD: 'Este campo es obligatorio',
|
|
111
|
+
MUST_BE_INTEGER: 'Debe ser un entero',
|
|
112
|
+
MUST_BE_NUMBER: 'Tiene que ser un número',
|
|
113
|
+
CLEAR: 'Claro',
|
|
114
|
+
GROUP_REQUIRED: 'Se requiere grupo. Debe existir al menos un grupo.',
|
|
115
|
+
GROUP: 'grupo',
|
|
116
|
+
THIS_GROUP: 'este grupo',
|
|
117
|
+
CHECK_FIELDS_TRY_AGAIN: 'Por favor revisa todos los campos y vuelve a intentarlo.',
|
|
118
|
+
CONFIRM_DELETE: '¿Estás seguro de que quieres eliminar?',
|
|
119
|
+
UPLOAD_FILES: 'Subir archivos',
|
|
120
|
+
FILE: 'Archivo',
|
|
121
|
+
FILES: 'Archivos',
|
|
122
|
+
ATTACHMENTS_FOR: 'Adjuntos para',
|
|
123
|
+
PARTNER: 'Pareja',
|
|
124
|
+
CP_OUTPUT: 'Salida CP',
|
|
125
|
+
PD_SPD: 'PD/SPD',
|
|
126
|
+
TEXT_MUST_BE_LESS_CHARS: 'El texto debe tener menos de {0} caracteres',
|
|
127
|
+
DOES_NOT_MATCH_PATTERN: 'No coincide con el patrón permitido',
|
|
128
|
+
NUMBER_MUST_BE_GREATER_THAN: 'El número debe ser mayor que {0}',
|
|
129
|
+
NUMBER_MUST_BE_LOWER_THAN: 'El número debe ser inferior a {0}',
|
|
130
|
+
DOCUMENT_TYPE: 'Tipo de Documento',
|
|
131
|
+
SELECT_DOCUMENT_TYPE: 'Seleccionar tipo de documento',
|
|
132
|
+
PLEASE_ANSWER: 'Importante: proporcione la respuesta si está disponible.'
|
|
65
133
|
}
|
|
66
134
|
};
|
|
67
135
|
export default translations;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '@unicef-polymer/etools-unicef/src/etools-dialog/etools-dialog';
|
|
2
2
|
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload-multi';
|
|
3
3
|
import '@unicef-polymer/etools-unicef/src/etools-dropdown/etools-dropdown';
|
|
4
|
+
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
4
5
|
import { CSSResultArray, LitElement, TemplateResult } from 'lit';
|
|
5
6
|
import { GenericObject } from '../lib/types/global.types';
|
|
6
7
|
import { BlueprintMetadata } from '../lib/types/form-builder.types';
|
|
@@ -65,6 +66,9 @@ export declare class FormAttachmentsPopup extends LitElement {
|
|
|
65
66
|
get uploadUrl(): string;
|
|
66
67
|
get jwtLocalStorageKey(): string;
|
|
67
68
|
constructor();
|
|
69
|
+
connectedCallback(): void;
|
|
70
|
+
disconnectedCallback(): void;
|
|
71
|
+
handleLanguageChange(e: CustomEvent): void;
|
|
68
72
|
render(): TemplateResult | void;
|
|
69
73
|
/**
|
|
70
74
|
* on Cancel button click
|
|
@@ -2,16 +2,17 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import '@unicef-polymer/etools-unicef/src/etools-dialog/etools-dialog';
|
|
3
3
|
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload-multi';
|
|
4
4
|
import '@unicef-polymer/etools-unicef/src/etools-dropdown/etools-dropdown';
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
5
6
|
import { deleteFileFromDexie } from '@unicef-polymer/etools-unicef/src/etools-upload/offline/dexie-operations';
|
|
6
|
-
import { css, LitElement } from 'lit';
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
7
8
|
import { property, query, customElement } from 'lit/decorators.js';
|
|
8
9
|
import { clone, equals } from 'ramda';
|
|
9
|
-
import { template } from './form-attachments-popup.tpl';
|
|
10
10
|
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
11
11
|
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
12
12
|
import { AttachmentsStyles } from '../lib/styles/attachments.styles';
|
|
13
13
|
import { AttachmentsHelper } from './form-attachments-popup.helper';
|
|
14
14
|
import { getTranslation } from '../lib/utils/translate';
|
|
15
|
+
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
15
16
|
let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
16
17
|
set dialogData({ attachments, title, metadata, readonly, computedPath, errors }) {
|
|
17
18
|
this.popupTitle = title;
|
|
@@ -47,11 +48,113 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
|
47
48
|
throw new Error('Please initialize attachments popup before use');
|
|
48
49
|
}
|
|
49
50
|
if (!this.language) {
|
|
50
|
-
this.language = window.
|
|
51
|
+
this.language = window.EtoolsLanguage || 'en';
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
super.connectedCallback();
|
|
56
|
+
document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
|
|
57
|
+
}
|
|
58
|
+
disconnectedCallback() {
|
|
59
|
+
super.disconnectedCallback();
|
|
60
|
+
document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
|
|
61
|
+
}
|
|
62
|
+
handleLanguageChange(e) {
|
|
63
|
+
this.language = e.detail.language;
|
|
64
|
+
}
|
|
53
65
|
render() {
|
|
54
|
-
|
|
66
|
+
var _a;
|
|
67
|
+
return html `
|
|
68
|
+
${DialogStyles}
|
|
69
|
+
<style>
|
|
70
|
+
etools-icon[name='error-outline'] {
|
|
71
|
+
color: var(--etools-upload-danger-color, #ea4022);
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
<etools-dialog
|
|
75
|
+
id="form-attachments-dialog"
|
|
76
|
+
size="md"
|
|
77
|
+
no-padding
|
|
78
|
+
keep-dialog-open
|
|
79
|
+
?opened="${this.dialogOpened}"
|
|
80
|
+
.okBtnText="${getTranslation(this.language, 'SAVE')}"
|
|
81
|
+
.cancelBtnText="${getTranslation(this.language, 'CANCEL')}"
|
|
82
|
+
.hideConfirmBtn="${this.readonly}"
|
|
83
|
+
dialog-title="${this.popupTitle}"
|
|
84
|
+
@close="${this.onClose}"
|
|
85
|
+
@confirm-btn-clicked="${() => this.saveChanges()}"
|
|
86
|
+
>
|
|
87
|
+
<!-- Link is used to download attachments -->
|
|
88
|
+
<a id="link" target="_blank" hidden></a>
|
|
89
|
+
|
|
90
|
+
<div class="popup-container">
|
|
91
|
+
${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
return html `
|
|
94
|
+
<div class="file-selector-container with-type-dropdown">
|
|
95
|
+
<!-- Type select Dropdown -->
|
|
96
|
+
<etools-dropdown
|
|
97
|
+
class="type-dropdown file-selector__type-dropdown"
|
|
98
|
+
.selected="${attachment.file_type}"
|
|
99
|
+
@etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
|
|
100
|
+
trigger-value-change-event
|
|
101
|
+
label="${getTranslation(this.language, 'DOCUMENT_TYPE')}"
|
|
102
|
+
placeholder="${getTranslation(this.language, 'SELECT_DOCUMENT_TYPE')}"
|
|
103
|
+
required
|
|
104
|
+
?readonly="${this.readonly}"
|
|
105
|
+
hide-search
|
|
106
|
+
.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}"
|
|
107
|
+
option-label="label"
|
|
108
|
+
option-value="value"
|
|
109
|
+
?invalid="${this.checkFileType(index)}"
|
|
110
|
+
.errorMessage="${this.retrieveErrorMessage(index)}"
|
|
111
|
+
allow-outside-scroll
|
|
112
|
+
dynamic-align
|
|
113
|
+
></etools-dropdown>
|
|
114
|
+
|
|
115
|
+
<!-- File name component -->
|
|
116
|
+
<div class="filename-container file-selector__filename">
|
|
117
|
+
<etools-icon class="file-icon" name="attachment"></etools-icon>
|
|
118
|
+
<span class="filename" title="${attachment.filename}">${attachment.filename}</span>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- Download Button -->
|
|
122
|
+
<etools-button
|
|
123
|
+
variant="text"
|
|
124
|
+
?hidden="${!attachment.url}"
|
|
125
|
+
class="download-button file-selector__download"
|
|
126
|
+
@click="${() => this.downloadFile(attachment)}"
|
|
127
|
+
>
|
|
128
|
+
<etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
|
|
129
|
+
${getTranslation(this.language, 'DOWNLOAD')}
|
|
130
|
+
</etools-button>
|
|
131
|
+
|
|
132
|
+
<!-- Delete Button -->
|
|
133
|
+
<etools-button
|
|
134
|
+
variant="text"
|
|
135
|
+
class="danger delete-button file-selector__delete"
|
|
136
|
+
?hidden="${this.readonly}"
|
|
137
|
+
@click="${() => this.deleteAttachment(index)}"
|
|
138
|
+
>
|
|
139
|
+
${getTranslation(this.language, 'DELETE')}
|
|
140
|
+
</etools-button>
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
})}
|
|
144
|
+
|
|
145
|
+
<!-- Upload button -->
|
|
146
|
+
<etools-upload-multi
|
|
147
|
+
class="with-padding"
|
|
148
|
+
activate-offline
|
|
149
|
+
?hidden="${this.readonly}"
|
|
150
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
151
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
152
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
153
|
+
>
|
|
154
|
+
</etools-upload-multi>
|
|
155
|
+
</div>
|
|
156
|
+
</etools-dialog>
|
|
157
|
+
`;
|
|
55
158
|
}
|
|
56
159
|
/**
|
|
57
160
|
* on Cancel button click
|
|
@@ -73,7 +176,7 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
|
73
176
|
this.attachments.forEach((attachment, index) => {
|
|
74
177
|
if (!attachment.file_type) {
|
|
75
178
|
fileTypeNotSelected = true;
|
|
76
|
-
this.errors[index] = { file_type: [
|
|
179
|
+
this.errors[index] = { file_type: [getTranslation(this.language, 'REQUIRED_FIELD')] };
|
|
77
180
|
}
|
|
78
181
|
else {
|
|
79
182
|
this.errors[index] = [];
|
|
@@ -173,54 +276,54 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
|
173
276
|
return [
|
|
174
277
|
SharedStyles,
|
|
175
278
|
AttachmentsStyles,
|
|
176
|
-
css `
|
|
177
|
-
.file-selector__type-dropdown {
|
|
178
|
-
flex-basis: 25%;
|
|
179
|
-
padding-left: 8px;
|
|
180
|
-
padding-right: 8px;
|
|
181
|
-
}
|
|
182
|
-
.file-selector__filename {
|
|
183
|
-
flex-basis: 35%;
|
|
184
|
-
}
|
|
185
|
-
.file-selector__download {
|
|
186
|
-
flex-basis: 10%;
|
|
187
|
-
}
|
|
188
|
-
.file-selector__delete {
|
|
189
|
-
flex-basis: 10%;
|
|
190
|
-
}
|
|
191
|
-
.file-selector-container.with-type-dropdown {
|
|
192
|
-
flex-wrap: nowrap;
|
|
193
|
-
}
|
|
194
|
-
.popup-container {
|
|
195
|
-
padding: 12px 12px 0;
|
|
196
|
-
}
|
|
197
|
-
@media (max-width: 380px) {
|
|
198
|
-
.file-selector-container.with-type-dropdown {
|
|
199
|
-
justify-content: center;
|
|
200
|
-
}
|
|
201
|
-
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
202
|
-
flex-basis: 90%;
|
|
203
|
-
}
|
|
204
|
-
.file-selector__filename {
|
|
205
|
-
flex-basis: 90%;
|
|
206
|
-
}
|
|
207
|
-
.file-selector__download {
|
|
208
|
-
flex-basis: 5%;
|
|
209
|
-
}
|
|
210
|
-
.file-selector__delete {
|
|
211
|
-
flex-basis: 5%;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
@media (max-width: 600px) {
|
|
215
|
-
etools-dropdown {
|
|
216
|
-
padding: 0;
|
|
217
|
-
}
|
|
218
|
-
.file-selector-container.with-type-dropdown {
|
|
219
|
-
border-bottom: 1px solid lightgrey;
|
|
220
|
-
flex-wrap: wrap;
|
|
221
|
-
padding-bottom: 10px;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
279
|
+
css `
|
|
280
|
+
.file-selector__type-dropdown {
|
|
281
|
+
flex-basis: 25%;
|
|
282
|
+
padding-left: 8px;
|
|
283
|
+
padding-right: 8px;
|
|
284
|
+
}
|
|
285
|
+
.file-selector__filename {
|
|
286
|
+
flex-basis: 35%;
|
|
287
|
+
}
|
|
288
|
+
.file-selector__download {
|
|
289
|
+
flex-basis: 10%;
|
|
290
|
+
}
|
|
291
|
+
.file-selector__delete {
|
|
292
|
+
flex-basis: 10%;
|
|
293
|
+
}
|
|
294
|
+
.file-selector-container.with-type-dropdown {
|
|
295
|
+
flex-wrap: nowrap;
|
|
296
|
+
}
|
|
297
|
+
.popup-container {
|
|
298
|
+
padding: 12px 12px 0;
|
|
299
|
+
}
|
|
300
|
+
@media (max-width: 380px) {
|
|
301
|
+
.file-selector-container.with-type-dropdown {
|
|
302
|
+
justify-content: center;
|
|
303
|
+
}
|
|
304
|
+
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
305
|
+
flex-basis: 90%;
|
|
306
|
+
}
|
|
307
|
+
.file-selector__filename {
|
|
308
|
+
flex-basis: 90%;
|
|
309
|
+
}
|
|
310
|
+
.file-selector__download {
|
|
311
|
+
flex-basis: 5%;
|
|
312
|
+
}
|
|
313
|
+
.file-selector__delete {
|
|
314
|
+
flex-basis: 5%;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
@media (max-width: 600px) {
|
|
318
|
+
etools-dropdown {
|
|
319
|
+
padding: 0;
|
|
320
|
+
}
|
|
321
|
+
.file-selector-container.with-type-dropdown {
|
|
322
|
+
border-bottom: 1px solid lightgrey;
|
|
323
|
+
flex-wrap: wrap;
|
|
324
|
+
padding-bottom: 10px;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
224
327
|
`
|
|
225
328
|
];
|
|
226
329
|
}
|
|
@@ -25,12 +25,13 @@ export class AbstractFieldBaseClass extends LitElement {
|
|
|
25
25
|
this.questionText = '';
|
|
26
26
|
this.required = false;
|
|
27
27
|
this.placeholder = '';
|
|
28
|
+
this.name = '';
|
|
28
29
|
this.value = null;
|
|
29
30
|
this.validators = [];
|
|
30
31
|
this.touched = false;
|
|
31
32
|
this._readonly = false;
|
|
32
33
|
if (!this.language) {
|
|
33
|
-
this.language = window.
|
|
34
|
+
this.language = window.EtoolsLanguage || 'en';
|
|
34
35
|
}
|
|
35
36
|
this.handleLanguageChange = this.handleLanguageChange.bind(this);
|
|
36
37
|
}
|
|
@@ -46,11 +47,11 @@ export class AbstractFieldBaseClass extends LitElement {
|
|
|
46
47
|
this.language = e.detail.language;
|
|
47
48
|
}
|
|
48
49
|
render() {
|
|
49
|
-
return html `
|
|
50
|
-
<div class="finding-container">
|
|
51
|
-
<div class="question"><slot>${this.questionTemplate()}</slot></div>
|
|
52
|
-
<div class="question-control">${this.controlTemplate()}</div>
|
|
53
|
-
</div>
|
|
50
|
+
return html `
|
|
51
|
+
<div class="finding-container">
|
|
52
|
+
<div class="question"><slot>${this.questionTemplate()}</slot></div>
|
|
53
|
+
<div class="question-control">${this.controlTemplate()}</div>
|
|
54
|
+
</div>
|
|
54
55
|
`;
|
|
55
56
|
}
|
|
56
57
|
questionTemplate() {
|
|
@@ -75,116 +76,102 @@ export class AbstractFieldBaseClass extends LitElement {
|
|
|
75
76
|
// language=CSS
|
|
76
77
|
return [
|
|
77
78
|
FlexLayoutClasses,
|
|
78
|
-
css `
|
|
79
|
-
:host {
|
|
80
|
-
display: block;
|
|
81
|
-
width: 100%;
|
|
82
|
-
padding: 0 25px 0 45px;
|
|
83
|
-
box-sizing: border-box;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.finding-container {
|
|
87
|
-
width: 100%;
|
|
88
|
-
display: flex;
|
|
89
|
-
}
|
|
90
|
-
.flex-wrapping {
|
|
91
|
-
flex-wrap: wrap;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
:host(.wide) .finding-container {
|
|
95
|
-
flex-direction: column;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
:host(.wide) .question {
|
|
99
|
-
margin-bottom: -8px;
|
|
100
|
-
min-height: 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.question-control,
|
|
104
|
-
.question {
|
|
105
|
-
min-width: 0;
|
|
106
|
-
min-height: 57px;
|
|
107
|
-
display: flex;
|
|
108
|
-
align-items: center;
|
|
109
|
-
}
|
|
110
|
-
.question {
|
|
111
|
-
flex: 2;
|
|
112
|
-
}
|
|
113
|
-
.question-control {
|
|
114
|
-
flex: 3;
|
|
115
|
-
}
|
|
116
|
-
.add-button {
|
|
117
|
-
padding: 3px;
|
|
118
|
-
margin: 10px;
|
|
119
|
-
background: transparent;
|
|
120
|
-
color: var(--primary-color);
|
|
121
|
-
border: 1px solid;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.full-width
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.question-control {
|
|
166
|
-
flex:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
:host(text-field) .question-control {
|
|
176
|
-
min-height: 150px;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.question-control .container paper-radio-group {
|
|
180
|
-
flex-direction: column;
|
|
181
|
-
opacity: 1 !important;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.finding-container {
|
|
185
|
-
flex-direction: column;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
79
|
+
css `
|
|
80
|
+
:host {
|
|
81
|
+
display: block;
|
|
82
|
+
width: 100%;
|
|
83
|
+
padding: 0 25px 0 45px;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.finding-container {
|
|
88
|
+
width: 100%;
|
|
89
|
+
display: flex;
|
|
90
|
+
}
|
|
91
|
+
.flex-wrapping {
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host(.wide) .finding-container {
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host(.wide) .question {
|
|
100
|
+
margin-bottom: -8px;
|
|
101
|
+
min-height: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.question-control,
|
|
105
|
+
.question {
|
|
106
|
+
min-width: 0;
|
|
107
|
+
min-height: 57px;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
}
|
|
111
|
+
.question {
|
|
112
|
+
flex: 2;
|
|
113
|
+
}
|
|
114
|
+
.question-control {
|
|
115
|
+
flex: 3;
|
|
116
|
+
}
|
|
117
|
+
.add-button {
|
|
118
|
+
padding: 3px;
|
|
119
|
+
margin: 10px;
|
|
120
|
+
background: transparent;
|
|
121
|
+
color: var(--primary-color);
|
|
122
|
+
border: 1px solid;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.full-width {
|
|
126
|
+
width: 100%;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.question-text {
|
|
130
|
+
font-weight: 500;
|
|
131
|
+
font-size: var(--etools-font-size-13, 13px);
|
|
132
|
+
color: var(--primary-text-color);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
etools-icon[name='close'] {
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.error-text {
|
|
140
|
+
color: var(--error-color);
|
|
141
|
+
font-size: var(--etools-font-size-12, 12px);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@media (max-width: 1080px) {
|
|
145
|
+
:host {
|
|
146
|
+
padding: 0 15px;
|
|
147
|
+
}
|
|
148
|
+
.finding-container {
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
}
|
|
151
|
+
.question,
|
|
152
|
+
.question-control {
|
|
153
|
+
flex: 0 1 auto;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media print {
|
|
158
|
+
.question-control {
|
|
159
|
+
align-items: start;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
:host(text-field) .question-control {
|
|
163
|
+
min-height: 150px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.question-control .container etools-radio-group {
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
opacity: 1 !important;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.finding-container {
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
188
175
|
`
|
|
189
176
|
];
|
|
190
177
|
}
|
|
@@ -204,6 +191,9 @@ __decorate([
|
|
|
204
191
|
__decorate([
|
|
205
192
|
property()
|
|
206
193
|
], AbstractFieldBaseClass.prototype, "placeholder", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
property()
|
|
196
|
+
], AbstractFieldBaseClass.prototype, "name", void 0);
|
|
207
197
|
__decorate([
|
|
208
198
|
property()
|
|
209
199
|
], AbstractFieldBaseClass.prototype, "value", void 0);
|
|
@@ -2,9 +2,12 @@ import { CSSResultArray, LitElement, TemplateResult } from 'lit';
|
|
|
2
2
|
import { BlueprintField } from '../lib/types/form-builder.types';
|
|
3
3
|
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
4
4
|
import { FieldOption } from './single-fields/scale-field';
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
|
|
6
|
+
import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
|
|
5
7
|
export declare class FieldRendererComponent extends LitElement {
|
|
6
8
|
field: BlueprintField;
|
|
7
9
|
value: any;
|
|
10
|
+
language: string;
|
|
8
11
|
errorMessage: string | null;
|
|
9
12
|
validations: FieldValidator[];
|
|
10
13
|
readonly: boolean;
|
|
@@ -13,8 +16,9 @@ export declare class FieldRendererComponent extends LitElement {
|
|
|
13
16
|
defaultValue: any;
|
|
14
17
|
render(): TemplateResult;
|
|
15
18
|
renderField(blueprintField: BlueprintField): TemplateResult;
|
|
16
|
-
renderStandardField({ input_type, label, help_text, required, placeholder, styling }: BlueprintField): TemplateResult;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
renderStandardField({ input_type, label, help_text, required, placeholder, styling, name }: BlueprintField, isMandatory?: boolean): TemplateResult;
|
|
20
|
+
renderTooltip(isMandatory: boolean): "" | TemplateResult<1>;
|
|
21
|
+
renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }: BlueprintField, isMandatory?: boolean): TemplateResult;
|
|
22
|
+
renderFieldLabel(label: string, helperText: string, isMandatory?: boolean): TemplateResult;
|
|
19
23
|
static get styles(): CSSResultArray;
|
|
20
24
|
}
|