lkt-item-crud 2.0.4 → 2.0.5
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 +4 -4
- package/dist/build.js +216 -201
- package/dist/components/ButtonNav.vue.d.ts +1 -1
- package/package.json +4 -4
- package/src/components/ButtonNav.vue +6 -3
- package/src/lib-components/LktItemCrud.vue +24 -0
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare function et(
|
|
1
|
+
declare function et(C?: boolean): void;
|
|
2
2
|
declare namespace tt {
|
|
3
|
-
function install(
|
|
3
|
+
function install(C: any, J?: {}): void;
|
|
4
4
|
}
|
|
5
|
-
declare function ot(
|
|
6
|
-
declare function at(
|
|
5
|
+
declare function ot(C: any): void;
|
|
6
|
+
declare function at(C: any): void;
|
|
7
7
|
export { et as debugLktItemCrud, tt as default, ot as setItemCrudDefaultDropIcon, at as setItemCrudDefaultSaveIcon };
|
package/dist/build.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineComponent as me, ref as
|
|
1
|
+
import { defineComponent as me, ref as i, watch as k, useSlots as be, computed as y, resolveComponent as de, createElementBlock as U, createCommentVNode as v, openBlock as s, withDirectives as Y, createBlock as w, unref as p, renderSlot as D, vShow as Z, mergeProps as x, withCtx as V, mergeDefaults as Be, nextTick as De, onMounted as Se, resolveDynamicComponent as Ie, normalizeProps as Ue, guardReactiveProps as we, createElementVNode as Te, toDisplayString as Me, createSlots as se } from "vue";
|
|
2
2
|
import { httpCall as Re } from "lkt-http-client";
|
|
3
3
|
import { DataState as ve } from "lkt-data-state";
|
|
4
|
-
import { ensureButtonConfig as
|
|
4
|
+
import { ensureButtonConfig as E, LktSettings as n, ItemCrudMode as $, ItemCrudButtonNavVisibility as ue, TablePermission as ne, ItemCrudView as pe, ItemCrudButtonNavPosition as ce, NotificationType as N, getDefaultValues as Ee, ItemCrud as Ne, ToastPositionX as O } from "lkt-vue-kernel";
|
|
5
5
|
import { closeModal as $e } from "lkt-modal";
|
|
6
6
|
import { __ as Ve } from "lkt-i18n";
|
|
7
|
-
import { openToast as
|
|
8
|
-
const
|
|
7
|
+
import { openToast as j } from "lkt-toast";
|
|
8
|
+
const G = class G {
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
const g = (...
|
|
13
|
-
|
|
14
|
-
}, et = (
|
|
15
|
-
|
|
10
|
+
G.debugEnabled = !1, G.defaultSaveIcon = "", G.defaultDropIcon = "";
|
|
11
|
+
let q = G;
|
|
12
|
+
const g = (...C) => {
|
|
13
|
+
q.debugEnabled && console.info("[LktItemCrud] ", ...C);
|
|
14
|
+
}, et = (C = !0) => {
|
|
15
|
+
q.debugEnabled = C;
|
|
16
16
|
}, Le = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "lkt-item-crud-buttons"
|
|
@@ -22,7 +22,7 @@ const g = (...B) => {
|
|
|
22
22
|
}, Pe = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "lkt-item-crud-buttons"
|
|
25
|
-
},
|
|
25
|
+
}, Xe = {
|
|
26
26
|
key: 5,
|
|
27
27
|
class: "lkt-item-crud-buttons"
|
|
28
28
|
}, fe = /* @__PURE__ */ me({
|
|
@@ -51,144 +51,144 @@ const g = (...B) => {
|
|
|
51
51
|
"save",
|
|
52
52
|
"drop"
|
|
53
53
|
],
|
|
54
|
-
setup(
|
|
55
|
-
const o =
|
|
54
|
+
setup(C, { expose: J, emit: ee }) {
|
|
55
|
+
const o = ee, a = C, c = i(E(a.createButton, n.defaultCreateButton)), M = i(E(a.updateButton, n.defaultUpdateButton)), d = i(E(a.dropButton, n.defaultDropButton)), r = i(E(a.editModeButton, n.defaultEditModeButton));
|
|
56
56
|
k(() => a.createButton, (t) => {
|
|
57
|
-
|
|
57
|
+
c.value = E(t, n.defaultCreateButton);
|
|
58
58
|
}, { deep: !0 }), k(() => a.updateButton, (t) => {
|
|
59
|
-
|
|
59
|
+
M.value = E(t, n.defaultUpdateButton);
|
|
60
60
|
}, { deep: !0 }), k(() => a.dropButton, (t) => {
|
|
61
|
-
|
|
61
|
+
d.value = E(t, n.defaultDropButton);
|
|
62
62
|
}, { deep: !0 }), k(() => a.editModeButton, (t) => {
|
|
63
|
-
r.value =
|
|
63
|
+
r.value = E(t, n.defaultEditModeButton);
|
|
64
64
|
}, { deep: !0 });
|
|
65
|
-
const
|
|
65
|
+
const m = be(), B = i(null), S = i(null), b = i(a.loading);
|
|
66
66
|
k(() => a.loading, (t) => b.value = t), k(b, (t) => o("update:loading", t));
|
|
67
|
-
const
|
|
68
|
-
k(() => a.editing, (t) =>
|
|
67
|
+
const f = i(a.editing);
|
|
68
|
+
k(() => a.editing, (t) => f.value = t), k(f, (t) => o("update:editing", t));
|
|
69
69
|
const h = () => {
|
|
70
70
|
b.value = !0;
|
|
71
71
|
}, I = () => {
|
|
72
72
|
b.value = !1;
|
|
73
|
-
},
|
|
74
|
-
o("create", t,
|
|
75
|
-
},
|
|
76
|
-
o("save", t,
|
|
77
|
-
},
|
|
78
|
-
o("drop", t,
|
|
73
|
+
}, z = (t, l) => {
|
|
74
|
+
typeof t > "u" || o("create", t, l);
|
|
75
|
+
}, T = (t, l) => {
|
|
76
|
+
typeof t > "u" || o("save", t, l);
|
|
77
|
+
}, F = (t, l) => {
|
|
78
|
+
typeof t > "u" || o("drop", t, l);
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
J({
|
|
81
81
|
doSave: () => {
|
|
82
|
-
|
|
82
|
+
B.value && typeof B.value.click == "function" && B.value.click();
|
|
83
83
|
},
|
|
84
84
|
doDrop: () => {
|
|
85
85
|
S.value && typeof S.value.click == "function" && S.value.click();
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
const
|
|
89
|
-
var t,
|
|
90
|
-
return a.mode !==
|
|
88
|
+
const X = y(() => {
|
|
89
|
+
var t, l;
|
|
90
|
+
return a.mode !== $.Create && !a.canUpdate || !a.dataChanged ? !1 : typeof ((t = M.value) == null ? void 0 : t.disabled) == "function" ? !M.value.disabled(a.item) : typeof ((l = M.value) == null ? void 0 : l.disabled) == "boolean" ? !M.value.disabled : !0;
|
|
91
91
|
}), _ = y(() => {
|
|
92
|
-
var t,
|
|
93
|
-
return a.mode !==
|
|
94
|
-
}),
|
|
95
|
-
var t,
|
|
96
|
-
return a.canDrop ? typeof ((t =
|
|
97
|
-
}),
|
|
98
|
-
return (t,
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
|
|
92
|
+
var t, l;
|
|
93
|
+
return a.mode !== $.Create || !a.dataChanged ? !1 : typeof ((t = c.value) == null ? void 0 : t.disabled) == "function" ? !c.value.disabled(a.item) : typeof ((l = c.value) == null ? void 0 : l.disabled) == "boolean" ? !c.value.disabled : !0;
|
|
94
|
+
}), H = y(() => {
|
|
95
|
+
var t, l;
|
|
96
|
+
return a.canDrop ? typeof ((t = d.value) == null ? void 0 : t.disabled) == "function" ? !d.value.disabled(a.item) : typeof ((l = d.value) == null ? void 0 : l.disabled) == "boolean" ? !d.value.disabled : !0 : !1;
|
|
97
|
+
}), A = y(() => a.canDrop ? !a.canUpdate && a.canDrop ? !0 : !b.value && a.editing && a.httpSuccessRead : !1), P = y(() => a.dataChanged ? !0 : b.value ? !1 : a.mode === $.Create ? !0 : a.buttonNavVisibility === ue.Never ? !1 : a.editing && a.httpSuccessRead), K = y(() => !a.canSwitchEditMode || !a.canUpdate && !a.canDrop || !a.canUpdate && a.canDrop ? !1 : !b.value && a.mode !== $.Create && a.httpSuccessRead), Q = y(() => a.buttonNavVisibility === ue.Always && (X.value || _.value || H.value) || m["prev-buttons-ever"] ? !0 : a.buttonNavVisibility === ue.Never ? !1 : P.value || A.value || K.value);
|
|
98
|
+
return (t, l) => {
|
|
99
|
+
const W = de("lkt-button");
|
|
100
|
+
return Q.value ? (s(), U("div", Le, [
|
|
101
|
+
p(m)["prev-buttons-ever"] ? Y((s(), U("div", Ae, [
|
|
102
102
|
D(t.$slots, "prev-buttons-ever")
|
|
103
103
|
], 512)), [
|
|
104
|
-
[
|
|
105
|
-
]) :
|
|
106
|
-
|
|
104
|
+
[Z, !b.value]
|
|
105
|
+
]) : v("", !0),
|
|
106
|
+
p(m)["prev-buttons"] ? Y((s(), U("div", Pe, [
|
|
107
107
|
D(t.$slots, "prev-buttons")
|
|
108
108
|
], 512)), [
|
|
109
|
-
[
|
|
110
|
-
]) :
|
|
111
|
-
t.mode ===
|
|
109
|
+
[Z, f.value && !b.value]
|
|
110
|
+
]) : v("", !0),
|
|
111
|
+
t.mode === p($).Update && P.value ? (s(), w(W, x({
|
|
112
112
|
key: 2,
|
|
113
113
|
ref_key: "saveButtonRef",
|
|
114
|
-
ref:
|
|
115
|
-
},
|
|
116
|
-
disabled: !
|
|
114
|
+
ref: B
|
|
115
|
+
}, M.value, {
|
|
116
|
+
disabled: !X.value,
|
|
117
117
|
onLoading: h,
|
|
118
118
|
onLoaded: I,
|
|
119
|
-
onClick:
|
|
119
|
+
onClick: T
|
|
120
120
|
}), {
|
|
121
|
-
default:
|
|
122
|
-
|
|
121
|
+
default: V(() => [
|
|
122
|
+
p(m)["button-save"] ? D(t.$slots, "button-save", {
|
|
123
123
|
key: 0,
|
|
124
124
|
item: t.item,
|
|
125
|
-
editMode:
|
|
125
|
+
editMode: f.value,
|
|
126
126
|
isCreate: !1,
|
|
127
127
|
canUpdate: t.canUpdate,
|
|
128
128
|
canDrop: t.canDrop
|
|
129
|
-
}) :
|
|
129
|
+
}) : v("", !0)
|
|
130
130
|
]),
|
|
131
131
|
_: 3
|
|
132
|
-
}, 16, ["disabled"])) : t.mode ===
|
|
132
|
+
}, 16, ["disabled"])) : t.mode === p($).Create && P.value ? (s(), w(W, x({
|
|
133
133
|
key: 3,
|
|
134
134
|
ref_key: "saveButtonRef",
|
|
135
|
-
ref:
|
|
136
|
-
},
|
|
135
|
+
ref: B
|
|
136
|
+
}, c.value, {
|
|
137
137
|
disabled: !_.value,
|
|
138
138
|
onLoading: h,
|
|
139
139
|
onLoaded: I,
|
|
140
|
-
onClick:
|
|
140
|
+
onClick: z
|
|
141
141
|
}), {
|
|
142
|
-
default:
|
|
143
|
-
|
|
142
|
+
default: V(() => [
|
|
143
|
+
p(m)["button-save"] ? D(t.$slots, "button-save", {
|
|
144
144
|
key: 0,
|
|
145
145
|
item: t.item,
|
|
146
|
-
editMode:
|
|
146
|
+
editMode: f.value,
|
|
147
147
|
isCreate: !0,
|
|
148
148
|
canUpdate: t.canUpdate,
|
|
149
149
|
canDrop: t.canDrop
|
|
150
|
-
}) :
|
|
150
|
+
}) : v("", !0)
|
|
151
151
|
]),
|
|
152
152
|
_: 3
|
|
153
|
-
}, 16, ["disabled"])) :
|
|
154
|
-
t.mode !==
|
|
153
|
+
}, 16, ["disabled"])) : v("", !0),
|
|
154
|
+
t.mode !== p($).Create ? Y((s(), w(W, x({
|
|
155
155
|
key: 4,
|
|
156
156
|
ref_key: "dropButtonRef",
|
|
157
157
|
ref: S
|
|
158
|
-
},
|
|
159
|
-
disabled: !
|
|
158
|
+
}, d.value, {
|
|
159
|
+
disabled: !H.value,
|
|
160
160
|
onLoading: h,
|
|
161
161
|
onLoaded: I,
|
|
162
|
-
onClick:
|
|
162
|
+
onClick: F
|
|
163
163
|
}), {
|
|
164
|
-
default:
|
|
165
|
-
|
|
164
|
+
default: V(() => [
|
|
165
|
+
p(m)["button-drop"] ? D(t.$slots, "button-drop", {
|
|
166
166
|
key: 0,
|
|
167
167
|
item: t.item,
|
|
168
|
-
editMode:
|
|
168
|
+
editMode: f.value,
|
|
169
169
|
isCreate: !1,
|
|
170
170
|
canUpdate: t.canUpdate,
|
|
171
171
|
canDrop: t.canDrop
|
|
172
|
-
}) :
|
|
172
|
+
}) : v("", !0)
|
|
173
173
|
]),
|
|
174
174
|
_: 3
|
|
175
175
|
}, 16, ["disabled"])), [
|
|
176
|
-
[
|
|
177
|
-
]) :
|
|
178
|
-
|
|
176
|
+
[Z, A.value]
|
|
177
|
+
]) : v("", !0),
|
|
178
|
+
p(m).buttons ? Y((s(), U("div", Xe, [
|
|
179
179
|
D(t.$slots, "buttons")
|
|
180
180
|
], 512)), [
|
|
181
|
-
[
|
|
182
|
-
]) :
|
|
183
|
-
|
|
184
|
-
checked:
|
|
185
|
-
"onUpdate:checked":
|
|
181
|
+
[Z, f.value && !b.value]
|
|
182
|
+
]) : v("", !0),
|
|
183
|
+
K.value ? (s(), w(W, x({ key: 6 }, r.value, {
|
|
184
|
+
checked: f.value,
|
|
185
|
+
"onUpdate:checked": l[0] || (l[0] = (ie) => f.value = ie),
|
|
186
186
|
class: "lkt-item-crud--switch-mode-button"
|
|
187
|
-
}), null, 16, ["checked"])) :
|
|
188
|
-
])) :
|
|
187
|
+
}), null, 16, ["checked"])) : v("", !0)
|
|
188
|
+
])) : v("", !0);
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
}),
|
|
191
|
+
}), _e = { class: "lkt-item-crud" }, Oe = {
|
|
192
192
|
key: 0,
|
|
193
193
|
class: "lkt-item-crud_header"
|
|
194
194
|
}, je = {
|
|
@@ -208,7 +208,7 @@ const g = (...B) => {
|
|
|
208
208
|
class: "lkt-grid-1"
|
|
209
209
|
}, Ke = /* @__PURE__ */ me({
|
|
210
210
|
__name: "LktItemCrud",
|
|
211
|
-
props: /* @__PURE__ */
|
|
211
|
+
props: /* @__PURE__ */ Be({
|
|
212
212
|
modelValue: {},
|
|
213
213
|
editing: { type: Boolean },
|
|
214
214
|
mode: {},
|
|
@@ -227,7 +227,7 @@ const g = (...B) => {
|
|
|
227
227
|
title: {},
|
|
228
228
|
beforeEmitUpdate: { type: Function },
|
|
229
229
|
notificationType: {}
|
|
230
|
-
},
|
|
230
|
+
}, Ee(Ne)),
|
|
231
231
|
emits: [
|
|
232
232
|
"update:modelValue",
|
|
233
233
|
"update:editing",
|
|
@@ -240,93 +240,108 @@ const g = (...B) => {
|
|
|
240
240
|
"error",
|
|
241
241
|
"modified-data"
|
|
242
242
|
],
|
|
243
|
-
setup(
|
|
244
|
-
const o =
|
|
245
|
-
let
|
|
246
|
-
const
|
|
247
|
-
g("fetchItem"),
|
|
243
|
+
setup(C, { expose: J, emit: ee }) {
|
|
244
|
+
const o = C, a = be(), c = ee;
|
|
245
|
+
let M = [];
|
|
246
|
+
const d = i(!0), r = i(o.modelValue), m = i(M), B = i(o.editing), S = i(!1), b = i(!1), f = i(200), h = i(new ve(r.value, o.dataStateConfig)), I = i(!1), z = i(new ve(o.readData)), T = i(o.mode === $.Create), F = i(!1), te = i(!1), L = i(null), X = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.Update)), _ = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.Drop)), H = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.SwitchEditMode)), A = async () => {
|
|
247
|
+
g("fetchItem"), d.value = !0, f.value = -1, b.value = !1;
|
|
248
248
|
try {
|
|
249
249
|
const e = await Re(o.readResource, o.readData);
|
|
250
|
-
if (g("fetchItem -> response", e),
|
|
251
|
-
S.value = !1,
|
|
250
|
+
if (g("fetchItem -> response", e), d.value = !1, f.value = e.httpStatus, !e.success) {
|
|
251
|
+
S.value = !1, f.value = e.httpStatus, c("error", e.httpStatus);
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
|
-
S.value = !0, r.value = e.data,
|
|
254
|
+
S.value = !0, r.value = e.data, m.value = e.perms, h.value.increment(r.value).turnStoredIntoOriginal(), I.value = h.value.changed(), z.value.turnStoredIntoOriginal(), c("read", e);
|
|
255
255
|
} catch {
|
|
256
|
-
|
|
256
|
+
d.value = !1, S.value = !1, f.value = 404, c("error", 404);
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
k(() => o.modelValue, (e) => {
|
|
261
261
|
r.value = e, h.value.increment(e);
|
|
262
262
|
}, { deep: !0 }), k(r, (e) => {
|
|
263
|
-
if (
|
|
263
|
+
if (F.value = !0, g("item updated ->", r.value), typeof o.beforeEmitUpdate == "function") {
|
|
264
264
|
g("item updated -> has beforeEmitUpdate");
|
|
265
265
|
let u = o.beforeEmitUpdate(r.value);
|
|
266
266
|
g("item updated -> override with: ", u), typeof u == "object" && (r.value = u);
|
|
267
267
|
}
|
|
268
|
-
|
|
269
|
-
}, { deep: !0 }), k(
|
|
270
|
-
|
|
268
|
+
c("update:modelValue", r.value), g("item updated -> update dataState"), h.value.increment(e), I.value = h.value.changed(), De(() => F.value = !1);
|
|
269
|
+
}, { deep: !0 }), k(m, () => c("perms", m.value)), k(I, (e) => {
|
|
270
|
+
c("modified-data", e);
|
|
271
271
|
}), k(() => o.readData, (e) => {
|
|
272
|
-
|
|
272
|
+
z.value.increment(e), z.value.changed() && A();
|
|
273
273
|
}), k(() => o.editing, (e) => {
|
|
274
|
-
g("editing updated -> updating editMode", e),
|
|
275
|
-
}), k(
|
|
276
|
-
g("editMode updated -> emit update", e),
|
|
274
|
+
g("editing updated -> updating editMode", e), B.value = e;
|
|
275
|
+
}), k(B, (e) => {
|
|
276
|
+
g("editMode updated -> emit update", e), c("update:editing", e);
|
|
277
277
|
}), Se(() => {
|
|
278
|
-
o.readResource && !
|
|
278
|
+
o.readResource && !T.value ? A() : T.value && (S.value = !0, B.value = !0, d.value = !1, h.value.increment(r.value).turnStoredIntoOriginal(), I.value = h.value.changed());
|
|
279
279
|
});
|
|
280
|
-
const
|
|
280
|
+
const P = (e, u) => {
|
|
281
281
|
if (u) {
|
|
282
|
-
if (
|
|
283
|
-
return b.value = !0,
|
|
282
|
+
if (d.value = !1, typeof e < "u" && (f.value = e.httpStatus, !e.success))
|
|
283
|
+
return b.value = !0, c("error", e.httpStatus), !1;
|
|
284
284
|
b.value = !0;
|
|
285
285
|
}
|
|
286
286
|
return !0;
|
|
287
|
-
},
|
|
288
|
-
!
|
|
289
|
-
},
|
|
290
|
-
if (g("onCreate"), !
|
|
291
|
-
o.notificationType ===
|
|
292
|
-
text:
|
|
293
|
-
details:
|
|
294
|
-
icon:
|
|
295
|
-
positionX:
|
|
287
|
+
}, K = (e) => {
|
|
288
|
+
!oe.value && e.autoReloadId && (g("doAutoReloadId -> autoReloadId detected: ", e.autoReloadId), o.readData.id = e.autoReloadId, g("doAutoReloadId -> turning off create mode"), T.value = !1, A());
|
|
289
|
+
}, Q = (e, u) => {
|
|
290
|
+
if (g("onCreate"), !P(u, o.createButton.resource)) {
|
|
291
|
+
o.notificationType === N.Toast && j({
|
|
292
|
+
text: n.defaultCreateErrorText,
|
|
293
|
+
details: n.defaultCreateErrorDetails,
|
|
294
|
+
icon: n.defaultCreateErrorIcon,
|
|
295
|
+
positionX: O.Right
|
|
296
296
|
});
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
te.value = !0, g("onCreate -> turn stored data into original"), h.value.increment(r.value).turnStoredIntoOriginal(), o.notificationType === N.Toast && j({
|
|
300
|
+
text: n.defaultCreateSuccessText,
|
|
301
|
+
details: n.defaultCreateSuccessDetails,
|
|
302
|
+
icon: n.defaultCreateSuccessIcon,
|
|
303
|
+
positionX: O.Right
|
|
304
|
+
}), K(u), c("create", u);
|
|
300
305
|
}, t = (e, u) => {
|
|
301
|
-
if (g("onUpdate"), !
|
|
302
|
-
o.notificationType ===
|
|
303
|
-
text:
|
|
304
|
-
details:
|
|
305
|
-
icon:
|
|
306
|
-
positionX:
|
|
306
|
+
if (g("onUpdate"), !P(u, o.updateButton.resource)) {
|
|
307
|
+
o.notificationType === N.Toast && j({
|
|
308
|
+
text: n.defaultUpdateErrorText,
|
|
309
|
+
details: n.defaultUpdateErrorDetails,
|
|
310
|
+
icon: n.defaultUpdateErrorIcon,
|
|
311
|
+
positionX: O.Right
|
|
307
312
|
});
|
|
308
313
|
return;
|
|
309
314
|
}
|
|
310
|
-
g("onUpdate -> turn stored data into original"), h.value.turnStoredIntoOriginal(),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
g("onUpdate -> turn stored data into original"), h.value.turnStoredIntoOriginal(), o.notificationType === N.Toast && j({
|
|
316
|
+
text: n.defaultUpdateSuccessText,
|
|
317
|
+
details: n.defaultUpdateSuccessDetails,
|
|
318
|
+
icon: n.defaultUpdateSuccessIcon,
|
|
319
|
+
positionX: O.Right
|
|
320
|
+
}), K(u), c("update", u);
|
|
321
|
+
}, l = (e, u) => {
|
|
322
|
+
if (g("onDrop"), !P(u, o.dropButton.resource)) {
|
|
323
|
+
o.notificationType === N.Toast && j({
|
|
324
|
+
text: n.defaultDropErrorText,
|
|
325
|
+
details: n.defaultDropErrorDetails,
|
|
326
|
+
icon: n.defaultDropErrorIcon,
|
|
327
|
+
positionX: O.Right
|
|
318
328
|
});
|
|
319
329
|
return;
|
|
320
330
|
}
|
|
321
|
-
|
|
331
|
+
o.notificationType === N.Toast && j({
|
|
332
|
+
text: n.defaultDropSuccessText,
|
|
333
|
+
details: n.defaultDropSuccessDetails,
|
|
334
|
+
icon: n.defaultDropSuccessIcon,
|
|
335
|
+
positionX: O.Right
|
|
336
|
+
}), c("drop", u), o.view === pe.Modal && (g("onDrop -> close modal"), $e(o.modalConfig.modalName, o.modalConfig.modalKey));
|
|
322
337
|
};
|
|
323
|
-
|
|
338
|
+
J({
|
|
324
339
|
doDrop: () => {
|
|
325
|
-
|
|
340
|
+
L.value && L.value.doDrop();
|
|
326
341
|
},
|
|
327
|
-
doRefresh:
|
|
342
|
+
doRefresh: A,
|
|
328
343
|
doSave: () => {
|
|
329
|
-
|
|
344
|
+
L.value && L.value.doSave();
|
|
330
345
|
},
|
|
331
346
|
hasModifiedData: () => h.value.changed()
|
|
332
347
|
});
|
|
@@ -338,9 +353,9 @@ const g = (...B) => {
|
|
|
338
353
|
if (typeof ((u = o.modalConfig) == null ? void 0 : u.beforeClose) == "function")
|
|
339
354
|
return o.modalConfig.beforeClose({
|
|
340
355
|
...e,
|
|
341
|
-
itemCreated:
|
|
356
|
+
itemCreated: te.value
|
|
342
357
|
});
|
|
343
|
-
},
|
|
358
|
+
}, ae = y(() => o.title.startsWith("__:") ? String(Ve(o.title.substring(3))) : o.title), he = y(() => d.value ? !1 : ae.value.length > 0 || !!a["post-title"]), oe = y(() => o.view === pe.Modal), re = y(() => oe.value ? "lkt-modal" : "section"), ke = y(() => re.value === "lkt-modal" ? {
|
|
344
359
|
title: o.title,
|
|
345
360
|
item: r.value,
|
|
346
361
|
...o.modalConfig,
|
|
@@ -348,33 +363,33 @@ const g = (...B) => {
|
|
|
348
363
|
"close-confirm": ge.value
|
|
349
364
|
} : {});
|
|
350
365
|
return (e, u) => {
|
|
351
|
-
const le = de("lkt-http-info"),
|
|
352
|
-
return
|
|
353
|
-
default:
|
|
354
|
-
|
|
355
|
-
!
|
|
356
|
-
|
|
366
|
+
const le = de("lkt-http-info"), Ce = de("lkt-loader");
|
|
367
|
+
return s(), w(Ie(re.value), Ue(we(ke.value)), {
|
|
368
|
+
default: V(() => [
|
|
369
|
+
Te("article", _e, [
|
|
370
|
+
!oe.value && he.value ? (s(), U("header", Oe, [
|
|
371
|
+
p(a)["pre-title"] ? (s(), U("div", je, [
|
|
357
372
|
D(e.$slots, "pre-title", {
|
|
358
373
|
item: r.value,
|
|
359
|
-
loading:
|
|
374
|
+
loading: d.value
|
|
360
375
|
})
|
|
361
|
-
])) :
|
|
362
|
-
|
|
363
|
-
|
|
376
|
+
])) : v("", !0),
|
|
377
|
+
ae.value.length > 0 ? (s(), U("h1", qe, Me(ae.value), 1)) : v("", !0),
|
|
378
|
+
p(a)["post-title"] ? (s(), U("div", ze, [
|
|
364
379
|
D(e.$slots, "post-title", {
|
|
365
380
|
item: r.value,
|
|
366
|
-
loading:
|
|
381
|
+
loading: d.value
|
|
367
382
|
})
|
|
368
|
-
])) :
|
|
369
|
-
])) :
|
|
370
|
-
e.buttonNavPosition ===
|
|
383
|
+
])) : v("", !0)
|
|
384
|
+
])) : v("", !0),
|
|
385
|
+
e.buttonNavPosition === p(ce).Top ? (s(), w(fe, {
|
|
371
386
|
key: 1,
|
|
372
387
|
ref_key: "buttonNav",
|
|
373
|
-
ref:
|
|
374
|
-
loading:
|
|
375
|
-
"onUpdate:loading": u[0] || (u[0] = (R) =>
|
|
376
|
-
editing:
|
|
377
|
-
"onUpdate:editing": u[1] || (u[1] = (R) =>
|
|
388
|
+
ref: L,
|
|
389
|
+
loading: d.value,
|
|
390
|
+
"onUpdate:loading": u[0] || (u[0] = (R) => d.value = R),
|
|
391
|
+
editing: B.value,
|
|
392
|
+
"onUpdate:editing": u[1] || (u[1] = (R) => B.value = R),
|
|
378
393
|
item: r.value,
|
|
379
394
|
mode: e.mode,
|
|
380
395
|
view: e.view,
|
|
@@ -385,61 +400,61 @@ const g = (...B) => {
|
|
|
385
400
|
"edit-mode-button": e.editModeButton,
|
|
386
401
|
"data-changed": I.value,
|
|
387
402
|
"http-success-read": S.value,
|
|
388
|
-
"can-update":
|
|
403
|
+
"can-update": X.value,
|
|
389
404
|
"can-drop": _.value,
|
|
390
|
-
"can-switch-edit-mode":
|
|
391
|
-
onCreate:
|
|
405
|
+
"can-switch-edit-mode": H.value,
|
|
406
|
+
onCreate: Q,
|
|
392
407
|
onSave: t,
|
|
393
|
-
onDrop:
|
|
408
|
+
onDrop: l
|
|
394
409
|
}, se({ _: 2 }, [
|
|
395
|
-
|
|
410
|
+
p(a)["prev-buttons-ever"] ? {
|
|
396
411
|
name: "prev-buttons-ever",
|
|
397
|
-
fn:
|
|
412
|
+
fn: V(() => [
|
|
398
413
|
D(e.$slots, "prev-buttons-ever")
|
|
399
414
|
]),
|
|
400
415
|
key: "0"
|
|
401
416
|
} : void 0,
|
|
402
|
-
|
|
417
|
+
p(a)["prev-buttons"] ? {
|
|
403
418
|
name: "prev-buttons-ever",
|
|
404
|
-
fn:
|
|
419
|
+
fn: V(() => [
|
|
405
420
|
D(e.$slots, "prev-buttons")
|
|
406
421
|
]),
|
|
407
422
|
key: "1"
|
|
408
423
|
} : void 0
|
|
409
|
-
]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) :
|
|
410
|
-
|
|
411
|
-
S.value ? (
|
|
412
|
-
b.value && e.notificationType ===
|
|
424
|
+
]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) : v("", !0),
|
|
425
|
+
d.value ? v("", !0) : (s(), U("div", Fe, [
|
|
426
|
+
S.value ? (s(), U("div", He, [
|
|
427
|
+
b.value && e.notificationType === p(N).Inline ? (s(), w(le, {
|
|
413
428
|
key: 0,
|
|
414
|
-
code:
|
|
415
|
-
palette:
|
|
429
|
+
code: f.value,
|
|
430
|
+
palette: f.value === 200 ? "success" : "danger",
|
|
416
431
|
quick: "",
|
|
417
432
|
"can-close": "",
|
|
418
433
|
onClose: u[2] || (u[2] = (R) => b.value = !1)
|
|
419
|
-
}, null, 8, ["code", "palette"])) :
|
|
434
|
+
}, null, 8, ["code", "palette"])) : v("", !0),
|
|
420
435
|
D(e.$slots, "item", {
|
|
421
436
|
item: r.value,
|
|
422
|
-
loading:
|
|
423
|
-
editMode:
|
|
424
|
-
isCreate:
|
|
425
|
-
canUpdate:
|
|
437
|
+
loading: d.value,
|
|
438
|
+
editMode: B.value,
|
|
439
|
+
isCreate: T.value,
|
|
440
|
+
canUpdate: X.value,
|
|
426
441
|
canDrop: _.value,
|
|
427
|
-
itemBeingEdited:
|
|
442
|
+
itemBeingEdited: F.value
|
|
428
443
|
})
|
|
429
|
-
])) : e.notificationType ===
|
|
444
|
+
])) : e.notificationType === p(N).Inline ? (s(), w(le, {
|
|
430
445
|
key: 1,
|
|
431
|
-
code:
|
|
432
|
-
}, null, 8, ["code"])) :
|
|
446
|
+
code: f.value
|
|
447
|
+
}, null, 8, ["code"])) : v("", !0)
|
|
433
448
|
])),
|
|
434
|
-
|
|
435
|
-
e.buttonNavPosition ===
|
|
449
|
+
d.value ? (s(), w(Ce, { key: 3 })) : v("", !0),
|
|
450
|
+
e.buttonNavPosition === p(ce).Bottom ? (s(), w(fe, {
|
|
436
451
|
key: 4,
|
|
437
452
|
ref_key: "buttonNav",
|
|
438
|
-
ref:
|
|
439
|
-
loading:
|
|
440
|
-
"onUpdate:loading": u[3] || (u[3] = (R) =>
|
|
441
|
-
editing:
|
|
442
|
-
"onUpdate:editing": u[4] || (u[4] = (R) =>
|
|
453
|
+
ref: L,
|
|
454
|
+
loading: d.value,
|
|
455
|
+
"onUpdate:loading": u[3] || (u[3] = (R) => d.value = R),
|
|
456
|
+
editing: B.value,
|
|
457
|
+
"onUpdate:editing": u[4] || (u[4] = (R) => B.value = R),
|
|
443
458
|
item: r.value,
|
|
444
459
|
mode: e.mode,
|
|
445
460
|
view: e.view,
|
|
@@ -450,28 +465,28 @@ const g = (...B) => {
|
|
|
450
465
|
"edit-mode-button": e.editModeButton,
|
|
451
466
|
"data-changed": I.value,
|
|
452
467
|
"http-success-read": S.value,
|
|
453
|
-
"can-update":
|
|
468
|
+
"can-update": X.value,
|
|
454
469
|
"can-drop": _.value,
|
|
455
|
-
"can-switch-edit-mode":
|
|
456
|
-
onCreate:
|
|
470
|
+
"can-switch-edit-mode": H.value,
|
|
471
|
+
onCreate: Q,
|
|
457
472
|
onSave: t,
|
|
458
|
-
onDrop:
|
|
473
|
+
onDrop: l
|
|
459
474
|
}, se({ _: 2 }, [
|
|
460
|
-
|
|
475
|
+
p(a)["prev-buttons-ever"] ? {
|
|
461
476
|
name: "prev-buttons-ever",
|
|
462
|
-
fn:
|
|
477
|
+
fn: V(() => [
|
|
463
478
|
D(e.$slots, "prev-buttons-ever")
|
|
464
479
|
]),
|
|
465
480
|
key: "0"
|
|
466
481
|
} : void 0,
|
|
467
|
-
|
|
482
|
+
p(a)["prev-buttons"] ? {
|
|
468
483
|
name: "prev-buttons-ever",
|
|
469
|
-
fn:
|
|
484
|
+
fn: V(() => [
|
|
470
485
|
D(e.$slots, "prev-buttons")
|
|
471
486
|
]),
|
|
472
487
|
key: "1"
|
|
473
488
|
} : void 0
|
|
474
|
-
]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) :
|
|
489
|
+
]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) : v("", !0)
|
|
475
490
|
])
|
|
476
491
|
]),
|
|
477
492
|
_: 3
|
|
@@ -479,13 +494,13 @@ const g = (...B) => {
|
|
|
479
494
|
};
|
|
480
495
|
}
|
|
481
496
|
}), tt = {
|
|
482
|
-
install: (
|
|
483
|
-
|
|
497
|
+
install: (C, J = {}) => {
|
|
498
|
+
C.component("lkt-item-crud") === void 0 && C.component("lkt-item-crud", Ke);
|
|
484
499
|
}
|
|
485
|
-
}, at = (
|
|
486
|
-
|
|
487
|
-
}, ot = (
|
|
488
|
-
|
|
500
|
+
}, at = (C) => {
|
|
501
|
+
q.defaultSaveIcon = C;
|
|
502
|
+
}, ot = (C) => {
|
|
503
|
+
q.defaultDropIcon = C;
|
|
489
504
|
};
|
|
490
505
|
export {
|
|
491
506
|
et as debugLktItemCrud,
|
|
@@ -1536,7 +1536,7 @@ declare const saveButtonRef: import("vue").Ref<HTMLButtonElement | null, HTMLBut
|
|
|
1536
1536
|
declare const dropButtonRef: import("vue").Ref<HTMLButtonElement | null, HTMLButtonElement | null>;
|
|
1537
1537
|
declare const isLoading: import("vue").Ref<boolean, boolean>;
|
|
1538
1538
|
declare const isEditing: import("vue").Ref<boolean, boolean>;
|
|
1539
|
-
declare const onButtonLoading: () => void, onButtonLoaded: () => void, onCreate: ($event: Event, r: HTTPResponse) => void, onSave: ($event: Event, r: HTTPResponse) => void, onDrop: ($event: Event, r: HTTPResponse) => void;
|
|
1539
|
+
declare const onButtonLoading: () => void, onButtonLoaded: () => void, onCreate: ($event: Event | undefined, r: HTTPResponse) => void, onSave: ($event: Event | undefined, r: HTTPResponse) => void, onDrop: ($event: Event | undefined, r: HTTPResponse) => void;
|
|
1540
1540
|
declare const ableToUpdate: import("vue").ComputedRef<boolean>, ableToCreate: import("vue").ComputedRef<boolean>, ableToDrop: import("vue").ComputedRef<boolean>, showDropButton: import("vue").ComputedRef<boolean>, showSaveButton: import("vue").ComputedRef<boolean>, showSwitchButton: import("vue").ComputedRef<boolean>, showButtons: import("vue").ComputedRef<boolean>;
|
|
1541
1541
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
1542
1542
|
declare var __VLS_1: {}, __VLS_3: {}, __VLS_17: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-item-crud",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/build.js",
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"vue-tsc": "^2.2.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
40
42
|
"lkt-button": "^2.0.4",
|
|
41
43
|
"lkt-data-state": "^1.0.9",
|
|
42
44
|
"lkt-http-client": "^1.0.12",
|
|
@@ -46,9 +48,7 @@
|
|
|
46
48
|
"lkt-modal": "^2.0.2",
|
|
47
49
|
"lkt-string-tools": "^1.0.2",
|
|
48
50
|
"lkt-toast": "^1.0.1",
|
|
49
|
-
"lkt-vue-kernel": "^1.0.27"
|
|
50
|
-
},
|
|
51
|
-
"peerDependencies": {
|
|
51
|
+
"lkt-vue-kernel": "^1.0.27",
|
|
52
52
|
"vue": "^3.3.0"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -87,13 +87,16 @@
|
|
|
87
87
|
onButtonLoaded = () => {
|
|
88
88
|
isLoading.value = false;
|
|
89
89
|
},
|
|
90
|
-
onCreate = ($event: Event, r: HTTPResponse) => {
|
|
90
|
+
onCreate = ($event: Event|undefined, r: HTTPResponse) => {
|
|
91
|
+
if (typeof $event === 'undefined') return;
|
|
91
92
|
emit('create', $event, r);
|
|
92
93
|
},
|
|
93
|
-
onSave = ($event: Event, r: HTTPResponse) => {
|
|
94
|
+
onSave = ($event: Event|undefined, r: HTTPResponse) => {
|
|
95
|
+
if (typeof $event === 'undefined') return;
|
|
94
96
|
emit('save', $event, r);
|
|
95
97
|
},
|
|
96
|
-
onDrop = ($event: Event, r: HTTPResponse) => {
|
|
98
|
+
onDrop = ($event: Event|undefined, r: HTTPResponse) => {
|
|
99
|
+
if (typeof $event === 'undefined') return;
|
|
97
100
|
emit('drop', $event, r);
|
|
98
101
|
};
|
|
99
102
|
|
|
@@ -187,6 +187,14 @@
|
|
|
187
187
|
itemCreated.value = true;
|
|
188
188
|
debug('onCreate -> turn stored data into original');
|
|
189
189
|
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
190
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
191
|
+
openToast(<ToastConfig>{
|
|
192
|
+
text: LktSettings.defaultCreateSuccessText,
|
|
193
|
+
details: LktSettings.defaultCreateSuccessDetails,
|
|
194
|
+
icon: LktSettings.defaultCreateSuccessIcon,
|
|
195
|
+
positionX: ToastPositionX.Right,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
190
198
|
doAutoReloadId(r);
|
|
191
199
|
emit('create', r);
|
|
192
200
|
},
|
|
@@ -205,6 +213,14 @@
|
|
|
205
213
|
}
|
|
206
214
|
debug('onUpdate -> turn stored data into original');
|
|
207
215
|
dataState.value.turnStoredIntoOriginal();
|
|
216
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
217
|
+
openToast(<ToastConfig>{
|
|
218
|
+
text: LktSettings.defaultUpdateSuccessText,
|
|
219
|
+
details: LktSettings.defaultUpdateSuccessDetails,
|
|
220
|
+
icon: LktSettings.defaultUpdateSuccessIcon,
|
|
221
|
+
positionX: ToastPositionX.Right,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
208
224
|
doAutoReloadId(r);
|
|
209
225
|
emit('update', r);
|
|
210
226
|
},
|
|
@@ -221,6 +237,14 @@
|
|
|
221
237
|
}
|
|
222
238
|
return;
|
|
223
239
|
}
|
|
240
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
241
|
+
openToast(<ToastConfig>{
|
|
242
|
+
text: LktSettings.defaultDropSuccessText,
|
|
243
|
+
details: LktSettings.defaultDropSuccessDetails,
|
|
244
|
+
icon: LktSettings.defaultDropSuccessIcon,
|
|
245
|
+
positionX: ToastPositionX.Right,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
224
248
|
emit('drop', r);
|
|
225
249
|
if (props.view === ItemCrudView.Modal) {
|
|
226
250
|
debug('onDrop -> close modal');
|