@unicef-polymer/etools-form-builder 2.1.4 → 2.1.5
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/assets/translations.d.ts +6 -6
- package/dist/assets/translations.js +67 -67
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +86 -86
- 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 +207 -207
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +11 -11
- 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 -33
- package/dist/form-fields/abstract-field-base.class.js +98 -98
- package/dist/form-fields/field-renderer-component.d.ts +20 -20
- package/dist/form-fields/field-renderer-component.js +108 -108
- 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 +100 -100
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +102 -102
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +47 -47
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +49 -49
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +30 -30
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
- package/dist/form-fields/single-fields/attachment-field.js +85 -85
- package/dist/form-fields/single-fields/base-field.d.ts +11 -11
- package/dist/form-fields/single-fields/base-field.js +58 -58
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
- package/dist/form-fields/single-fields/boolean-field.js +29 -29
- package/dist/form-fields/single-fields/number-field.d.ts +10 -10
- package/dist/form-fields/single-fields/number-field.js +46 -46
- package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
- package/dist/form-fields/single-fields/scale-field.js +52 -52
- package/dist/form-fields/single-fields/text-field.d.ts +8 -8
- package/dist/form-fields/single-fields/text-field.js +29 -29
- package/dist/form-groups/form-abstract-group.d.ts +65 -65
- package/dist/form-groups/form-abstract-group.js +255 -255
- package/dist/form-groups/form-card.d.ts +32 -32
- package/dist/form-groups/form-card.js +89 -89
- package/dist/form-groups/form-collapsed-card.d.ts +70 -70
- package/dist/form-groups/form-collapsed-card.js +225 -225
- 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 -18
- package/dist/lib/additional-components/confirmation-dialog.js +52 -52
- package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
- package/dist/lib/additional-components/etools-fb-card.js +99 -99
- 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 +3 -3
- 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 +59 -59
- 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/translate.d.ts +1 -1
- package/dist/lib/utils/translate.js +9 -9
- package/dist/lib/utils/validations.helper.d.ts +26 -26
- package/dist/lib/utils/validations.helper.js +42 -42
- package/package.json +4 -4
|
@@ -1,184 +1,184 @@
|
|
|
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 '@unicef-polymer/etools-dialog/etools-dialog';
|
|
8
|
-
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
9
|
-
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
10
|
-
import '@polymer/paper-button/paper-button';
|
|
11
|
-
import '@polymer/iron-icons/iron-icons';
|
|
12
|
-
import { css, customElement, LitElement, property, query } from 'lit-element';
|
|
13
|
-
import { clone, equals } from 'ramda';
|
|
14
|
-
import { template } from './form-attachments-popup.tpl';
|
|
15
|
-
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
16
|
-
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
17
|
-
import { AttachmentsStyles } from '../lib/styles/attachments.styles';
|
|
18
|
-
import { AttachmentsHelper } from './form-attachments-popup.helper';
|
|
19
|
-
import { deleteFileFromDexie } from '@unicef-polymer/etools-upload/offline/dexie-operations';
|
|
20
|
-
import { getTranslation } from '../lib/utils/translate';
|
|
21
|
-
let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
22
|
-
constructor() {
|
|
23
|
-
super();
|
|
24
|
-
this.dialogOpened = true;
|
|
25
|
-
this.saveBtnClicked = false;
|
|
26
|
-
this.attachments = [];
|
|
27
|
-
this.readonly = false;
|
|
28
|
-
this.popupTitle = '';
|
|
29
|
-
this.computedPath = [];
|
|
30
|
-
this.errors = [];
|
|
31
|
-
/**
|
|
32
|
-
* Array of offline saved fileIds that was remove from popup.
|
|
33
|
-
* We need to remove them from IDB but only after confirm button click
|
|
34
|
-
*/
|
|
35
|
-
this.filesForRemove = [];
|
|
36
|
-
this.originalAttachments = [];
|
|
37
|
-
if (!AttachmentsHelper.isInitialized) {
|
|
38
|
-
throw new Error('Please initialize attachments popup before use');
|
|
39
|
-
}
|
|
40
|
-
if (!this.language) {
|
|
41
|
-
this.language = window.localStorage.defaultLanguage || 'en';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
set dialogData({ attachments, title, metadata, readonly, computedPath, errors }) {
|
|
45
|
-
this.popupTitle = title;
|
|
46
|
-
this.attachments = clone(attachments) || [];
|
|
47
|
-
this.originalAttachments = clone(attachments) || [];
|
|
48
|
-
this.metadata = clone(metadata);
|
|
49
|
-
this.readonly = Boolean(readonly);
|
|
50
|
-
this.computedPath = computedPath;
|
|
51
|
-
this.errors = clone(errors) || [];
|
|
52
|
-
}
|
|
53
|
-
get uploadUrl() {
|
|
54
|
-
return AttachmentsHelper.uploadUrl;
|
|
55
|
-
}
|
|
56
|
-
get jwtLocalStorageKey() {
|
|
57
|
-
return AttachmentsHelper.jwtLocalStorageKey;
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
60
|
-
return template.call(this);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* on Cancel button click
|
|
64
|
-
* Remove offline saved attachments from IDB if they are missing in originalAttachments
|
|
65
|
-
*/
|
|
66
|
-
onClose() {
|
|
67
|
-
this.attachments.forEach(({ url, attachment }) => {
|
|
68
|
-
const existsInOriginal = this.originalAttachments
|
|
69
|
-
.map((item) => item.attachment || [])
|
|
70
|
-
.includes(attachment);
|
|
71
|
-
if (!existsInOriginal && !url) {
|
|
72
|
-
deleteFileFromDexie(attachment);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
fireEvent(this, 'response', { confirmed: false });
|
|
76
|
-
}
|
|
77
|
-
async saveChanges() {
|
|
78
|
-
let fileTypeNotSelected = false;
|
|
79
|
-
this.attachments.forEach((attachment, index) => {
|
|
80
|
-
if (!attachment.file_type) {
|
|
81
|
-
fileTypeNotSelected = true;
|
|
82
|
-
this.errors[index] = { file_type: ['This field is required'] };
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.errors[index] = [];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
this.requestUpdate();
|
|
89
|
-
if (fileTypeNotSelected) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (this.filesForRemove.length) {
|
|
93
|
-
for (const fileId of this.filesForRemove) {
|
|
94
|
-
await deleteFileFromDexie(fileId);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Don't confirm popup if no changes was made
|
|
99
|
-
*/
|
|
100
|
-
if (!equals(this.attachments, this.originalAttachments)) {
|
|
101
|
-
fireEvent(this, 'response', { confirmed: true, attachments: this.attachments });
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
fireEvent(this, 'response', { confirmed: false });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
checkFileType(index) {
|
|
108
|
-
var _a;
|
|
109
|
-
return (_a = this.errors[index]) === null || _a === void 0 ? void 0 : _a.file_type;
|
|
110
|
-
}
|
|
111
|
-
retrieveErrorMessage(index) {
|
|
112
|
-
return this.errors[index] && this.errors[index].file_type ? this.errors[index].file_type[0] : '';
|
|
113
|
-
}
|
|
114
|
-
downloadFile(attachment) {
|
|
115
|
-
const url = attachment.url;
|
|
116
|
-
this.link.href = url;
|
|
117
|
-
this.link.click();
|
|
118
|
-
window.URL.revokeObjectURL(url);
|
|
119
|
-
}
|
|
120
|
-
changeFileType(attachment, newType, index) {
|
|
121
|
-
if (newType && attachment.file_type !== newType) {
|
|
122
|
-
attachment.file_type = newType;
|
|
123
|
-
this.errors[index] = [];
|
|
124
|
-
this.requestUpdate();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
attachmentsUploaded({ success, error }) {
|
|
128
|
-
const parsedAttachments = success
|
|
129
|
-
.map((attachment) => {
|
|
130
|
-
if (this.isUploadedAttachment(attachment)) {
|
|
131
|
-
return {
|
|
132
|
-
url: attachment.file_link,
|
|
133
|
-
attachment: attachment.id,
|
|
134
|
-
filename: attachment.filename,
|
|
135
|
-
file_type: null
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
else if (this.isOfflineSavedAttachment(attachment)) {
|
|
139
|
-
return {
|
|
140
|
-
attachment: attachment.id,
|
|
141
|
-
filename: attachment.filename,
|
|
142
|
-
composedPath: this.computedPath,
|
|
143
|
-
file_type: null
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
console.warn('Missing fields in parsed attachment');
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
.filter((attachment) => Boolean(attachment));
|
|
152
|
-
this.attachments = [...this.attachments, ...parsedAttachments];
|
|
153
|
-
if (error && error.length) {
|
|
154
|
-
console.error(error);
|
|
155
|
-
fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
deleteAttachment(index) {
|
|
159
|
-
const [attachment] = this.attachments.splice(index, 1);
|
|
160
|
-
if (!attachment.hasOwnProperty('url')) {
|
|
161
|
-
/**
|
|
162
|
-
* prepare attachment for remove from IDB after Popup confirm
|
|
163
|
-
*/
|
|
164
|
-
this.filesForRemove.push(attachment.attachment);
|
|
165
|
-
}
|
|
166
|
-
this.attachments = [...this.attachments];
|
|
167
|
-
}
|
|
168
|
-
isUploadedAttachment(attachment) {
|
|
169
|
-
return (attachment.hasOwnProperty('filename') &&
|
|
170
|
-
attachment.hasOwnProperty('id') &&
|
|
171
|
-
attachment.hasOwnProperty('file_link') &&
|
|
172
|
-
!attachment.hasOwnProperty('unsynced'));
|
|
173
|
-
}
|
|
174
|
-
isOfflineSavedAttachment(attachment) {
|
|
175
|
-
return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
|
|
176
|
-
}
|
|
177
|
-
static get styles() {
|
|
178
|
-
// language=CSS
|
|
179
|
-
return [
|
|
180
|
-
SharedStyles,
|
|
181
|
-
AttachmentsStyles,
|
|
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 '@unicef-polymer/etools-dialog/etools-dialog';
|
|
8
|
+
import '@unicef-polymer/etools-upload/etools-upload-multi';
|
|
9
|
+
import '@unicef-polymer/etools-dropdown/etools-dropdown';
|
|
10
|
+
import '@polymer/paper-button/paper-button';
|
|
11
|
+
import '@polymer/iron-icons/iron-icons';
|
|
12
|
+
import { css, customElement, LitElement, property, query } from 'lit-element';
|
|
13
|
+
import { clone, equals } from 'ramda';
|
|
14
|
+
import { template } from './form-attachments-popup.tpl';
|
|
15
|
+
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
16
|
+
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
17
|
+
import { AttachmentsStyles } from '../lib/styles/attachments.styles';
|
|
18
|
+
import { AttachmentsHelper } from './form-attachments-popup.helper';
|
|
19
|
+
import { deleteFileFromDexie } from '@unicef-polymer/etools-upload/offline/dexie-operations';
|
|
20
|
+
import { getTranslation } from '../lib/utils/translate';
|
|
21
|
+
let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.dialogOpened = true;
|
|
25
|
+
this.saveBtnClicked = false;
|
|
26
|
+
this.attachments = [];
|
|
27
|
+
this.readonly = false;
|
|
28
|
+
this.popupTitle = '';
|
|
29
|
+
this.computedPath = [];
|
|
30
|
+
this.errors = [];
|
|
31
|
+
/**
|
|
32
|
+
* Array of offline saved fileIds that was remove from popup.
|
|
33
|
+
* We need to remove them from IDB but only after confirm button click
|
|
34
|
+
*/
|
|
35
|
+
this.filesForRemove = [];
|
|
36
|
+
this.originalAttachments = [];
|
|
37
|
+
if (!AttachmentsHelper.isInitialized) {
|
|
38
|
+
throw new Error('Please initialize attachments popup before use');
|
|
39
|
+
}
|
|
40
|
+
if (!this.language) {
|
|
41
|
+
this.language = window.localStorage.defaultLanguage || 'en';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
set dialogData({ attachments, title, metadata, readonly, computedPath, errors }) {
|
|
45
|
+
this.popupTitle = title;
|
|
46
|
+
this.attachments = clone(attachments) || [];
|
|
47
|
+
this.originalAttachments = clone(attachments) || [];
|
|
48
|
+
this.metadata = clone(metadata);
|
|
49
|
+
this.readonly = Boolean(readonly);
|
|
50
|
+
this.computedPath = computedPath;
|
|
51
|
+
this.errors = clone(errors) || [];
|
|
52
|
+
}
|
|
53
|
+
get uploadUrl() {
|
|
54
|
+
return AttachmentsHelper.uploadUrl;
|
|
55
|
+
}
|
|
56
|
+
get jwtLocalStorageKey() {
|
|
57
|
+
return AttachmentsHelper.jwtLocalStorageKey;
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return template.call(this);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* on Cancel button click
|
|
64
|
+
* Remove offline saved attachments from IDB if they are missing in originalAttachments
|
|
65
|
+
*/
|
|
66
|
+
onClose() {
|
|
67
|
+
this.attachments.forEach(({ url, attachment }) => {
|
|
68
|
+
const existsInOriginal = this.originalAttachments
|
|
69
|
+
.map((item) => item.attachment || [])
|
|
70
|
+
.includes(attachment);
|
|
71
|
+
if (!existsInOriginal && !url) {
|
|
72
|
+
deleteFileFromDexie(attachment);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
fireEvent(this, 'response', { confirmed: false });
|
|
76
|
+
}
|
|
77
|
+
async saveChanges() {
|
|
78
|
+
let fileTypeNotSelected = false;
|
|
79
|
+
this.attachments.forEach((attachment, index) => {
|
|
80
|
+
if (!attachment.file_type) {
|
|
81
|
+
fileTypeNotSelected = true;
|
|
82
|
+
this.errors[index] = { file_type: ['This field is required'] };
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.errors[index] = [];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.requestUpdate();
|
|
89
|
+
if (fileTypeNotSelected) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (this.filesForRemove.length) {
|
|
93
|
+
for (const fileId of this.filesForRemove) {
|
|
94
|
+
await deleteFileFromDexie(fileId);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Don't confirm popup if no changes was made
|
|
99
|
+
*/
|
|
100
|
+
if (!equals(this.attachments, this.originalAttachments)) {
|
|
101
|
+
fireEvent(this, 'response', { confirmed: true, attachments: this.attachments });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
fireEvent(this, 'response', { confirmed: false });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
checkFileType(index) {
|
|
108
|
+
var _a;
|
|
109
|
+
return (_a = this.errors[index]) === null || _a === void 0 ? void 0 : _a.file_type;
|
|
110
|
+
}
|
|
111
|
+
retrieveErrorMessage(index) {
|
|
112
|
+
return this.errors[index] && this.errors[index].file_type ? this.errors[index].file_type[0] : '';
|
|
113
|
+
}
|
|
114
|
+
downloadFile(attachment) {
|
|
115
|
+
const url = attachment.url;
|
|
116
|
+
this.link.href = url;
|
|
117
|
+
this.link.click();
|
|
118
|
+
window.URL.revokeObjectURL(url);
|
|
119
|
+
}
|
|
120
|
+
changeFileType(attachment, newType, index) {
|
|
121
|
+
if (newType && attachment.file_type !== newType) {
|
|
122
|
+
attachment.file_type = newType;
|
|
123
|
+
this.errors[index] = [];
|
|
124
|
+
this.requestUpdate();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
attachmentsUploaded({ success, error }) {
|
|
128
|
+
const parsedAttachments = success
|
|
129
|
+
.map((attachment) => {
|
|
130
|
+
if (this.isUploadedAttachment(attachment)) {
|
|
131
|
+
return {
|
|
132
|
+
url: attachment.file_link,
|
|
133
|
+
attachment: attachment.id,
|
|
134
|
+
filename: attachment.filename,
|
|
135
|
+
file_type: null
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else if (this.isOfflineSavedAttachment(attachment)) {
|
|
139
|
+
return {
|
|
140
|
+
attachment: attachment.id,
|
|
141
|
+
filename: attachment.filename,
|
|
142
|
+
composedPath: this.computedPath,
|
|
143
|
+
file_type: null
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
console.warn('Missing fields in parsed attachment');
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
.filter((attachment) => Boolean(attachment));
|
|
152
|
+
this.attachments = [...this.attachments, ...parsedAttachments];
|
|
153
|
+
if (error && error.length) {
|
|
154
|
+
console.error(error);
|
|
155
|
+
fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
deleteAttachment(index) {
|
|
159
|
+
const [attachment] = this.attachments.splice(index, 1);
|
|
160
|
+
if (!attachment.hasOwnProperty('url')) {
|
|
161
|
+
/**
|
|
162
|
+
* prepare attachment for remove from IDB after Popup confirm
|
|
163
|
+
*/
|
|
164
|
+
this.filesForRemove.push(attachment.attachment);
|
|
165
|
+
}
|
|
166
|
+
this.attachments = [...this.attachments];
|
|
167
|
+
}
|
|
168
|
+
isUploadedAttachment(attachment) {
|
|
169
|
+
return (attachment.hasOwnProperty('filename') &&
|
|
170
|
+
attachment.hasOwnProperty('id') &&
|
|
171
|
+
attachment.hasOwnProperty('file_link') &&
|
|
172
|
+
!attachment.hasOwnProperty('unsynced'));
|
|
173
|
+
}
|
|
174
|
+
isOfflineSavedAttachment(attachment) {
|
|
175
|
+
return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
|
|
176
|
+
}
|
|
177
|
+
static get styles() {
|
|
178
|
+
// language=CSS
|
|
179
|
+
return [
|
|
180
|
+
SharedStyles,
|
|
181
|
+
AttachmentsStyles,
|
|
182
182
|
css `
|
|
183
183
|
.file-selector__type-dropdown {
|
|
184
184
|
flex-basis: 25%;
|
|
@@ -227,29 +227,29 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
|
|
|
227
227
|
padding-bottom: 10px;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
`
|
|
231
|
-
];
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
__decorate([
|
|
235
|
-
property()
|
|
236
|
-
], FormAttachmentsPopup.prototype, "dialogOpened", void 0);
|
|
237
|
-
__decorate([
|
|
238
|
-
property()
|
|
239
|
-
], FormAttachmentsPopup.prototype, "saveBtnClicked", void 0);
|
|
240
|
-
__decorate([
|
|
241
|
-
property()
|
|
242
|
-
], FormAttachmentsPopup.prototype, "attachments", void 0);
|
|
243
|
-
__decorate([
|
|
244
|
-
property()
|
|
245
|
-
], FormAttachmentsPopup.prototype, "metadata", void 0);
|
|
246
|
-
__decorate([
|
|
247
|
-
property()
|
|
248
|
-
], FormAttachmentsPopup.prototype, "language", void 0);
|
|
249
|
-
__decorate([
|
|
250
|
-
query('#link')
|
|
251
|
-
], FormAttachmentsPopup.prototype, "link", void 0);
|
|
252
|
-
FormAttachmentsPopup = __decorate([
|
|
253
|
-
customElement('form-attachments-popup')
|
|
254
|
-
], FormAttachmentsPopup);
|
|
255
|
-
export { FormAttachmentsPopup };
|
|
230
|
+
`
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
__decorate([
|
|
235
|
+
property()
|
|
236
|
+
], FormAttachmentsPopup.prototype, "dialogOpened", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property()
|
|
239
|
+
], FormAttachmentsPopup.prototype, "saveBtnClicked", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property()
|
|
242
|
+
], FormAttachmentsPopup.prototype, "attachments", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
property()
|
|
245
|
+
], FormAttachmentsPopup.prototype, "metadata", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
property()
|
|
248
|
+
], FormAttachmentsPopup.prototype, "language", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
query('#link')
|
|
251
|
+
], FormAttachmentsPopup.prototype, "link", void 0);
|
|
252
|
+
FormAttachmentsPopup = __decorate([
|
|
253
|
+
customElement('form-attachments-popup')
|
|
254
|
+
], FormAttachmentsPopup);
|
|
255
|
+
export { FormAttachmentsPopup };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FormAttachmentsPopup } from './form-attachments-popup';
|
|
2
|
-
import { TemplateResult } from 'lit-html';
|
|
3
|
-
export declare function template(this: FormAttachmentsPopup): TemplateResult;
|
|
1
|
+
import { FormAttachmentsPopup } from './form-attachments-popup';
|
|
2
|
+
import { TemplateResult } from 'lit-html';
|
|
3
|
+
export declare function template(this: FormAttachmentsPopup): TemplateResult;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { InputStyles } from '../lib/styles/input-styles';
|
|
3
|
-
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
4
|
-
import { getTranslation } from '../lib/utils/translate';
|
|
5
|
-
export function template() {
|
|
6
|
-
var _a;
|
|
1
|
+
import { html } from 'lit-html';
|
|
2
|
+
import { InputStyles } from '../lib/styles/input-styles';
|
|
3
|
+
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
4
|
+
import { getTranslation } from '../lib/utils/translate';
|
|
5
|
+
export function template() {
|
|
6
|
+
var _a;
|
|
7
7
|
return html `
|
|
8
8
|
${InputStyles} ${DialogStyles}
|
|
9
9
|
<etools-dialog
|
|
@@ -23,8 +23,8 @@ export function template() {
|
|
|
23
23
|
<a id="link" target="_blank" hidden></a>
|
|
24
24
|
|
|
25
25
|
<div class="popup-container">
|
|
26
|
-
${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
|
|
27
|
-
var _a, _b;
|
|
26
|
+
${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
|
|
27
|
+
var _a, _b;
|
|
28
28
|
return html `
|
|
29
29
|
<div class="file-selector-container with-type-dropdown">
|
|
30
30
|
<!-- Type select Dropdown -->
|
|
@@ -72,7 +72,7 @@ export function template() {
|
|
|
72
72
|
${getTranslation(this.language, 'DELETE')}
|
|
73
73
|
</paper-button>
|
|
74
74
|
</div>
|
|
75
|
-
`;
|
|
75
|
+
`;
|
|
76
76
|
})}
|
|
77
77
|
|
|
78
78
|
<!-- Upload button -->
|
|
@@ -87,5 +87,5 @@ export function template() {
|
|
|
87
87
|
</etools-upload-multi>
|
|
88
88
|
</div>
|
|
89
89
|
</etools-dialog>
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form-attachments-popup';
|
|
2
|
-
export * from './form-attachments-popup.helper';
|
|
1
|
+
export * from './form-attachments-popup';
|
|
2
|
+
export * from './form-attachments-popup.helper';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form-attachments-popup';
|
|
2
|
-
export * from './form-attachments-popup.helper';
|
|
1
|
+
export * from './form-attachments-popup';
|
|
2
|
+
export * from './form-attachments-popup.helper';
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
|
-
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
3
|
-
/**
|
|
4
|
-
* Class that contains common properties and methods for single and repeatable fields
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
|
|
7
|
-
questionText: string;
|
|
8
|
-
language: string;
|
|
9
|
-
set isReadonly(readonly: boolean);
|
|
10
|
-
get isReadonly(): boolean;
|
|
11
|
-
required: boolean;
|
|
12
|
-
placeholder: string;
|
|
13
|
-
value: T | null;
|
|
14
|
-
validators: FieldValidator[];
|
|
15
|
-
touched: boolean;
|
|
16
|
-
set defaultValue(value: any);
|
|
17
|
-
private _defaultValue;
|
|
18
|
-
private _readonly;
|
|
19
|
-
constructor();
|
|
20
|
-
connectedCallback(): void;
|
|
21
|
-
disconnectedCallback(): void;
|
|
22
|
-
handleLanguageChange(e: CustomEvent): void;
|
|
23
|
-
protected render(): TemplateResult;
|
|
24
|
-
protected questionTemplate(): TemplateResult;
|
|
25
|
-
protected metaValidation(value: unknown): string | null;
|
|
26
|
-
private setDefaultValue;
|
|
27
|
-
protected abstract valueChanged(...args: any): void;
|
|
28
|
-
protected abstract customValidation(value: unknown): string | null;
|
|
29
|
-
protected abstract controlTemplate(...args: any): TemplateResult;
|
|
30
|
-
protected abstract setValue(value: T): void;
|
|
31
|
-
protected abstract validateField(value: T): void;
|
|
32
|
-
static get styles(): CSSResultArray;
|
|
33
|
-
}
|
|
1
|
+
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
|
+
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
3
|
+
/**
|
|
4
|
+
* Class that contains common properties and methods for single and repeatable fields
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
|
|
7
|
+
questionText: string;
|
|
8
|
+
language: string;
|
|
9
|
+
set isReadonly(readonly: boolean);
|
|
10
|
+
get isReadonly(): boolean;
|
|
11
|
+
required: boolean;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
value: T | null;
|
|
14
|
+
validators: FieldValidator[];
|
|
15
|
+
touched: boolean;
|
|
16
|
+
set defaultValue(value: any);
|
|
17
|
+
private _defaultValue;
|
|
18
|
+
private _readonly;
|
|
19
|
+
constructor();
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
handleLanguageChange(e: CustomEvent): void;
|
|
23
|
+
protected render(): TemplateResult;
|
|
24
|
+
protected questionTemplate(): TemplateResult;
|
|
25
|
+
protected metaValidation(value: unknown): string | null;
|
|
26
|
+
private setDefaultValue;
|
|
27
|
+
protected abstract valueChanged(...args: any): void;
|
|
28
|
+
protected abstract customValidation(value: unknown): string | null;
|
|
29
|
+
protected abstract controlTemplate(...args: any): TemplateResult;
|
|
30
|
+
protected abstract setValue(value: T): void;
|
|
31
|
+
protected abstract validateField(value: T): void;
|
|
32
|
+
static get styles(): CSSResultArray;
|
|
33
|
+
}
|