lkt-item-crud 1.1.25 → 1.1.26
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
declare namespace
|
|
3
|
-
function install(l: any,
|
|
1
|
+
declare function Te(l?: boolean): void;
|
|
2
|
+
declare namespace $e {
|
|
3
|
+
function install(l: any, h?: {}): void;
|
|
4
4
|
}
|
|
5
|
-
export {
|
|
5
|
+
export { Te as debugLktItemCrud, $e as default };
|
package/dist/build.js
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
import { defineComponent as ce, useSlots as ve, ref as i, computed as s, watch as
|
|
1
|
+
import { defineComponent as ce, useSlots as ve, ref as i, computed as s, watch as b, nextTick as fe, resolveComponent as L, openBlock as f, createElementBlock as w, unref as C, renderSlot as U, createCommentVNode as m, createElementVNode as X, toDisplayString as pe, withDirectives as O, createBlock as T, withCtx as Y, vShow as $, createVNode as Z } from "vue";
|
|
2
2
|
import { httpCall as me } from "lkt-http-client";
|
|
3
3
|
import { DataState as ee } from "lkt-data-state";
|
|
4
|
-
import { execModal as he, refreshModal as
|
|
4
|
+
import { execModal as he, refreshModal as ke, closeModal as be, openModal as Ce, reOpenModal as De } from "lkt-modal";
|
|
5
5
|
const q = class q {
|
|
6
6
|
};
|
|
7
7
|
q.debugEnabled = !1;
|
|
8
8
|
let F = q;
|
|
9
9
|
const u = (...l) => {
|
|
10
10
|
F.debugEnabled && console.info("[LktItemCrud] ", ...l);
|
|
11
|
-
},
|
|
11
|
+
}, Te = (l = !0) => {
|
|
12
12
|
F.debugEnabled = l;
|
|
13
13
|
}, j = (l) => {
|
|
14
14
|
u("runModalCallback -> init", l);
|
|
15
|
-
let
|
|
15
|
+
let h = l.modalKey ? l.modalKey : "_", M = l.args ? l.args : {};
|
|
16
16
|
switch (l.action) {
|
|
17
17
|
case "reOpen":
|
|
18
|
-
return De(l.modalName,
|
|
18
|
+
return De(l.modalName, h, M);
|
|
19
19
|
case "open":
|
|
20
|
-
return Ce(l.modalName,
|
|
20
|
+
return Ce(l.modalName, h, M);
|
|
21
21
|
case "close":
|
|
22
|
-
return
|
|
22
|
+
return be(l.modalName, h);
|
|
23
23
|
case "refresh":
|
|
24
|
-
return
|
|
24
|
+
return ke(l.modalName, h, M);
|
|
25
25
|
case "exec":
|
|
26
26
|
let e = l.method;
|
|
27
|
-
return e ? he(l.modalName,
|
|
27
|
+
return e ? he(l.modalName, h, e, M) : void 0;
|
|
28
28
|
}
|
|
29
29
|
}, Se = { class: "lkt-item-crud" }, ye = {
|
|
30
30
|
key: 0,
|
|
31
31
|
class: "lkt-item-crud_header"
|
|
32
|
-
}, ge = {
|
|
32
|
+
}, ge = {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: "lkt-item-crud_header-slot"
|
|
35
|
+
}, Me = { class: "lkt-item-crud_header-title" }, Be = {
|
|
36
|
+
key: 1,
|
|
37
|
+
class: "lkt-item-crud_header-slot"
|
|
38
|
+
}, _e = { class: "lkt-item-crud-buttons" }, we = {
|
|
33
39
|
key: 1,
|
|
34
40
|
class: "lkt-item-crud_content"
|
|
35
|
-
},
|
|
41
|
+
}, Ie = {
|
|
36
42
|
key: 0,
|
|
37
43
|
class: "lkt-grid-1"
|
|
38
|
-
},
|
|
44
|
+
}, Ee = /* @__PURE__ */ ce({
|
|
39
45
|
__name: "LktItemCrud",
|
|
40
46
|
props: {
|
|
41
47
|
modelValue: { default: () => ({}) },
|
|
@@ -79,192 +85,198 @@ const u = (...l) => {
|
|
|
79
85
|
editing: { type: Boolean, default: !1 }
|
|
80
86
|
},
|
|
81
87
|
emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
|
|
82
|
-
setup(l, { expose:
|
|
83
|
-
const e = l,
|
|
88
|
+
setup(l, { expose: h, emit: M }) {
|
|
89
|
+
const e = l, p = ve(), n = M;
|
|
84
90
|
let ae = [];
|
|
85
|
-
const d = i(!0), r = i(e.modelValue),
|
|
86
|
-
u("fetchItem"), d.value = !0, v.value = -1,
|
|
91
|
+
const d = i(!0), r = i(e.modelValue), I = i(ae), c = i(e.editing), k = i(!1), D = i(!1), v = i(200), R = i(null), V = i(null), B = i(new ee(r.value, e.dataStateConfig)), J = i(new ee(e.readData)), o = i(e.isCreate), K = i(!1), te = s(() => o.value ? e.createConfirm : e.updateConfirm), le = s(() => o.value ? e.createConfirmData : e.updateConfirmData), x = s(() => o.value ? e.createResource : e.updateResource), oe = s(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = s(() => o.value ? e.createDisabled : e.updateDisabled), S = s(() => !o.value && I.value.includes("update")), y = s(() => !o.value && I.value.includes("drop")), N = async () => {
|
|
92
|
+
u("fetchItem"), d.value = !0, v.value = -1, D.value = !1;
|
|
87
93
|
try {
|
|
88
94
|
const a = await me(e.readResource, e.readData);
|
|
89
95
|
if (u("fetchItem -> response", a), d.value = !1, v.value = a.httpStatus, !a.success) {
|
|
90
|
-
|
|
96
|
+
k.value = !1, v.value = a.httpStatus, n("error", a.httpStatus);
|
|
91
97
|
return;
|
|
92
98
|
}
|
|
93
|
-
|
|
99
|
+
k.value = !0, r.value = a.data, I.value = a.perms, B.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), n("read", a);
|
|
94
100
|
} catch {
|
|
95
|
-
d.value = !1,
|
|
101
|
+
d.value = !1, k.value = !1, v.value = 404, n("error", 404);
|
|
96
102
|
return;
|
|
97
103
|
}
|
|
98
|
-
}, de = s(() => d.value ? !1 : e.title || !!
|
|
99
|
-
|
|
100
|
-
r.value = a,
|
|
101
|
-
}, { deep: !0 }),
|
|
104
|
+
}, de = s(() => d.value ? !1 : e.title || !!p["post-title"]);
|
|
105
|
+
b(() => e.modelValue, (a) => {
|
|
106
|
+
r.value = a, B.value.increment(a);
|
|
107
|
+
}, { deep: !0 }), b(r, (a) => {
|
|
102
108
|
if (K.value = !0, u("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
103
109
|
u("item updated -> has beforeEmitUpdate");
|
|
104
110
|
let t = e.beforeEmitUpdate(r.value);
|
|
105
111
|
u("item updated -> override with: ", t), typeof t == "object" && (r.value = t);
|
|
106
112
|
}
|
|
107
|
-
n("update:modelValue", r.value), u("item updated -> update dataState"),
|
|
108
|
-
}, { deep: !0 }),
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
J.value.increment(a), J.value.changed() &&
|
|
112
|
-
}),
|
|
113
|
+
n("update:modelValue", r.value), u("item updated -> update dataState"), B.value.increment(a), fe(() => K.value = !1);
|
|
114
|
+
}, { deep: !0 }), b(I, () => n("perms", I.value));
|
|
115
|
+
const H = s(() => ue.value || !o.value && !S.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : B.value.changed());
|
|
116
|
+
b(H, (a) => n("modified-data", a)), b(o, (a) => n("update:isCreate", a)), b(() => e.readData, (a) => {
|
|
117
|
+
J.value.increment(a), J.value.changed() && N();
|
|
118
|
+
}), b(() => e.editing, (a) => {
|
|
113
119
|
u("editing updated -> updating editMode", a), c.value = a;
|
|
114
|
-
}),
|
|
120
|
+
}), b(c, (a) => {
|
|
115
121
|
u("editMode updated -> emit update", a), n("update:editing", a);
|
|
116
|
-
}), e.readResource && !o.value ?
|
|
122
|
+
}), e.readResource && !o.value ? N() : o.value && (k.value = !0, c.value = !0, d.value = !1);
|
|
117
123
|
const re = (a, t) => {
|
|
118
124
|
if (d.value = !1, v.value = t.httpStatus, !t.success) {
|
|
119
|
-
|
|
125
|
+
D.value = !0, n("error", t.httpStatus);
|
|
120
126
|
return;
|
|
121
127
|
}
|
|
122
|
-
|
|
123
|
-
j(
|
|
128
|
+
D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((g) => {
|
|
129
|
+
j(g);
|
|
124
130
|
})), n("drop", t);
|
|
125
131
|
}, ne = (a, t) => {
|
|
126
|
-
if (u("onSave -> received response:", t), n("before-save"),
|
|
132
|
+
if (u("onSave -> received response:", t), n("before-save"), x.value) {
|
|
127
133
|
if (d.value = !1, v.value = t.httpStatus, !t.success) {
|
|
128
|
-
|
|
134
|
+
D.value = !0, n("error", t.httpStatus);
|
|
129
135
|
return;
|
|
130
136
|
}
|
|
131
|
-
|
|
137
|
+
D.value = !0;
|
|
132
138
|
}
|
|
133
|
-
let
|
|
134
|
-
o.value || (u("onSave -> turn stored data into original"),
|
|
135
|
-
j(
|
|
136
|
-
}))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((
|
|
137
|
-
j(
|
|
138
|
-
}))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1,
|
|
139
|
-
},
|
|
139
|
+
let g = o.value ? "create" : "update";
|
|
140
|
+
o.value || (u("onSave -> turn stored data into original"), B.value.turnStoredIntoOriginal()), g === "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) => {
|
|
141
|
+
j(E);
|
|
142
|
+
}))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((E) => {
|
|
143
|
+
j(E);
|
|
144
|
+
}))), !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()), n(g, t);
|
|
145
|
+
}, P = () => {
|
|
140
146
|
d.value = !0, v.value = -1;
|
|
141
|
-
},
|
|
147
|
+
}, z = () => {
|
|
142
148
|
d.value = !1;
|
|
143
149
|
};
|
|
144
|
-
|
|
150
|
+
h({
|
|
145
151
|
doDrop: () => {
|
|
146
|
-
|
|
152
|
+
V.value && typeof V.value.click == "function" && V.value.click();
|
|
147
153
|
},
|
|
148
|
-
doRefresh:
|
|
154
|
+
doRefresh: N,
|
|
149
155
|
doSave: () => {
|
|
150
|
-
|
|
156
|
+
R.value && typeof R.value.click == "function" && R.value.click();
|
|
151
157
|
}
|
|
152
158
|
});
|
|
153
|
-
const
|
|
159
|
+
const A = s(() => !S.value && y.value ? !0 : !e.hiddenDrop && !d.value && c.value && k.value), G = s(() => B.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && k.value), Q = s(() => e.hideSwitchEdition || !S.value && !y.value || !S.value && y.value ? !1 : !d.value && !o.value && k.value && !(e.dropDisabled && e.updateDisabled)), ie = s(() => !e.hiddenButtons && (G.value || A.value || Q.value));
|
|
154
160
|
return (a, t) => {
|
|
155
|
-
const
|
|
156
|
-
return
|
|
157
|
-
de.value ? (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
L(a.$slots, "post-title", {
|
|
161
|
+
const g = L("lkt-button"), E = L("lkt-field-switch"), W = L("lkt-http-info"), se = L("lkt-loader");
|
|
162
|
+
return f(), w("article", Se, [
|
|
163
|
+
de.value ? (f(), w("header", ye, [
|
|
164
|
+
C(p)["pre-title"] ? (f(), w("div", ge, [
|
|
165
|
+
U(a.$slots, "pre-title", {
|
|
161
166
|
item: r.value,
|
|
162
167
|
loading: d.value
|
|
163
168
|
})
|
|
164
|
-
])
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
])) : m("", !0),
|
|
170
|
+
X("h1", Me, pe(a.title), 1),
|
|
171
|
+
C(p)["post-title"] ? (f(), w("div", Be, [
|
|
172
|
+
U(a.$slots, "post-title", {
|
|
173
|
+
item: r.value,
|
|
174
|
+
loading: d.value
|
|
175
|
+
})
|
|
176
|
+
])) : m("", !0)
|
|
177
|
+
])) : m("", !0),
|
|
178
|
+
O(X("div", _e, [
|
|
179
|
+
o.value ? m("", !0) : O((f(), T(g, {
|
|
168
180
|
key: 0,
|
|
169
|
-
ref: (
|
|
181
|
+
ref: (_) => V.value = _,
|
|
170
182
|
palette: "danger",
|
|
171
|
-
disabled: a.dropDisabled || !
|
|
183
|
+
disabled: a.dropDisabled || !y.value,
|
|
172
184
|
"confirm-modal": a.dropConfirm,
|
|
173
185
|
"confirm-data": a.dropConfirmData,
|
|
174
186
|
resource: a.dropResource,
|
|
175
187
|
"resource-data": a.dropData,
|
|
176
|
-
text:
|
|
177
|
-
icon:
|
|
178
|
-
onLoading:
|
|
179
|
-
onLoaded:
|
|
188
|
+
text: C(p)["button-drop"] ? "" : a.dropText,
|
|
189
|
+
icon: C(p)["button-drop"] ? "" : a.dropIcon,
|
|
190
|
+
onLoading: P,
|
|
191
|
+
onLoaded: z,
|
|
180
192
|
onClick: re
|
|
181
193
|
}, {
|
|
182
194
|
default: Y(() => [
|
|
183
|
-
|
|
195
|
+
C(p)["button-drop"] ? U(a.$slots, "button-drop", {
|
|
184
196
|
key: 0,
|
|
185
197
|
item: r.value,
|
|
186
198
|
editMode: c.value,
|
|
187
199
|
isCreate: o.value,
|
|
188
|
-
canUpdate:
|
|
189
|
-
canDrop:
|
|
190
|
-
}) :
|
|
200
|
+
canUpdate: S.value,
|
|
201
|
+
canDrop: y.value
|
|
202
|
+
}) : m("", !0)
|
|
191
203
|
]),
|
|
192
204
|
_: 3
|
|
193
205
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
|
|
194
|
-
[$,
|
|
206
|
+
[$, A.value]
|
|
195
207
|
]),
|
|
196
|
-
O(Z(
|
|
197
|
-
ref: (
|
|
208
|
+
O(Z(g, {
|
|
209
|
+
ref: (_) => R.value = _,
|
|
198
210
|
palette: "success",
|
|
199
|
-
disabled: !
|
|
211
|
+
disabled: !H.value,
|
|
200
212
|
"confirm-modal": te.value,
|
|
201
213
|
"confirm-data": le.value,
|
|
202
|
-
resource:
|
|
214
|
+
resource: x.value,
|
|
203
215
|
"resource-data": oe.value,
|
|
204
|
-
text:
|
|
205
|
-
icon:
|
|
206
|
-
onLoading:
|
|
207
|
-
onLoaded:
|
|
216
|
+
text: C(p)["button-save"] ? "" : a.saveText,
|
|
217
|
+
icon: C(p)["button-save"] ? "" : a.saveIcon,
|
|
218
|
+
onLoading: P,
|
|
219
|
+
onLoaded: z,
|
|
208
220
|
onClick: ne
|
|
209
221
|
}, {
|
|
210
222
|
default: Y(() => [
|
|
211
|
-
|
|
223
|
+
C(p)["button-save"] ? U(a.$slots, "button-save", {
|
|
212
224
|
key: 0,
|
|
213
225
|
item: r.value,
|
|
214
226
|
editMode: c.value,
|
|
215
227
|
isCreate: o.value,
|
|
216
|
-
canUpdate:
|
|
217
|
-
canDrop:
|
|
218
|
-
}) :
|
|
228
|
+
canUpdate: S.value,
|
|
229
|
+
canDrop: y.value
|
|
230
|
+
}) : m("", !0)
|
|
219
231
|
]),
|
|
220
232
|
_: 3
|
|
221
233
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"]), [
|
|
222
|
-
[$,
|
|
234
|
+
[$, G.value]
|
|
223
235
|
]),
|
|
224
|
-
O(Z(
|
|
236
|
+
O(Z(E, {
|
|
225
237
|
modelValue: c.value,
|
|
226
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
238
|
+
"onUpdate:modelValue": t[0] || (t[0] = (_) => c.value = _),
|
|
227
239
|
label: a.editModeText
|
|
228
240
|
}, null, 8, ["modelValue", "label"]), [
|
|
229
|
-
[$,
|
|
241
|
+
[$, Q.value]
|
|
230
242
|
])
|
|
231
243
|
], 512), [
|
|
232
244
|
[$, ie.value]
|
|
233
245
|
]),
|
|
234
|
-
d.value ?
|
|
235
|
-
|
|
236
|
-
|
|
246
|
+
d.value ? m("", !0) : (f(), w("div", we, [
|
|
247
|
+
k.value ? (f(), w("div", Ie, [
|
|
248
|
+
D.value ? (f(), T(W, {
|
|
237
249
|
key: 0,
|
|
238
250
|
code: v.value,
|
|
239
251
|
quick: "",
|
|
240
252
|
palette: v.value === 200 ? "success" : "danger",
|
|
241
253
|
"can-close": "",
|
|
242
|
-
onClose: t[1] || (t[1] = (
|
|
243
|
-
}, null, 8, ["code", "palette"])) :
|
|
244
|
-
|
|
254
|
+
onClose: t[1] || (t[1] = (_) => D.value = !1)
|
|
255
|
+
}, null, 8, ["code", "palette"])) : m("", !0),
|
|
256
|
+
U(a.$slots, "item", {
|
|
245
257
|
item: r.value,
|
|
246
258
|
loading: d.value,
|
|
247
259
|
editMode: c.value,
|
|
248
260
|
isCreate: o.value,
|
|
249
|
-
canUpdate:
|
|
250
|
-
canDrop:
|
|
261
|
+
canUpdate: S.value,
|
|
262
|
+
canDrop: y.value,
|
|
251
263
|
itemBeingEdited: K.value
|
|
252
264
|
})
|
|
253
|
-
])) : (
|
|
265
|
+
])) : (f(), T(W, {
|
|
254
266
|
key: 1,
|
|
255
267
|
code: v.value
|
|
256
268
|
}, null, 8, ["code"]))
|
|
257
269
|
])),
|
|
258
|
-
d.value ? (
|
|
270
|
+
d.value ? (f(), T(se, { key: 2 })) : m("", !0)
|
|
259
271
|
]);
|
|
260
272
|
};
|
|
261
273
|
}
|
|
262
|
-
}),
|
|
263
|
-
install: (l,
|
|
264
|
-
l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud",
|
|
274
|
+
}), $e = {
|
|
275
|
+
install: (l, h = {}) => {
|
|
276
|
+
l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Ee);
|
|
265
277
|
}
|
|
266
278
|
};
|
|
267
279
|
export {
|
|
268
|
-
|
|
269
|
-
|
|
280
|
+
Te as debugLktItemCrud,
|
|
281
|
+
$e as default
|
|
270
282
|
};
|
|
@@ -223,6 +223,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
223
223
|
onDropModalCallbacks: ModalCallbackConfig[];
|
|
224
224
|
editing: boolean;
|
|
225
225
|
}, {}>, {
|
|
226
|
+
"pre-title"?(_: {
|
|
227
|
+
item: LktObject;
|
|
228
|
+
loading: boolean;
|
|
229
|
+
}): any;
|
|
226
230
|
"post-title"?(_: {
|
|
227
231
|
item: LktObject;
|
|
228
232
|
loading: boolean;
|
package/package.json
CHANGED
|
@@ -356,8 +356,11 @@ const showDropButton = computed(() => {
|
|
|
356
356
|
<template>
|
|
357
357
|
<article class="lkt-item-crud">
|
|
358
358
|
<header class="lkt-item-crud_header" v-if="displayHeader">
|
|
359
|
+
<div class="lkt-item-crud_header-slot" v-if="slots['pre-title']">
|
|
360
|
+
<slot name="pre-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
|
|
361
|
+
</div>
|
|
359
362
|
<h1 class="lkt-item-crud_header-title">{{ title }}</h1>
|
|
360
|
-
<div class="lkt-item-crud_header-slot">
|
|
363
|
+
<div class="lkt-item-crud_header-slot" v-if="slots['post-title']">
|
|
361
364
|
<slot name="post-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
|
|
362
365
|
</div>
|
|
363
366
|
</header>
|