lkt-item-crud 1.2.4 → 1.2.6
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 +5 -5
- package/dist/build.js +232 -223
- package/package.json +1 -1
- package/src/components/ButtonNav.vue +11 -10
- package/src/lib-components/LktItemCrud.vue +35 -15
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
declare namespace
|
|
1
|
+
declare function _e(o?: boolean): void;
|
|
2
|
+
declare namespace xe {
|
|
3
3
|
function install(o: any, g?: {}): void;
|
|
4
4
|
}
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
export {
|
|
5
|
+
declare function tt(o: any): void;
|
|
6
|
+
declare function et(o: any): void;
|
|
7
|
+
export { _e as debugLktItemCrud, xe as default, tt as setItemCrudDefaultDropIcon, et as setItemCrudDefaultSaveIcon };
|
package/dist/build.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { httpCall as
|
|
3
|
-
import { DataState as
|
|
4
|
-
import { execModal as
|
|
5
|
-
import { __ as
|
|
1
|
+
import { defineComponent as pe, useSlots as ce, ref as s, watch as C, resolveComponent as Z, openBlock as i, createElementBlock as w, unref as m, withDirectives as z, renderSlot as y, vShow as K, createCommentVNode as c, createBlock as M, withCtx as E, computed as v, nextTick as ye, onMounted as ke, resolveDynamicComponent as De, normalizeProps as ge, guardReactiveProps as Se, createElementVNode as we, toDisplayString as Be, createSlots as se } from "vue";
|
|
2
|
+
import { httpCall as Me } from "lkt-http-client";
|
|
3
|
+
import { DataState as ie } from "lkt-data-state";
|
|
4
|
+
import { execModal as Ie, refreshModal as Te, closeModal as Ue, openModal as Re, reOpenModal as Ne } from "lkt-modal";
|
|
5
|
+
import { __ as $e } from "lkt-i18n";
|
|
6
6
|
const F = class F {
|
|
7
7
|
};
|
|
8
8
|
F.debugEnabled = !1, F.defaultSaveIcon = "", F.defaultDropIcon = "";
|
|
9
|
-
let
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
9
|
+
let U = F;
|
|
10
|
+
const p = (...o) => {
|
|
11
|
+
U.debugEnabled && console.info("[LktItemCrud] ", ...o);
|
|
12
|
+
}, _e = (o = !0) => {
|
|
13
|
+
U.debugEnabled = o;
|
|
14
14
|
}, Y = (o) => {
|
|
15
|
-
|
|
16
|
-
let g = o.modalKey ? o.modalKey : "_",
|
|
15
|
+
p("runModalCallback -> init", o);
|
|
16
|
+
let g = o.modalKey ? o.modalKey : "_", I = o.args ? o.args : {};
|
|
17
17
|
switch (o.action) {
|
|
18
18
|
case "reOpen":
|
|
19
|
-
return
|
|
19
|
+
return Ne(o.modalName, g, I);
|
|
20
20
|
case "open":
|
|
21
|
-
return
|
|
21
|
+
return Re(o.modalName, g, I);
|
|
22
22
|
case "close":
|
|
23
|
-
return
|
|
23
|
+
return Ue(o.modalName, g);
|
|
24
24
|
case "refresh":
|
|
25
|
-
return
|
|
25
|
+
return Te(o.modalName, g, I);
|
|
26
26
|
case "exec":
|
|
27
27
|
let e = o.method;
|
|
28
|
-
return e ?
|
|
28
|
+
return e ? Ie(o.modalName, g, e, I) : void 0;
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, Ee = { class: "lkt-item-crud-buttons" }, Ve = {
|
|
31
31
|
key: 0,
|
|
32
32
|
class: "lkt-item-crud-buttons"
|
|
33
|
-
},
|
|
33
|
+
}, Le = {
|
|
34
34
|
key: 1,
|
|
35
35
|
class: "lkt-item-crud-buttons"
|
|
36
|
-
},
|
|
36
|
+
}, Oe = {
|
|
37
37
|
key: 4,
|
|
38
38
|
class: "lkt-item-crud-buttons"
|
|
39
|
-
},
|
|
39
|
+
}, ve = /* @__PURE__ */ pe({
|
|
40
40
|
__name: "ButtonNav",
|
|
41
41
|
props: {
|
|
42
42
|
item: { default: () => ({}) },
|
|
@@ -65,144 +65,144 @@ const v = (...o) => {
|
|
|
65
65
|
editModeText: {}
|
|
66
66
|
},
|
|
67
67
|
emits: ["update:loading", "update:editing", "save", "drop"],
|
|
68
|
-
setup(o, { expose: g, emit:
|
|
69
|
-
const e =
|
|
70
|
-
|
|
71
|
-
const f =
|
|
72
|
-
|
|
68
|
+
setup(o, { expose: g, emit: I }) {
|
|
69
|
+
const e = I, b = o, u = ce(), V = s(null), d = s(null), r = s(b.loading);
|
|
70
|
+
C(() => b.loading, (a) => r.value = a), C(r, (a) => e("update:loading", a));
|
|
71
|
+
const f = s(b.editing);
|
|
72
|
+
C(() => b.editing, (a) => f.value = a), C(f, (a) => e("update:editing", a));
|
|
73
73
|
const h = () => {
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
e("save");
|
|
79
|
-
}, D = () => {
|
|
80
|
-
e("drop");
|
|
74
|
+
r.value = !0;
|
|
75
|
+
}, k = () => {
|
|
76
|
+
r.value = !1;
|
|
77
|
+
}, B = (a, S) => {
|
|
78
|
+
e("save", a, S);
|
|
79
|
+
}, D = (a, S) => {
|
|
80
|
+
e("drop", a, S);
|
|
81
81
|
};
|
|
82
82
|
return g({
|
|
83
83
|
doSave: () => {
|
|
84
|
-
|
|
84
|
+
V.value && typeof V.value.click == "function" && V.value.click();
|
|
85
85
|
},
|
|
86
86
|
doDrop: () => {
|
|
87
|
-
|
|
87
|
+
d.value && typeof d.value.click == "function" && d.value.click();
|
|
88
88
|
}
|
|
89
|
-
}), (
|
|
89
|
+
}), (a, S) => {
|
|
90
90
|
const n = Z("lkt-button");
|
|
91
|
-
return
|
|
92
|
-
m(u)["prev-buttons-ever"] ? z((
|
|
93
|
-
y(
|
|
91
|
+
return i(), w("div", Ee, [
|
|
92
|
+
m(u)["prev-buttons-ever"] ? z((i(), w("div", Ve, [
|
|
93
|
+
y(a.$slots, "prev-buttons-ever")
|
|
94
94
|
], 512)), [
|
|
95
|
-
[K, !
|
|
95
|
+
[K, !r.value]
|
|
96
96
|
]) : c("", !0),
|
|
97
|
-
m(u)["prev-buttons"] ? z((
|
|
98
|
-
y(
|
|
97
|
+
m(u)["prev-buttons"] ? z((i(), w("div", Le, [
|
|
98
|
+
y(a.$slots, "prev-buttons")
|
|
99
99
|
], 512)), [
|
|
100
|
-
[K, f.value && !
|
|
100
|
+
[K, f.value && !r.value]
|
|
101
101
|
]) : c("", !0),
|
|
102
|
-
|
|
102
|
+
a.showSaveButton ? (i(), M(n, {
|
|
103
103
|
key: 2,
|
|
104
104
|
ref_key: "saveButton",
|
|
105
|
-
ref:
|
|
105
|
+
ref: V,
|
|
106
106
|
palette: "success",
|
|
107
|
-
disabled: !
|
|
108
|
-
"confirm-modal":
|
|
109
|
-
"confirm-data":
|
|
110
|
-
resource:
|
|
111
|
-
"resource-data":
|
|
112
|
-
text: m(u)["button-save"] ? "" :
|
|
113
|
-
icon: m(u)["button-save"] ? "" :
|
|
107
|
+
disabled: !a.ableToSave,
|
|
108
|
+
"confirm-modal": a.saveConfirm,
|
|
109
|
+
"confirm-data": a.confirmData,
|
|
110
|
+
resource: a.saveResource,
|
|
111
|
+
"resource-data": a.saveData,
|
|
112
|
+
text: m(u)["button-save"] ? "" : a.saveText,
|
|
113
|
+
icon: m(u)["button-save"] ? "" : a.saveIcon,
|
|
114
114
|
onLoading: h,
|
|
115
|
-
onLoaded:
|
|
116
|
-
onClick:
|
|
115
|
+
onLoaded: k,
|
|
116
|
+
onClick: B
|
|
117
117
|
}, {
|
|
118
|
-
default:
|
|
119
|
-
m(u)["button-save"] ? y(
|
|
118
|
+
default: E(() => [
|
|
119
|
+
m(u)["button-save"] ? y(a.$slots, "button-save", {
|
|
120
120
|
key: 0,
|
|
121
|
-
item:
|
|
121
|
+
item: a.item,
|
|
122
122
|
editMode: f.value,
|
|
123
|
-
isCreate:
|
|
124
|
-
canUpdate:
|
|
125
|
-
canDrop:
|
|
123
|
+
isCreate: a.createMode,
|
|
124
|
+
canUpdate: a.canUpdate,
|
|
125
|
+
canDrop: a.canDrop
|
|
126
126
|
}) : c("", !0)
|
|
127
127
|
]),
|
|
128
128
|
_: 3
|
|
129
129
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])) : c("", !0),
|
|
130
|
-
|
|
130
|
+
a.createMode ? c("", !0) : z((i(), M(n, {
|
|
131
131
|
key: 3,
|
|
132
132
|
ref_key: "dropButton",
|
|
133
|
-
ref:
|
|
133
|
+
ref: d,
|
|
134
134
|
palette: "danger",
|
|
135
|
-
disabled: !
|
|
136
|
-
"confirm-modal":
|
|
137
|
-
"confirm-data":
|
|
138
|
-
resource:
|
|
139
|
-
"resource-data":
|
|
140
|
-
text: m(u)["button-drop"] ? "" :
|
|
141
|
-
icon: m(u)["button-drop"] ? "" :
|
|
135
|
+
disabled: !a.ableToDrop,
|
|
136
|
+
"confirm-modal": a.dropConfirm,
|
|
137
|
+
"confirm-data": a.dropConfirmData,
|
|
138
|
+
resource: a.dropResource,
|
|
139
|
+
"resource-data": a.dropData,
|
|
140
|
+
text: m(u)["button-drop"] ? "" : a.dropText,
|
|
141
|
+
icon: m(u)["button-drop"] ? "" : a.dropIcon,
|
|
142
142
|
onLoading: h,
|
|
143
|
-
onLoaded:
|
|
143
|
+
onLoaded: k,
|
|
144
144
|
onClick: D
|
|
145
145
|
}, {
|
|
146
|
-
default:
|
|
147
|
-
m(u)["button-drop"] ? y(
|
|
146
|
+
default: E(() => [
|
|
147
|
+
m(u)["button-drop"] ? y(a.$slots, "button-drop", {
|
|
148
148
|
key: 0,
|
|
149
|
-
item:
|
|
149
|
+
item: a.item,
|
|
150
150
|
editMode: f.value,
|
|
151
|
-
isCreate:
|
|
152
|
-
canUpdate:
|
|
153
|
-
canDrop:
|
|
151
|
+
isCreate: a.createMode,
|
|
152
|
+
canUpdate: a.canUpdate,
|
|
153
|
+
canDrop: a.canDrop
|
|
154
154
|
}) : c("", !0)
|
|
155
155
|
]),
|
|
156
156
|
_: 3
|
|
157
157
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
|
|
158
|
-
[K,
|
|
158
|
+
[K, a.showDropButton]
|
|
159
159
|
]),
|
|
160
|
-
m(u).buttons ? z((
|
|
161
|
-
y(
|
|
160
|
+
m(u).buttons ? z((i(), w("div", Oe, [
|
|
161
|
+
y(a.$slots, "buttons")
|
|
162
162
|
], 512)), [
|
|
163
|
-
[K, f.value && !
|
|
163
|
+
[K, f.value && !r.value]
|
|
164
164
|
]) : c("", !0),
|
|
165
|
-
|
|
165
|
+
a.showSwitchButton ? (i(), M(n, {
|
|
166
166
|
key: 5,
|
|
167
167
|
checked: f.value,
|
|
168
|
-
"onUpdate:checked":
|
|
168
|
+
"onUpdate:checked": S[0] || (S[0] = (L) => f.value = L),
|
|
169
169
|
class: "lkt-item-crud--switch-mode-button",
|
|
170
170
|
"show-switch": "",
|
|
171
|
-
text:
|
|
171
|
+
text: a.editModeText
|
|
172
172
|
}, null, 8, ["checked", "text"])) : c("", !0)
|
|
173
173
|
]);
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
var _ = /* @__PURE__ */ ((o) => (o.Top = "top", o.Bottom = "bottom", o))(_ || {}), j = /* @__PURE__ */ ((o) => (o.Changed = "changed", o.Always = "always", o))(j || {});
|
|
178
|
-
const
|
|
178
|
+
const Ae = { class: "lkt-item-crud" }, ze = {
|
|
179
179
|
key: 0,
|
|
180
180
|
class: "lkt-item-crud_header"
|
|
181
|
-
},
|
|
181
|
+
}, Ke = {
|
|
182
182
|
key: 0,
|
|
183
183
|
class: "lkt-item-crud_header-slot"
|
|
184
|
-
},
|
|
184
|
+
}, Fe = {
|
|
185
185
|
key: 1,
|
|
186
186
|
class: "lkt-item-crud_header-title"
|
|
187
|
-
},
|
|
187
|
+
}, Pe = {
|
|
188
188
|
key: 2,
|
|
189
189
|
class: "lkt-item-crud_header-slot"
|
|
190
|
-
},
|
|
190
|
+
}, Je = {
|
|
191
191
|
key: 2,
|
|
192
192
|
class: "lkt-item-crud_content"
|
|
193
|
-
},
|
|
193
|
+
}, je = {
|
|
194
194
|
key: 0,
|
|
195
195
|
class: "lkt-grid-1"
|
|
196
|
-
},
|
|
196
|
+
}, qe = /* @__PURE__ */ pe({
|
|
197
197
|
__name: "LktItemCrud",
|
|
198
198
|
props: {
|
|
199
199
|
modelValue: { default: () => ({}) },
|
|
200
200
|
title: { default: "" },
|
|
201
201
|
editModeText: { default: "Edition Mode" },
|
|
202
202
|
saveText: { default: "Save" },
|
|
203
|
-
saveIcon: { default: () =>
|
|
203
|
+
saveIcon: { default: () => U.defaultSaveIcon },
|
|
204
204
|
dropText: { default: "Delete" },
|
|
205
|
-
dropIcon: { default: () =>
|
|
205
|
+
dropIcon: { default: () => U.defaultDropIcon },
|
|
206
206
|
hiddenSave: { type: Boolean, default: !1 },
|
|
207
207
|
hiddenDrop: { type: Boolean, default: !1 },
|
|
208
208
|
hiddenButtons: { type: Boolean, default: !1 },
|
|
@@ -250,63 +250,65 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
250
250
|
beforeClose: { type: Function, default: void 0 }
|
|
251
251
|
},
|
|
252
252
|
emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
|
|
253
|
-
setup(o, { expose: g, emit:
|
|
254
|
-
const e = o, b =
|
|
255
|
-
let
|
|
256
|
-
const
|
|
257
|
-
|
|
253
|
+
setup(o, { expose: g, emit: I }) {
|
|
254
|
+
const e = o, b = ce(), u = I;
|
|
255
|
+
let V = [];
|
|
256
|
+
const d = s(!0), r = s(e.modelValue), f = s(V), h = s(e.editing), k = s(!1), B = s(!1), D = s(200), x = s(null), ee = s(null), a = s(new ie(r.value, e.dataStateConfig)), S = s(new ie(e.readData)), n = s(e.isCreate), L = s(!1), te = s(!1), P = s(null), ae = v(() => n.value ? e.createConfirm : e.updateConfirm), oe = v(() => n.value ? e.createConfirmData : e.updateConfirmData), q = v(() => n.value ? e.createResource : e.updateResource), le = v(() => n.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), fe = v(() => n.value ? e.createDisabled : e.updateDisabled), R = v(() => !n.value && Array.isArray(f.value) && f.value.includes("update")), N = v(() => !n.value && Array.isArray(f.value) && f.value.includes("drop")), J = async () => {
|
|
257
|
+
p("fetchItem"), d.value = !0, D.value = -1, B.value = !1;
|
|
258
258
|
try {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
|
|
259
|
+
const t = await Me(e.readResource, e.readData);
|
|
260
|
+
if (p("fetchItem -> response", t), d.value = !1, D.value = t.httpStatus, !t.success) {
|
|
261
|
+
k.value = !1, D.value = t.httpStatus, u("error", t.httpStatus);
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
k.value = !0, r.value = t.data, f.value = t.perms, a.value.increment(r.value).turnStoredIntoOriginal(), S.value.turnStoredIntoOriginal(), u("read", t);
|
|
265
265
|
} catch {
|
|
266
|
-
|
|
266
|
+
d.value = !1, k.value = !1, D.value = 404, u("error", 404);
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, { deep: !0 }),
|
|
273
|
-
if (L.value = !0,
|
|
274
|
-
|
|
275
|
-
let l = e.beforeEmitUpdate(
|
|
276
|
-
|
|
270
|
+
C(() => e.modelValue, (t) => {
|
|
271
|
+
r.value = t, a.value.increment(t);
|
|
272
|
+
}, { deep: !0 }), C(r, (t) => {
|
|
273
|
+
if (L.value = !0, p("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
274
|
+
p("item updated -> has beforeEmitUpdate");
|
|
275
|
+
let l = e.beforeEmitUpdate(r.value);
|
|
276
|
+
p("item updated -> override with: ", l), typeof l == "object" && (r.value = l);
|
|
277
277
|
}
|
|
278
|
-
u("update:modelValue",
|
|
279
|
-
}, { deep: !0 }),
|
|
280
|
-
const O =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
|
|
285
|
-
}),
|
|
286
|
-
|
|
287
|
-
}),
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
278
|
+
u("update:modelValue", r.value), p("item updated -> update dataState"), a.value.increment(t), ye(() => L.value = !1);
|
|
279
|
+
}, { deep: !0 }), C(f, () => u("perms", f.value));
|
|
280
|
+
const O = v(() => fe.value || !n.value && !R.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : a.value.changed()), H = v(() => !e.dropDisabled && N.value);
|
|
281
|
+
C(O, (t) => u("modified-data", t)), C(n, (t) => u("update:isCreate", t)), C(() => e.readData, (t) => {
|
|
282
|
+
S.value.increment(t), S.value.changed() && J();
|
|
283
|
+
}), C(() => e.editing, (t) => {
|
|
284
|
+
p("editing updated -> updating editMode", t), h.value = t;
|
|
285
|
+
}), C(h, (t) => {
|
|
286
|
+
p("editMode updated -> emit update", t), u("update:editing", t);
|
|
287
|
+
}), ke(() => {
|
|
288
|
+
e.readResource && !n.value ? J() : n.value && (k.value = !0, h.value = !0, d.value = !1, a.value.increment(r.value).turnStoredIntoOriginal());
|
|
289
|
+
});
|
|
290
|
+
const re = (t, l) => {
|
|
291
|
+
if (d.value = !1, D.value = l.httpStatus, !l.success) {
|
|
292
|
+
B.value = !0, u("error", l.httpStatus);
|
|
291
293
|
return;
|
|
292
294
|
}
|
|
293
|
-
|
|
294
|
-
Y(
|
|
295
|
+
B.value = !0, e.onDropModalCallbacks.length > 0 && (p("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach(($) => {
|
|
296
|
+
Y($);
|
|
295
297
|
})), u("drop", l);
|
|
296
|
-
}, de = (
|
|
297
|
-
if (
|
|
298
|
-
if (
|
|
299
|
-
|
|
298
|
+
}, de = (t, l) => {
|
|
299
|
+
if (p("onSave -> received response:", l), u("before-save"), q.value) {
|
|
300
|
+
if (d.value = !1, typeof l < "u" && (D.value = l.httpStatus, !l.success)) {
|
|
301
|
+
B.value = !0, u("error", l.httpStatus);
|
|
300
302
|
return;
|
|
301
303
|
}
|
|
302
|
-
|
|
304
|
+
B.value = !0;
|
|
303
305
|
}
|
|
304
|
-
let
|
|
305
|
-
n.value || (
|
|
306
|
+
let $ = n.value ? "create" : "update";
|
|
307
|
+
n.value || (p("onSave -> turn stored data into original"), a.value.turnStoredIntoOriginal()), $ === "create" ? (te.value = !0, a.value.increment(r.value).turnStoredIntoOriginal(), typeof e.onCreate == "function" && (p("onSave -> trigger onCreate callback"), e.onCreate(l), e.onCreateModalCallbacks.length > 0 && (p("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((A) => {
|
|
306
308
|
Y(A);
|
|
307
|
-
}))) : typeof e.onUpdate == "function" && (
|
|
309
|
+
})))) : typeof e.onUpdate == "function" && (p("onSave -> trigger onUpdate callback"), e.onUpdate(l), e.onUpdateModalCallbacks.length > 0 && (p("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((A) => {
|
|
308
310
|
Y(A);
|
|
309
|
-
}))), !e.insideModal && l.autoReloadId && (
|
|
311
|
+
}))), !e.insideModal && l.autoReloadId && (p("onSave -> autoReloadId detected: ", l.autoReloadId), e.readData.id = l.autoReloadId, p("onSave -> turning off create mode"), n.value = !1, J()), u($, l);
|
|
310
312
|
};
|
|
311
313
|
g({
|
|
312
314
|
doDrop: () => {
|
|
@@ -316,164 +318,171 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
316
318
|
doSave: () => {
|
|
317
319
|
P.value && x.value.doSave();
|
|
318
320
|
},
|
|
319
|
-
hasModifiedData: () =>
|
|
321
|
+
hasModifiedData: () => a.value.changed()
|
|
320
322
|
});
|
|
321
|
-
const
|
|
323
|
+
const me = v(() => a.value.changed() ? e.editedCloseConfirm : ""), be = (t) => {
|
|
324
|
+
if (typeof e.beforeClose == "function")
|
|
325
|
+
return e.beforeClose({
|
|
326
|
+
...t,
|
|
327
|
+
itemCreated: te.value
|
|
328
|
+
});
|
|
329
|
+
}, W = v(() => !R.value && N.value ? !0 : !e.hiddenDrop && !d.value && h.value && k.value), G = v(() => a.value.changed() ? !0 : d.value ? !1 : n.value ? !0 : e.buttonNavVisibility === j.Always ? O.value : !e.hiddenSave && h.value && k.value), Q = v(() => e.hideSwitchEdition || !R.value && !N.value || !R.value && N.value ? !1 : !d.value && !n.value && k.value && !(e.dropDisabled && e.updateDisabled)), ue = v(() => e.buttonNavVisibility === j.Always && (O.value || H.value) || b["prev-buttons-ever"] ? !0 : !e.hiddenButtons && (G.value || W.value || Q.value)), X = v(() => e.title.startsWith("__:") ? String($e(e.title.substring(3))) : e.title), he = v(() => d.value ? !1 : X.value.length > 0 || !!b["post-title"]), ne = v(() => e.insideModal ? "lkt-modal" : "section"), Ce = v(() => ne.value === "lkt-modal" ? {
|
|
322
330
|
"modal-name": e.modalName,
|
|
323
331
|
"modal-key": e.modalKey,
|
|
324
332
|
"z-index": e.zIndex,
|
|
325
333
|
"pre-title": e.preTitle,
|
|
326
334
|
"show-close": e.showClose,
|
|
327
|
-
"before-close":
|
|
335
|
+
"before-close": be,
|
|
328
336
|
"disabled-close": e.disabledClose,
|
|
329
337
|
"disabled-veil-click": e.disabledVeilClick,
|
|
330
|
-
"close-confirm":
|
|
338
|
+
"close-confirm": me.value,
|
|
331
339
|
"close-confirm-key": e.editedCloseConfirmKey,
|
|
332
340
|
title: e.title,
|
|
333
|
-
size: e.size
|
|
341
|
+
size: e.size,
|
|
342
|
+
item: r.value
|
|
334
343
|
} : {});
|
|
335
|
-
return (
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
default:
|
|
339
|
-
|
|
340
|
-
!
|
|
341
|
-
m(b)["pre-title"] ? (
|
|
342
|
-
y(
|
|
343
|
-
item:
|
|
344
|
-
loading:
|
|
344
|
+
return (t, l) => {
|
|
345
|
+
const $ = Z("lkt-http-info"), A = Z("lkt-loader");
|
|
346
|
+
return i(), M(De(ne.value), ge(Se(Ce.value)), {
|
|
347
|
+
default: E(() => [
|
|
348
|
+
we("article", Ae, [
|
|
349
|
+
!t.insideModal && he.value ? (i(), w("header", ze, [
|
|
350
|
+
m(b)["pre-title"] ? (i(), w("div", Ke, [
|
|
351
|
+
y(t.$slots, "pre-title", {
|
|
352
|
+
item: r.value,
|
|
353
|
+
loading: d.value
|
|
345
354
|
})
|
|
346
355
|
])) : c("", !0),
|
|
347
|
-
X.value.length > 0 ? (
|
|
348
|
-
m(b)["post-title"] ? (
|
|
349
|
-
y(
|
|
350
|
-
item:
|
|
351
|
-
loading:
|
|
356
|
+
X.value.length > 0 ? (i(), w("h1", Fe, Be(X.value), 1)) : c("", !0),
|
|
357
|
+
m(b)["post-title"] ? (i(), w("div", Pe, [
|
|
358
|
+
y(t.$slots, "post-title", {
|
|
359
|
+
item: r.value,
|
|
360
|
+
loading: d.value
|
|
352
361
|
})
|
|
353
362
|
])) : c("", !0)
|
|
354
363
|
])) : c("", !0),
|
|
355
|
-
|
|
364
|
+
ue.value && t.buttonNavPosition === "top" ? (i(), M(ve, {
|
|
356
365
|
key: 1,
|
|
357
366
|
ref_key: "buttonNav",
|
|
358
367
|
ref: P,
|
|
359
|
-
loading:
|
|
360
|
-
"onUpdate:loading": l[0] || (l[0] = (
|
|
368
|
+
loading: d.value,
|
|
369
|
+
"onUpdate:loading": l[0] || (l[0] = (T) => d.value = T),
|
|
361
370
|
editing: h.value,
|
|
362
|
-
"onUpdate:editing": l[1] || (l[1] = (
|
|
363
|
-
item:
|
|
371
|
+
"onUpdate:editing": l[1] || (l[1] = (T) => h.value = T),
|
|
372
|
+
item: r.value,
|
|
364
373
|
"create-mode": n.value,
|
|
365
|
-
"can-update":
|
|
366
|
-
"can-drop":
|
|
374
|
+
"can-update": R.value,
|
|
375
|
+
"can-drop": N.value,
|
|
367
376
|
"show-switch-button": Q.value,
|
|
368
377
|
"show-save-button": G.value,
|
|
369
378
|
"show-drop-button": W.value,
|
|
370
379
|
"able-to-save": O.value,
|
|
371
380
|
"able-to-drop": H.value,
|
|
372
381
|
"save-confirm": ae.value,
|
|
373
|
-
"drop-confirm":
|
|
374
|
-
"confirm-data":
|
|
375
|
-
"drop-confirm-data":
|
|
382
|
+
"drop-confirm": t.dropConfirm,
|
|
383
|
+
"confirm-data": oe.value,
|
|
384
|
+
"drop-confirm-data": t.dropConfirmData,
|
|
376
385
|
"save-resource": q.value,
|
|
377
|
-
"drop-resource":
|
|
378
|
-
"save-data":
|
|
379
|
-
"drop-data":
|
|
380
|
-
"save-text":
|
|
381
|
-
"drop-text":
|
|
382
|
-
"save-icon":
|
|
383
|
-
"drop-icon":
|
|
384
|
-
"edit-mode-text":
|
|
386
|
+
"drop-resource": t.dropResource,
|
|
387
|
+
"save-data": le.value,
|
|
388
|
+
"drop-data": t.dropData,
|
|
389
|
+
"save-text": t.saveText,
|
|
390
|
+
"drop-text": t.dropText,
|
|
391
|
+
"save-icon": t.saveIcon,
|
|
392
|
+
"drop-icon": t.dropIcon,
|
|
393
|
+
"edit-mode-text": t.editModeText,
|
|
385
394
|
onSave: de,
|
|
386
|
-
onDrop:
|
|
387
|
-
},
|
|
395
|
+
onDrop: re
|
|
396
|
+
}, se({ _: 2 }, [
|
|
388
397
|
m(b)["prev-buttons-ever"] ? {
|
|
389
398
|
name: "prev-buttons-ever",
|
|
390
|
-
fn:
|
|
391
|
-
y(
|
|
399
|
+
fn: E(() => [
|
|
400
|
+
y(t.$slots, "prev-buttons-ever")
|
|
392
401
|
]),
|
|
393
402
|
key: "0"
|
|
394
403
|
} : void 0,
|
|
395
404
|
m(b)["prev-buttons"] ? {
|
|
396
405
|
name: "prev-buttons-ever",
|
|
397
|
-
fn:
|
|
398
|
-
y(
|
|
406
|
+
fn: E(() => [
|
|
407
|
+
y(t.$slots, "prev-buttons")
|
|
399
408
|
]),
|
|
400
409
|
key: "1"
|
|
401
410
|
} : void 0
|
|
402
411
|
]), 1032, ["loading", "editing", "item", "create-mode", "can-update", "can-drop", "show-switch-button", "show-save-button", "show-drop-button", "able-to-save", "able-to-drop", "save-confirm", "drop-confirm", "confirm-data", "drop-confirm-data", "save-resource", "drop-resource", "save-data", "drop-data", "save-text", "drop-text", "save-icon", "drop-icon", "edit-mode-text"])) : c("", !0),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
412
|
+
d.value ? c("", !0) : (i(), w("div", Je, [
|
|
413
|
+
k.value ? (i(), w("div", je, [
|
|
414
|
+
B.value ? (i(), M($, {
|
|
406
415
|
key: 0,
|
|
407
416
|
code: D.value,
|
|
408
417
|
quick: "",
|
|
409
418
|
palette: D.value === 200 ? "success" : "danger",
|
|
410
419
|
"can-close": "",
|
|
411
|
-
onClose: l[2] || (l[2] = (
|
|
420
|
+
onClose: l[2] || (l[2] = (T) => B.value = !1)
|
|
412
421
|
}, null, 8, ["code", "palette"])) : c("", !0),
|
|
413
|
-
y(
|
|
414
|
-
item:
|
|
415
|
-
loading:
|
|
422
|
+
y(t.$slots, "item", {
|
|
423
|
+
item: r.value,
|
|
424
|
+
loading: d.value,
|
|
416
425
|
editMode: h.value,
|
|
417
426
|
isCreate: n.value,
|
|
418
|
-
canUpdate:
|
|
419
|
-
canDrop:
|
|
427
|
+
canUpdate: R.value,
|
|
428
|
+
canDrop: N.value,
|
|
420
429
|
itemBeingEdited: L.value
|
|
421
430
|
})
|
|
422
|
-
])) : (
|
|
431
|
+
])) : (i(), M($, {
|
|
423
432
|
key: 1,
|
|
424
433
|
code: D.value
|
|
425
434
|
}, null, 8, ["code"]))
|
|
426
435
|
])),
|
|
427
|
-
|
|
428
|
-
|
|
436
|
+
d.value ? (i(), M(A, { key: 3 })) : c("", !0),
|
|
437
|
+
t.buttonNavPosition === m(_).Bottom ? z((i(), M(ve, {
|
|
429
438
|
key: 4,
|
|
430
439
|
ref_key: "buttonNav",
|
|
431
440
|
ref: P,
|
|
432
|
-
loading:
|
|
433
|
-
"onUpdate:loading": l[3] || (l[3] = (
|
|
441
|
+
loading: d.value,
|
|
442
|
+
"onUpdate:loading": l[3] || (l[3] = (T) => d.value = T),
|
|
434
443
|
editing: h.value,
|
|
435
|
-
"onUpdate:editing": l[4] || (l[4] = (
|
|
436
|
-
item:
|
|
444
|
+
"onUpdate:editing": l[4] || (l[4] = (T) => h.value = T),
|
|
445
|
+
item: r.value,
|
|
437
446
|
"create-mode": n.value,
|
|
438
|
-
"can-update":
|
|
439
|
-
"can-drop":
|
|
447
|
+
"can-update": R.value,
|
|
448
|
+
"can-drop": N.value,
|
|
440
449
|
"show-switch-button": Q.value,
|
|
441
450
|
"show-save-button": G.value,
|
|
442
451
|
"show-drop-button": W.value,
|
|
443
452
|
"able-to-save": O.value,
|
|
444
453
|
"able-to-drop": H.value,
|
|
445
454
|
"save-confirm": ae.value,
|
|
446
|
-
"drop-confirm":
|
|
447
|
-
"confirm-data":
|
|
448
|
-
"drop-confirm-data":
|
|
455
|
+
"drop-confirm": t.dropConfirm,
|
|
456
|
+
"confirm-data": oe.value,
|
|
457
|
+
"drop-confirm-data": t.dropConfirmData,
|
|
449
458
|
"save-resource": q.value,
|
|
450
|
-
"drop-resource":
|
|
451
|
-
"save-data":
|
|
452
|
-
"drop-data":
|
|
453
|
-
"save-text":
|
|
454
|
-
"drop-text":
|
|
455
|
-
"save-icon":
|
|
456
|
-
"drop-icon":
|
|
457
|
-
"edit-mode-text":
|
|
459
|
+
"drop-resource": t.dropResource,
|
|
460
|
+
"save-data": le.value,
|
|
461
|
+
"drop-data": t.dropData,
|
|
462
|
+
"save-text": t.saveText,
|
|
463
|
+
"drop-text": t.dropText,
|
|
464
|
+
"save-icon": t.saveIcon,
|
|
465
|
+
"drop-icon": t.dropIcon,
|
|
466
|
+
"edit-mode-text": t.editModeText,
|
|
458
467
|
onSave: de,
|
|
459
|
-
onDrop:
|
|
460
|
-
},
|
|
468
|
+
onDrop: re
|
|
469
|
+
}, se({ _: 2 }, [
|
|
461
470
|
m(b)["prev-buttons-ever"] ? {
|
|
462
471
|
name: "prev-buttons-ever",
|
|
463
|
-
fn:
|
|
464
|
-
y(
|
|
472
|
+
fn: E(() => [
|
|
473
|
+
y(t.$slots, "prev-buttons-ever")
|
|
465
474
|
]),
|
|
466
475
|
key: "0"
|
|
467
476
|
} : void 0,
|
|
468
477
|
m(b)["prev-buttons"] ? {
|
|
469
478
|
name: "prev-buttons-ever",
|
|
470
|
-
fn:
|
|
471
|
-
y(
|
|
479
|
+
fn: E(() => [
|
|
480
|
+
y(t.$slots, "prev-buttons")
|
|
472
481
|
]),
|
|
473
482
|
key: "1"
|
|
474
483
|
} : void 0
|
|
475
484
|
]), 1032, ["loading", "editing", "item", "create-mode", "can-update", "can-drop", "show-switch-button", "show-save-button", "show-drop-button", "able-to-save", "able-to-drop", "save-confirm", "drop-confirm", "confirm-data", "drop-confirm-data", "save-resource", "drop-resource", "save-data", "drop-data", "save-text", "drop-text", "save-icon", "drop-icon", "edit-mode-text"])), [
|
|
476
|
-
[K,
|
|
485
|
+
[K, ue.value]
|
|
477
486
|
]) : c("", !0)
|
|
478
487
|
])
|
|
479
488
|
]),
|
|
@@ -481,18 +490,18 @@ const Ve = { class: "lkt-item-crud" }, Le = {
|
|
|
481
490
|
}, 16);
|
|
482
491
|
};
|
|
483
492
|
}
|
|
484
|
-
}),
|
|
493
|
+
}), xe = {
|
|
485
494
|
install: (o, g = {}) => {
|
|
486
|
-
o.component("lkt-item-crud") === void 0 && o.component("lkt-item-crud",
|
|
495
|
+
o.component("lkt-item-crud") === void 0 && o.component("lkt-item-crud", qe);
|
|
487
496
|
}
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
},
|
|
491
|
-
|
|
497
|
+
}, et = (o) => {
|
|
498
|
+
U.defaultSaveIcon = o;
|
|
499
|
+
}, tt = (o) => {
|
|
500
|
+
U.defaultDropIcon = o;
|
|
492
501
|
};
|
|
493
502
|
export {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
503
|
+
_e as debugLktItemCrud,
|
|
504
|
+
xe as default,
|
|
505
|
+
tt as setItemCrudDefaultDropIcon,
|
|
506
|
+
et as setItemCrudDefaultSaveIcon
|
|
498
507
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, useSlots, watch } from 'vue';
|
|
3
3
|
import { LktObject } from 'lkt-ts-interfaces';
|
|
4
|
+
import { HTTPResponse } from 'lkt-http-client';
|
|
4
5
|
|
|
5
6
|
const emit = defineEmits(['update:loading', 'update:editing', 'save', 'drop']);
|
|
6
7
|
|
|
@@ -57,11 +58,11 @@
|
|
|
57
58
|
onButtonLoaded = () => {
|
|
58
59
|
isLoading.value = false;
|
|
59
60
|
},
|
|
60
|
-
onSave = () => {
|
|
61
|
-
emit('save');
|
|
61
|
+
onSave = ($event: Event, r: HTTPResponse) => {
|
|
62
|
+
emit('save', $event, r);
|
|
62
63
|
},
|
|
63
|
-
onDrop = () => {
|
|
64
|
-
emit('drop');
|
|
64
|
+
onDrop = ($event: Event, r: HTTPResponse) => {
|
|
65
|
+
emit('drop', $event, r);
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
const doSave = () => {
|
|
@@ -100,9 +101,9 @@
|
|
|
100
101
|
:resource-data="saveData"
|
|
101
102
|
:text="slots['button-save'] ? '' : saveText"
|
|
102
103
|
:icon="slots['button-save'] ? '' : saveIcon"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
@loading="onButtonLoading"
|
|
105
|
+
@loaded="onButtonLoaded"
|
|
106
|
+
@click="onSave">
|
|
106
107
|
<slot v-if="!!slots['button-save']" name="button-save" :item="item"
|
|
107
108
|
:edit-mode="isEditing"
|
|
108
109
|
:is-create="createMode"
|
|
@@ -122,9 +123,9 @@
|
|
|
122
123
|
:resource-data="dropData"
|
|
123
124
|
:text="slots['button-drop'] ? '' : dropText"
|
|
124
125
|
:icon="slots['button-drop'] ? '' : dropIcon"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
@loading="onButtonLoading"
|
|
127
|
+
@loaded="onButtonLoaded"
|
|
128
|
+
@click="onDrop">
|
|
128
129
|
<slot v-if="!!slots['button-drop']" name="button-drop" :item="item"
|
|
129
130
|
:edit-mode="isEditing"
|
|
130
131
|
:is-create="createMode"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, ref, useSlots, watch } from 'vue';
|
|
2
|
+
import { computed, nextTick, onMounted, ref, useSlots, watch } from 'vue';
|
|
3
3
|
import { httpCall, HTTPResponse } from 'lkt-http-client';
|
|
4
4
|
import { DataState } from 'lkt-data-state';
|
|
5
5
|
import { debug } from '../functions/debug';
|
|
@@ -143,7 +143,8 @@
|
|
|
143
143
|
dataState = ref(new DataState(item.value, props.dataStateConfig)),
|
|
144
144
|
readDataState = ref(new DataState(props.readData)),
|
|
145
145
|
createMode = ref(props.isCreate),
|
|
146
|
-
itemBeingEdited = ref(false)
|
|
146
|
+
itemBeingEdited = ref(false),
|
|
147
|
+
itemCreated = ref(false);
|
|
147
148
|
|
|
148
149
|
const buttonNav = ref(null);
|
|
149
150
|
|
|
@@ -259,13 +260,16 @@
|
|
|
259
260
|
emit('update:editing', v);
|
|
260
261
|
});
|
|
261
262
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
onMounted(() => {
|
|
264
|
+
// Fetch item
|
|
265
|
+
if (props.readResource && !createMode.value) fetchItem();
|
|
266
|
+
else if (createMode.value) {
|
|
267
|
+
httpSuccessRead.value = true;
|
|
268
|
+
editMode.value = true;
|
|
269
|
+
isLoading.value = false;
|
|
270
|
+
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
271
|
+
}
|
|
272
|
+
})
|
|
269
273
|
|
|
270
274
|
const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
271
275
|
isLoading.value = false;
|
|
@@ -289,11 +293,13 @@
|
|
|
289
293
|
emit('before-save');
|
|
290
294
|
if (saveResource.value) {
|
|
291
295
|
isLoading.value = false;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
296
|
+
if (typeof r !== 'undefined') {
|
|
297
|
+
httpStatus.value = r.httpStatus;
|
|
298
|
+
if (!r.success) {
|
|
299
|
+
showStoreMessage.value = true;
|
|
300
|
+
emit('error', r.httpStatus);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
297
303
|
}
|
|
298
304
|
showStoreMessage.value = true;
|
|
299
305
|
}
|
|
@@ -303,7 +309,10 @@
|
|
|
303
309
|
dataState.value.turnStoredIntoOriginal();
|
|
304
310
|
}
|
|
305
311
|
|
|
312
|
+
|
|
306
313
|
if (emits === 'create') {
|
|
314
|
+
itemCreated.value = true;
|
|
315
|
+
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
307
316
|
if (typeof props.onCreate === 'function') {
|
|
308
317
|
debug('onSave -> trigger onCreate callback');
|
|
309
318
|
props.onCreate(r);
|
|
@@ -357,6 +366,15 @@
|
|
|
357
366
|
return dataState.value.changed() ? props.editedCloseConfirm : '';
|
|
358
367
|
});
|
|
359
368
|
|
|
369
|
+
const crudBeforeClose = (modalData: LktObject) => {
|
|
370
|
+
if (typeof props.beforeClose === 'function') {
|
|
371
|
+
return props.beforeClose({
|
|
372
|
+
...modalData,
|
|
373
|
+
itemCreated: itemCreated.value,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
360
378
|
const showDropButton = computed(() => {
|
|
361
379
|
if (!canUpdate.value && canDrop.value) return true;
|
|
362
380
|
|
|
@@ -412,19 +430,21 @@
|
|
|
412
430
|
}),
|
|
413
431
|
computedContainerAttrs = computed(() => {
|
|
414
432
|
if (computedContainerTag.value === 'lkt-modal') {
|
|
433
|
+
|
|
415
434
|
return {
|
|
416
435
|
'modal-name': props.modalName,
|
|
417
436
|
'modal-key': props.modalKey,
|
|
418
437
|
'z-index': props.zIndex,
|
|
419
438
|
'pre-title': props.preTitle,
|
|
420
439
|
'show-close': props.showClose,
|
|
421
|
-
'before-close':
|
|
440
|
+
'before-close': crudBeforeClose,
|
|
422
441
|
'disabled-close': props.disabledClose,
|
|
423
442
|
'disabled-veil-click': props.disabledVeilClick,
|
|
424
443
|
'close-confirm': closeConfirm.value,
|
|
425
444
|
'close-confirm-key': props.editedCloseConfirmKey,
|
|
426
445
|
title: props.title,
|
|
427
446
|
size: props.size,
|
|
447
|
+
item: item.value,
|
|
428
448
|
};
|
|
429
449
|
}
|
|
430
450
|
return {};
|