lkt-item-crud 2.0.12 → 2.0.13

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.
@@ -1,12 +1,4 @@
1
- import { SetupContext } from 'vue';
2
- import { HTTPResponse } from 'lkt-http-client';
3
1
  import { ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, NotificationType } from 'lkt-vue-kernel';
4
- import ButtonNav from '../components/ButtonNav.vue';
5
- declare const slots: SetupContext['slots'];
6
- declare const isLoading: import("vue").Ref<boolean, boolean>, item: import("vue").Ref<LktObject, LktObject>, perms: import("vue").Ref<string[], string[]>, editMode: import("vue").Ref<boolean, boolean>, httpSuccessRead: import("vue").Ref<boolean, boolean>, showStoreMessage: import("vue").Ref<boolean, boolean>, httpStatus: import("vue").Ref<number, number>, dataChanged: import("vue").Ref<boolean, boolean>, createMode: import("vue").Ref<boolean, boolean>, itemBeingEdited: import("vue").Ref<boolean, boolean>, buttonNav: import("vue").Ref<null, null>, canUpdate: import("vue").ComputedRef<boolean>, canDrop: import("vue").ComputedRef<boolean>, canSwitchEditMode: import("vue").ComputedRef<boolean>;
7
- declare const onCreate: ($event: PointerEvent, r: HTTPResponse) => void, onUpdate: ($event: PointerEvent, r: HTTPResponse) => void, onDrop: ($event: PointerEvent, r: HTTPResponse) => void;
8
- declare const computedTitle: import("vue").ComputedRef<string>, displayHeader: import("vue").ComputedRef<boolean>, computedInsideModal: import("vue").ComputedRef<boolean>, computedContainerTag: import("vue").ComputedRef<"lkt-modal" | "section">, computedContainerAttrs: import("vue").ComputedRef<{}>;
9
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
10
2
  declare var __VLS_6: {
11
3
  item: LktObject;
12
4
  loading: boolean;
@@ -31,7 +23,7 @@ declare var __VLS_6: {
31
23
  itemBeingEdited: boolean;
32
24
  perms: string[];
33
25
  }, __VLS_54: {}, __VLS_56: {};
34
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
26
+ type __VLS_Slots = {} & {
35
27
  'pre-title'?: (props: typeof __VLS_6) => any;
36
28
  } & {
37
29
  'post-title'?: (props: typeof __VLS_8) => any;
@@ -45,82 +37,12 @@ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$
45
37
  'prev-buttons-ever'?: (props: typeof __VLS_54) => any;
46
38
  } & {
47
39
  'prev-buttons'?: (props: typeof __VLS_56) => any;
48
- }>;
49
- declare const __VLS_self: import("vue").DefineComponent<ItemCrudConfig, {
50
- ItemCrudButtonNavPosition: typeof ItemCrudButtonNavPosition;
51
- NotificationType: typeof NotificationType;
52
- ButtonNav: typeof ButtonNav;
53
- slots: typeof slots;
54
- isLoading: typeof isLoading;
55
- item: typeof item;
56
- perms: typeof perms;
57
- editMode: typeof editMode;
58
- httpSuccessRead: typeof httpSuccessRead;
59
- showStoreMessage: typeof showStoreMessage;
60
- httpStatus: typeof httpStatus;
61
- dataChanged: typeof dataChanged;
62
- createMode: typeof createMode;
63
- itemBeingEdited: typeof itemBeingEdited;
64
- buttonNav: typeof buttonNav;
65
- canUpdate: typeof canUpdate;
66
- canDrop: typeof canDrop;
67
- canSwitchEditMode: typeof canSwitchEditMode;
68
- onCreate: typeof onCreate;
69
- onUpdate: typeof onUpdate;
70
- onDrop: typeof onDrop;
71
- computedTitle: typeof computedTitle;
72
- displayHeader: typeof displayHeader;
73
- computedInsideModal: typeof computedInsideModal;
74
- computedContainerTag: typeof computedContainerTag;
75
- computedContainerAttrs: typeof computedContainerAttrs;
76
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
77
- error: (...args: any[]) => void;
78
- drop: (...args: any[]) => void;
79
- update: (...args: any[]) => void;
80
- create: (...args: any[]) => void;
81
- read: (...args: any[]) => void;
82
- perms: (...args: any[]) => void;
83
- "update:editing": (...args: any[]) => void;
84
- "update:modelValue": (...args: any[]) => void;
85
- "before-save": (...args: any[]) => void;
86
- "modified-data": (...args: any[]) => void;
87
- }, string, import("vue").PublicProps, Readonly<ItemCrudConfig> & Readonly<{
88
- onError?: ((...args: any[]) => any) | undefined;
89
- onDrop?: ((...args: any[]) => any) | undefined;
90
- onUpdate?: ((...args: any[]) => any) | undefined;
91
- onCreate?: ((...args: any[]) => any) | undefined;
92
- onRead?: ((...args: any[]) => any) | undefined;
93
- onPerms?: ((...args: any[]) => any) | undefined;
94
- "onUpdate:editing"?: ((...args: any[]) => any) | undefined;
95
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
96
- "onBefore-save"?: ((...args: any[]) => any) | undefined;
97
- "onModified-data"?: ((...args: any[]) => any) | undefined;
98
- }>, {
99
- view: ItemCrudView;
100
- title: string;
101
- mode: ItemCrudMode;
102
- modelValue: LktObject;
103
- editing: boolean;
104
- perms: import("lkt-vue-kernel").ValidTablePermission[];
105
- editModeButton: import("lkt-vue-kernel").ButtonConfig | false;
106
- dropButton: import("lkt-vue-kernel").ButtonConfig | false;
107
- createButton: import("lkt-vue-kernel").ButtonConfig | false;
108
- updateButton: import("lkt-vue-kernel").ButtonConfig | false;
109
- groupButton: import("lkt-vue-kernel").ButtonConfig | boolean;
110
- buttonNavPosition: ItemCrudButtonNavPosition;
111
- buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
112
- modalConfig: import("lkt-vue-kernel").ModalConfig;
113
- saveConfig: import("lkt-vue-kernel").SaveConfig;
114
- dataStateConfig: import("lkt-data-state").DataStateConfig;
115
- readResource: string;
116
- readData: LktObject;
117
- beforeEmitUpdate: Function;
118
- notificationType: NotificationType;
119
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
+ };
120
41
  declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
121
42
  doDrop: () => void;
122
43
  doRefresh: () => Promise<void>;
123
44
  doSave: () => void;
45
+ turnStoredDataIntoOriginal: () => void;
124
46
  hasModifiedData: () => boolean;
125
47
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
126
48
  error: (...args: any[]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -316,7 +316,7 @@
316
316
  :edit-mode="isEditing"
317
317
  :is-create="true"
318
318
  :can-update="canUpdate"
319
- :can-drop="canDrop" />
319
+ :can-drop="false" />
320
320
  </lkt-button>
321
321
 
322
322
  <lkt-button
@@ -17,7 +17,7 @@
17
17
  ToastConfig,
18
18
  ToastPositionX,
19
19
  } from 'lkt-vue-kernel';
20
- import { closeModal } from 'lkt-modal';
20
+ import { closeModal, updateModalKey } from 'lkt-modal';
21
21
  import { __ } from 'lkt-i18n';
22
22
  import ButtonNav from '../components/ButtonNav.vue';
23
23
  import { openToast } from 'lkt-toast';
@@ -61,6 +61,10 @@
61
61
  canDrop = computed(() => !createMode.value && Array.isArray(perms.value) && perms.value.includes(TablePermission.Drop)),
62
62
  canSwitchEditMode = computed(() => !createMode.value && Array.isArray(perms.value) && perms.value.includes(TablePermission.SwitchEditMode));
63
63
 
64
+ watch(() => props.mode, (v) => {
65
+ createMode.value = v === ItemCrudMode.Create;
66
+ })
67
+
64
68
  const fetchItem = async () => {
65
69
  debug('fetchItem');
66
70
  isLoading.value = true;
@@ -172,12 +176,19 @@
172
176
  return true;
173
177
  },
174
178
  doAutoReloadId = (r?: HTTPResponse) => {
175
- if (!computedInsideModal.value && typeof r !== 'undefined' && r.autoReloadId) {
179
+ debug('doAutoReloadId -> enter: ', r);
180
+ if (typeof r !== 'undefined' && r.autoReloadId) {
176
181
  debug('doAutoReloadId -> autoReloadId detected: ', r.autoReloadId);
177
- props.readData['id'] = r.autoReloadId;
178
- debug('doAutoReloadId -> turning off create mode');
179
- createMode.value = false;
180
- fetchItem();
182
+ if (!computedInsideModal.value) {
183
+ debug('doAutoReloadId -> outsideModal');
184
+ props.readData['id'] = r.autoReloadId;
185
+ debug('doAutoReloadId -> turning off create mode');
186
+ createMode.value = false;
187
+ fetchItem();
188
+ } else {
189
+ debug('doAutoReloadId -> insideModal: ', props);
190
+ updateModalKey(props.modalConfig.modalName, props.modalConfig.modalKey, r.autoReloadId);
191
+ }
181
192
  }
182
193
  },
183
194
  onCreate = ($event: PointerEvent, r: HTTPResponse) => {
@@ -205,6 +216,7 @@
205
216
  });
206
217
  }
207
218
  doAutoReloadId(r);
219
+ debug('onCreate -> beforeEmitCreate');
208
220
  emit('create', r);
209
221
  },
210
222
  onUpdate = ($event: PointerEvent, r: HTTPResponse) => {
@@ -274,6 +286,9 @@
274
286
  doDrop,
275
287
  doRefresh: fetchItem,
276
288
  doSave,
289
+ turnStoredDataIntoOriginal: () => {
290
+ dataState.value.increment(item.value).turnStoredIntoOriginal();
291
+ },
277
292
  hasModifiedData: () => dataState.value.changed(),
278
293
  });
279
294