lkt-item-crud 1.1.20 → 1.1.21

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent as ie, useSlots as ce, ref as s, computed as n, watch as B, nextTick as ve, resolveComponent as E, openBlock as v, createElementBlock as y, createElementVNode as J, toDisplayString as K, renderSlot as V, createCommentVNode as U, withDirectives as I, createBlock as N, withCtx as X, unref as Y, vShow as L, createVNode as Z } from "vue";
1
+ import { defineComponent as ie, useSlots as ce, ref as s, computed as n, watch as B, nextTick as ve, resolveComponent as E, openBlock as v, createElementBlock as M, createElementVNode as J, toDisplayString as K, renderSlot as V, createCommentVNode as U, withDirectives as I, createBlock as N, withCtx as X, unref as Y, vShow as L, createVNode as Z } from "vue";
2
2
  import { httpCall as fe } from "lkt-http-client";
3
3
  import { DataState as pe } from "lkt-data-state";
4
4
  import { execModal as me, refreshModal as he, closeModal as ke, openModal as Ce, reOpenModal as be } from "lkt-modal";
@@ -78,7 +78,7 @@ const r = (...l) => {
78
78
  setup(l, { expose: f, emit: D }) {
79
79
  const e = l, T = ce(), i = D;
80
80
  let ee = [];
81
- const d = s(!0), u = s(e.modelValue), M = s(ee), p = s(!1), m = s(!1), h = s(!1), c = s(200), w = s(null), R = s(null), _ = s(new pe(u.value, e.dataStateConfig)), o = s(e.isCreate), $ = s(!1), ae = n(() => o.value ? e.createConfirm : e.updateConfirm), te = n(() => o.value ? e.createConfirmData : e.updateConfirmData), H = n(() => o.value ? e.createResource : e.updateResource), le = n(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(u.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(u.value)) }), oe = n(() => o.value ? e.createDisabled : e.updateDisabled), k = n(() => !o.value && M.value.includes("update")), C = n(() => !o.value && M.value.includes("drop")), F = async () => {
81
+ const d = s(!0), u = s(e.modelValue), _ = s(ee), p = s(!1), m = s(!1), h = s(!1), c = s(200), w = s(null), R = s(null), S = s(new pe(u.value, e.dataStateConfig)), o = s(e.isCreate), $ = s(!1), ae = n(() => o.value ? e.createConfirm : e.updateConfirm), te = n(() => o.value ? e.createConfirmData : e.updateConfirmData), H = n(() => o.value ? e.createResource : e.updateResource), le = n(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(u.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(u.value)) }), oe = n(() => o.value ? e.createDisabled : e.updateDisabled), k = n(() => !o.value && _.value.includes("update")), C = n(() => !o.value && _.value.includes("drop")), F = async () => {
82
82
  r("fetchItem"), d.value = !0, c.value = -1, h.value = !1;
83
83
  try {
84
84
  const a = await fe(e.readResource, e.readData);
@@ -86,23 +86,23 @@ const r = (...l) => {
86
86
  m.value = !1, c.value = a.httpStatus, i("error", a.httpStatus);
87
87
  return;
88
88
  }
89
- m.value = !0, u.value = a.data, M.value = a.perms, _.value.increment(u.value).turnStoredIntoOriginal(), i("read", a);
89
+ m.value = !0, u.value = a.data, _.value = a.perms, S.value.increment(u.value).turnStoredIntoOriginal(), i("read", a);
90
90
  } catch {
91
91
  d.value = !1, m.value = !1, c.value = 404, i("error", 404);
92
92
  return;
93
93
  }
94
94
  }, ue = n(() => d.value ? !1 : e.title || !!T["post-title"]);
95
95
  B(() => e.modelValue, (a) => {
96
- u.value = a, _.value.increment(a);
96
+ u.value = a, S.value.increment(a);
97
97
  }, { deep: !0 }), B(u, (a) => {
98
98
  if ($.value = !0, r("item updated ->", u.value), typeof e.beforeEmitUpdate == "function") {
99
99
  r("item updated -> has beforeEmitUpdate");
100
100
  let t = e.beforeEmitUpdate(u.value);
101
101
  r("item updated -> override with: ", t), typeof t == "object" && (u.value = t);
102
102
  }
103
- i("update:modelValue", u.value), r("item updated -> update dataState"), _.value.increment(a), ve(() => $.value = !1);
104
- }, { deep: !0 }), B(M, () => i("perms", M.value));
105
- const P = n(() => oe.value || !o.value && !k.value || typeof e.saveValidator == "function" && !e.saveValidator(u.value) ? !1 : _.value.changed());
103
+ i("update:modelValue", u.value), r("item updated -> update dataState"), S.value.increment(a), ve(() => $.value = !1);
104
+ }, { deep: !0 }), B(_, () => i("perms", _.value));
105
+ const P = n(() => oe.value || !o.value && !k.value || typeof e.saveValidator == "function" && !e.saveValidator(u.value) ? !1 : S.value.changed());
106
106
  B(P, (a) => i("modified-data", a)), B(o, (a) => i("update:isCreate", a)), e.readResource && !o.value ? F() : o.value && (m.value = !0, p.value = !0, d.value = !1);
