lkt-item-crud 1.1.26 → 1.1.28
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 +3 -3
- package/dist/build.js +105 -100
- package/dist/lib-components/LktItemCrud.vue.d.ts +1 -0
- package/package.json +4 -2
- package/src/lib-components/LktItemCrud.vue +18 -10
package/dist/build.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
declare namespace
|
|
1
|
+
declare function Je(l?: boolean): void;
|
|
2
|
+
declare namespace Ke {
|
|
3
3
|
function install(l: any, h?: {}): void;
|
|
4
4
|
}
|
|
5
|
-
export {
|
|
5
|
+
export { Je as debugLktItemCrud, Ke as default };
|
package/dist/build.js
CHANGED
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { httpCall as
|
|
1
|
+
import { defineComponent as ve, useSlots as ce, ref as s, computed as n, watch as b, nextTick as fe, resolveComponent as L, openBlock as v, createElementBlock as _, unref as C, renderSlot as U, createCommentVNode as p, toDisplayString as pe, withDirectives as O, createElementVNode as me, createBlock as T, withCtx as Y, vShow as $, createVNode as Z } from "vue";
|
|
2
|
+
import { httpCall as he } from "lkt-http-client";
|
|
3
3
|
import { DataState as ee } from "lkt-data-state";
|
|
4
|
-
import { execModal as
|
|
4
|
+
import { execModal as ke, refreshModal as be, closeModal as Ce, openModal as De, reOpenModal as Se } from "lkt-modal";
|
|
5
|
+
import { __ as ye } from "lkt-i18n";
|
|
5
6
|
const q = class q {
|
|
6
7
|
};
|
|
7
8
|
q.debugEnabled = !1;
|
|
8
9
|
let F = q;
|
|
9
10
|
const u = (...l) => {
|
|
10
11
|
F.debugEnabled && console.info("[LktItemCrud] ", ...l);
|
|
11
|
-
},
|
|
12
|
+
}, Je = (l = !0) => {
|
|
12
13
|
F.debugEnabled = l;
|
|
13
14
|
}, j = (l) => {
|
|
14
15
|
u("runModalCallback -> init", l);
|
|
15
|
-
let h = l.modalKey ? l.modalKey : "_",
|
|
16
|
+
let h = l.modalKey ? l.modalKey : "_", B = l.args ? l.args : {};
|
|
16
17
|
switch (l.action) {
|
|
17
18
|
case "reOpen":
|
|
18
|
-
return
|
|
19
|
+
return Se(l.modalName, h, B);
|
|
19
20
|
case "open":
|
|
20
|
-
return
|
|
21
|
+
return De(l.modalName, h, B);
|
|
21
22
|
case "close":
|
|
22
|
-
return
|
|
23
|
+
return Ce(l.modalName, h);
|
|
23
24
|
case "refresh":
|
|
24
|
-
return
|
|
25
|
+
return be(l.modalName, h, B);
|
|
25
26
|
case "exec":
|
|
26
27
|
let e = l.method;
|
|
27
|
-
return e ?
|
|
28
|
+
return e ? ke(l.modalName, h, e, B) : void 0;
|
|
28
29
|
}
|
|
29
|
-
},
|
|
30
|
+
}, ge = { class: "lkt-item-crud" }, Me = {
|
|
30
31
|
key: 0,
|
|
31
32
|
class: "lkt-item-crud_header"
|
|
32
|
-
},
|
|
33
|
+
}, _e = {
|
|
33
34
|
key: 0,
|
|
34
35
|
class: "lkt-item-crud_header-slot"
|
|
35
|
-
},
|
|
36
|
+
}, Be = {
|
|
36
37
|
key: 1,
|
|
38
|
+
class: "lkt-item-crud_header-title"
|
|
39
|
+
}, we = {
|
|
40
|
+
key: 2,
|
|
37
41
|
class: "lkt-item-crud_header-slot"
|
|
38
|
-
},
|
|
42
|
+
}, Ie = { class: "lkt-item-crud-buttons" }, Ee = {
|
|
39
43
|
key: 1,
|
|
40
44
|
class: "lkt-item-crud_content"
|
|
41
|
-
},
|
|
45
|
+
}, Ue = {
|
|
42
46
|
key: 0,
|
|
43
47
|
class: "lkt-grid-1"
|
|
44
|
-
},
|
|
48
|
+
}, Re = /* @__PURE__ */ ve({
|
|
45
49
|
__name: "LktItemCrud",
|
|
46
50
|
props: {
|
|
47
51
|
modelValue: { default: () => ({}) },
|
|
@@ -85,65 +89,65 @@ const u = (...l) => {
|
|
|
85
89
|
editing: { type: Boolean, default: !1 }
|
|
86
90
|
},
|
|
87
91
|
emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
|
|
88
|
-
setup(l, { expose: h, emit:
|
|
89
|
-
const e = l,
|
|
92
|
+
setup(l, { expose: h, emit: B }) {
|
|
93
|
+
const e = l, m = ce(), i = B;
|
|
90
94
|
let ae = [];
|
|
91
|
-
const d =
|
|
92
|
-
u("fetchItem"), d.value = !0,
|
|
95
|
+
const d = s(!0), r = s(e.modelValue), I = s(ae), c = s(e.editing), k = s(!1), D = s(!1), f = s(200), R = s(null), V = s(null), S = s(new ee(r.value, e.dataStateConfig)), J = s(new ee(e.readData)), o = s(e.isCreate), K = s(!1), te = n(() => o.value ? e.createConfirm : e.updateConfirm), le = n(() => o.value ? e.createConfirmData : e.updateConfirmData), H = n(() => o.value ? e.createResource : e.updateResource), oe = n(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = n(() => o.value ? e.createDisabled : e.updateDisabled), y = n(() => !o.value && I.value.includes("update")), g = n(() => !o.value && I.value.includes("drop")), N = async () => {
|
|
96
|
+
u("fetchItem"), d.value = !0, f.value = -1, D.value = !1;
|
|
93
97
|
try {
|
|
94
|
-
const a = await
|
|
95
|
-
if (u("fetchItem -> response", a), d.value = !1,
|
|
96
|
-
k.value = !1,
|
|
98
|
+
const a = await he(e.readResource, e.readData);
|
|
99
|
+
if (u("fetchItem -> response", a), d.value = !1, f.value = a.httpStatus, !a.success) {
|
|
100
|
+
k.value = !1, f.value = a.httpStatus, i("error", a.httpStatus);
|
|
97
101
|
return;
|
|
98
102
|
}
|
|
99
|
-
k.value = !0, r.value = a.data, I.value = a.perms,
|
|
103
|
+
k.value = !0, r.value = a.data, I.value = a.perms, S.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), i("read", a);
|
|
100
104
|
} catch {
|
|
101
|
-
d.value = !1, k.value = !1,
|
|
105
|
+
d.value = !1, k.value = !1, f.value = 404, i("error", 404);
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
|
-
}
|
|
108
|
+
};
|
|
105
109
|
b(() => e.modelValue, (a) => {
|
|
106
|
-
r.value = a,
|
|
110
|
+
r.value = a, S.value.increment(a);
|
|
107
111
|
}, { deep: !0 }), b(r, (a) => {
|
|
108
112
|
if (K.value = !0, u("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
|
|
109
113
|
u("item updated -> has beforeEmitUpdate");
|
|
110
114
|
let t = e.beforeEmitUpdate(r.value);
|
|
111
115
|
u("item updated -> override with: ", t), typeof t == "object" && (r.value = t);
|
|
112
116
|
}
|
|
113
|
-
|
|
114
|
-
}, { deep: !0 }), b(I, () =>
|
|
115
|
-
const
|
|
116
|
-
b(
|
|
117
|
+
i("update:modelValue", r.value), u("item updated -> update dataState"), S.value.increment(a), fe(() => K.value = !1);
|
|
118
|
+
}, { deep: !0 }), b(I, () => i("perms", I.value));
|
|
119
|
+
const P = n(() => ue.value || !o.value && !y.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : S.value.changed());
|
|
120
|
+
b(P, (a) => i("modified-data", a)), b(o, (a) => i("update:isCreate", a)), b(() => e.readData, (a) => {
|
|
117
121
|
J.value.increment(a), J.value.changed() && N();
|
|
118
122
|
}), b(() => e.editing, (a) => {
|
|
119
123
|
u("editing updated -> updating editMode", a), c.value = a;
|
|
120
124
|
}), b(c, (a) => {
|
|
121
|
-
u("editMode updated -> emit update", a),
|
|
125
|
+
u("editMode updated -> emit update", a), i("update:editing", a);
|
|
122
126
|
}), e.readResource && !o.value ? N() : o.value && (k.value = !0, c.value = !0, d.value = !1);
|
|
123
|
-
const
|
|
124
|
-
if (d.value = !1,
|
|
125
|
-
D.value = !0,
|
|
127
|
+
const de = (a, t) => {
|
|
128
|
+
if (d.value = !1, f.value = t.httpStatus, !t.success) {
|
|
129
|
+
D.value = !0, i("error", t.httpStatus);
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
128
|
-
D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((
|
|
129
|
-
j(
|
|
130
|
-
})),
|
|
131
|
-
},
|
|
132
|
-
if (u("onSave -> received response:", t),
|
|
133
|
-
if (d.value = !1,
|
|
134
|
-
D.value = !0,
|
|
132
|
+
D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((M) => {
|
|
133
|
+
j(M);
|
|
134
|
+
})), i("drop", t);
|
|
135
|
+
}, re = (a, t) => {
|
|
136
|
+
if (u("onSave -> received response:", t), i("before-save"), H.value) {
|
|
137
|
+
if (d.value = !1, f.value = t.httpStatus, !t.success) {
|
|
138
|
+
D.value = !0, i("error", t.httpStatus);
|
|
135
139
|
return;
|
|
136
140
|
}
|
|
137
141
|
D.value = !0;
|
|
138
142
|
}
|
|
139
|
-
let
|
|
140
|
-
o.value || (u("onSave -> turn stored data into original"),
|
|
143
|
+
let M = o.value ? "create" : "update";
|
|
144
|
+
o.value || (u("onSave -> turn stored data into original"), S.value.turnStoredIntoOriginal()), M === "create" ? typeof e.onCreate == "function" && (u("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (u("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((E) => {
|
|
141
145
|
j(E);
|
|
142
146
|
}))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((E) => {
|
|
143
147
|
j(E);
|
|
144
|
-
}))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, N()),
|
|
145
|
-
},
|
|
146
|
-
d.value = !0,
|
|
148
|
+
}))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, N()), i(M, t);
|
|
149
|
+
}, W = () => {
|
|
150
|
+
d.value = !0, f.value = -1;
|
|
147
151
|
}, z = () => {
|
|
148
152
|
d.value = !1;
|
|
149
153
|
};
|
|
@@ -154,80 +158,81 @@ const u = (...l) => {
|
|
|
154
158
|
doRefresh: N,
|
|
155
159
|
doSave: () => {
|
|
156
160
|
R.value && typeof R.value.click == "function" && R.value.click();
|
|
157
|
-
}
|
|
161
|
+
},
|
|
162
|
+
hasModifiedData: () => S.value.changed()
|
|
158
163
|
});
|
|
159
|
-
const A =
|
|
164
|
+
const A = n(() => !y.value && g.value ? !0 : !e.hiddenDrop && !d.value && c.value && k.value), G = n(() => S.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && k.value), Q = n(() => e.hideSwitchEdition || !y.value && !g.value || !y.value && g.value ? !1 : !d.value && !o.value && k.value && !(e.dropDisabled && e.updateDisabled)), ne = n(() => !e.hiddenButtons && (G.value || A.value || Q.value)), x = n(() => e.title.startsWith("__:") ? String(ye(e.title.substring(3))) : e.title), ie = n(() => d.value ? !1 : x.value.length > 0 || !!m["post-title"]);
|
|
160
165
|
return (a, t) => {
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
C(
|
|
166
|
+
const M = L("lkt-button"), E = L("lkt-field-switch"), X = L("lkt-http-info"), se = L("lkt-loader");
|
|
167
|
+
return v(), _("article", ge, [
|
|
168
|
+
ie.value ? (v(), _("header", Me, [
|
|
169
|
+
C(m)["pre-title"] ? (v(), _("div", _e, [
|
|
165
170
|
U(a.$slots, "pre-title", {
|
|
166
171
|
item: r.value,
|
|
167
172
|
loading: d.value
|
|
168
173
|
})
|
|
169
|
-
])) :
|
|
170
|
-
|
|
171
|
-
C(
|
|
174
|
+
])) : p("", !0),
|
|
175
|
+
x.value.length > 0 ? (v(), _("h1", Be, pe(x.value), 1)) : p("", !0),
|
|
176
|
+
C(m)["post-title"] ? (v(), _("div", we, [
|
|
172
177
|
U(a.$slots, "post-title", {
|
|
173
178
|
item: r.value,
|
|
174
179
|
loading: d.value
|
|
175
180
|
})
|
|
176
|
-
])) :
|
|
177
|
-
])) :
|
|
178
|
-
O(
|
|
179
|
-
o.value ?
|
|
181
|
+
])) : p("", !0)
|
|
182
|
+
])) : p("", !0),
|
|
183
|
+
O(me("div", Ie, [
|
|
184
|
+
o.value ? p("", !0) : O((v(), T(M, {
|
|
180
185
|
key: 0,
|
|
181
|
-
ref: (
|
|
186
|
+
ref: (w) => V.value = w,
|
|
182
187
|
palette: "danger",
|
|
183
|
-
disabled: a.dropDisabled || !
|
|
188
|
+
disabled: a.dropDisabled || !g.value,
|
|
184
189
|
"confirm-modal": a.dropConfirm,
|
|
185
190
|
"confirm-data": a.dropConfirmData,
|
|
186
191
|
resource: a.dropResource,
|
|
187
192
|
"resource-data": a.dropData,
|
|
188
|
-
text: C(
|
|
189
|
-
icon: C(
|
|
190
|
-
onLoading:
|
|
193
|
+
text: C(m)["button-drop"] ? "" : a.dropText,
|
|
194
|
+
icon: C(m)["button-drop"] ? "" : a.dropIcon,
|
|
195
|
+
onLoading: W,
|
|
191
196
|
onLoaded: z,
|
|
192
|
-
onClick:
|
|
197
|
+
onClick: de
|
|
193
198
|
}, {
|
|
194
199
|
default: Y(() => [
|
|
195
|
-
C(
|
|
200
|
+
C(m)["button-drop"] ? U(a.$slots, "button-drop", {
|
|
196
201
|
key: 0,
|
|
197
202
|
item: r.value,
|
|
198
203
|
editMode: c.value,
|
|
199
204
|
isCreate: o.value,
|
|
200
|
-
canUpdate:
|
|
201
|
-
canDrop:
|
|
202
|
-
}) :
|
|
205
|
+
canUpdate: y.value,
|
|
206
|
+
canDrop: g.value
|
|
207
|
+
}) : p("", !0)
|
|
203
208
|
]),
|
|
204
209
|
_: 3
|
|
205
210
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
|
|
206
211
|
[$, A.value]
|
|
207
212
|
]),
|
|
208
|
-
O(Z(
|
|
209
|
-
ref: (
|
|
213
|
+
O(Z(M, {
|
|
214
|
+
ref: (w) => R.value = w,
|
|
210
215
|
palette: "success",
|
|
211
|
-
disabled: !
|
|
216
|
+
disabled: !P.value,
|
|
212
217
|
"confirm-modal": te.value,
|
|
213
218
|
"confirm-data": le.value,
|
|
214
|
-
resource:
|
|
219
|
+
resource: H.value,
|
|
215
220
|
"resource-data": oe.value,
|
|
216
|
-
text: C(
|
|
217
|
-
icon: C(
|
|
218
|
-
onLoading:
|
|
221
|
+
text: C(m)["button-save"] ? "" : a.saveText,
|
|
222
|
+
icon: C(m)["button-save"] ? "" : a.saveIcon,
|
|
223
|
+
onLoading: W,
|
|
219
224
|
onLoaded: z,
|
|
220
|
-
onClick:
|
|
225
|
+
onClick: re
|
|
221
226
|
}, {
|
|
222
227
|
default: Y(() => [
|
|
223
|
-
C(
|
|
228
|
+
C(m)["button-save"] ? U(a.$slots, "button-save", {
|
|
224
229
|
key: 0,
|
|
225
230
|
item: r.value,
|
|
226
231
|
editMode: c.value,
|
|
227
232
|
isCreate: o.value,
|
|
228
|
-
canUpdate:
|
|
229
|
-
canDrop:
|
|
230
|
-
}) :
|
|
233
|
+
canUpdate: y.value,
|
|
234
|
+
canDrop: g.value
|
|
235
|
+
}) : p("", !0)
|
|
231
236
|
]),
|
|
232
237
|
_: 3
|
|
233
238
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"]), [
|
|
@@ -235,48 +240,48 @@ const u = (...l) => {
|
|
|
235
240
|
]),
|
|
236
241
|
O(Z(E, {
|
|
237
242
|
modelValue: c.value,
|
|
238
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
243
|
+
"onUpdate:modelValue": t[0] || (t[0] = (w) => c.value = w),
|
|
239
244
|
label: a.editModeText
|
|
240
245
|
}, null, 8, ["modelValue", "label"]), [
|
|
241
246
|
[$, Q.value]
|
|
242
247
|
])
|
|
243
248
|
], 512), [
|
|
244
|
-
[$,
|
|
249
|
+
[$, ne.value]
|
|
245
250
|
]),
|
|
246
|
-
d.value ?
|
|
247
|
-
k.value ? (
|
|
248
|
-
D.value ? (
|
|
251
|
+
d.value ? p("", !0) : (v(), _("div", Ee, [
|
|
252
|
+
k.value ? (v(), _("div", Ue, [
|
|
253
|
+
D.value ? (v(), T(X, {
|
|
249
254
|
key: 0,
|
|
250
|
-
code:
|
|
255
|
+
code: f.value,
|
|
251
256
|
quick: "",
|
|
252
|
-
palette:
|
|
257
|
+
palette: f.value === 200 ? "success" : "danger",
|
|
253
258
|
"can-close": "",
|
|
254
|
-
onClose: t[1] || (t[1] = (
|
|
255
|
-
}, null, 8, ["code", "palette"])) :
|
|
259
|
+
onClose: t[1] || (t[1] = (w) => D.value = !1)
|
|
260
|
+
}, null, 8, ["code", "palette"])) : p("", !0),
|
|
256
261
|
U(a.$slots, "item", {
|
|
257
262
|
item: r.value,
|
|
258
263
|
loading: d.value,
|
|
259
264
|
editMode: c.value,
|
|
260
265
|
isCreate: o.value,
|
|
261
|
-
canUpdate:
|
|
262
|
-
canDrop:
|
|
266
|
+
canUpdate: y.value,
|
|
267
|
+
canDrop: g.value,
|
|
263
268
|
itemBeingEdited: K.value
|
|
264
269
|
})
|
|
265
|
-
])) : (
|
|
270
|
+
])) : (v(), T(X, {
|
|
266
271
|
key: 1,
|
|
267
|
-
code:
|
|
272
|
+
code: f.value
|
|
268
273
|
}, null, 8, ["code"]))
|
|
269
274
|
])),
|
|
270
|
-
d.value ? (
|
|
275
|
+
d.value ? (v(), T(se, { key: 2 })) : p("", !0)
|
|
271
276
|
]);
|
|
272
277
|
};
|
|
273
278
|
}
|
|
274
|
-
}),
|
|
279
|
+
}), Ke = {
|
|
275
280
|
install: (l, h = {}) => {
|
|
276
|
-
l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud",
|
|
281
|
+
l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Re);
|
|
277
282
|
}
|
|
278
283
|
};
|
|
279
284
|
export {
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
Je as debugLktItemCrud,
|
|
286
|
+
Ke as default
|
|
282
287
|
};
|
|
@@ -82,6 +82,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
82
82
|
doDrop: () => void;
|
|
83
83
|
doRefresh: () => Promise<void>;
|
|
84
84
|
doSave: () => void;
|
|
85
|
+
hasModifiedData: () => boolean;
|
|
85
86
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
86
87
|
error: (...args: any[]) => void;
|
|
87
88
|
drop: (...args: any[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-item-crud",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/build.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "
|
|
21
|
+
"build": "vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/",
|
|
22
|
+
"rebuild": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
|
|
22
23
|
},
|
|
23
24
|
"author": "Antonio Ibáñez",
|
|
24
25
|
"devDependencies": {
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"lkt-field-switch": "^1.0.0",
|
|
43
44
|
"lkt-http-client": "^1.0.12",
|
|
44
45
|
"lkt-http-info": "^1.0.2",
|
|
46
|
+
"lkt-i18n": "^1.0.4",
|
|
45
47
|
"lkt-loader": "^1.0.2",
|
|
46
48
|
"lkt-modal": "^1.1.1",
|
|
47
49
|
"lkt-string-tools": "^1.0.2",
|
|
@@ -6,6 +6,7 @@ import {debug} from "../functions/debug";
|
|
|
6
6
|
import {LktObject} from "lkt-ts-interfaces";
|
|
7
7
|
import {ModalCallbackConfig} from "../types/ModalCallbackConfig";
|
|
8
8
|
import {runModalCallback} from "../functions/modalCallbacks";
|
|
9
|
+
import {__} from "lkt-i18n";
|
|
9
10
|
|
|
10
11
|
const props = withDefaults(defineProps<{
|
|
11
12
|
modelValue: LktObject
|
|
@@ -37,9 +38,9 @@ const props = withDefaults(defineProps<{
|
|
|
37
38
|
updateDisabled: boolean
|
|
38
39
|
dropDisabled: boolean
|
|
39
40
|
saveValidator: Function
|
|
40
|
-
beforeEmitUpdate: Function|undefined
|
|
41
|
-
onCreate: Function|undefined
|
|
42
|
-
onUpdate: Function|undefined
|
|
41
|
+
beforeEmitUpdate: Function | undefined
|
|
42
|
+
onCreate: Function | undefined
|
|
43
|
+
onUpdate: Function | undefined
|
|
43
44
|
insideModal: boolean
|
|
44
45
|
hideSwitchEdition: boolean
|
|
45
46
|
dataStateConfig: LktObject
|
|
@@ -167,11 +168,6 @@ const fetchItem = async () => {
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
const displayHeader = computed(() => {
|
|
171
|
-
if (isLoading.value) return false;
|
|
172
|
-
|
|
173
|
-
return props.title || !!slots['post-title'];
|
|
174
|
-
})
|
|
175
171
|
|
|
176
172
|
watch(() => props.modelValue, v => {
|
|
177
173
|
item.value = v;
|
|
@@ -316,7 +312,8 @@ const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
|
316
312
|
defineExpose({
|
|
317
313
|
doDrop,
|
|
318
314
|
doRefresh: fetchItem,
|
|
319
|
-
doSave
|
|
315
|
+
doSave,
|
|
316
|
+
hasModifiedData: () => dataState.value.changed()
|
|
320
317
|
});
|
|
321
318
|
|
|
322
319
|
const showDropButton = computed(() => {
|
|
@@ -350,6 +347,17 @@ const showDropButton = computed(() => {
|
|
|
350
347
|
}),
|
|
351
348
|
showButtons = computed(() => {
|
|
352
349
|
return !props.hiddenButtons && (showSaveButton.value || showDropButton.value || showSwitchButton.value);
|
|
350
|
+
}),
|
|
351
|
+
computedTitle = computed(() => {
|
|
352
|
+
if (props.title.startsWith('__:')) {
|
|
353
|
+
return String(__(props.title.substring(3)));
|
|
354
|
+
}
|
|
355
|
+
return props.title;
|
|
356
|
+
}),
|
|
357
|
+
displayHeader = computed(() => {
|
|
358
|
+
if (isLoading.value) return false;
|
|
359
|
+
|
|
360
|
+
return computedTitle.value.length > 0 || !!slots['post-title'];
|
|
353
361
|
});
|
|
354
362
|
</script>
|
|
355
363
|
|
|
@@ -359,7 +367,7 @@ const showDropButton = computed(() => {
|
|
|
359
367
|
<div class="lkt-item-crud_header-slot" v-if="slots['pre-title']">
|
|
360
368
|
<slot name="pre-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
|
|
361
369
|
</div>
|
|
362
|
-
<h1 class="lkt-item-crud_header-title">{{
|
|
370
|
+
<h1 class="lkt-item-crud_header-title" v-if="computedTitle.length > 0">{{ computedTitle }}</h1>
|
|
363
371
|
<div class="lkt-item-crud_header-slot" v-if="slots['post-title']">
|
|
364
372
|
<slot name="post-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
|
|
365
373
|
</div>
|