@dile/crud 1.1.1 → 1.1.3
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.
|
@@ -55,6 +55,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
|
|
|
55
55
|
static get properties() {
|
|
56
56
|
return {
|
|
57
57
|
operation: { type: String },
|
|
58
|
+
method: { type: String },
|
|
58
59
|
endpoint: { type: String },
|
|
59
60
|
actionLabel: { type: String },
|
|
60
61
|
cancelLabel: { type: String },
|
|
@@ -166,7 +167,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
|
|
|
166
167
|
></dile-ajax>
|
|
167
168
|
<dile-ajax
|
|
168
169
|
id="ajaxsave"
|
|
169
|
-
method="${this.saveMethod(this.operation)}"
|
|
170
|
+
method="${this.saveMethod(this.operation, this.method)}"
|
|
170
171
|
url="${this.endpoint}${this.operation == 'insert' ? '' : `/${this.relatedId}`}"
|
|
171
172
|
@ajax-success="${this.doSuccessSave}"
|
|
172
173
|
@ajax-error="${this.doErrorSave}"
|
|
@@ -264,16 +265,28 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
|
|
|
264
265
|
|
|
265
266
|
}
|
|
266
267
|
|
|
267
|
-
saveMethod(operation) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
saveMethod(operation, method) {
|
|
269
|
+
if(this.operation != '') {
|
|
270
|
+
switch(operation) {
|
|
271
|
+
case 'insert':
|
|
272
|
+
return 'post';
|
|
273
|
+
case 'update':
|
|
274
|
+
return 'put';
|
|
275
|
+
}
|
|
276
|
+
} else if(this.isValidMethod(method)) {
|
|
277
|
+
return method;
|
|
273
278
|
}
|
|
274
279
|
throw this.translations.ajax_form_not_supported;
|
|
275
280
|
}
|
|
276
281
|
|
|
282
|
+
isValidMethod(method) {
|
|
283
|
+
if (!method || typeof method !== 'string') {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
const validMethods = ['get', 'post', 'put', 'patch', 'delete'];
|
|
287
|
+
return validMethods.includes(method.toLowerCase());
|
|
288
|
+
}
|
|
289
|
+
|
|
277
290
|
clearErrors() {
|
|
278
291
|
this.form.clearErrors();
|
|
279
292
|
this.feedback.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://dile-components.com/",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dile/ui": "^2.
|
|
27
|
+
"@dile/ui": "^2.12.0",
|
|
28
28
|
"axios": "^1.13.0",
|
|
29
29
|
"lit": "^2.7.0 || ^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "506c1d3a4cff8576780bd59802a0ff020de8736c"
|
|
35
35
|
}
|