@dile/crud 2.5.3 → 2.5.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.
|
@@ -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,6 +218,10 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
204
218
|
}
|
|
205
219
|
|
|
206
220
|
doErrorAction(e) {
|
|
221
|
+
this.loading = false;
|
|
222
|
+
if (this.confirmElement) {
|
|
223
|
+
this.confirmElement.resetProcessing();
|
|
224
|
+
}
|
|
207
225
|
this.responseAdapter.setResponse(e.detail);
|
|
208
226
|
this.selectedActionForm.showErrors(e.detail.errors);
|
|
209
227
|
this.dispatchEvent(new CustomEvent('crud-action-error', {
|
|
@@ -217,11 +235,15 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
|
|
|
217
235
|
}
|
|
218
236
|
|
|
219
237
|
getActionForm() {
|
|
220
|
-
let actionForm = this.shadowRoot.querySelector(`[action="${this.selection}"]`)
|
|
238
|
+
let actionForm = this.shadowRoot.querySelector(`[action="${this.selection}"]`);
|
|
221
239
|
return actionForm;
|
|
222
240
|
}
|
|
223
241
|
|
|
224
242
|
cancelAction() {
|
|
243
|
+
this.loading = false;
|
|
244
|
+
if (this.confirmElement) {
|
|
245
|
+
this.confirmElement.resetProcessing();
|
|
246
|
+
}
|
|
225
247
|
this.selectedActionForm.clearErrors();
|
|
226
248
|
this.selectedActionForm.resetData();
|
|
227
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5",
|
|
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.6",
|
|
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": "3bc0a2459a5ced3e7105ce061f93f07a9c798759"
|
|
36
36
|
}
|