@hostlink/nuxt-light 1.48.11 → 1.48.12
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.
package/dist/module.json
CHANGED
|
@@ -23,9 +23,10 @@ let redirect = true;
|
|
|
23
23
|
if (props.context.attrs.onSubmitted) {
|
|
24
24
|
redirect = false;
|
|
25
25
|
}
|
|
26
|
+
const modelName = props.context.attrs.modelName || (typeof route.name === "string" ? route.name.split("-")[0] : void 0);
|
|
27
|
+
const id = props.context.attrs.modelId || route.params[typeof route.name === "string" ? route.name.split("-")[1] : "id"];
|
|
26
28
|
if (!props.context.onSubmit) {
|
|
27
29
|
props.context.node.props.onSubmit = async function() {
|
|
28
|
-
const [module, id_name] = route.name.split("-");
|
|
29
30
|
const removeUndefined = (obj) => {
|
|
30
31
|
if (obj === null || obj === void 0) {
|
|
31
32
|
return obj;
|
|
@@ -50,8 +51,8 @@ if (!props.context.onSubmit) {
|
|
|
50
51
|
};
|
|
51
52
|
const v = removeUndefined(props.context.value);
|
|
52
53
|
try {
|
|
53
|
-
if (
|
|
54
|
-
if (await model(
|
|
54
|
+
if (id) {
|
|
55
|
+
if (await model(modelName).update(Number(id), v)) {
|
|
55
56
|
quasar.notify({
|
|
56
57
|
message: "Updated successfully",
|
|
57
58
|
color: "positive",
|
|
@@ -62,7 +63,7 @@ if (!props.context.onSubmit) {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
} else {
|
|
65
|
-
if (await model(
|
|
66
|
+
if (await model(modelName).add(v)) {
|
|
66
67
|
quasar.notify({
|
|
67
68
|
message: "Added successfully",
|
|
68
69
|
color: "positive",
|