@unicef-polymer/etools-form-builder 2.1.0-rc.6 → 2.1.1

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