@dile/crud 1.1.3 → 1.1.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.
|
@@ -168,7 +168,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
|
|
|
168
168
|
<dile-ajax
|
|
169
169
|
id="ajaxsave"
|
|
170
170
|
method="${this.saveMethod(this.operation, this.method)}"
|
|
171
|
-
url="${this.
|
|
171
|
+
url="${this.generateEndpoint(this.operation, this.method, this.relatedId)}"
|
|
172
172
|
@ajax-success="${this.doSuccessSave}"
|
|
173
173
|
@ajax-error="${this.doErrorSave}"
|
|
174
174
|
language="${this.language}"
|
|
@@ -287,6 +287,22 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
|
|
|
287
287
|
return validMethods.includes(method.toLowerCase());
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
generateEndpoint(operation, method, relatedId) {
|
|
291
|
+
if (operation === 'insert') {
|
|
292
|
+
return this.endpoint;
|
|
293
|
+
} else if (operation === 'update') {
|
|
294
|
+
return `${this.endpoint}/${relatedId}`;
|
|
295
|
+
} else if (method) {
|
|
296
|
+
const methodLower = method.toLowerCase();
|
|
297
|
+
if (methodLower === 'post') {
|
|
298
|
+
return this.endpoint;
|
|
299
|
+
} else if (['put', 'patch', 'delete'].includes(methodLower) && relatedId) {
|
|
300
|
+
return `${this.endpoint}/${relatedId}`;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return this.endpoint;
|
|
304
|
+
}
|
|
305
|
+
|
|
290
306
|
clearErrors() {
|
|
291
307
|
this.form.clearErrors();
|
|
292
308
|
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.4",
|
|
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": "e60b713895058e0b14a9b018a1e6f825846813c4"
|
|
35
35
|
}
|