lkt-item-crud 1.1.27 → 1.1.28
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as ve, useSlots as ce, ref as s, computed as n, watch as b, nextTick as fe, resolveComponent as L, openBlock as v, createElementBlock as
|
|
1
|
+
import { defineComponent as ve, useSlots as ce, ref as s, computed as n, watch as b, nextTick as fe, resolveComponent as L, openBlock as v, createElementBlock as _, unref as C, renderSlot as U, createCommentVNode as p, toDisplayString as pe, withDirectives as O, createElementVNode as me, createBlock as T, withCtx as Y, vShow as $, createVNode as Z } from "vue";
|
|
2
2
|
import { httpCall as he } from "lkt-http-client";
|
|
3
3
|
import { DataState as ee } from "lkt-data-state";
|
|
4
4
|
import { execModal as ke, refreshModal as be, closeModal as Ce, openModal as De, reOpenModal as Se } from "lkt-modal";
|
|
@@ -13,19 +13,19 @@ const u = (...l) => {
|
|
|
13
13
|
F.debugEnabled = l;
|
|
14
14
|
}, j = (l) => {
|
|
15
15
|
u("runModalCallback -> init", l);
|
|
16
|
-
let h = l.modalKey ? l.modalKey : "_",
|
|
16
|
+
let h = l.modalKey ? l.modalKey : "_", B = l.args ? l.args : {};
|
|
17
17
|
switch (l.action) {
|
|
18
18
|
case "reOpen":
|
|
19
|
-
return Se(l.modalName, h,
|
|
19
|
+
return Se(l.modalName, h, B);
|
|
20
20
|
case "open":
|
|
21
|
-
return De(l.modalName, h,
|
|
21
|
+
return De(l.modalName, h, B);
|
|
22
22
|
case "close":
|
|
23
23
|
return Ce(l.modalName, h);
|
|
24
24
|
case "refresh":
|
|
25
|
-
return be(l.modalName, h,
|
|
25
|
+
return be(l.modalName, h, B);
|
|
26
26
|
case "exec":
|
|
27
27
|
let e = l.method;
|
|
28
|
-
return e ? ke(l.modalName, h, e,
|
|
28
|
+
return e ? ke(l.modalName, h, e, B) : void 0;
|
|
29
29
|
}
|
|
30
30
|
}, ge = { class: "lkt-item-crud" }, Me = {
|
|
31
31
|
key: 0,
|
|
@@ -89,10 +89,10 @@ const u = (...l) => {
|
|
|
89
89
|
editing: { type: Boolean, default: !1 }
|
|
90
90
|
},
|
|
91
91
|
emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
|
|
92
|
-
setup(l, { expose: h, emit:
|
|
93
|
-
const e = l, m = ce(), i =
|
|
92
|
+
setup(l, { expose: h, emit: B }) {
|
|
93
|
+
const e = l, m = ce(), i = B;
|
|
94
94
|
let ae = [];
|
|
95
|
-
const d = s(!0), r = s(e.modelValue), I = s(ae), c = s(e.editing), k = s(!1), D = s(!1), f = s(200), R = s(null), V = s(null),
|
|
95
|
+
const d = s(!0), r = s(e.modelValue), I = s(ae), c = s(e.editing), k = s(!1), D = s(!1), f = s(200), R = s(null), V = s(null), S = s(new ee(r.value, e.dataStateConfig)), J = s(new ee(e.readData)), o = s(e.isCreate), K = s(!1), te = n(() => o.value ? e.createConfirm : e.updateConfirm), le = n(() => o.value ? e.createConfirmData : e.updateConfirmData), H = n(() => o.value ? e.createResource : e.updateResource), oe = n(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = n(() => o.value ? e.createDisabled : e.updateDisabled), y = n(() => !o.value && I.value.includes("update")), g = n(() => !o.value && I.value.includes("drop")), N = async () => {
|
|
96
96
|
u("fetchItem"), d.value = !0, f.value = -1, D.value = !1;
|
|
97
97
|
try {
|
|
98
98
|
const a = await he(e.readResource, e.readData);
|
|
@@ -100,23 +100,23 @@ const u = (...l) => {
|
|
|
100
100
|
k.value = !1, f.value = a.httpStatus, i("error", a.httpStatus);
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
k.value = !0, r.value = a.data, I.value = a.perms,
|
|
103
|
+
k.value = !0, r.value = a.data, I.value = a.perms, S.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), i("read", a);
|
|
104
104
|
} catch {
|
|
105
105
|
d.value = !1, k.value = !1, f.value = 404, i("error", 404);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
b(() => e.modelValue, (a) => {
|
|
110
|
-
r.value = a,
|
|
110
|
+
r.value = a, S.value.increment(a);
|
|
111
111
|
}, { deep: !0 }), b(r, (a) => {
|
|
112
112
|
if (K.value = !0, u("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
113
113
|
u("item updated -> has beforeEmitUpdate");
|
|
114
114
|
let t = e.beforeEmitUpdate(r.value);
|
|
115
115
|
u("item updated -> override with: ", t), typeof t == "object" && (r.value = t);
|
|
116
116
|
}
|
|
117
|
-
i("update:modelValue", r.value), u("item updated -> update dataState"),
|
|
117
|
+
i("update:modelValue", r.value), u("item updated -> update dataState"), S.value.increment(a), fe(() => K.value = !1);
|
|
118
118
|
}, { deep: !0 }), b(I, () => i("perms", I.value));
|
|
119
|
-
const P = n(() => ue.value || !o.value && !
|
|
119
|
+
const P = n(() => ue.value || !o.value && !y.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : S.value.changed());
|
|
120
120
|
b(P, (a) => i("modified-data", a)), b(o, (a) => i("update:isCreate", a)), b(() => e.readData, (a) => {
|
|
121
121
|
J.value.increment(a), J.value.changed() && N();
|
|
122
122
|
}), b(() => e.editing, (a) => {
|
|
@@ -129,8 +129,8 @@ const u = (...l) => {
|
|
|
129
129
|
D.value = !0, i("error", t.httpStatus);
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((
|
|
133
|
-
j(
|
|
132
|
+
D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((M) => {
|
|
133
|
+
j(M);
|
|
134
134
|
})), i("drop", t);
|
|
135
135
|
}, re = (a, t) => {
|
|
136
136
|
if (u("onSave -> received response:", t), i("before-save"), H.value) {
|
|
@@ -140,12 +140,12 @@ const u = (...l) => {
|
|
|
140
140
|
}
|
|
141
141
|
D.value = !0;
|
|
142
142
|
}
|
|
143
|
-
let
|
|
144
|
-
o.value || (u("onSave -> turn stored data into original"),
|
|
143
|
+
let M = o.value ? "create" : "update";
|
|
144
|
+
o.value || (u("onSave -> turn stored data into original"), S.value.turnStoredIntoOriginal()), M === "create" ? typeof e.onCreate == "function" && (u("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (u("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((E) => {
|
|
145
145
|
j(E);
|
|
146
146
|
}))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((E) => {
|
|
147
147
|
j(E);
|
|
148
|
-
}))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, N()), i(
|
|
148
|
+
}))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, N()), i(M, t);
|
|
149
149
|
}, W = () => {
|
|
150
150
|
d.value = !0, f.value = -1;
|
|
151
151
|
}, z = () => {
|
|
@@ -158,21 +158,22 @@ const u = (...l) => {
|
|
|
158
158
|
doRefresh: N,
|
|
159
159
|
doSave: () => {
|
|
160
160
|
R.value && typeof R.value.click == "function" && R.value.click();
|
|
161
|
-
}
|
|
161
|
+
},
|
|
162
|
+
hasModifiedData: () => S.value.changed()
|
|
162
163
|
});
|
|
163
|
-
const A = n(() => !
|
|
164
|
+
const A = n(() => !y.value && g.value ? !0 : !e.hiddenDrop && !d.value && c.value && k.value), G = n(() => S.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && k.value), Q = n(() => e.hideSwitchEdition || !y.value && !g.value || !y.value && g.value ? !1 : !d.value && !o.value && k.value && !(e.dropDisabled && e.updateDisabled)), ne = n(() => !e.hiddenButtons && (G.value || A.value || Q.value)), x = n(() => e.title.startsWith("__:") ? String(ye(e.title.substring(3))) : e.title), ie = n(() => d.value ? !1 : x.value.length > 0 || !!m["post-title"]);
|
|
164
165
|
return (a, t) => {
|
|
165
|
-
const
|
|
166
|
-
return v(),
|
|
167
|
-
ie.value ? (v(),
|
|
168
|
-
C(m)["pre-title"] ? (v(),
|
|
166
|
+
const M = L("lkt-button"), E = L("lkt-field-switch"), X = L("lkt-http-info"), se = L("lkt-loader");
|
|
167
|
+
return v(), _("article", ge, [
|
|
168
|
+
ie.value ? (v(), _("header", Me, [
|
|
169
|
+
C(m)["pre-title"] ? (v(), _("div", _e, [
|
|
169
170
|
U(a.$slots, "pre-title", {
|
|
170
171
|
item: r.value,
|
|
171
172
|
loading: d.value
|
|
172
173
|
})
|
|
173
174
|
])) : p("", !0),
|
|
174
|
-
x.value.length > 0 ? (v(),
|
|
175
|
-
C(m)["post-title"] ? (v(),
|
|
175
|
+
x.value.length > 0 ? (v(), _("h1", Be, pe(x.value), 1)) : p("", !0),
|
|
176
|
+
C(m)["post-title"] ? (v(), _("div", we, [
|
|
176
177
|
U(a.$slots, "post-title", {
|
|
177
178
|
item: r.value,
|
|
178
179
|
loading: d.value
|
|
@@ -180,11 +181,11 @@ const u = (...l) => {
|
|
|
180
181
|
])) : p("", !0)
|
|
181
182
|
])) : p("", !0),
|
|
182
183
|
O(me("div", Ie, [
|
|
183
|
-
o.value ? p("", !0) : O((v(), T(
|
|
184
|
+
o.value ? p("", !0) : O((v(), T(M, {
|
|
184
185
|
key: 0,
|
|
185
186
|
ref: (w) => V.value = w,
|
|
186
187
|
palette: "danger",
|
|
187
|
-
disabled: a.dropDisabled || !
|
|
188
|
+
disabled: a.dropDisabled || !g.value,
|
|
188
189
|
"confirm-modal": a.dropConfirm,
|
|
189
190
|
"confirm-data": a.dropConfirmData,
|
|
190
191
|
resource: a.dropResource,
|
|
@@ -201,15 +202,15 @@ const u = (...l) => {
|
|
|
201
202
|
item: r.value,
|
|
202
203
|
editMode: c.value,
|
|
203
204
|
isCreate: o.value,
|
|
204
|
-
canUpdate:
|
|
205
|
-
canDrop:
|
|
205
|
+
canUpdate: y.value,
|
|
206
|
+
canDrop: g.value
|
|
206
207
|
}) : p("", !0)
|
|
207
208
|
]),
|
|
208
209
|
_: 3
|
|
209
210
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
|
|
210
211
|
[$, A.value]
|
|
211
212
|
]),
|
|
212
|
-
O(Z(
|
|
213
|
+
O(Z(M, {
|
|
213
214
|
ref: (w) => R.value = w,
|
|
214
215
|
palette: "success",
|
|
215
216
|
disabled: !P.value,
|
|
@@ -229,8 +230,8 @@ const u = (...l) => {
|
|
|
229
230
|
item: r.value,
|
|
230
231
|
editMode: c.value,
|
|
231
232
|
isCreate: o.value,
|
|
232
|
-
canUpdate:
|
|
233
|
-
canDrop:
|
|
233
|
+
canUpdate: y.value,
|
|
234
|
+
canDrop: g.value
|
|
234
235
|
}) : p("", !0)
|
|
235
236
|
]),
|
|
236
237
|
_: 3
|
|
@@ -247,8 +248,8 @@ const u = (...l) => {
|
|
|
247
248
|
], 512), [
|
|
248
249
|
[$, ne.value]
|
|
249
250
|
]),
|
|
250
|
-
d.value ? p("", !0) : (v(),
|
|
251
|
-
k.value ? (v(),
|
|
251
|
+
d.value ? p("", !0) : (v(), _("div", Ee, [
|
|
252
|
+
k.value ? (v(), _("div", Ue, [
|
|
252
253
|
D.value ? (v(), T(X, {
|
|
253
254
|
key: 0,
|
|
254
255
|
code: f.value,
|
|
@@ -262,8 +263,8 @@ const u = (...l) => {
|
|
|
262
263
|
loading: d.value,
|
|
263
264
|
editMode: c.value,
|
|
264
265
|
isCreate: o.value,
|
|
265
|
-
canUpdate:
|
|
266
|
-
canDrop:
|
|
266
|
+
canUpdate: y.value,
|
|
267
|
+
canDrop: g.value,
|
|
267
268
|
itemBeingEdited: K.value
|
|
268
269
|
})
|
|
269
270
|
])) : (v(), T(X, {
|
|
@@ -82,6 +82,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
82
82
|
doDrop: () => void;
|
|
83
83
|
doRefresh: () => Promise<void>;
|
|
84
84
|
doSave: () => void;
|
|
85
|
+
hasModifiedData: () => boolean;
|
|
85
86
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
86
87
|
error: (...args: any[]) => void;
|
|
87
88
|
drop: (...args: any[]) => void;
|
package/package.json
CHANGED