lkt-item-crud 1.1.15 → 1.1.16
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/build.d.ts +2 -2
- package/dist/build.js +28 -28
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +1 -0
package/dist/build.d.ts
CHANGED
package/dist/build.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as ne, useSlots as
|
|
2
|
-
import { httpCall as
|
|
1
|
+
import { defineComponent as ne, useSlots as ie, ref as s, computed as d, watch as D, resolveComponent as w, openBlock as v, createElementBlock as h, createElementVNode as E, toDisplayString as j, renderSlot as q, createCommentVNode as g, withDirectives as O, createBlock as V, withCtx as G, unref as K, vShow as I, createVNode as Q } from "vue";
|
|
2
|
+
import { httpCall as se } from "lkt-http-client";
|
|
3
3
|
import { DataState as ce } from "lkt-data-state";
|
|
4
4
|
const N = class N {
|
|
5
5
|
};
|
|
6
6
|
N.debugEnabled = !1;
|
|
7
7
|
let U = N;
|
|
8
|
-
const
|
|
8
|
+
const n = (...u) => {
|
|
9
9
|
U.debugEnabled && console.info("[LktItemCrud] ", ...u);
|
|
10
|
-
},
|
|
10
|
+
}, qe = (u = !0) => {
|
|
11
11
|
U.debugEnabled = u;
|
|
12
12
|
}, ve = { class: "lkt-item-crud" }, fe = {
|
|
13
13
|
key: 0,
|
|
@@ -55,50 +55,50 @@ const i = (...u) => {
|
|
|
55
55
|
},
|
|
56
56
|
emits: ["update:modelValue", "update:isCreate", "read", "create", "update", "drop", "perms", "error", "modified-data"],
|
|
57
57
|
setup(u, { expose: T, emit: W }) {
|
|
58
|
-
const e = u, L =
|
|
58
|
+
const e = u, L = ie(), i = W;
|
|
59
59
|
let X = [];
|
|
60
60
|
const o = s(!0), r = s(e.modelValue), b = s(X), f = s(!1), p = s(!1), m = s(!1), c = s(200), C = s(null), B = s(null), S = s(new ce(r.value)), l = s(e.isCreate), Y = d(() => l.value ? e.createConfirm : e.updateConfirm), Z = d(() => l.value ? e.createConfirmData : e.updateConfirmData), $ = d(() => l.value ? e.createResource : e.updateResource), ee = d(() => l.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), te = d(() => l.value ? e.createDisabled : e.updateDisabled), _ = d(() => !l.value && b.value.includes("update")), R = d(() => !l.value && b.value.includes("drop")), M = async () => {
|
|
61
|
-
|
|
61
|
+
n("fetchItem"), o.value = !0, c.value = -1, m.value = !1;
|
|
62
62
|
try {
|
|
63
|
-
const t = await
|
|
64
|
-
if (
|
|
65
|
-
p.value = !1, c.value = t.httpStatus,
|
|
63
|
+
const t = await se(e.readResource, e.readData);
|
|
64
|
+
if (n("fetchItem -> response", t), o.value = !1, c.value = t.httpStatus, !t.success) {
|
|
65
|
+
p.value = !1, c.value = t.httpStatus, i("error", t.httpStatus);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
p.value = !0, r.value = t.data, b.value = t.perms, S.value.increment(r.value).turnStoredIntoOriginal(),
|
|
68
|
+
p.value = !0, r.value = t.data, b.value = t.perms, S.value.increment(r.value).turnStoredIntoOriginal(), i("read", t);
|
|
69
69
|
} catch {
|
|
70
|
-
o.value = !1, p.value = !1, c.value = 404,
|
|
70
|
+
o.value = !1, p.value = !1, c.value = 404, i("error", 404);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
}, ae = d(() => o.value ? !1 : e.title || !!L["post-title"]);
|
|
74
74
|
D(() => e.modelValue, (t) => {
|
|
75
75
|
r.value = t, S.value.increment(t);
|
|
76
76
|
}, { deep: !0 }), D(r, (t) => {
|
|
77
|
-
if (
|
|
78
|
-
|
|
77
|
+
if (n("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
78
|
+
n("item updated -> has beforeEmitUpdate");
|
|
79
79
|
let a = e.beforeEmitUpdate(r.value);
|
|
80
|
-
typeof a == "object" && (r.value = a);
|
|
80
|
+
n("item updated -> override with: ", a), typeof a == "object" && (r.value = a);
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
}, { deep: !0 }), D(b, () =>
|
|
82
|
+
i("update:modelValue", r.value), n("item updated -> update dataState"), S.value.increment(t);
|
|
83
|
+
}, { deep: !0 }), D(b, () => i("perms", b.value));
|
|
84
84
|
const x = d(() => te.value || !l.value && !_.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : S.value.changed());
|
|
85
|
-
D(x, (t) =>
|
|
85
|
+
D(x, (t) => i("modified-data", t)), D(l, (t) => i("update:isCreate", t)), e.readResource && !l.value ? M() : l.value && (p.value = !0, f.value = !0, o.value = !1);
|
|
86
86
|
const le = (t, a) => {
|
|
87
87
|
if (o.value = !1, c.value = a.httpStatus, !a.success) {
|
|
88
|
-
m.value = !0,
|
|
88
|
+
m.value = !0, i("error", a.httpStatus);
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
m.value = !0,
|
|
91
|
+
m.value = !0, i("drop", a);
|
|
92
92
|
}, ue = (t, a) => {
|
|
93
|
-
if (
|
|
93
|
+
if (n("onSave -> received response:", a), $.value) {
|
|
94
94
|
if (o.value = !1, c.value = a.httpStatus, !a.success) {
|
|
95
|
-
m.value = !0,
|
|
95
|
+
m.value = !0, i("error", a.httpStatus);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
m.value = !0;
|
|
99
99
|
}
|
|
100
100
|
let k = l.value ? "create" : "update";
|
|
101
|
-
l.value || (
|
|
101
|
+
l.value || (n("onSave -> turn stored data into original"), S.value.turnStoredIntoOriginal()), k === "create" ? typeof e.onCreate == "function" && (n("onSave -> trigger onCreate callback"), e.onCreate(a)) : typeof e.onUpdate == "function" && (n("onSave -> trigger onUpdate callback"), e.onUpdate(a)), !e.insideModal && a.autoReloadId && (n("onSave -> autoReloadId detected: ", a.autoReloadId), e.readData.id = a.autoReloadId, n("onSave -> turning off create mode"), l.value = !1, M()), i(k, a);
|
|
102
102
|
}, F = () => {
|
|
103
103
|
o.value = !0, c.value = -1;
|
|
104
104
|
}, J = () => {
|
|
@@ -115,12 +115,12 @@ const i = (...u) => {
|
|
|
115
115
|
});
|
|
116
116
|
const A = d(() => !e.hiddenDrop && !o.value && f.value && p.value), H = d(() => o.value ? !1 : l.value ? !0 : !e.hiddenSave && f.value && p.value), P = d(() => !o.value && !l.value && p.value && !(e.dropDisabled && e.updateDisabled)), oe = d(() => !e.hiddenButtons && (H.value || A.value || P.value));
|
|
117
117
|
return (t, a) => {
|
|
118
|
-
const k =
|
|
118
|
+
const k = w("lkt-button"), re = w("lkt-field-switch"), z = w("lkt-http-info"), de = w("lkt-loader");
|
|
119
119
|
return v(), h("article", ve, [
|
|
120
120
|
ae.value ? (v(), h("header", fe, [
|
|
121
121
|
E("h1", pe, j(u.title), 1),
|
|
122
122
|
E("div", me, [
|
|
123
|
-
|
|
123
|
+
q(t.$slots, "post-title", {
|
|
124
124
|
item: r.value,
|
|
125
125
|
loading: o.value
|
|
126
126
|
})
|
|
@@ -141,7 +141,7 @@ const i = (...u) => {
|
|
|
141
141
|
onClick: le
|
|
142
142
|
}, {
|
|
143
143
|
default: G(() => [
|
|
144
|
-
K(L)["button-drop"] ?
|
|
144
|
+
K(L)["button-drop"] ? q(t.$slots, "button-drop", {
|
|
145
145
|
key: 0,
|
|
146
146
|
item: r.value,
|
|
147
147
|
editMode: f.value,
|
|
@@ -167,7 +167,7 @@ const i = (...u) => {
|
|
|
167
167
|
onClick: ue
|
|
168
168
|
}, {
|
|
169
169
|
default: G(() => [
|
|
170
|
-
K(L)["button-save"] ?
|
|
170
|
+
K(L)["button-save"] ? q(t.$slots, "button-save", {
|
|
171
171
|
key: 0,
|
|
172
172
|
item: r.value,
|
|
173
173
|
editMode: f.value,
|
|
@@ -200,7 +200,7 @@ const i = (...u) => {
|
|
|
200
200
|
"can-close": "",
|
|
201
201
|
onClose: a[1] || (a[1] = (y) => m.value = !1)
|
|
202
202
|
}, null, 8, ["code", "palette"])) : g("", !0),
|
|
203
|
-
|
|
203
|
+
q(t.$slots, "item", {
|
|
204
204
|
item: r.value,
|
|
205
205
|
loading: o.value,
|
|
206
206
|
editMode: f.value,
|
|
@@ -223,6 +223,6 @@ const i = (...u) => {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
export {
|
|
226
|
-
|
|
226
|
+
qe as debugLktItemCrud,
|
|
227
227
|
Oe as default
|
|
228
228
|
};
|
package/package.json
CHANGED
|
@@ -144,6 +144,7 @@ watch(item, (v) => {
|
|
|
144
144
|
if (typeof props.beforeEmitUpdate === 'function') {
|
|
145
145
|
debug('item updated -> has beforeEmitUpdate');
|
|
146
146
|
let override = props.beforeEmitUpdate(item.value);
|
|
147
|
+
debug('item updated -> override with: ', override);
|
|
147
148
|
if (typeof override === 'object') item.value = override;
|
|
148
149
|
}
|
|
149
150
|
emit('update:modelValue', item.value);
|