@dile/crud 2.5.2 → 2.5.4
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.
|
@@ -2,7 +2,8 @@ import { LitElement, html, css } from 'lit';
|
|
|
2
2
|
import { moreVertIcon } from '@dile/icons';
|
|
3
3
|
import '@dile/ui/components/confirm/confirm.js';
|
|
4
4
|
import '@dile/ui/components/select/select.js';
|
|
5
|
-
import '
|
|
5
|
+
import '@dile/ui/components/spinner/spinner-modal.js';
|
|
6
|
+
import '../../ajax/ajax.js';
|
|
6
7
|
import '../../ui/crud-list-options.js';
|
|
7
8
|
import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
|
|
8
9
|
import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
|
|
@@ -62,8 +63,9 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
62
63
|
endpoint: { type: String },
|
|
63
64
|
actions: { type: Array },
|
|
64
65
|
formActionsTemplate: { type: Object },
|
|
65
|
-
destructive: { type: Boolean, reflect: true
|
|
66
|
+
destructive: { type: Boolean, reflect: true },
|
|
66
67
|
responseAdapter: { type: Object },
|
|
68
|
+
loading: { type: Boolean },
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -73,6 +75,7 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
73
75
|
this.actions = [];
|
|
74
76
|
this.selection = 'DeleteAction';
|
|
75
77
|
this.responseAdapter = new ResponseApiAdapter();
|
|
78
|
+
this.loading = false;
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
firstUpdated() {
|
|
@@ -85,7 +88,8 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
85
88
|
${this.ajaxTemplate}
|
|
86
89
|
${this.actionListTemplate}
|
|
87
90
|
${this.confirmActionTemplate}
|
|
88
|
-
|
|
91
|
+
<dile-spinner-modal ?active=${this.loading}></dile-spinner-modal>
|
|
92
|
+
`;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
get ajaxTemplate() {
|
|
@@ -119,7 +123,7 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
119
123
|
${this.actions.map(action => html`<option value="${action.name}">${action.label}</option>`)}
|
|
120
124
|
</select>
|
|
121
125
|
</dile-select>
|
|
122
|
-
|
|
126
|
+
`;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
get confirmActionTemplate() {
|
|
@@ -169,15 +173,24 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
169
173
|
this.confirmElement.open();
|
|
170
174
|
let listOptions = this.shadowRoot.querySelector('dile-crud-list-options');
|
|
171
175
|
if (listOptions) {
|
|
172
|
-
listOptions.close()
|
|
176
|
+
listOptions.close();
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
get selectedActionForm() {
|
|
177
|
-
return this.shadowRoot.querySelector(`[action="${this.selection}"]`)
|
|
181
|
+
return this.shadowRoot.querySelector(`[action="${this.selection}"]`);
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
doAction() {
|
|
185
|
+
this.loading = true;
|
|
186
|
+
this.dispatchEvent(new CustomEvent('crud-action-start', {
|
|
187
|
+
bubbles: true,
|
|
188
|
+
composed: true,
|
|
189
|
+
detail: {
|
|
190
|
+
action: this.selection,
|
|
191
|
+
actionIds: this.actionIds,
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
181
194
|
let actionData = this.selectedActionForm.getData();
|
|
182
195
|
this.ajaxAction.data = {
|
|
183
196
|
type: this.selection,
|
|
@@ -188,6 +201,7 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
doSuccessAction(e) {
|
|
204
|
+
this.loading = false;
|
|
191
205
|
this.selectedActionForm.resetData();
|
|
192
206
|
this.selectedActionForm.clearErrors();
|
|
193
207
|
this.confirmElement.close();
|
|
@@ -204,23 +218,26 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
204
218
|
}
|
|
205
219
|
|
|
206
220
|
doErrorAction(e) {
|
|
221
|
+
this.loading = false;
|
|
207
222
|
this.responseAdapter.setResponse(e.detail);
|
|
208
223
|
this.selectedActionForm.showErrors(e.detail.errors);
|
|
209
224
|
this.dispatchEvent(new CustomEvent('crud-action-error', {
|
|
210
225
|
bubbles: true,
|
|
211
226
|
composed: true,
|
|
212
227
|
detail: {
|
|
213
|
-
msg:this.responseAdapter.getActionResponseValidationErrorMessage(),
|
|
228
|
+
msg: this.responseAdapter.getActionResponseValidationErrorMessage(),
|
|
229
|
+
errors: this.responseAdapter.getValidationErrors(),
|
|
214
230
|
}
|
|
215
231
|
}));
|
|
216
232
|
}
|
|
217
233
|
|
|
218
234
|
getActionForm() {
|
|
219
|
-
let actionForm = this.shadowRoot.querySelector(`[action="${this.selection}"]`)
|
|
235
|
+
let actionForm = this.shadowRoot.querySelector(`[action="${this.selection}"]`);
|
|
220
236
|
return actionForm;
|
|
221
237
|
}
|
|
222
238
|
|
|
223
239
|
cancelAction() {
|
|
240
|
+
this.loading = false;
|
|
224
241
|
this.selectedActionForm.clearErrors();
|
|
225
242
|
this.selectedActionForm.resetData();
|
|
226
243
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://dile-components.com/",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dile/ui": "^3.6.
|
|
28
|
+
"@dile/ui": "^3.6.5",
|
|
29
29
|
"axios": "^1.19.0",
|
|
30
30
|
"lit": "^2.7.0 || ^3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ee029c01956874746ff8c78f02f4868ef4ce4875"
|
|
36
36
|
}
|