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