@dile/crud 0.0.24 → 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 == 200) {
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('Bad server response');
58
+ this.dispatchError('Unhandled success server response');
57
59
  }
58
60
  })
59
61
  .catch(err => {
@@ -11,7 +11,7 @@ export class DileAjaxForm extends LitElement {
11
11
  :host {
12
12
  display: block;
13
13
  }
14
- :host([small]) {
14
+ :host([buttonSmall]) {
15
15
  --dile-button-padding-y: 0.25rem;
16
16
  --dile-button-padding-x: 0.5rem;
17
17
  --dile-button-font-size: 0.875rem;
@@ -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.customMessage(false);
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.customMessage(true);
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.customMessage(true);
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
- customMessage(success) {
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.24",
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": "4236ff820cf8ad8f3b178fce60b76fc59509df12"
34
+ "gitHead": "97061a86abf5bd422da53498cf94b900a78d1b3f"
35
35
  }