@dile/crud 0.2.1 → 0.2.2
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.
|
@@ -5,86 +5,90 @@ import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
|
|
|
5
5
|
import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
|
|
6
6
|
|
|
7
7
|
export class DileCrudUpdate extends DileI18nMixin(LitElement) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
static styles = [
|
|
9
|
+
formStyles,
|
|
10
|
+
css`
|
|
11
11
|
|
|
12
12
|
`
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
static get properties() {
|
|
16
|
-
return {
|
|
17
|
-
title: { type: String },
|
|
18
|
-
relatedId: { type: String },
|
|
19
|
-
endpoint: { type: String },
|
|
20
|
-
actionLabel: { type: String },
|
|
21
|
-
loadOnInit: { type: Boolean },
|
|
22
|
-
formTemplate: { type: Object },
|
|
23
|
-
buttonSmall: { type: Boolean },
|
|
24
|
-
responseAdapter: { type: Object },
|
|
25
|
-
formIdentifier: { type: String },
|
|
26
|
-
sendDataAsFormData: { type: Boolean },
|
|
27
|
-
showCancelButton: { type: Boolean },
|
|
28
|
-
};
|
|
29
|
-
}
|
|
13
|
+
];
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
title: { type: String },
|
|
18
|
+
relatedId: { type: String },
|
|
19
|
+
endpoint: { type: String },
|
|
20
|
+
actionLabel: { type: String },
|
|
21
|
+
loadOnInit: { type: Boolean },
|
|
22
|
+
formTemplate: { type: Object },
|
|
23
|
+
buttonSmall: { type: Boolean },
|
|
24
|
+
responseAdapter: { type: Object },
|
|
25
|
+
formIdentifier: { type: String },
|
|
26
|
+
sendDataAsFormData: { type: Boolean },
|
|
27
|
+
showCancelButton: { type: Boolean },
|
|
28
|
+
data: { type: Object },
|
|
29
|
+
setDataOnInit: { type: Boolean },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
this.responseAdapter = new ResponseApiAdapter();
|
|
36
|
+
this.loadOnInit = false;
|
|
37
|
+
this.formIdentifier = 'updateform';
|
|
38
|
+
}
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
get formElement() {
|
|
41
|
+
return this.shadowRoot.getElementById('elform');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
return html`
|
|
44
46
|
${this.title
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
? html`<h1>${this.title}</h1>`
|
|
48
|
+
: ''
|
|
49
|
+
}
|
|
50
|
+
<dile-ajax-form
|
|
51
|
+
id="elform"
|
|
52
|
+
operation="update"
|
|
53
|
+
endpoint="${this.endpoint}"
|
|
54
|
+
actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
|
|
55
|
+
@save-success="${this.doSuccessSave}"
|
|
56
|
+
?buttonSmall="${this.buttonSmall}"
|
|
57
|
+
relatedId="${this.relatedId}"
|
|
58
|
+
?loadOnInit="${this.loadOnInit}"
|
|
59
|
+
.responseAdapter="${this.responseAdapter}"
|
|
60
|
+
formIdentifier="${this.formIdentifier}"
|
|
61
|
+
language="${this.language}"
|
|
62
|
+
?sendDataAsFormData=${this.sendDataAsFormData}
|
|
63
|
+
?showCancelButton=${this.showCancelButton}
|
|
64
|
+
?setDataOnInit=${this.setDataOnInit}
|
|
65
|
+
.data=${this.data}
|
|
66
|
+
>
|
|
67
|
+
${this.formTemplate()}
|
|
68
|
+
</dile-ajax-form>
|
|
65
69
|
`;
|
|
66
|
-
|
|
70
|
+
}
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
doSuccessSave(e) {
|
|
73
|
+
this.dispatchEvent(new CustomEvent('crud-update-success', {
|
|
74
|
+
bubbles: true,
|
|
75
|
+
composed: true,
|
|
76
|
+
detail: e.detail
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
edit(id) {
|
|
81
|
+
this.relatedId = id;
|
|
82
|
+
this.updateComplete.then(() => {
|
|
83
|
+
this.formElement.loadData();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
clearFeedback() {
|
|
88
|
+
this.formElement.clearFeedback();
|
|
89
|
+
}
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
actionLabelComputed(label, translations) {
|
|
92
|
+
return label ? label : translations?.update_label ? translations.update_label : 'Update';
|
|
93
|
+
}
|
|
90
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "631d93271645e9b413490ab0a9576c5f80026826"
|
|
35
35
|
}
|