107
107
  const de = (a, t) => {
108
108
  if (d.value = !1, c.value = t.httpStatus, !t.success) {
@@ -121,7 +121,7 @@ const r = (...l) => {
121
121
  h.value = !0;
122
122
  }
123
123
  let b = o.value ? "create" : "update";
124
- o.value || (r("onSave -> turn stored data into original"), _.value.turnStoredIntoOriginal()), b === "create" ? typeof e.onCreate == "function" && (r("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (r("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((g) => {
124
+ o.value || (r("onSave -> turn stored data into original"), S.value.turnStoredIntoOriginal()), b === "create" ? typeof e.onCreate == "function" && (r("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (r("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((g) => {
125
125
  j(g);
126
126
  }))) : typeof e.onUpdate == "function" && (r("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (r("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((g) => {
127
127
  j(g);
@@ -140,11 +140,11 @@ const r = (...l) => {
140
140
  w.value && typeof w.value.click == "function" && w.value.click();
141
141
  }
142
142
  });
143
- const A = n(() => !k.value && C.value ? !0 : !e.hiddenDrop && !d.value && p.value && m.value), G = n(() => d.value ? !1 : o.value ? !0 : !e.hiddenSave && p.value && m.value), Q = n(() => !k.value && !C.value || !k.value && C.value ? !1 : !d.value && !o.value && m.value && !(e.dropDisabled && e.updateDisabled)), ne = n(() => !e.hiddenButtons && (G.value || A.value || Q.value));
143
+ const A = n(() => !k.value && C.value ? !0 : !e.hiddenDrop && !d.value && p.value && m.value), G = n(() => S.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && p.value && m.value), Q = n(() => !k.value && !C.value || !k.value && C.value ? !1 : !d.value && !o.value && m.value && !(e.dropDisabled && e.updateDisabled)), ne = n(() => !e.hiddenButtons && (G.value || A.value || Q.value));
144
144
  return n(() => u), (a, t) => {
145
145
  const b = E("lkt-button"), g = E("lkt-field-switch"), W = E("lkt-http-info"), se = E("lkt-loader");
146
- return v(), y("article", De, [
147
- ue.value ? (v(), y("header", Se, [
146
+ return v(), M("article", De, [
147
+ ue.value ? (v(), M("header", Se, [
148
148
  J("h1", ye, K(a.title), 1),
149
149
  J("div", Me, [
150
150
  V(a.$slots, "post-title", {
@@ -156,7 +156,7 @@ const r = (...l) => {
156
156
  I(J("div", _e, [
157
157
  o.value ? U("", !0) : I((v(), N(b, {
158
158
  key: 0,
159
- ref: (S) => R.value = S,
159
+ ref: (y) => R.value = y,
160
160
  palette: "danger",
161
161
  disabled: a.dropDisabled || !C.value,
162
162
  "confirm-modal": a.dropConfirm,
@@ -175,14 +175,14 @@ const r = (...l) => {
175
175
  isCreate: o.value,
176
176
  canUpdate: k.value,
177
177
  canDrop: C.value
178
- }) : (v(), y("span", ge, K(a.dropText), 1))
178
+ }) : (v(), M("span", ge, K(a.dropText), 1))
179
179
  ]),
180
180
  _: 3
181
181
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"])), [
182
182
  [L, A.value]
183
183
  ]),
184
184
  I(Z(b, {
185
- ref: (S) => w.value = S,
185
+ ref: (y) => w.value = y,
186
186
  palette: "success",
187
187
  disabled: !P.value,
188
188
  "confirm-modal": ae.value,
@@ -201,7 +201,7 @@ const r = (...l) => {
201
201
  isCreate: o.value,
202
202
  canUpdate: k.value,
203
203
  canDrop: C.value
204
- }) : (v(), y("span", Be, K(a.saveText), 1))
204
+ }) : (v(), M("span", Be, K(a.saveText), 1))
205
205
  ]),
206
206
  _: 3
207
207
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
@@ -209,7 +209,7 @@ const r = (...l) => {
209
209
  ]),
210
210
  I(Z(g, {
211
211
  modelValue: p.value,
212
- "onUpdate:modelValue": t[0] || (t[0] = (S) => p.value = S),
212
+ "onUpdate:modelValue": t[0] || (t[0] = (y) => p.value = y),
213
213
  label: a.editModeText
214
214
  }, null, 8, ["modelValue", "label"]), [
215
215
  [L, Q.value]
@@ -217,15 +217,15 @@ const r = (...l) => {
217
217
  ], 512), [
218
218
  [L, ne.value]
219
219
  ]),
220
- d.value ? U("", !0) : (v(), y("div", Ue, [
221
- m.value ? (v(), y("div", we, [
220
+ d.value ? U("", !0) : (v(), M("div", Ue, [
221
+ m.value ? (v(), M("div", we, [
222
222
  h.value ? (v(), N(W, {
223
223
  key: 0,
224
224
  code: c.value,
225
225
  quick: "",
226
226
  palette: c.value === 200 ? "success" : "danger",
227
227
  "can-close": "",
228
- onClose: t[1] || (t[1] = (S) => h.value = !1)
228
+ onClose: t[1] || (t[1] = (y) => h.value = !1)
229
229
  }, null, 8, ["code", "palette"])) : U("", !0),
230
230
  V(a.$slots, "item", {
231
231
  item: u.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -305,6 +305,8 @@ const showDropButton = computed(() => {
305
305
  && httpSuccessRead.value;
306
306
  }),
307
307
  showSaveButton = computed(() => {
308
+
309
+ if (dataState.value.changed()) return true;
308
310
  if (isLoading.value) return false;
309
311
 
310
312
  if (createMode.value) return true;
@@ -324,9 +326,6 @@ const showDropButton = computed(() => {
324
326
  }),
325
327
  showButtons = computed(() => {
326
328
  return !props.hiddenButtons && (showSaveButton.value || showDropButton.value || showSwitchButton.value);
327
- }),
328
- computedItem = computed(() => {
329
- return item;
330
329
  });
331
330
  </script>
332
331