@dile/crud 0.0.25 → 0.0.26
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.
|
@@ -7,6 +7,7 @@ export class DileAjax extends DileAxios(LitElement) {
|
|
|
7
7
|
data: { type: Object },
|
|
8
8
|
method: { type: String },
|
|
9
9
|
url: { type: String },
|
|
10
|
+
statusSuccessCodes: { type: Array },
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -15,6 +16,7 @@ export class DileAjax extends DileAxios(LitElement) {
|
|
|
15
16
|
this.data = {};
|
|
16
17
|
this.method = 'post';
|
|
17
18
|
this.url = '';
|
|
19
|
+
this.statusSuccessCodes = [200, 201];
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
generateRequest() {
|
|
@@ -39,7 +41,7 @@ export class DileAjax extends DileAxios(LitElement) {
|
|
|
39
41
|
break
|
|
40
42
|
}
|
|
41
43
|
request.then((response) => {
|
|
42
|
-
if(response.status
|
|
44
|
+
if(this.statusSuccessCodes.includes(response.status)) {
|
|
43
45
|
let res = response.data;
|
|
44
46
|
if(res.error) {
|
|
45
47
|
this.dispatchError(res.data);
|
|
@@ -53,7 +55,7 @@ export class DileAjax extends DileAxios(LitElement) {
|
|
|
53
55
|
}));
|
|
54
56
|
}
|
|
55
57
|
} else {
|
|
56
|
-
this.dispatchError('
|
|
58
|
+
this.dispatchError('Unhandled success server response');
|
|
57
59
|
}
|
|
58
60
|
})
|
|
59
61
|
.catch(err => {
|
|
@@ -111,7 +111,7 @@ export class DileAjaxForm extends LitElement {
|
|
|
111
111
|
|
|
112
112
|
doErrorGet(e) {
|
|
113
113
|
this.responseAdapter.setResponse(e.detail);
|
|
114
|
-
let msg = this.
|
|
114
|
+
let msg = this._customErrorMessage();
|
|
115
115
|
this.feedback.negativeFeedback(msg);
|
|
116
116
|
this.dispatchEvent(new CustomEvent('dile-ajax-form-get-error', {
|
|
117
117
|
bubbles: true,
|
|
@@ -141,7 +141,7 @@ export class DileAjaxForm extends LitElement {
|
|
|
141
141
|
|
|
142
142
|
doErrorSave(e) {
|
|
143
143
|
this.responseAdapter.setResponse(e.detail);
|
|
144
|
-
let msg = this.
|
|
144
|
+
let msg = this._customErrorMessage();
|
|
145
145
|
this.feedback.negativeFeedbackWithDelay(msg, 5000);
|
|
146
146
|
let validationErrors = this.responseAdapter.getValidationErrors();
|
|
147
147
|
this.form.showErrors(validationErrors);
|
|
@@ -159,7 +159,7 @@ export class DileAjaxForm extends LitElement {
|
|
|
159
159
|
doSuccessSave(e) {
|
|
160
160
|
this.responseAdapter.setResponse(e.detail);
|
|
161
161
|
let data = this.responseAdapter.getData();
|
|
162
|
-
let msg = this.
|
|
162
|
+
let msg = this._customSuccessMessage();
|
|
163
163
|
this.feedback.positiveFeedbackWithDelay(msg, 5000);
|
|
164
164
|
this.dispatchEvent(new CustomEvent('save-success', {
|
|
165
165
|
bubbles: true,
|
|
@@ -202,7 +202,15 @@ export class DileAjaxForm extends LitElement {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
_customErrorMessage() {
|
|
206
|
+
return this._customMessage(false);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_customSuccessMessage() {
|
|
210
|
+
return this._customMessage(true);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
_customMessage(success) {
|
|
206
214
|
let message = this.responseAdapter.getMessage();
|
|
207
215
|
if(message) {
|
|
208
216
|
return message;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
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": "97061a86abf5bd422da53498cf94b900a78d1b3f"
|
|
35
35
|
}
|