lkt-item-crud 1.2.5 → 1.2.6
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 +5 -5
- package/dist/build.js +146 -137
- package/package.json +1 -1
- package/src/components/ButtonNav.vue +6 -6
- package/src/lib-components/LktItemCrud.vue +29 -11
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
declare namespace
|
|
1
|
+
declare function _e(o?: boolean): void;
|
|
2
|
+
declare namespace xe {
|
|
3
3
|
function install(o: any, g?: {}): void;
|
|
4
4
|
}
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
export {
|
|
5
|
+
declare function tt(o: any): void;
|
|
6
|
+
declare function et(o: any): void;
|
|
7
|
+
export { _e as debugLktItemCrud, xe as default, tt as setItemCrudDefaultDropIcon, et as setItemCrudDefaultSaveIcon };
|
package/dist/build.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { httpCall as
|
|
3
|
-
import { DataState as
|
|
4
|
-
import { execModal as
|
|
5
|
-
import { __ as
|
|
1
|
+
import { defineComponent as pe, useSlots as ce, ref as s, watch as C, resolveComponent as Z, openBlock as i, createElementBlock as w, unref as m, withDirectives as z, renderSlot as y, vShow as K, createCommentVNode as c, createBlock as M, withCtx as E, computed as v, nextTick as ye, onMounted as ke, resolveDynamicComponent as De, normalizeProps as ge, guardReactiveProps as Se, createElementVNode as we, toDisplayString as Be, createSlots as se } from "vue";
|
|
2
|
+
import { httpCall as Me } from "lkt-http-client";
|
|
3
|
+
import { DataState as ie } from "lkt-data-state";
|
|
4
|
+
import { execModal as Ie, refreshModal as Te, closeModal as Ue, openModal as Re, reOpenModal as Ne } from "lkt-modal";
|
|
5
|
+
import { __ as $e } from "lkt-i18n";
|
|
6
6
|
const F = class F {
|
|
7
7
|
};
|
|
8
8
|
F.debugEnabled = !1, F.defaultSaveIcon = "", F.defaultDropIcon = "";
|
|
9
9
|
let U = F;
|
|
10
|
-
const
|
|
10
|
+
const p = (...o) => {
|
|
11
11
|
U.debugEnabled && console.info("[LktItemCrud] ", ...o);
|
|
12
|
-
},
|
|
12
|
+
}, _e = (o = !0) => {
|
|
13
13
|
U.debugEnabled = o;
|
|
14
14
|
}, Y = (o) => {
|
|
15
|
-
|
|
15
|
+
p("runModalCallback -> init", o);
|
|
16
16
|
let g = o.modalKey ? o.modalKey : "_", I = o.args ? o.args : {};
|
|
17
17
|
switch (o.action) {
|
|
18
18
|
case "reOpen":
|
|
19
|
-
return
|
|
19
|
+
return Ne(o.modalName, g, I);
|
|
20
20
|
case "open":
|
|
21
|
-
return
|
|
21
|
+
return Re(o.modalName, g, I);
|
|
22
22
|
case "close":
|
|
23
|
-
return
|
|
23
|
+
return Ue(o.modalName, g);
|
|
24
24
|
case "refresh":
|
|
25
|
-
return
|
|
25
|
+
return Te(o.modalName, g, I);
|
|
26
26
|
case "exec":
|
|
27
27
|
let e = o.method;
|
|
28
|
-
return e ?
|
|
28
|
+
return e ? Ie(o.modalName, g, e, I) : void 0;
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, Ee = { class: "lkt-item-crud-buttons" }, Ve = {
|
|
31
31
|
key: 0,
|
|
32
32
|
class: "lkt-item-crud-buttons"
|
|
33
|
-
},
|
|
33
|
+
}, Le = {
|
|
34
34
|
key: 1,
|
|
35
35
|
class: "lkt-item-crud-buttons"
|
|
36
|
-
},
|
|
36
|
+
}, Oe = {
|
|
37
37
|
key: 4,
|
|
38
38
|
class: "lkt-item-crud-buttons"
|
|
39
|
-
},
|
|
39
|
+
}, ve = /* @__PURE__ */ pe({
|
|
40
40
|
__name: "ButtonNav",
|
|
41
41
|
props: {
|
|
42
42
|
item: { default: () => ({}) },
|
|
@@ -66,14 +66,14 @@ const v = (...o) => {
|
|
|
66
66
|
},
|
|
67
67
|
emits: ["update:loading", "update:editing", "save", "drop"],
|
|
68
68
|
setup(o, { expose: g, emit: I }) {
|
|
69
|
-
const e = I, b = o, u =
|
|
70
|
-
|
|
71
|
-
const f =
|
|
72
|
-
|
|
69
|
+
const e = I, b = o, u = ce(), V = s(null), d = s(null), r = s(b.loading);
|
|
70
|
+
C(() => b.loading, (a) => r.value = a), C(r, (a) => e("update:loading", a));
|
|
71
|
+
const f = s(b.editing);
|
|
72
|
+
C(() => b.editing, (a) => f.value = a), C(f, (a) => e("update:editing", a));
|
|
73
73
|
const h = () => {
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
74
|
+
r.value = !0;
|
|
75
|
+
}, k = () => {
|
|
76
|
+
r.value = !1;
|
|
77
77
|
}, B = (a, S) => {
|
|
78
78
|
e("save", a, S);
|
|
79
79
|
}, D = (a, S) => {
|
|
@@ -84,22 +84,22 @@ const v = (...o) => {
|
|
|
84
84
|
V.value && typeof V.value.click == "function" && V.value.click();
|
|
85
85
|
},
|
|
86
86
|
doDrop: () => {
|
|
87
|
-
|
|
87
|
+
d.value && typeof d.value.click == "function" && d.value.click();
|
|
88
88
|
}
|
|
89
89
|
}), (a, S) => {
|
|
90
90
|
const n = Z("lkt-button");
|
|
91
|
-
return
|
|
92
|
-
m(u)["prev-buttons-ever"] ? z((
|
|
93
|
-
|
|
91
|
+
return i(), w("div", Ee, [
|
|
92
|
+
m(u)["prev-buttons-ever"] ? z((i(), w("div", Ve, [
|
|
93
|
+
y(a.$slots, "prev-buttons-ever")
|
|
94
94
|
], 512)), [
|
|
95
|
-
[K, !
|
|
95
|
+
[K, !r.value]
|
|
96
96
|
]) : c("", !0),
|
|
97
|
-
m(u)["prev-buttons"] ? z((
|
|
98
|
-
|
|
97
|
+
m(u)["prev-buttons"] ? z((i(), w("div", Le, [
|
|
98
|
+
y(a.$slots, "prev-buttons")
|
|
99
99
|
], 512)), [
|
|
100
|
-
[K, f.value && !
|
|
100
|
+
[K, f.value && !r.value]
|
|
101
101
|
]) : c("", !0),
|
|
102
|
-
a.showSaveButton ? (
|
|
102
|
+
a.showSaveButton ? (i(), M(n, {
|
|
103
103
|
key: 2,
|
|
104
104
|
ref_key: "saveButton",
|
|
105
105
|
ref: V,
|
|
@@ -112,11 +112,11 @@ const v = (...o) => {
|
|
|
112
112
|
text: m(u)["button-save"] ? "" : a.saveText,
|
|
113
113
|
icon: m(u)["button-save"] ? "" : a.saveIcon,
|
|
114
114
|
onLoading: h,
|
|
115
|
-
onLoaded:
|
|
115
|
+
onLoaded: k,
|
|
116
116
|
onClick: B
|
|
117
117
|
}, {
|
|
118
118
|
default: E(() => [
|
|
119
|
-
m(u)["button-save"] ?
|
|
119
|
+
m(u)["button-save"] ? y(a.$slots, "button-save", {
|
|
120
120
|
key: 0,
|
|
121
121
|
item: a.item,
|
|
122
122
|
editMode: f.value,
|
|
@@ -127,10 +127,10 @@ const v = (...o) => {
|
|
|
127
127
|
]),
|
|
128
128
|
_: 3
|
|
129
129
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])) : c("", !0),
|
|
130
|
-
a.createMode ? c("", !0) : z((
|
|
130
|
+
a.createMode ? c("", !0) : z((i(), M(n, {
|
|
131
131
|
key: 3,
|
|
132
132
|
ref_key: "dropButton",
|
|
133
|
-
ref:
|
|
133
|
+
ref: d,
|
|
134
134
|
palette: "danger",
|
|
135
135
|
disabled: !a.ableToDrop,
|
|
136
136
|
"confirm-modal": a.dropConfirm,
|
|
@@ -140,11 +140,11 @@ const v = (...o) => {
|
|
|
140
140
|
text: m(u)["button-drop"] ? "" : a.dropText,
|
|
141
141
|
icon: m(u)["button-drop"] ? "" : a.dropIcon,
|
|
142
142
|
onLoading: h,
|
|
143
|
-
onLoaded:
|
|
143
|
+
onLoaded: k,
|
|
144
144
|
onClick: D
|
|
145
145
|
}, {
|
|
146
146
|
default: E(() => [
|
|
147
|
-
m(u)["button-drop"] ?
|
|
147
|
+
m(u)["button-drop"] ? y(a.$slots, "button-drop", {
|
|
148
148
|
key: 0,
|
|
149
149
|
item: a.item,
|
|
150
150
|
editMode: f.value,
|
|
@@ -157,12 +157,12 @@ const v = (...o) => {
|
|
|
157
157
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
|
|
158
158
|
[K, a.showDropButton]
|
|
159
159
|
]),
|
|
160
|
-
m(u).buttons ? z((
|
|
161
|
-
|
|
160
|
+
m(u).buttons ? z((i(), w("div", Oe, [
|
|
161
|
+
y(a.$slots, "buttons")
|
|
162
162
|
], 512)), [
|
|
163
|
-
[K, f.value && !
|
|
163
|
+
[K, f.value && !r.value]
|
|
164
164
|
]) : c("", !0),
|
|
165
|
-
a.showSwitchButton ? (
|
|
165
|
+
a.showSwitchButton ? (i(), M(n, {
|
|
166
166
|
key: 5,
|
|
167
167
|
checked: f.value,
|
|
168
168
|
"onUpdate:checked": S[0] || (S[0] = (L) => f.value = L),
|
|
@@ -175,25 +175,25 @@ const v = (...o) => {
|
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
var _ = /* @__PURE__ */ ((o) => (o.Top = "top", o.Bottom = "bottom", o))(_ || {}), j = /* @__PURE__ */ ((o) => (o.Changed = "changed", o.Always = "always", o))(j || {});
|
|
178
|
-
const
|
|
178
|
+
const Ae = { class: "lkt-item-crud" }, ze = {
|
|
179
179
|
key: 0,
|
|
180
180
|
class: "lkt-item-crud_header"
|
|
181
|
-
},
|
|
181
|
+
}, Ke = {
|
|
182
182
|
key: 0,
|
|
183
183
|
class: "lkt-item-crud_header-slot"
|
|
184
|
-
},
|
|
184
|
+
}, Fe = {
|
|
185
185
|
key: 1,
|
|
186
186
|
class: "lkt-item-crud_header-title"
|
|
187
|
-
},
|
|
187
|
+
}, Pe = {
|
|
188
188
|
key: 2,
|
|
189
189
|
class: "lkt-item-crud_header-slot"
|
|
190
|
-
},
|
|
190
|
+
}, Je = {
|
|
191
191
|
key: 2,
|
|
192
192
|
class: "lkt-item-crud_content"
|
|
193
|
-
},
|
|
193
|
+
}, je = {
|
|
194
194
|
key: 0,
|
|
195
195
|
class: "lkt-grid-1"
|
|
196
|
-
},
|
|
196
|
+
}, qe = /* @__PURE__ */ pe({
|
|
197
197
|
__name: "LktItemCrud",
|
|
198
198
|
props: {
|
|
199
199
|
modelValue: { default: () => ({}) },
|
|
@@ -251,62 +251,64 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
251
251
|
},
|
|
252
252
|
emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
|
|
253
253
|
setup(o, { expose: g, emit: I }) {
|
|
254
|
-
const e = o, b =
|
|
254
|
+
const e = o, b = ce(), u = I;
|
|
255
255
|
let V = [];
|
|
256
|
-
const
|
|
257
|
-
|
|
256
|
+
const d = s(!0), r = s(e.modelValue), f = s(V), h = s(e.editing), k = s(!1), B = s(!1), D = s(200), x = s(null), ee = s(null), a = s(new ie(r.value, e.dataStateConfig)), S = s(new ie(e.readData)), n = s(e.isCreate), L = s(!1), te = s(!1), P = s(null), ae = v(() => n.value ? e.createConfirm : e.updateConfirm), oe = v(() => n.value ? e.createConfirmData : e.updateConfirmData), q = v(() => n.value ? e.createResource : e.updateResource), le = v(() => n.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), fe = v(() => n.value ? e.createDisabled : e.updateDisabled), R = v(() => !n.value && Array.isArray(f.value) && f.value.includes("update")), N = v(() => !n.value && Array.isArray(f.value) && f.value.includes("drop")), J = async () => {
|
|
257
|
+
p("fetchItem"), d.value = !0, D.value = -1, B.value = !1;
|
|
258
258
|
try {
|
|
259
|
-
const t = await
|
|
260
|
-
if (
|
|
261
|
-
|
|
259
|
+
const t = await Me(e.readResource, e.readData);
|
|
260
|
+
if (p("fetchItem -> response", t), d.value = !1, D.value = t.httpStatus, !t.success) {
|
|
261
|
+
k.value = !1, D.value = t.httpStatus, u("error", t.httpStatus);
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
k.value = !0, r.value = t.data, f.value = t.perms, a.value.increment(r.value).turnStoredIntoOriginal(), S.value.turnStoredIntoOriginal(), u("read", t);
|
|
265
265
|
} catch {
|
|
266
|
-
|
|
266
|
+
d.value = !1, k.value = !1, D.value = 404, u("error", 404);
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, { deep: !0 }),
|
|
273
|
-
if (L.value = !0,
|
|
274
|
-
|
|
275
|
-
let l = e.beforeEmitUpdate(
|
|
276
|
-
|
|
270
|
+
C(() => e.modelValue, (t) => {
|
|
271
|
+
r.value = t, a.value.increment(t);
|
|
272
|
+
}, { deep: !0 }), C(r, (t) => {
|
|
273
|
+
if (L.value = !0, p("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
274
|
+
p("item updated -> has beforeEmitUpdate");
|
|
275
|
+
let l = e.beforeEmitUpdate(r.value);
|
|
276
|
+
p("item updated -> override with: ", l), typeof l == "object" && (r.value = l);
|
|
277
277
|
}
|
|
278
|
-
u("update:modelValue",
|
|
279
|
-
}, { deep: !0 }),
|
|
280
|
-
const O =
|
|
281
|
-
|
|
278
|
+
u("update:modelValue", r.value), p("item updated -> update dataState"), a.value.increment(t), ye(() => L.value = !1);
|
|
279
|
+
}, { deep: !0 }), C(f, () => u("perms", f.value));
|
|
280
|
+
const O = v(() => fe.value || !n.value && !R.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : a.value.changed()), H = v(() => !e.dropDisabled && N.value);
|
|
281
|
+
C(O, (t) => u("modified-data", t)), C(n, (t) => u("update:isCreate", t)), C(() => e.readData, (t) => {
|
|
282
282
|
S.value.increment(t), S.value.changed() && J();
|
|
283
|
-
}),
|
|
284
|
-
|
|
285
|
-
}),
|
|
286
|
-
|
|
287
|
-
}),
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
}), C(() => e.editing, (t) => {
|
|
284
|
+
p("editing updated -> updating editMode", t), h.value = t;
|
|
285
|
+
}), C(h, (t) => {
|
|
286
|
+
p("editMode updated -> emit update", t), u("update:editing", t);
|
|
287
|
+
}), ke(() => {
|
|
288
|
+
e.readResource && !n.value ? J() : n.value && (k.value = !0, h.value = !0, d.value = !1, a.value.increment(r.value).turnStoredIntoOriginal());
|
|
289
|
+
});
|
|
290
|
+
const re = (t, l) => {
|
|
291
|
+
if (d.value = !1, D.value = l.httpStatus, !l.success) {
|
|
290
292
|
B.value = !0, u("error", l.httpStatus);
|
|
291
293
|
return;
|
|
292
294
|
}
|
|
293
|
-
B.value = !0, e.onDropModalCallbacks.length > 0 && (
|
|
295
|
+
B.value = !0, e.onDropModalCallbacks.length > 0 && (p("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach(($) => {
|
|
294
296
|
Y($);
|
|
295
297
|
})), u("drop", l);
|
|
296
298
|
}, de = (t, l) => {
|
|
297
|
-
if (
|
|
298
|
-
if (
|
|
299
|
+
if (p("onSave -> received response:", l), u("before-save"), q.value) {
|
|
300
|
+
if (d.value = !1, typeof l < "u" && (D.value = l.httpStatus, !l.success)) {
|
|
299
301
|
B.value = !0, u("error", l.httpStatus);
|
|
300
302
|
return;
|
|
301
303
|
}
|
|
302
304
|
B.value = !0;
|
|
303
305
|
}
|
|
304
306
|
let $ = n.value ? "create" : "update";
|
|
305
|
-
n.value || (
|
|
307
|
+
n.value || (p("onSave -> turn stored data into original"), a.value.turnStoredIntoOriginal()), $ === "create" ? (te.value = !0, a.value.increment(r.value).turnStoredIntoOriginal(), typeof e.onCreate == "function" && (p("onSave -> trigger onCreate callback"), e.onCreate(l), e.onCreateModalCallbacks.length > 0 && (p("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((A) => {
|
|
306
308
|
Y(A);
|
|
307
|
-
}))) : typeof e.onUpdate == "function" && (
|
|
309
|
+
})))) : typeof e.onUpdate == "function" && (p("onSave -> trigger onUpdate callback"), e.onUpdate(l), e.onUpdateModalCallbacks.length > 0 && (p("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((A) => {
|
|
308
310
|
Y(A);
|
|
309
|
-
}))), !e.insideModal && l.autoReloadId && (
|
|
311
|
+
}))), !e.insideModal && l.autoReloadId && (p("onSave -> autoReloadId detected: ", l.autoReloadId), e.readData.id = l.autoReloadId, p("onSave -> turning off create mode"), n.value = !1, J()), u($, l);
|
|
310
312
|
};
|
|
311
313
|
g({
|
|
312
314
|
doDrop: () => {
|
|
@@ -318,49 +320,56 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
318
320
|
},
|
|
319
321
|
hasModifiedData: () => a.value.changed()
|
|
320
322
|
});
|
|
321
|
-
const
|
|
323
|
+
const me = v(() => a.value.changed() ? e.editedCloseConfirm : ""), be = (t) => {
|
|
324
|
+
if (typeof e.beforeClose == "function")
|
|
325
|
+
return e.beforeClose({
|
|
326
|
+
...t,
|
|
327
|
+
itemCreated: te.value
|
|
328
|
+
});
|
|
329
|
+
}, W = v(() => !R.value && N.value ? !0 : !e.hiddenDrop && !d.value && h.value && k.value), G = v(() => a.value.changed() ? !0 : d.value ? !1 : n.value ? !0 : e.buttonNavVisibility === j.Always ? O.value : !e.hiddenSave && h.value && k.value), Q = v(() => e.hideSwitchEdition || !R.value && !N.value || !R.value && N.value ? !1 : !d.value && !n.value && k.value && !(e.dropDisabled && e.updateDisabled)), ue = v(() => e.buttonNavVisibility === j.Always && (O.value || H.value) || b["prev-buttons-ever"] ? !0 : !e.hiddenButtons && (G.value || W.value || Q.value)), X = v(() => e.title.startsWith("__:") ? String($e(e.title.substring(3))) : e.title), he = v(() => d.value ? !1 : X.value.length > 0 || !!b["post-title"]), ne = v(() => e.insideModal ? "lkt-modal" : "section"), Ce = v(() => ne.value === "lkt-modal" ? {
|
|
322
330
|
"modal-name": e.modalName,
|
|
323
331
|
"modal-key": e.modalKey,
|
|
324
332
|
"z-index": e.zIndex,
|
|
325
333
|
"pre-title": e.preTitle,
|
|
326
334
|
"show-close": e.showClose,
|
|
327
|
-
"before-close":
|
|
335
|
+
"before-close": be,
|
|
328
336
|
"disabled-close": e.disabledClose,
|
|
329
337
|
"disabled-veil-click": e.disabledVeilClick,
|
|
330
|
-
"close-confirm":
|
|
338
|
+
"close-confirm": me.value,
|
|
331
339
|
"close-confirm-key": e.editedCloseConfirmKey,
|
|
332
340
|
title: e.title,
|
|
333
|
-
size: e.size
|
|
341
|
+
size: e.size,
|
|
342
|
+
item: r.value
|
|
334
343
|
} : {});
|
|
335
344
|
return (t, l) => {
|
|
336
345
|
const $ = Z("lkt-http-info"), A = Z("lkt-loader");
|
|
337
|
-
return
|
|
346
|
+
return i(), M(De(ne.value), ge(Se(Ce.value)), {
|
|
338
347
|
default: E(() => [
|
|
339
|
-
|
|
340
|
-
!t.insideModal &&
|
|
341
|
-
m(b)["pre-title"] ? (
|
|
342
|
-
|
|
343
|
-
item:
|
|
344
|
-
loading:
|
|
348
|
+
we("article", Ae, [
|
|
349
|
+
!t.insideModal && he.value ? (i(), w("header", ze, [
|
|
350
|
+
m(b)["pre-title"] ? (i(), w("div", Ke, [
|
|
351
|
+
y(t.$slots, "pre-title", {
|
|
352
|
+
item: r.value,
|
|
353
|
+
loading: d.value
|
|
345
354
|
})
|
|
346
355
|
])) : c("", !0),
|
|
347
|
-
X.value.length > 0 ? (
|
|
348
|
-
m(b)["post-title"] ? (
|
|
349
|
-
|
|
350
|
-
item:
|
|
351
|
-
loading:
|
|
356
|
+
X.value.length > 0 ? (i(), w("h1", Fe, Be(X.value), 1)) : c("", !0),
|
|
357
|
+
m(b)["post-title"] ? (i(), w("div", Pe, [
|
|
358
|
+
y(t.$slots, "post-title", {
|
|
359
|
+
item: r.value,
|
|
360
|
+
loading: d.value
|
|
352
361
|
})
|
|
353
362
|
])) : c("", !0)
|
|
354
363
|
])) : c("", !0),
|
|
355
|
-
|
|
364
|
+
ue.value && t.buttonNavPosition === "top" ? (i(), M(ve, {
|
|
356
365
|
key: 1,
|
|
357
366
|
ref_key: "buttonNav",
|
|
358
367
|
ref: P,
|
|
359
|
-
loading:
|
|
360
|
-
"onUpdate:loading": l[0] || (l[0] = (T) =>
|
|
368
|
+
loading: d.value,
|
|
369
|
+
"onUpdate:loading": l[0] || (l[0] = (T) => d.value = T),
|
|
361
370
|
editing: h.value,
|
|
362
371
|
"onUpdate:editing": l[1] || (l[1] = (T) => h.value = T),
|
|
363
|
-
item:
|
|
372
|
+
item: r.value,
|
|
364
373
|
"create-mode": n.value,
|
|
365
374
|
"can-update": R.value,
|
|
366
375
|
"can-drop": N.value,
|
|
@@ -369,13 +378,13 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
369
378
|
"show-drop-button": W.value,
|
|
370
379
|
"able-to-save": O.value,
|
|
371
380
|
"able-to-drop": H.value,
|
|
372
|
-
"save-confirm":
|
|
381
|
+
"save-confirm": ae.value,
|
|
373
382
|
"drop-confirm": t.dropConfirm,
|
|
374
|
-
"confirm-data":
|
|
383
|
+
"confirm-data": oe.value,
|
|
375
384
|
"drop-confirm-data": t.dropConfirmData,
|
|
376
385
|
"save-resource": q.value,
|
|
377
386
|
"drop-resource": t.dropResource,
|
|
378
|
-
"save-data":
|
|
387
|
+
"save-data": le.value,
|
|
379
388
|
"drop-data": t.dropData,
|
|
380
389
|
"save-text": t.saveText,
|
|
381
390
|
"drop-text": t.dropText,
|
|
@@ -383,26 +392,26 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
383
392
|
"drop-icon": t.dropIcon,
|
|
384
393
|
"edit-mode-text": t.editModeText,
|
|
385
394
|
onSave: de,
|
|
386
|
-
onDrop:
|
|
387
|
-
},
|
|
395
|
+
onDrop: re
|
|
396
|
+
}, se({ _: 2 }, [
|
|
388
397
|
m(b)["prev-buttons-ever"] ? {
|
|
389
398
|
name: "prev-buttons-ever",
|
|
390
399
|
fn: E(() => [
|
|
391
|
-
|
|
400
|
+
y(t.$slots, "prev-buttons-ever")
|
|
392
401
|
]),
|
|
393
402
|
key: "0"
|
|
394
403
|
} : void 0,
|
|
395
404
|
m(b)["prev-buttons"] ? {
|
|
396
405
|
name: "prev-buttons-ever",
|
|
397
406
|
fn: E(() => [
|
|
398
|
-
|
|
407
|
+
y(t.$slots, "prev-buttons")
|
|
399
408
|
]),
|
|
400
409
|
key: "1"
|
|
401
410
|
} : void 0
|
|
402
411
|
]), 1032, ["loading", "editing", "item", "create-mode", "can-update", "can-drop", "show-switch-button", "show-save-button", "show-drop-button", "able-to-save", "able-to-drop", "save-confirm", "drop-confirm", "confirm-data", "drop-confirm-data", "save-resource", "drop-resource", "save-data", "drop-data", "save-text", "drop-text", "save-icon", "drop-icon", "edit-mode-text"])) : c("", !0),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
B.value ? (
|
|
412
|
+
d.value ? c("", !0) : (i(), w("div", Je, [
|
|
413
|
+
k.value ? (i(), w("div", je, [
|
|
414
|
+
B.value ? (i(), M($, {
|
|
406
415
|
key: 0,
|
|
407
416
|
code: D.value,
|
|
408
417
|
quick: "",
|
|
@@ -410,30 +419,30 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
410
419
|
"can-close": "",
|
|
411
420
|
onClose: l[2] || (l[2] = (T) => B.value = !1)
|
|
412
421
|
}, null, 8, ["code", "palette"])) : c("", !0),
|
|
413
|
-
|
|
414
|
-
item:
|
|
415
|
-
loading:
|
|
422
|
+
y(t.$slots, "item", {
|
|
423
|
+
item: r.value,
|
|
424
|
+
loading: d.value,
|
|
416
425
|
editMode: h.value,
|
|
417
426
|
isCreate: n.value,
|
|
418
427
|
canUpdate: R.value,
|
|
419
428
|
canDrop: N.value,
|
|
420
429
|
itemBeingEdited: L.value
|
|
421
430
|
})
|
|
422
|
-
])) : (
|
|
431
|
+
])) : (i(), M($, {
|
|
423
432
|
key: 1,
|
|
424
433
|
code: D.value
|
|
425
434
|
}, null, 8, ["code"]))
|
|
426
435
|
])),
|
|
427
|
-
|
|
428
|
-
t.buttonNavPosition === m(_).Bottom ? z((
|
|
436
|
+
d.value ? (i(), M(A, { key: 3 })) : c("", !0),
|
|
437
|
+
t.buttonNavPosition === m(_).Bottom ? z((i(), M(ve, {
|
|
429
438
|
key: 4,
|
|
430
439
|
ref_key: "buttonNav",
|
|
431
440
|
ref: P,
|
|
432
|
-
loading:
|
|
433
|
-
"onUpdate:loading": l[3] || (l[3] = (T) =>
|
|
441
|
+
loading: d.value,
|
|
442
|
+
"onUpdate:loading": l[3] || (l[3] = (T) => d.value = T),
|
|
434
443
|
editing: h.value,
|
|
435
444
|
"onUpdate:editing": l[4] || (l[4] = (T) => h.value = T),
|
|
436
|
-
item:
|
|
445
|
+
item: r.value,
|
|
437
446
|
"create-mode": n.value,
|
|
438
447
|
"can-update": R.value,
|
|
439
448
|
"can-drop": N.value,
|
|
@@ -442,13 +451,13 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
442
451
|
"show-drop-button": W.value,
|
|
443
452
|
"able-to-save": O.value,
|
|
444
453
|
"able-to-drop": H.value,
|
|
445
|
-
"save-confirm":
|
|
454
|
+
"save-confirm": ae.value,
|
|
446
455
|
"drop-confirm": t.dropConfirm,
|
|
447
|
-
"confirm-data":
|
|
456
|
+
"confirm-data": oe.value,
|
|
448
457
|
"drop-confirm-data": t.dropConfirmData,
|
|
449
458
|
"save-resource": q.value,
|
|
450
459
|
"drop-resource": t.dropResource,
|
|
451
|
-
"save-data":
|
|
460
|
+
"save-data": le.value,
|
|
452
461
|
"drop-data": t.dropData,
|
|
453
462
|
"save-text": t.saveText,
|
|
454
463
|
"drop-text": t.dropText,
|
|
@@ -456,24 +465,24 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
456
465
|
"drop-icon": t.dropIcon,
|
|
457
466
|
"edit-mode-text": t.editModeText,
|
|
458
467
|
onSave: de,
|
|
459
|
-
onDrop:
|
|
460
|
-
},
|
|
468
|
+
onDrop: re
|
|
469
|
+
}, se({ _: 2 }, [
|
|
461
470
|
m(b)["prev-buttons-ever"] ? {
|
|
462
471
|
name: "prev-buttons-ever",
|
|
463
472
|
fn: E(() => [
|
|
464
|
-
|
|
473
|
+
y(t.$slots, "prev-buttons-ever")
|
|
465
474
|
]),
|
|
466
475
|
key: "0"
|
|
467
476
|
} : void 0,
|
|
468
477
|
m(b)["prev-buttons"] ? {
|
|
469
478
|
name: "prev-buttons-ever",
|
|
470
479
|
fn: E(() => [
|
|
471
|
-
|
|
480
|
+
y(t.$slots, "prev-buttons")
|
|
472
481
|
]),
|
|
473
482
|
key: "1"
|
|
474
483
|
} : void 0
|
|
475
484
|
]), 1032, ["loading", "editing", "item", "create-mode", "can-update", "can-drop", "show-switch-button", "show-save-button", "show-drop-button", "able-to-save", "able-to-drop", "save-confirm", "drop-confirm", "confirm-data", "drop-confirm-data", "save-resource", "drop-resource", "save-data", "drop-data", "save-text", "drop-text", "save-icon", "drop-icon", "edit-mode-text"])), [
|
|
476
|
-
[K,
|
|
485
|
+
[K, ue.value]
|
|
477
486
|
]) : c("", !0)
|
|
478
487
|
])
|
|
479
488
|
]),
|
|
@@ -481,18 +490,18 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
481
490
|
}, 16);
|
|
482
491
|
};
|
|
483
492
|
}
|
|
484
|
-
}),
|
|
493
|
+
}), xe = {
|
|
485
494
|
install: (o, g = {}) => {
|
|
486
|
-
o.component("lkt-item-crud") === void 0 && o.component("lkt-item-crud",
|
|
495
|
+
o.component("lkt-item-crud") === void 0 && o.component("lkt-item-crud", qe);
|
|
487
496
|
}
|
|
488
|
-
},
|
|
497
|
+
}, et = (o) => {
|
|
489
498
|
U.defaultSaveIcon = o;
|
|
490
|
-
},
|
|
499
|
+
}, tt = (o) => {
|
|
491
500
|
U.defaultDropIcon = o;
|
|
492
501
|
};
|
|
493
502
|
export {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
503
|
+
_e as debugLktItemCrud,
|
|
504
|
+
xe as default,
|
|
505
|
+
tt as setItemCrudDefaultDropIcon,
|
|
506
|
+
et as setItemCrudDefaultSaveIcon
|
|
498
507
|
};
|
package/package.json
CHANGED
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
:resource-data="saveData"
|
|
102
102
|
:text="slots['button-save'] ? '' : saveText"
|
|
103
103
|
:icon="slots['button-save'] ? '' : saveIcon"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
@loading="onButtonLoading"
|
|
105
|
+
@loaded="onButtonLoaded"
|
|
106
|
+
@click="onSave">
|
|
107
107
|
<slot v-if="!!slots['button-save']" name="button-save" :item="item"
|
|
108
108
|
:edit-mode="isEditing"
|
|
109
109
|
:is-create="createMode"
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
:resource-data="dropData"
|
|
124
124
|
:text="slots['button-drop'] ? '' : dropText"
|
|
125
125
|
:icon="slots['button-drop'] ? '' : dropIcon"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
@loading="onButtonLoading"
|
|
127
|
+
@loaded="onButtonLoaded"
|
|
128
|
+
@click="onDrop">
|
|
129
129
|
<slot v-if="!!slots['button-drop']" name="button-drop" :item="item"
|
|
130
130
|
:edit-mode="isEditing"
|
|
131
131
|
:is-create="createMode"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, ref, useSlots, watch } from 'vue';
|
|
2
|
+
import { computed, nextTick, onMounted, ref, useSlots, watch } from 'vue';
|
|
3
3
|
import { httpCall, HTTPResponse } from 'lkt-http-client';
|
|
4
4
|
import { DataState } from 'lkt-data-state';
|
|
5
5
|
import { debug } from '../functions/debug';
|
|
@@ -143,7 +143,8 @@
|
|
|
143
143
|
dataState = ref(new DataState(item.value, props.dataStateConfig)),
|
|
144
144
|
readDataState = ref(new DataState(props.readData)),
|
|
145
145
|
createMode = ref(props.isCreate),
|
|
146
|
-
itemBeingEdited = ref(false)
|
|
146
|
+
itemBeingEdited = ref(false),
|
|
147
|
+
itemCreated = ref(false);
|
|
147
148
|
|
|
148
149
|
const buttonNav = ref(null);
|
|
149
150
|
|
|
@@ -259,13 +260,16 @@
|
|
|
259
260
|
emit('update:editing', v);
|
|
260
261
|
});
|
|
261
262
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
onMounted(() => {
|
|
264
|
+
// Fetch item
|
|
265
|
+
if (props.readResource && !createMode.value) fetchItem();
|
|
266
|
+
else if (createMode.value) {
|
|
267
|
+
httpSuccessRead.value = true;
|
|
268
|
+
editMode.value = true;
|
|
269
|
+
isLoading.value = false;
|
|
270
|
+
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
271
|
+
}
|
|
272
|
+
})
|
|
269
273
|
|
|
270
274
|
const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
271
275
|
isLoading.value = false;
|
|
@@ -291,7 +295,7 @@
|
|
|
291
295
|
isLoading.value = false;
|
|
292
296
|
if (typeof r !== 'undefined') {
|
|
293
297
|
httpStatus.value = r.httpStatus;
|
|
294
|
-
if (r.success) {
|
|
298
|
+
if (!r.success) {
|
|
295
299
|
showStoreMessage.value = true;
|
|
296
300
|
emit('error', r.httpStatus);
|
|
297
301
|
return;
|
|
@@ -305,7 +309,10 @@
|
|
|
305
309
|
dataState.value.turnStoredIntoOriginal();
|
|
306
310
|
}
|
|
307
311
|
|
|
312
|
+
|
|
308
313
|
if (emits === 'create') {
|
|
314
|
+
itemCreated.value = true;
|
|
315
|
+
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
309
316
|
if (typeof props.onCreate === 'function') {
|
|
310
317
|
debug('onSave -> trigger onCreate callback');
|
|
311
318
|
props.onCreate(r);
|
|
@@ -359,6 +366,15 @@
|
|
|
359
366
|
return dataState.value.changed() ? props.editedCloseConfirm : '';
|
|
360
367
|
});
|
|
361
368
|
|
|
369
|
+
const crudBeforeClose = (modalData: LktObject) => {
|
|
370
|
+
if (typeof props.beforeClose === 'function') {
|
|
371
|
+
return props.beforeClose({
|
|
372
|
+
...modalData,
|
|
373
|
+
itemCreated: itemCreated.value,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
362
378
|
const showDropButton = computed(() => {
|
|
363
379
|
if (!canUpdate.value && canDrop.value) return true;
|
|
364
380
|
|
|
@@ -414,19 +430,21 @@
|
|
|
414
430
|
}),
|
|
415
431
|
computedContainerAttrs = computed(() => {
|
|
416
432
|
if (computedContainerTag.value === 'lkt-modal') {
|
|
433
|
+
|
|
417
434
|
return {
|
|
418
435
|
'modal-name': props.modalName,
|
|
419
436
|
'modal-key': props.modalKey,
|
|
420
437
|
'z-index': props.zIndex,
|
|
421
438
|
'pre-title': props.preTitle,
|
|
422
439
|
'show-close': props.showClose,
|
|
423
|
-
'before-close':
|
|
440
|
+
'before-close': crudBeforeClose,
|
|
424
441
|
'disabled-close': props.disabledClose,
|
|
425
442
|
'disabled-veil-click': props.disabledVeilClick,
|
|
426
443
|
'close-confirm': closeConfirm.value,
|
|
427
444
|
'close-confirm-key': props.editedCloseConfirmKey,
|
|
428
445
|
title: props.title,
|
|
429
446
|
size: props.size,
|
|
447
|
+
item: item.value,
|
|
430
448
|
};
|
|
431
449
|
}
|
|
432
450
|
return {};
|