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 Ie(c?: boolean): void;
2
- declare namespace Ue {
3
- function install(c: any, J?: {}): void;
1
+ declare function Te(l?: boolean): void;
2
+ declare namespace $e {
3
+ function install(l: any, f?: {}): void;
4
4
  }
5
- export { Ie as debugLktItemCrud, Ue as default };
5
+ export { Te as debugLktItemCrud, $e as default };
package/dist/build.js CHANGED
@@ -1,24 +1,41 @@
1
- import { defineComponent as se, useSlots as ie, ref as r, computed as d, watch as S, nextTick as ve, resolveComponent as w, openBlock as v, createElementBlock as k, createElementVNode as $, toDisplayString as O, renderSlot as V, createCommentVNode as y, withDirectives as I, createBlock as U, withCtx as Q, unref as W, vShow as E, createVNode as X } from "vue";
2
- import { httpCall as ce } from "lkt-http-client";
3
- import { DataState as fe } from "lkt-data-state";
4
- const F = class F {
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
- F.debugEnabled = !1;
7
- let L = F;
8
- const n = (...c) => {
9
- L.debugEnabled && console.info("[LktItemCrud] ", ...c);
10
- }, Ie = (c = !0) => {
11
- L.debugEnabled = c;
12
- }, pe = { class: "lkt-item-crud" }, me = {
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
- }, he = { class: "lkt-item-crud_header-title" }, ke = { class: "lkt-item-crud_header-slot" }, De = { class: "lkt-item-crud-buttons" }, be = { key: 1 }, Ce = { key: 1 }, Se = {
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
- }, ye = {
35
+ }, we = {
19
36
  key: 0,
20
37
  class: "lkt-grid-1"
21
- }, ge = /* @__PURE__ */ se({
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(c, { expose: J, emit: Y }) {
59
- const t = c, M = ie(), s = Y;
60
- let Z = [];
61
- const o = r(!0), u = r(t.modelValue), D = r(Z), f = r(!1), p = r(!1), m = r(!1), i = r(200), g = r(null), _ = r(null), b = r(new fe(u.value, t.dataStateConfig)), l = r(t.isCreate), T = r(!1), x = d(() => l.value ? t.createConfirm : t.updateConfirm), ee = d(() => l.value ? t.createConfirmData : t.updateConfirmData), j = d(() => l.value ? t.createResource : t.updateResource), te = d(() => l.value ? { ...t.createData, ...JSON.parse(JSON.stringify(u.value)) } : { ...t.updateData, ...JSON.parse(JSON.stringify(u.value)) }), ae = d(() => l.value ? t.createDisabled : t.updateDisabled), B = d(() => !l.value && D.value.includes("update")), R = d(() => !l.value && D.value.includes("drop")), N = async () => {
62
- n("fetchItem"), o.value = !0, i.value = -1, m.value = !1;
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 e = await ce(t.readResource, t.readData);
65
- if (n("fetchItem -> response", e), o.value = !1, i.value = e.httpStatus, !e.success) {
66
- p.value = !1, i.value = e.httpStatus, s("error", e.httpStatus);
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
- p.value = !0, u.value = e.data, D.value = e.perms, b.value.increment(u.value).turnStoredIntoOriginal(), s("read", e);
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
- o.value = !1, p.value = !1, i.value = 404, s("error", 404);
91
+ d.value = !1, m.value = !1, c.value = 404, i("error", 404);
72
92
  return;
73
93
  }
74
- }, le = d(() => o.value ? !1 : t.title || !!M["post-title"]);
75
- S(() => t.modelValue, (e) => {
76
- u.value = e, b.value.increment(e);
77
- }, { deep: !0 }), S(u, (e) => {
78
- if (T.value = !0, n("item updated ->", u.value), typeof t.beforeEmitUpdate == "function") {
79
- n("item updated -> has beforeEmitUpdate");
80
- let a = t.beforeEmitUpdate(u.value);
81
- n("item updated -> override with: ", a), typeof a == "object" && (u.value = a);
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
- s("update:modelValue", u.value), n("item updated -> update dataState"), b.value.increment(e), ve(() => T.value = !1);
84
- }, { deep: !0 }), S(D, () => s("perms", D.value));
85
- const q = d(() => ae.value || !l.value && !B.value || typeof t.saveValidator == "function" && !t.saveValidator(u.value) ? !1 : b.value.changed());
86
- S(q, (e) => s("modified-data", e)), S(l, (e) => s("update:isCreate", e)), t.readResource && !l.value ? N() : l.value && (p.value = !0, f.value = !0, o.value = !1);
87
- const ue = (e, a) => {
88
- if (o.value = !1, i.value = a.httpStatus, !a.success) {
89
- m.value = !0, s("error", a.httpStatus);
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
- m.value = !0, s("drop", a);
93
- }, oe = (e, a) => {
94
- if (n("onSave -> received response:", a), j.value) {
95
- if (o.value = !1, i.value = a.httpStatus, !a.success) {
96
- m.value = !0, s("error", a.httpStatus);
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
- m.value = !0;
121
+ h.value = !0;
100
122
  }
101
- let C = l.value ? "create" : "update";
102
- l.value || (n("onSave -> turn stored data into original"), b.value.turnStoredIntoOriginal()), C === "create" ? typeof t.onCreate == "function" && (n("onSave -> trigger onCreate callback"), t.onCreate(a)) : typeof t.onUpdate == "function" && (n("onSave -> trigger onUpdate callback"), t.onUpdate(a)), !t.insideModal && a.autoReloadId && (n("onSave -> autoReloadId detected: ", a.autoReloadId), t.readData.id = a.autoReloadId, n("onSave -> turning off create mode"), l.value = !1, N()), s(C, a);
103
- }, H = () => {
104
- o.value = !0, i.value = -1;
105
- }, P = () => {
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
- J({
134
+ f({
109
135
  doDrop: () => {
110
- _.value && typeof _.value.click == "function" && _.value.click();
136
+ U.value && typeof U.value.click == "function" && U.value.click();
111
137
  },
112
- doRefresh: N,
138
+ doRefresh: F,
113
139
  doSave: () => {
114
- g.value && typeof g.value.click == "function" && g.value.click();
140
+ B.value && typeof B.value.click == "function" && B.value.click();
115
141
  }
116
142
  });
117
- const z = d(() => !t.hiddenDrop && !o.value && f.value && p.value), A = d(() => o.value ? !1 : l.value ? !0 : !t.hiddenSave && f.value && p.value), G = d(() => !o.value && !l.value && p.value && !(t.dropDisabled && t.updateDisabled)), de = d(() => !t.hiddenButtons && (A.value || z.value || G.value));
118
- return d(() => u), (e, a) => {
119
- const C = w("lkt-button"), re = w("lkt-field-switch"), K = w("lkt-http-info"), ne = w("lkt-loader");
120
- return v(), k("article", pe, [
121
- le.value ? (v(), k("header", me, [
122
- $("h1", he, O(e.title), 1),
123
- $("div", ke, [
124
- V(e.$slots, "post-title", {
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: o.value
152
+ loading: d.value
127
153
  })
128
154
  ])
129
- ])) : y("", !0),
130
- I($("div", De, [
131
- l.value ? y("", !0) : I((v(), U(C, {
155
+ ])) : g("", !0),
156
+ I(J("div", _e, [
157
+ o.value ? g("", !0) : I((v(), N(k, {
132
158
  key: 0,
133
- ref: (h) => _.value = h,
159
+ ref: (b) => U.value = b,
134
160
  palette: "danger",
135
- disabled: e.dropDisabled || !R.value,
136
- "confirm-modal": e.dropConfirm,
137
- "confirm-data": e.dropConfirmData,
138
- resource: e.dropResource,
139
- "resource-data": e.dropData,
140
- onLoading: H,
141
- onLoaded: P,
142
- onClick: ue
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: Q(() => [
145
- W(M)["button-drop"] ? V(e.$slots, "button-drop", {
170
+ default: X(() => [
171
+ Y(T)["button-drop"] ? V(a.$slots, "button-drop", {
146
172
  key: 0,
147
173
  item: u.value,
148
- editMode: f.value,
149
- isCreate: l.value,
150
- canUpdate: B.value,
174
+ editMode: p.value,
175
+ isCreate: o.value,
176
+ canUpdate: w.value,
151
177
  canDrop: R.value
152
- }) : (v(), k("span", be, O(e.dropText), 1))
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
- [E, z.value]
182
+ [L, A.value]
157
183
  ]),
158
- I(X(C, {
159
- ref: (h) => g.value = h,
184
+ I(Z(k, {
185
+ ref: (b) => B.value = b,
160
186
  palette: "success",
161
- disabled: !q.value,
162
- "confirm-modal": x.value,
163
- "confirm-data": ee.value,
164
- resource: j.value,
165
- "resource-data": te.value,
166
- onLoading: H,
167
- onLoaded: P,
168
- onClick: oe
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: Q(() => [
171
- W(M)["button-save"] ? V(e.$slots, "button-save", {
196
+ default: X(() => [
197
+ Y(T)["button-save"] ? V(a.$slots, "button-save", {
172
198
  key: 0,
173
199
  item: u.value,
174
- editMode: f.value,
175
- isCreate: l.value,
176
- canUpdate: B.value,
200
+ editMode: p.value,
201
+ isCreate: o.value,
202
+ canUpdate: w.value,
177
203
  canDrop: R.value
178
- }) : (v(), k("span", Ce, O(e.saveText), 1))
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
- [E, A.value]
208
+ [L, G.value]
183
209
  ]),
184
- I(X(re, {
185
- modelValue: f.value,
186
- "onUpdate:modelValue": a[0] || (a[0] = (h) => f.value = h),
187
- label: e.editModeText
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
- [E, G.value]
215
+ [L, Q.value]
190
216
  ])
191
217
  ], 512), [
192
- [E, de.value]
218
+ [L, ne.value]
193
219
  ]),
194
- o.value ? y("", !0) : (v(), k("div", Se, [
195
- p.value ? (v(), k("div", ye, [
196
- m.value ? (v(), U(K, {
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: i.value,
224
+ code: c.value,
199
225
  quick: "",
200
- palette: i.value === 200 ? "success" : "danger",
226
+ palette: c.value === 200 ? "success" : "danger",
201
227
  "can-close": "",
202
- onClose: a[1] || (a[1] = (h) => m.value = !1)
203
- }, null, 8, ["code", "palette"])) : y("", !0),
204
- V(e.$slots, "item", {
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: o.value,
207
- editMode: f.value,
208
- isCreate: l.value,
209
- canUpdate: B.value,
232
+ loading: d.value,
233
+ editMode: p.value,
234
+ isCreate: o.value,
235
+ canUpdate: w.value,
210
236
  canDrop: R.value,
211
- itemBeingEdited: T.value
237
+ itemBeingEdited: $.value
212
238
  })
213
- ])) : (v(), U(K, {
239
+ ])) : (v(), N(W, {
214
240
  key: 1,
215
- code: i.value
241
+ code: c.value
216
242
  }, null, 8, ["code"]))
217
243
  ])),
218
- o.value ? (v(), U(ne, { key: 2 })) : y("", !0)
244
+ d.value ? (v(), N(se, { key: 2 })) : g("", !0)
219
245
  ]);
220
246
  };
221
247
  }
222
- }), Ue = {
223
- install: (c, J = {}) => {
224
- c.component("lkt-item-crud") === void 0 && c.component("lkt-item-crud", ge);
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
- Ie as debugLktItemCrud,
229
- Ue as default
254
+ Te as debugLktItemCrud,
255
+ $e as default
230
256
  };
@@ -0,0 +1,2 @@
1
+ import { ModalCallbackConfig } from "../types/ModalCallbackConfig";
2
+ export declare const runModalCallback: (cfg: ModalCallbackConfig) => void;
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { LktObject } from "lkt-ts-interfaces";
2
+ export type ModalCallbackConfig = {
3
+ modalName: string;
4
+ modalKey?: '_' | string | number;
5
+ action: 'refresh' | 'close' | 'reOpen' | 'exec' | 'open';
6
+ method?: string;
7
+ args?: LktObject;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "1.1.17",
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": ["dist/*", "src/**/*.vue"],
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