lkt-item-crud 1.1.13 → 1.1.14
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.js +34 -34
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +6 -1
package/dist/build.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as ne, useSlots as se, ref as s, computed as d, watch as D, resolveComponent as q, openBlock as
|
|
1
|
+
import { defineComponent as ne, useSlots as se, ref as s, computed as d, watch as D, resolveComponent as q, openBlock as v, createElementBlock as h, createElementVNode as E, toDisplayString as j, renderSlot as w, createCommentVNode as g, withDirectives as O, createBlock as V, withCtx as G, unref as K, vShow as I, createVNode as Q } from "vue";
|
|
2
2
|
import { httpCall as ie } 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 i = (...u) => {
|
|
9
9
|
U.debugEnabled && console.info("[LktItemCrud] ", ...u);
|
|
10
10
|
}, we = (u = !0) => {
|
|
11
11
|
U.debugEnabled = u;
|
|
@@ -57,45 +57,45 @@ const p = (...u) => {
|
|
|
57
57
|
setup(u, { expose: T, emit: W }) {
|
|
58
58
|
const e = u, L = se(), n = W;
|
|
59
59
|
let X = [];
|
|
60
|
-
const o = s(!0), r = s(e.modelValue), S = s(X),
|
|
61
|
-
|
|
60
|
+
const o = s(!0), r = s(e.modelValue), S = s(X), f = s(!1), p = s(!1), m = s(!1), c = s(200), C = s(null), B = s(null), b = s(new ce(r.value)), a = s(e.isCreate), Y = d(() => a.value ? e.createConfirm : e.updateConfirm), Z = d(() => a.value ? e.createConfirmData : e.updateConfirmData), $ = d(() => a.value ? e.createResource : e.updateResource), ee = d(() => a.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), te = d(() => a.value ? e.createDisabled : e.updateDisabled), _ = d(() => !a.value && S.value.includes("update")), R = d(() => !a.value && S.value.includes("drop")), M = async () => {
|
|
61
|
+
i("fetchItem"), o.value = !0, c.value = -1, m.value = !1;
|
|
62
62
|
try {
|
|
63
63
|
const t = await ie(e.readResource, e.readData);
|
|
64
|
-
if (
|
|
65
|
-
|
|
64
|
+
if (i("fetchItem -> response", t), o.value = !1, c.value = t.httpStatus, !t.success) {
|
|
65
|
+
p.value = !1, c.value = t.httpStatus, n("error", t.httpStatus);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
p.value = !0, r.value = t.data, S.value = t.perms, b.value.increment(r.value).turnStoredIntoOriginal(), n("read", t);
|
|
69
69
|
} catch {
|
|
70
|
-
o.value = !1,
|
|
70
|
+
o.value = !1, p.value = !1, c.value = 404, n("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, b.value.increment(t);
|
|
76
76
|
}, { deep: !0 }), D(r, (t) => {
|
|
77
|
-
typeof e.beforeEmitUpdate == "function" && e.beforeEmitUpdate(r.value), n("update:modelValue", r.value), b.value.increment(t);
|
|
77
|
+
i("item updated ->", r.value), typeof e.beforeEmitUpdate == "function" && (i("item updated -> has beforeEmitUpdate"), e.beforeEmitUpdate(r.value)), n("update:modelValue", r.value), i("item updated -> update dataState"), b.value.increment(t);
|
|
78
78
|
}, { deep: !0 }), D(S, () => n("perms", S.value));
|
|
79
79
|
const x = d(() => te.value || !a.value && !_.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : b.value.changed());
|
|
80
|
-
D(x, (t) => n("modified-data", t)), D(a, (t) => n("update:isCreate", t)), e.readResource && !a.value ? M() : a.value && (
|
|
80
|
+
D(x, (t) => n("modified-data", t)), D(a, (t) => n("update:isCreate", t)), e.readResource && !a.value ? M() : a.value && (p.value = !0, f.value = !0, o.value = !1);
|
|
81
81
|
const le = (t, l) => {
|
|
82
|
-
if (o.value = !1,
|
|
82
|
+
if (o.value = !1, c.value = l.httpStatus, !l.success) {
|
|
83
83
|
m.value = !0, n("error", l.httpStatus);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
m.value = !0, n("drop", l);
|
|
87
87
|
}, ue = (t, l) => {
|
|
88
|
-
if (
|
|
89
|
-
if (o.value = !1,
|
|
88
|
+
if (i("onSave -> received response:", l), $.value) {
|
|
89
|
+
if (o.value = !1, c.value = l.httpStatus, !l.success) {
|
|
90
90
|
m.value = !0, n("error", l.httpStatus);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
m.value = !0;
|
|
94
94
|
}
|
|
95
95
|
let k = a.value ? "create" : "update";
|
|
96
|
-
a.value || (
|
|
96
|
+
a.value || (i("onSave -> turn stored data into original"), b.value.turnStoredIntoOriginal()), k === "create" ? typeof e.onCreate == "function" && (i("onSave -> trigger onCreate callback"), e.onCreate(l)) : typeof e.onUpdate == "function" && (i("onSave -> trigger onUpdate callback"), e.onUpdate(l)), !e.insideModal && l.autoReloadId && (i("onSave -> autoReloadId detected: ", l.autoReloadId), e.readData.id = l.autoReloadId, i("onSave -> turning off create mode"), a.value = !1, M()), n(k, l);
|
|
97
97
|
}, F = () => {
|
|
98
|
-
o.value = !0,
|
|
98
|
+
o.value = !0, c.value = -1;
|
|
99
99
|
}, J = () => {
|
|
100
100
|
o.value = !1;
|
|
101
101
|
};
|
|
@@ -108,11 +108,11 @@ const p = (...u) => {
|
|
|
108
108
|
C.value && typeof C.value.click == "function" && C.value.click();
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
-
const A = d(() => !e.hiddenDrop && !o.value &&
|
|
111
|
+
const A = d(() => !e.hiddenDrop && !o.value && f.value && p.value), H = d(() => o.value ? !1 : a.value ? !0 : !e.hiddenSave && f.value && p.value), P = d(() => !o.value && !a.value && p.value && !(e.dropDisabled && e.updateDisabled)), oe = d(() => !e.hiddenButtons && (H.value || A.value || P.value));
|
|
112
112
|
return (t, l) => {
|
|
113
113
|
const k = q("lkt-button"), re = q("lkt-field-switch"), z = q("lkt-http-info"), de = q("lkt-loader");
|
|
114
|
-
return
|
|
115
|
-
ae.value ? (
|
|
114
|
+
return v(), h("article", ve, [
|
|
115
|
+
ae.value ? (v(), h("header", fe, [
|
|
116
116
|
E("h1", pe, j(u.title), 1),
|
|
117
117
|
E("div", me, [
|
|
118
118
|
w(t.$slots, "post-title", {
|
|
@@ -122,7 +122,7 @@ const p = (...u) => {
|
|
|
122
122
|
])
|
|
123
123
|
])) : g("", !0),
|
|
124
124
|
O(E("div", ye, [
|
|
125
|
-
a.value ? g("", !0) : O((
|
|
125
|
+
a.value ? g("", !0) : O((v(), V(k, {
|
|
126
126
|
key: 0,
|
|
127
127
|
ref: (y) => B.value = y,
|
|
128
128
|
palette: "danger",
|
|
@@ -139,11 +139,11 @@ const p = (...u) => {
|
|
|
139
139
|
K(L)["button-drop"] ? w(t.$slots, "button-drop", {
|
|
140
140
|
key: 0,
|
|
141
141
|
item: r.value,
|
|
142
|
-
editMode:
|
|
142
|
+
editMode: f.value,
|
|
143
143
|
isCreate: a.value,
|
|
144
144
|
canUpdate: _.value,
|
|
145
145
|
canDrop: R.value
|
|
146
|
-
}) : (
|
|
146
|
+
}) : (v(), h("span", he, j(u.dropText), 1))
|
|
147
147
|
]),
|
|
148
148
|
_: 3
|
|
149
149
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"])), [
|
|
@@ -165,19 +165,19 @@ const p = (...u) => {
|
|
|
165
165
|
K(L)["button-save"] ? w(t.$slots, "button-save", {
|
|
166
166
|
key: 0,
|
|
167
167
|
item: r.value,
|
|
168
|
-
editMode:
|
|
168
|
+
editMode: f.value,
|
|
169
169
|
isCreate: a.value,
|
|
170
170
|
canUpdate: _.value,
|
|
171
171
|
canDrop: R.value
|
|
172
|
-
}) : (
|
|
172
|
+
}) : (v(), h("span", Se, j(u.saveText), 1))
|
|
173
173
|
]),
|
|
174
174
|
_: 3
|
|
175
175
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
|
|
176
176
|
[I, H.value]
|
|
177
177
|
]),
|
|
178
178
|
O(Q(re, {
|
|
179
|
-
modelValue:
|
|
180
|
-
"onUpdate:modelValue": l[0] || (l[0] = (y) =>
|
|
179
|
+
modelValue: f.value,
|
|
180
|
+
"onUpdate:modelValue": l[0] || (l[0] = (y) => f.value = y),
|
|
181
181
|
label: u.editModeText
|
|
182
182
|
}, null, 8, ["modelValue", "label"]), [
|
|
183
183
|
[I, P.value]
|
|
@@ -185,30 +185,30 @@ const p = (...u) => {
|
|
|
185
185
|
], 512), [
|
|
186
186
|
[I, oe.value]
|
|
187
187
|
]),
|
|
188
|
-
o.value ? g("", !0) : (
|
|
189
|
-
|
|
190
|
-
m.value ? (
|
|
188
|
+
o.value ? g("", !0) : (v(), h("div", be, [
|
|
189
|
+
p.value ? (v(), h("div", ke, [
|
|
190
|
+
m.value ? (v(), V(z, {
|
|
191
191
|
key: 0,
|
|
192
|
-
code:
|
|
192
|
+
code: c.value,
|
|
193
193
|
quick: "",
|
|
194
|
-
palette:
|
|
194
|
+
palette: c.value === 200 ? "success" : "danger",
|
|
195
195
|
"can-close": "",
|
|
196
196
|
onClose: l[1] || (l[1] = (y) => m.value = !1)
|
|
197
197
|
}, null, 8, ["code", "palette"])) : g("", !0),
|
|
198
198
|
w(t.$slots, "item", {
|
|
199
199
|
item: r.value,
|
|
200
200
|
loading: o.value,
|
|
201
|
-
editMode:
|
|
201
|
+
editMode: f.value,
|
|
202
202
|
isCreate: a.value,
|
|
203
203
|
canUpdate: _.value,
|
|
204
204
|
canDrop: R.value
|
|
205
205
|
})
|
|
206
|
-
])) : (
|
|
206
|
+
])) : (v(), V(z, {
|
|
207
207
|
key: 1,
|
|
208
|
-
code:
|
|
208
|
+
code: c.value
|
|
209
209
|
}, null, 8, ["code"]))
|
|
210
210
|
])),
|
|
211
|
-
o.value ? (
|
|
211
|
+
o.value ? (v(), V(de, { key: 2 })) : g("", !0)
|
|
212
212
|
]);
|
|
213
213
|
};
|
|
214
214
|
}
|
package/package.json
CHANGED
|
@@ -140,8 +140,13 @@ watch(() => props.modelValue, v => {
|
|
|
140
140
|
}, {deep: true});
|
|
141
141
|
|
|
142
142
|
watch(item, (v) => {
|
|
143
|
-
|
|
143
|
+
debug('item updated ->', item.value);
|
|
144
|
+
if (typeof props.beforeEmitUpdate === 'function') {
|
|
145
|
+
debug('item updated -> has beforeEmitUpdate');
|
|
146
|
+
props.beforeEmitUpdate(item.value);
|
|
147
|
+
}
|
|
144
148
|
emit('update:modelValue', item.value);
|
|
149
|
+
debug('item updated -> update dataState');
|
|
145
150
|
dataState.value.increment(v);
|
|
146
151
|
}, {deep: true});
|
|
147
152
|
|