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 CHANGED
@@ -1,5 +1,5 @@
1
- declare function Te(l?: boolean): void;
2
- declare namespace $e {
1
+ declare function Je(l?: boolean): void;
2
+ declare namespace Ke {
3
3
  function install(l: any, h?: {}): void;
4
4
  }
5
- export { Te as debugLktItemCrud, $e as default };
5
+ export { Je as debugLktItemCrud, Ke as default };
package/dist/build.js CHANGED
@@ -1,47 +1,51 @@
1
- import { defineComponent as ce, useSlots as ve, ref as i, computed as s, watch as b, nextTick as fe, resolveComponent as L, openBlock as f, createElementBlock as w, unref as C, renderSlot as U, createCommentVNode as m, createElementVNode as X, toDisplayString as pe, withDirectives as O, createBlock as T, withCtx as Y, vShow as $, createVNode as Z } from "vue";
2
- import { httpCall as me } from "lkt-http-client";
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 he, refreshModal as ke, closeModal as be, openModal as Ce, reOpenModal as De } from "lkt-modal";
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
- }, Te = (l = !0) => {
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 : "_", M = l.args ? l.args : {};
16
+ let h = l.modalKey ? l.modalKey : "_", B = l.args ? l.args : {};
16
17
  switch (l.action) {
17
18
  case "reOpen":
18
- return De(l.modalName, h, M);
19
+ return Se(l.modalName, h, B);
19
20
  case "open":
20
- return Ce(l.modalName, h, M);
21
+ return De(l.modalName, h, B);
21
22
  case "close":
22
- return be(l.modalName, h);
23
+ return Ce(l.modalName, h);
23
24
  case "refresh":
24
- return ke(l.modalName, h, M);
25
+ return be(l.modalName, h, B);
25
26
  case "exec":
26
27
  let e = l.method;
27
- return e ? he(l.modalName, h, e, M) : void 0;
28
+ return e ? ke(l.modalName, h, e, B) : void 0;
28
29
  }
29
- }, Se = { class: "lkt-item-crud" }, ye = {
30
+ }, ge = { class: "lkt-item-crud" }, Me = {
30
31
  key: 0,
31
32
  class: "lkt-item-crud_header"
32
- }, ge = {
33
+ }, _e = {
33
34
  key: 0,
34
35
  class: "lkt-item-crud_header-slot"
35
- }, Me = { class: "lkt-item-crud_header-title" }, Be = {
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
- }, _e = { class: "lkt-item-crud-buttons" }, we = {
42
+ }, Ie = { class: "lkt-item-crud-buttons" }, Ee = {
39
43
  key: 1,
40
44
  class: "lkt-item-crud_content"
41
- }, Ie = {
45
+ }, Ue = {
42
46
  key: 0,
43
47
  class: "lkt-grid-1"
44
- }, Ee = /* @__PURE__ */ ce({
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: M }) {
89
- const e = l, p = ve(), n = M;
92
+ setup(l, { expose: h, emit: B }) {
93
+ const e = l, m = ce(), i = B;
90
94
  let ae = [];
91
- const d = i(!0), r = i(e.modelValue), I = i(ae), c = i(e.editing), k = i(!1), D = i(!1), v = i(200), R = i(null), V = i(null), B = i(new ee(r.value, e.dataStateConfig)), J = i(new ee(e.readData)), o = i(e.isCreate), K = i(!1), te = s(() => o.value ? e.createConfirm : e.updateConfirm), le = s(() => o.value ? e.createConfirmData : e.updateConfirmData), x = s(() => o.value ? e.createResource : e.updateResource), oe = s(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = s(() => o.value ? e.createDisabled : e.updateDisabled), S = s(() => !o.value && I.value.includes("update")), y = s(() => !o.value && I.value.includes("drop")), N = async () => {
92
- u("fetchItem"), d.value = !0, v.value = -1, D.value = !1;
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 me(e.readResource, e.readData);
95
- if (u("fetchItem -> response", a), d.value = !1, v.value = a.httpStatus, !a.success) {
96
- k.value = !1, v.value = a.httpStatus, n("error", a.httpStatus);
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, B.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), n("read", a);
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, v.value = 404, n("error", 404);
105
+ d.value = !1, k.value = !1, f.value = 404, i("error", 404);
102
106
  return;
103
107
  }
104
- }, de = s(() => d.value ? !1 : e.title || !!p["post-title"]);
108
+ };
105
109
  b(() => e.modelValue, (a) => {
106
- r.value = a, B.value.increment(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
- n("update:modelValue", r.value), u("item updated -> update dataState"), B.value.increment(a), fe(() => K.value = !1);
114
- }, { deep: !0 }), b(I, () => n("perms", I.value));
115
- const H = s(() => ue.value || !o.value && !S.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : B.value.changed());
116
- b(H, (a) => n("modified-data", a)), b(o, (a) => n("update:isCreate", a)), b(() => e.readData, (a) => {
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), n("update:editing", 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 re = (a, t) => {
124
- if (d.value = !1, v.value = t.httpStatus, !t.success) {
125
- D.value = !0, n("error", t.httpStatus);
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((g) => {
129
- j(g);
130
- })), n("drop", t);
131
- }, ne = (a, t) => {
132
- if (u("onSave -> received response:", t), n("before-save"), x.value) {
133
- if (d.value = !1, v.value = t.httpStatus, !t.success) {
134
- D.value = !0, n("error", t.httpStatus);
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 g = o.value ? "create" : "update";
140
- 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) => {
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()), n(g, t);
145
- }, P = () => {
146
- d.value = !0, v.value = -1;
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 = s(() => !S.value && y.value ? !0 : !e.hiddenDrop && !d.value && c.value && k.value), G = s(() => B.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && k.value), Q = s(() => e.hideSwitchEdition || !S.value && !y.value || !S.value && y.value ? !1 : !d.value && !o.value && k.value && !(e.dropDisabled && e.updateDisabled)), ie = s(() => !e.hiddenButtons && (G.value || A.value || Q.value));
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 g = L("lkt-button"), E = L("lkt-field-switch"), W = L("lkt-http-info"), se = L("lkt-loader");
162
- return f(), w("article", Se, [
163
- de.value ? (f(), w("header", ye, [
164
- C(p)["pre-title"] ? (f(), w("div", ge, [
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
- ])) : m("", !0),
170
- X("h1", Me, pe(a.title), 1),
171
- C(p)["post-title"] ? (f(), w("div", Be, [
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
- ])) : m("", !0)
177
- ])) : m("", !0),
178
- O(X("div", _e, [
179
- o.value ? m("", !0) : O((f(), T(g, {
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: (_) => V.value = _,
186
+ ref: (w) => V.value = w,
182
187
  palette: "danger",
183
- disabled: a.dropDisabled || !y.value,
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(p)["button-drop"] ? "" : a.dropText,
189
- icon: C(p)["button-drop"] ? "" : a.dropIcon,
190
- onLoading: P,
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: re
197
+ onClick: de
193
198
  }, {
194
199
  default: Y(() => [
195
- C(p)["button-drop"] ? U(a.$slots, "button-drop", {
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: S.value,
201
- canDrop: y.value
202
- }) : m("", !0)
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(g, {
209
- ref: (_) => R.value = _,
213
+ O(Z(M, {
214
+ ref: (w) => R.value = w,
210
215
  palette: "success",
211
- disabled: !H.value,
216
+ disabled: !P.value,
212
217
  "confirm-modal": te.value,
213
218
  "confirm-data": le.value,
214
- resource: x.value,
219
+ resource: H.value,
215
220
  "resource-data": oe.value,
216
- text: C(p)["button-save"] ? "" : a.saveText,
217
- icon: C(p)["button-save"] ? "" : a.saveIcon,
218
- onLoading: P,
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: ne
225
+ onClick: re
221
226
  }, {
222
227
  default: Y(() => [
223
- C(p)["button-save"] ? U(a.$slots, "button-save", {
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: S.value,
229
- canDrop: y.value
230
- }) : m("", !0)
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] = (_) => c.value = _),
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
- [$, ie.value]
249
+ [$, ne.value]
245
250
  ]),
246
- d.value ? m("", !0) : (f(), w("div", we, [
247
- k.value ? (f(), w("div", Ie, [
248
- D.value ? (f(), T(W, {
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: v.value,
255
+ code: f.value,
251
256
  quick: "",
252
- palette: v.value === 200 ? "success" : "danger",
257
+ palette: f.value === 200 ? "success" : "danger",
253
258
  "can-close": "",
254
- onClose: t[1] || (t[1] = (_) => D.value = !1)
255
- }, null, 8, ["code", "palette"])) : m("", !0),
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: S.value,
262
- canDrop: y.value,
266
+ canUpdate: y.value,
267
+ canDrop: g.value,
263
268
  itemBeingEdited: K.value
264
269
  })
265
- ])) : (f(), T(W, {
270
+ ])) : (v(), T(X, {
266
271
  key: 1,
267
- code: v.value
272
+ code: f.value
268
273
  }, null, 8, ["code"]))
269
274
  ])),
270
- d.value ? (f(), T(se, { key: 2 })) : m("", !0)
275
+ d.value ? (v(), T(se, { key: 2 })) : p("", !0)
271
276
  ]);
272
277
  };
273
278
  }
274
- }), $e = {
279
+ }), Ke = {
275
280
  install: (l, h = {}) => {
276
- l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Ee);
281
+ l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Re);
277
282
  }
278
283
  };
279
284
  export {
280
- Te as debugLktItemCrud,
281
- $e as default
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.26",
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": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
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">{{ title }}</h1>
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>