@unicef-polymer/etools-form-builder 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -674
- package/README.md +1 -1
- package/dist/assets/translations.d.ts +6 -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 +255 -255
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +91 -91
- 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 +213 -213
- package/dist/form-fields/field-renderer-component.d.ts +20 -20
- package/dist/form-fields/field-renderer-component.js +255 -255
- package/dist/form-fields/index.d.ts +12 -12
- package/dist/form-fields/index.js +12 -12
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +209 -209
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +124 -124
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +67 -67
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
- package/dist/form-fields/single-fields/attachment-field.js +98 -98
- 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 +49 -49
- package/dist/form-fields/single-fields/number-field.d.ts +10 -10
- package/dist/form-fields/single-fields/number-field.js +67 -67
- package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
- package/dist/form-fields/single-fields/scale-field.js +108 -108
- package/dist/form-fields/single-fields/text-field.d.ts +8 -8
- package/dist/form-fields/single-fields/text-field.js +54 -54
- package/dist/form-groups/form-abstract-group.d.ts +71 -71
- package/dist/form-groups/form-abstract-group.js +398 -398
- package/dist/form-groups/form-card.d.ts +32 -32
- package/dist/form-groups/form-card.js +113 -113
- package/dist/form-groups/form-collapsed-card.d.ts +71 -71
- package/dist/form-groups/form-collapsed-card.js +259 -259
- 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 +72 -72
- package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
- package/dist/lib/additional-components/etools-fb-card.js +239 -238
- package/dist/lib/styles/attachments.styles.d.ts +2 -2
- package/dist/lib/styles/attachments.styles.js +72 -72
- package/dist/lib/styles/card-styles.d.ts +2 -2
- package/dist/lib/styles/card-styles.js +154 -154
- package/dist/lib/styles/dialog.styles.d.ts +2 -2
- package/dist/lib/styles/dialog.styles.js +85 -85
- package/dist/lib/styles/elevation-styles.d.ts +9 -9
- package/dist/lib/styles/elevation-styles.js +43 -43
- package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
- package/dist/lib/styles/flex-layout-classes.js +319 -319
- package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
- package/dist/lib/styles/form-builder-card.styles.js +49 -49
- package/dist/lib/styles/input-styles.d.ts +2 -2
- package/dist/lib/styles/input-styles.js +138 -138
- package/dist/lib/styles/page-layout-styles.d.ts +2 -2
- package/dist/lib/styles/page-layout-styles.js +201 -201
- package/dist/lib/styles/shared-styles.d.ts +2 -2
- package/dist/lib/styles/shared-styles.js +70 -70
- package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
- package/dist/lib/types/form-builder.interfaces.js +0 -0
- package/dist/lib/types/form-builder.types.d.ts +59 -59
- package/dist/lib/types/form-builder.types.js +0 -0
- package/dist/lib/types/global.types.d.ts +4 -4
- package/dist/lib/types/global.types.js +0 -0
- package/dist/lib/utils/dialog.d.ts +10 -10
- package/dist/lib/utils/dialog.js +21 -21
- package/dist/lib/utils/fire-custom-event.d.ts +1 -1
- package/dist/lib/utils/fire-custom-event.js +7 -7
- package/dist/lib/utils/translate.d.ts +1 -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 +56 -56
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
-
import '@polymer/paper-input/paper-textarea';
|
|
3
|
-
import { RepeatableBaseField } from './repeatable-base-field';
|
|
4
|
-
export declare class RepeatableTextField extends RepeatableBaseField<string> {
|
|
5
|
-
protected controlTemplate(value: string | null, index: number): TemplateResult;
|
|
6
|
-
protected customValidation(): string | null;
|
|
7
|
-
static get styles(): CSSResultArray;
|
|
8
|
-
}
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
+
import '@polymer/paper-input/paper-textarea';
|
|
3
|
+
import { RepeatableBaseField } from './repeatable-base-field';
|
|
4
|
+
export declare class RepeatableTextField extends RepeatableBaseField<string> {
|
|
5
|
+
protected controlTemplate(value: string | null, index: number): TemplateResult;
|
|
6
|
+
protected customValidation(): string | null;
|
|
7
|
+
static get styles(): CSSResultArray;
|
|
8
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
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 { css, customElement, html } from 'lit-element';
|
|
8
|
-
import '@polymer/paper-input/paper-textarea';
|
|
9
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
10
|
-
import { RepeatableBaseField } from './repeatable-base-field';
|
|
11
|
-
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
12
|
-
let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField {
|
|
13
|
-
controlTemplate(value, index) {
|
|
14
|
-
return html `
|
|
15
|
-
${InputStyles}
|
|
16
|
-
<paper-textarea
|
|
17
|
-
id="textarea"
|
|
18
|
-
class="no-padding-left"
|
|
19
|
-
no-label-float
|
|
20
|
-
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
21
|
-
.value="${value}"
|
|
22
|
-
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
23
|
-
?readonly="${this.isReadonly}"
|
|
24
|
-
?invalid="${this.errorMessage[index]}"
|
|
25
|
-
error-message="${this.errorMessage[index]}"
|
|
26
|
-
>
|
|
27
|
-
</paper-textarea>
|
|
28
|
-
`;
|
|
29
|
-
}
|
|
30
|
-
customValidation() {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
static get styles() {
|
|
34
|
-
// language=CSS
|
|
35
|
-
return [
|
|
36
|
-
...AbstractFieldBaseClass.styles,
|
|
37
|
-
css `
|
|
38
|
-
:host(.wide) paper-textarea {
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
}
|
|
41
|
-
@media (max-width: 380px) {
|
|
42
|
-
.no-padding-left {
|
|
43
|
-
padding-left: 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
`
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
RepeatableTextField = __decorate([
|
|
51
|
-
customElement('repeatable-text-field')
|
|
52
|
-
], RepeatableTextField);
|
|
53
|
-
export { RepeatableTextField };
|
|
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 { css, customElement, html } from 'lit-element';
|
|
8
|
+
import '@polymer/paper-input/paper-textarea';
|
|
9
|
+
import { InputStyles } from '../../lib/styles/input-styles';
|
|
10
|
+
import { RepeatableBaseField } from './repeatable-base-field';
|
|
11
|
+
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
12
|
+
let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField {
|
|
13
|
+
controlTemplate(value, index) {
|
|
14
|
+
return html `
|
|
15
|
+
${InputStyles}
|
|
16
|
+
<paper-textarea
|
|
17
|
+
id="textarea"
|
|
18
|
+
class="no-padding-left"
|
|
19
|
+
no-label-float
|
|
20
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
21
|
+
.value="${value}"
|
|
22
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
23
|
+
?readonly="${this.isReadonly}"
|
|
24
|
+
?invalid="${this.errorMessage[index]}"
|
|
25
|
+
error-message="${this.errorMessage[index]}"
|
|
26
|
+
>
|
|
27
|
+
</paper-textarea>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
customValidation() {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
static get styles() {
|
|
34
|
+
// language=CSS
|
|
35
|
+
return [
|
|
36
|
+
...AbstractFieldBaseClass.styles,
|
|
37
|
+
css `
|
|
38
|
+
:host(.wide) paper-textarea {
|
|
39
|
+
padding-left: 0;
|
|
40
|
+
}
|
|
41
|
+
@media (max-width: 380px) {
|
|
42
|
+
.no-padding-left {
|
|
43
|
+
padding-left: 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
RepeatableTextField = __decorate([
|
|
51
|
+
customElement('repeatable-text-field')
|
|
52
|
+
], RepeatableTextField);
|
|
53
|
+
export { RepeatableTextField };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import '@unicef-polymer/etools-upload/etools-upload';
|
|
2
|
-
import { BaseField } from './base-field';
|
|
3
|
-
import { SingleUploadFinishedDetails, StoredAttachment } from '../../form-attachments-popup';
|
|
4
|
-
import { TemplateResult, CSSResultArray } from 'lit-element';
|
|
5
|
-
export declare class AttachmentField extends BaseField<StoredAttachment | null> {
|
|
6
|
-
get uploadUrl(): string;
|
|
7
|
-
get jwtLocalStorageKey(): string;
|
|
8
|
-
computedPath: string[];
|
|
9
|
-
protected controlTemplate(): TemplateResult;
|
|
10
|
-
protected customValidation(): string | null;
|
|
11
|
-
protected attachmentsUploaded({ success, error }: SingleUploadFinishedDetails): void;
|
|
12
|
-
protected downloadFile(attachment: StoredAttachment | null): void;
|
|
13
|
-
private isUploadedAttachment;
|
|
14
|
-
private isOfflineSavedAttachment;
|
|
15
|
-
static get styles(): CSSResultArray;
|
|
16
|
-
}
|
|
1
|
+
import '@unicef-polymer/etools-upload/etools-upload';
|
|
2
|
+
import { BaseField } from './base-field';
|
|
3
|
+
import { SingleUploadFinishedDetails, StoredAttachment } from '../../form-attachments-popup';
|
|
4
|
+
import { TemplateResult, CSSResultArray } from 'lit-element';
|
|
5
|
+
export declare class AttachmentField extends BaseField<StoredAttachment | null> {
|
|
6
|
+
get uploadUrl(): string;
|
|
7
|
+
get jwtLocalStorageKey(): string;
|
|
8
|
+
computedPath: string[];
|
|
9
|
+
protected controlTemplate(): TemplateResult;
|
|
10
|
+
protected customValidation(): string | null;
|
|
11
|
+
protected attachmentsUploaded({ success, error }: SingleUploadFinishedDetails): void;
|
|
12
|
+
protected downloadFile(attachment: StoredAttachment | null): void;
|
|
13
|
+
private isUploadedAttachment;
|
|
14
|
+
private isOfflineSavedAttachment;
|
|
15
|
+
static get styles(): CSSResultArray;
|
|
16
|
+
}
|
|
@@ -1,98 +1,98 @@
|
|
|
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-upload/etools-upload';
|
|
8
|
-
import { BaseField } from './base-field';
|
|
9
|
-
import { AttachmentsHelper } from '../../form-attachments-popup';
|
|
10
|
-
import { html, customElement } from 'lit-element';
|
|
11
|
-
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
12
|
-
import { SharedStyles } from '../../lib/styles/shared-styles';
|
|
13
|
-
import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
|
|
14
|
-
import { getTranslation } from '../../lib/utils/translate';
|
|
15
|
-
let AttachmentField = class AttachmentField extends BaseField {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.computedPath = [];
|
|
19
|
-
}
|
|
20
|
-
get uploadUrl() {
|
|
21
|
-
return AttachmentsHelper.uploadUrl;
|
|
22
|
-
}
|
|
23
|
-
get jwtLocalStorageKey() {
|
|
24
|
-
return AttachmentsHelper.jwtLocalStorageKey;
|
|
25
|
-
}
|
|
26
|
-
controlTemplate() {
|
|
27
|
-
return html `
|
|
28
|
-
<!-- Upload button -->
|
|
29
|
-
<etools-upload
|
|
30
|
-
class="with-padding"
|
|
31
|
-
activate-offline
|
|
32
|
-
.uploadedFileInfo="${this.value}"
|
|
33
|
-
?readonly="${this.isReadonly}"
|
|
34
|
-
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
35
|
-
@delete-file="${() => this.valueChanged(null)}"
|
|
36
|
-
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
37
|
-
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
38
|
-
>
|
|
39
|
-
</etools-upload>
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
customValidation() {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
attachmentsUploaded({ success, error }) {
|
|
46
|
-
if (this.isUploadedAttachment(success)) {
|
|
47
|
-
this.valueChanged({
|
|
48
|
-
url: success.file_link,
|
|
49
|
-
attachment: success.id,
|
|
50
|
-
filename: success.filename,
|
|
51
|
-
file_type: null
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else if (this.isOfflineSavedAttachment(success)) {
|
|
55
|
-
this.valueChanged({
|
|
56
|
-
attachment: success.id,
|
|
57
|
-
filename: success.filename,
|
|
58
|
-
composedPath: [],
|
|
59
|
-
file_type: null
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
console.warn('Missing fields in parsed attachment');
|
|
64
|
-
this.valueChanged(null);
|
|
65
|
-
}
|
|
66
|
-
if (error && error.length) {
|
|
67
|
-
console.error(error);
|
|
68
|
-
fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
downloadFile(attachment) {
|
|
72
|
-
if (!(attachment === null || attachment === void 0 ? void 0 : attachment.url)) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const link = document.createElement('a');
|
|
76
|
-
link.target = '_blank';
|
|
77
|
-
link.href = attachment.url;
|
|
78
|
-
link.click();
|
|
79
|
-
window.URL.revokeObjectURL(attachment.url);
|
|
80
|
-
}
|
|
81
|
-
isUploadedAttachment(attachment) {
|
|
82
|
-
return (attachment.hasOwnProperty('filename') &&
|
|
83
|
-
attachment.hasOwnProperty('id') &&
|
|
84
|
-
attachment.hasOwnProperty('file_link') &&
|
|
85
|
-
!attachment.hasOwnProperty('unsynced'));
|
|
86
|
-
}
|
|
87
|
-
isOfflineSavedAttachment(attachment) {
|
|
88
|
-
return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
|
|
89
|
-
}
|
|
90
|
-
static get styles() {
|
|
91
|
-
// language=CSS
|
|
92
|
-
return [...BaseField.styles, SharedStyles, AttachmentsStyles];
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
AttachmentField = __decorate([
|
|
96
|
-
customElement('attachments-field')
|
|
97
|
-
], AttachmentField);
|
|
98
|
-
export { AttachmentField };
|
|
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-upload/etools-upload';
|
|
8
|
+
import { BaseField } from './base-field';
|
|
9
|
+
import { AttachmentsHelper } from '../../form-attachments-popup';
|
|
10
|
+
import { html, customElement } from 'lit-element';
|
|
11
|
+
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
12
|
+
import { SharedStyles } from '../../lib/styles/shared-styles';
|
|
13
|
+
import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
|
|
14
|
+
import { getTranslation } from '../../lib/utils/translate';
|
|
15
|
+
let AttachmentField = class AttachmentField extends BaseField {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.computedPath = [];
|
|
19
|
+
}
|
|
20
|
+
get uploadUrl() {
|
|
21
|
+
return AttachmentsHelper.uploadUrl;
|
|
22
|
+
}
|
|
23
|
+
get jwtLocalStorageKey() {
|
|
24
|
+
return AttachmentsHelper.jwtLocalStorageKey;
|
|
25
|
+
}
|
|
26
|
+
controlTemplate() {
|
|
27
|
+
return html `
|
|
28
|
+
<!-- Upload button -->
|
|
29
|
+
<etools-upload
|
|
30
|
+
class="with-padding"
|
|
31
|
+
activate-offline
|
|
32
|
+
.uploadedFileInfo="${this.value}"
|
|
33
|
+
?readonly="${this.isReadonly}"
|
|
34
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
35
|
+
@delete-file="${() => this.valueChanged(null)}"
|
|
36
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
37
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
38
|
+
>
|
|
39
|
+
</etools-upload>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
customValidation() {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
attachmentsUploaded({ success, error }) {
|
|
46
|
+
if (this.isUploadedAttachment(success)) {
|
|
47
|
+
this.valueChanged({
|
|
48
|
+
url: success.file_link,
|
|
49
|
+
attachment: success.id,
|
|
50
|
+
filename: success.filename,
|
|
51
|
+
file_type: null
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else if (this.isOfflineSavedAttachment(success)) {
|
|
55
|
+
this.valueChanged({
|
|
56
|
+
attachment: success.id,
|
|
57
|
+
filename: success.filename,
|
|
58
|
+
composedPath: [],
|
|
59
|
+
file_type: null
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.warn('Missing fields in parsed attachment');
|
|
64
|
+
this.valueChanged(null);
|
|
65
|
+
}
|
|
66
|
+
if (error && error.length) {
|
|
67
|
+
console.error(error);
|
|
68
|
+
fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
downloadFile(attachment) {
|
|
72
|
+
if (!(attachment === null || attachment === void 0 ? void 0 : attachment.url)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const link = document.createElement('a');
|
|
76
|
+
link.target = '_blank';
|
|
77
|
+
link.href = attachment.url;
|
|
78
|
+
link.click();
|
|
79
|
+
window.URL.revokeObjectURL(attachment.url);
|
|
80
|
+
}
|
|
81
|
+
isUploadedAttachment(attachment) {
|
|
82
|
+
return (attachment.hasOwnProperty('filename') &&
|
|
83
|
+
attachment.hasOwnProperty('id') &&
|
|
84
|
+
attachment.hasOwnProperty('file_link') &&
|
|
85
|
+
!attachment.hasOwnProperty('unsynced'));
|
|
86
|
+
}
|
|
87
|
+
isOfflineSavedAttachment(attachment) {
|
|
88
|
+
return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
|
|
89
|
+
}
|
|
90
|
+
static get styles() {
|
|
91
|
+
// language=CSS
|
|
92
|
+
return [...BaseField.styles, SharedStyles, AttachmentsStyles];
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
AttachmentField = __decorate([
|
|
96
|
+
customElement('attachments-field')
|
|
97
|
+
], AttachmentField);
|
|
98
|
+
export { AttachmentField };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit-element';
|
|
2
|
-
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
3
|
-
export declare abstract class BaseField<T> extends AbstractFieldBaseClass<T> {
|
|
4
|
-
set errorMessage(message: string | null);
|
|
5
|
-
get errorMessage(): string | null;
|
|
6
|
-
protected _errorMessage: string | null;
|
|
7
|
-
protected valueChanged(newValue: T): void;
|
|
8
|
-
protected setValue(newValue: T | null): void;
|
|
9
|
-
protected validateField(value: T): void;
|
|
10
|
-
protected abstract controlTemplate(): TemplateResult;
|
|
11
|
-
}
|
|
1
|
+
import { TemplateResult } from 'lit-element';
|
|
2
|
+
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
3
|
+
export declare abstract class BaseField<T> extends AbstractFieldBaseClass<T> {
|
|
4
|
+
set errorMessage(message: string | null);
|
|
5
|
+
get errorMessage(): string | null;
|
|
6
|
+
protected _errorMessage: string | null;
|
|
7
|
+
protected valueChanged(newValue: T): void;
|
|
8
|
+
protected setValue(newValue: T | null): void;
|
|
9
|
+
protected validateField(value: T): void;
|
|
10
|
+
protected abstract controlTemplate(): TemplateResult;
|
|
11
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
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 { property } from 'lit-element';
|
|
8
|
-
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
9
|
-
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
10
|
-
import { getTranslation } from '../../lib/utils/translate';
|
|
11
|
-
export class BaseField extends AbstractFieldBaseClass {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
this._errorMessage = null;
|
|
15
|
-
}
|
|
16
|
-
set errorMessage(message) {
|
|
17
|
-
this._errorMessage = message;
|
|
18
|
-
}
|
|
19
|
-
get errorMessage() {
|
|
20
|
-
return this.isReadonly ? null : this._errorMessage;
|
|
21
|
-
}
|
|
22
|
-
valueChanged(newValue) {
|
|
23
|
-
if (!newValue && this.value === undefined) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (!this.isReadonly && newValue !== this.value && this.touched) {
|
|
27
|
-
this.validateField(newValue);
|
|
28
|
-
}
|
|
29
|
-
else if (this.isReadonly || !this.touched) {
|
|
30
|
-
this._errorMessage = null;
|
|
31
|
-
}
|
|
32
|
-
if (newValue !== this.value) {
|
|
33
|
-
this.value = newValue;
|
|
34
|
-
fireEvent(this, 'value-changed', { value: newValue });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
setValue(newValue) {
|
|
38
|
-
this.value = newValue;
|
|
39
|
-
fireEvent(this, 'value-changed', { value: newValue });
|
|
40
|
-
}
|
|
41
|
-
validateField(value) {
|
|
42
|
-
let errorMessage;
|
|
43
|
-
if (this.required && !value && typeof value !== 'number') {
|
|
44
|
-
errorMessage = getTranslation(this.language, 'REQUIRED_FIELD');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
errorMessage = this.metaValidation(value);
|
|
48
|
-
}
|
|
49
|
-
if (this._errorMessage !== errorMessage) {
|
|
50
|
-
fireEvent(this, 'error-changed', { error: errorMessage });
|
|
51
|
-
this._errorMessage = errorMessage;
|
|
52
|
-
this.requestUpdate();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
__decorate([
|
|
57
|
-
property()
|
|
58
|
-
], BaseField.prototype, "_errorMessage", void 0);
|
|
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 { property } from 'lit-element';
|
|
8
|
+
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
9
|
+
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
10
|
+
import { getTranslation } from '../../lib/utils/translate';
|
|
11
|
+
export class BaseField extends AbstractFieldBaseClass {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this._errorMessage = null;
|
|
15
|
+
}
|
|
16
|
+
set errorMessage(message) {
|
|
17
|
+
this._errorMessage = message;
|
|
18
|
+
}
|
|
19
|
+
get errorMessage() {
|
|
20
|
+
return this.isReadonly ? null : this._errorMessage;
|
|
21
|
+
}
|
|
22
|
+
valueChanged(newValue) {
|
|
23
|
+
if (!newValue && this.value === undefined) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!this.isReadonly && newValue !== this.value && this.touched) {
|
|
27
|
+
this.validateField(newValue);
|
|
28
|
+
}
|
|
29
|
+
else if (this.isReadonly || !this.touched) {
|
|
30
|
+
this._errorMessage = null;
|
|
31
|
+
}
|
|
32
|
+
if (newValue !== this.value) {
|
|
33
|
+
this.value = newValue;
|
|
34
|
+
fireEvent(this, 'value-changed', { value: newValue });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setValue(newValue) {
|
|
38
|
+
this.value = newValue;
|
|
39
|
+
fireEvent(this, 'value-changed', { value: newValue });
|
|
40
|
+
}
|
|
41
|
+
validateField(value) {
|
|
42
|
+
let errorMessage;
|
|
43
|
+
if (this.required && !value && typeof value !== 'number') {
|
|
44
|
+
errorMessage = getTranslation(this.language, 'REQUIRED_FIELD');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
errorMessage = this.metaValidation(value);
|
|
48
|
+
}
|
|
49
|
+
if (this._errorMessage !== errorMessage) {
|
|
50
|
+
fireEvent(this, 'error-changed', { error: errorMessage });
|
|
51
|
+
this._errorMessage = errorMessage;
|
|
52
|
+
this.requestUpdate();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
__decorate([
|
|
57
|
+
property()
|
|
58
|
+
], BaseField.prototype, "_errorMessage", void 0);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
-
import { BaseField } from './base-field';
|
|
3
|
-
import '@polymer/paper-toggle-button';
|
|
4
|
-
export declare class BooleanField extends BaseField<boolean> {
|
|
5
|
-
protected controlTemplate(): TemplateResult;
|
|
6
|
-
protected customValidation(): string | null;
|
|
7
|
-
static get styles(): CSSResultArray;
|
|
8
|
-
}
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
+
import { BaseField } from './base-field';
|
|
3
|
+
import '@polymer/paper-toggle-button';
|
|
4
|
+
export declare class BooleanField extends BaseField<boolean> {
|
|
5
|
+
protected controlTemplate(): TemplateResult;
|
|
6
|
+
protected customValidation(): string | null;
|
|
7
|
+
static get styles(): CSSResultArray;
|
|
8
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
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 { css, customElement, html } from 'lit-element';
|
|
8
|
-
import { BaseField } from './base-field';
|
|
9
|
-
import '@polymer/paper-toggle-button';
|
|
10
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
11
|
-
let BooleanField = class BooleanField extends BaseField {
|
|
12
|
-
controlTemplate() {
|
|
13
|
-
return html `
|
|
14
|
-
${InputStyles}
|
|
15
|
-
<paper-toggle-button
|
|
16
|
-
class="no-padding-left"
|
|
17
|
-
?checked="${this.value}"
|
|
18
|
-
@iron-change="${(event) => this.valueChanged(event.currentTarget.checked)}"
|
|
19
|
-
?disabled="${this.isReadonly}"
|
|
20
|
-
>
|
|
21
|
-
</paper-toggle-button>
|
|
22
|
-
|
|
23
|
-
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
24
|
-
`;
|
|
25
|
-
}
|
|
26
|
-
customValidation() {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
static get styles() {
|
|
30
|
-
// language=CSS
|
|
31
|
-
return [
|
|
32
|
-
...BaseField.styles,
|
|
33
|
-
css `
|
|
34
|
-
:host(.wide) paper-textarea {
|
|
35
|
-
padding-left: 0;
|
|
36
|
-
}
|
|
37
|
-
@media (max-width: 380px) {
|
|
38
|
-
.no-padding-left {
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
BooleanField = __decorate([
|
|
47
|
-
customElement('boolean-field')
|
|
48
|
-
], BooleanField);
|
|
49
|
-
export { BooleanField };
|
|
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 { css, customElement, html } from 'lit-element';
|
|
8
|
+
import { BaseField } from './base-field';
|
|
9
|
+
import '@polymer/paper-toggle-button';
|
|
10
|
+
import { InputStyles } from '../../lib/styles/input-styles';
|
|
11
|
+
let BooleanField = class BooleanField extends BaseField {
|
|
12
|
+
controlTemplate() {
|
|
13
|
+
return html `
|
|
14
|
+
${InputStyles}
|
|
15
|
+
<paper-toggle-button
|
|
16
|
+
class="no-padding-left"
|
|
17
|
+
?checked="${this.value}"
|
|
18
|
+
@iron-change="${(event) => this.valueChanged(event.currentTarget.checked)}"
|
|
19
|
+
?disabled="${this.isReadonly}"
|
|
20
|
+
>
|
|
21
|
+
</paper-toggle-button>
|
|
22
|
+
|
|
23
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
customValidation() {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
static get styles() {
|
|
30
|
+
// language=CSS
|
|
31
|
+
return [
|
|
32
|
+
...BaseField.styles,
|
|
33
|
+
css `
|
|
34
|
+
:host(.wide) paper-textarea {
|
|
35
|
+
padding-left: 0;
|
|
36
|
+
}
|
|
37
|
+
@media (max-width: 380px) {
|
|
38
|
+
.no-padding-left {
|
|
39
|
+
padding-left: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
BooleanField = __decorate([
|
|
47
|
+
customElement('boolean-field')
|
|
48
|
+
], BooleanField);
|
|
49
|
+
export { BooleanField };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
-
import { BaseField } from './base-field';
|
|
3
|
-
import '@polymer/paper-input/paper-input';
|
|
4
|
-
export declare class NumberField extends BaseField<number> {
|
|
5
|
-
isInteger: boolean;
|
|
6
|
-
protected controlTemplate(): TemplateResult;
|
|
7
|
-
protected valueChanged(newValue: number): void;
|
|
8
|
-
protected customValidation(value: number): string | null;
|
|
9
|
-
static get styles(): CSSResultArray;
|
|
10
|
-
}
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit-element';
|
|
2
|
+
import { BaseField } from './base-field';
|
|
3
|
+
import '@polymer/paper-input/paper-input';
|
|
4
|
+
export declare class NumberField extends BaseField<number> {
|
|
5
|
+
isInteger: boolean;
|
|
6
|
+
protected controlTemplate(): TemplateResult;
|
|
7
|
+
protected valueChanged(newValue: number): void;
|
|
8
|
+
protected customValidation(value: number): string | null;
|
|
9
|
+
static get styles(): CSSResultArray;
|
|
10
|
+
}
|