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