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