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 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 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
- 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
+ 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
- }, 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" }, _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
- }, 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,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(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;
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 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);
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
- p.value = !0, u.value = e.data, D.value = e.perms, b.value.increment(u.value).turnStoredIntoOriginal(), s("read", e);
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
- o.value = !1, p.value = !1, i.value = 404, s("error", 404);
90
+ d.value = !1, m.value = !1, c.value = 404, i("error", 404);
72
91
  return;
73
92
  }
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);
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
- 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);
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
- 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);
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
- m.value = !0;
118
+ h.value = !0;
100
119
  }
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;
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
- o.value = !1;
127
+ d.value = !0, c.value = -1;
128
+ }, x = () => {
129
+ d.value = !1;
107
130
  };
108
- J({
131
+ f({
109
132
  doDrop: () => {
110
- _.value && typeof _.value.click == "function" && _.value.click();
133
+ U.value && typeof U.value.click == "function" && U.value.click();
111
134
  },
112
- doRefresh: N,
135
+ doRefresh: F,
113
136
  doSave: () => {
114
- g.value && typeof g.value.click == "function" && g.value.click();
137
+ B.value && typeof B.value.click == "function" && B.value.click();
115
138
  }
116
139
  });
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", {
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: o.value
149
+ loading: d.value
127
150
  })
128
151
  ])
129
- ])) : y("", !0),
130
- I($("div", De, [
131
- l.value ? y("", !0) : I((v(), U(C, {
152
+ ])) : g("", !0),
153
+ I(J("div", Me, [
154
+ o.value ? g("", !0) : I((v(), N(y, {
132
155
  key: 0,
133
- ref: (h) => _.value = h,
156
+ ref: (C) => U.value = C,
134
157
  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
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: Q(() => [
145
- W(M)["button-drop"] ? V(e.$slots, "button-drop", {
167
+ default: W(() => [
168
+ X(T)["button-drop"] ? V(a.$slots, "button-drop", {
146
169
  key: 0,
147
170
  item: u.value,
148
- editMode: f.value,
149
- isCreate: l.value,
150
- canUpdate: B.value,
171
+ editMode: p.value,
172
+ isCreate: o.value,
173
+ canUpdate: w.value,
151
174
  canDrop: R.value
152
- }) : (v(), k("span", be, O(e.dropText), 1))
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
- [E, z.value]
179
+ [L, z.value]
157
180
  ]),
158
- I(X(C, {
159
- ref: (h) => g.value = h,
181
+ I(Y(y, {
182
+ ref: (C) => B.value = C,
160
183
  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
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: Q(() => [
171
- W(M)["button-save"] ? V(e.$slots, "button-save", {
193
+ default: W(() => [
194
+ X(T)["button-save"] ? V(a.$slots, "button-save", {
172
195
  key: 0,
173
196
  item: u.value,
174
- editMode: f.value,
175
- isCreate: l.value,
176
- canUpdate: B.value,
197
+ editMode: p.value,
198
+ isCreate: o.value,
199
+ canUpdate: w.value,
177
200
  canDrop: R.value
178
- }) : (v(), k("span", Ce, O(e.saveText), 1))
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
- [E, A.value]
205
+ [L, A.value]
183
206
  ]),
184
- I(X(re, {
185
- modelValue: f.value,
186
- "onUpdate:modelValue": a[0] || (a[0] = (h) => f.value = h),
187
- label: e.editModeText
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
- [E, G.value]
212
+ [L, G.value]
190
213
  ])
191
214
  ], 512), [
192
- [E, de.value]
215
+ [L, ne.value]
193
216
  ]),
194
- o.value ? y("", !0) : (v(), k("div", Se, [
195
- p.value ? (v(), k("div", ye, [
196
- m.value ? (v(), U(K, {
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: i.value,
221
+ code: c.value,
199
222
  quick: "",
200
- palette: i.value === 200 ? "success" : "danger",
223
+ palette: c.value === 200 ? "success" : "danger",
201
224
  "can-close": "",
202
- onClose: a[1] || (a[1] = (h) => m.value = !1)
203
- }, null, 8, ["code", "palette"])) : y("", !0),
204
- V(e.$slots, "item", {
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: o.value,
207
- editMode: f.value,
208
- isCreate: l.value,
209
- canUpdate: B.value,
229
+ loading: d.value,
230
+ editMode: p.value,
231
+ isCreate: o.value,
232
+ canUpdate: w.value,
210
233
  canDrop: R.value,
211
- itemBeingEdited: T.value
234
+ itemBeingEdited: $.value
212
235
  })
213
- ])) : (v(), U(K, {
236
+ ])) : (v(), N(Q, {
214
237
  key: 1,
215
- code: i.value
238
+ code: c.value
216
239
  }, null, 8, ["code"]))
217
240
  ])),
218
- o.value ? (v(), U(ne, { key: 2 })) : y("", !0)
241
+ d.value ? (v(), N(se, { key: 2 })) : g("", !0)
219
242
  ]);
220
243
  };
221
244
  }
222
- }), Ue = {
223
- install: (c, J = {}) => {
224
- c.component("lkt-item-crud") === void 0 && c.component("lkt-item-crud", ge);
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
- Ie as debugLktItemCrud,
229
- Ue as default
251
+ Te as debugLktItemCrud,
252
+ $e as default
230
253
  };
@@ -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,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;
@@ -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.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": ["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,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