lkt-item-crud 2.0.22 → 2.0.24

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.
@@ -21,7 +21,7 @@ declare var __VLS_17: {
21
21
  canUpdate: boolean | undefined;
22
22
  canDrop: boolean | undefined;
23
23
  perms: string[] | undefined;
24
- }, __VLS_52: {
24
+ }, __VLS_55: string, __VLS_56: {}, __VLS_58: {
25
25
  item: LktObject;
26
26
  loading: false;
27
27
  editMode: boolean;
@@ -30,8 +30,10 @@ declare var __VLS_17: {
30
30
  canDrop: boolean;
31
31
  itemBeingEdited: boolean;
32
32
  perms: string[];
33
- }, __VLS_73: {}, __VLS_75: {};
33
+ }, __VLS_79: {}, __VLS_81: {};
34
34
  type __VLS_Slots = {} & {
35
+ [K in NonNullable<typeof __VLS_55>]?: (props: typeof __VLS_56) => any;
36
+ } & {
35
37
  'prev-buttons-ever'?: (props: typeof __VLS_17) => any;
36
38
  } & {
37
39
  'prev-buttons'?: (props: typeof __VLS_19) => any;
@@ -44,11 +46,11 @@ type __VLS_Slots = {} & {
44
46
  } & {
45
47
  'prev-buttons'?: (props: typeof __VLS_38) => any;
46
48
  } & {
47
- item?: (props: typeof __VLS_52) => any;
49
+ item?: (props: typeof __VLS_58) => any;
48
50
  } & {
49
- 'prev-buttons-ever'?: (props: typeof __VLS_73) => any;
51
+ 'prev-buttons-ever'?: (props: typeof __VLS_79) => any;
50
52
  } & {
51
- 'prev-buttons'?: (props: typeof __VLS_75) => any;
53
+ 'prev-buttons'?: (props: typeof __VLS_81) => any;
52
54
  };
53
55
  declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
54
56
  doDrop: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "2.0.22",
3
+ "version": "2.0.24",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -7,7 +7,7 @@
7
7
  ButtonConfig,
8
8
  ensureButtonConfig, FormUiConfig,
9
9
  getDefaultValues,
10
- getFormDataState,
10
+ getFormDataState, getFormSlotKeys,
11
11
  ItemCrud,
12
12
  ItemCrudButtonNavPosition,
13
13
  ItemCrudConfig,
@@ -74,6 +74,7 @@
74
74
  itemBeingEdited = ref(false),
75
75
  itemCreated = ref(false),
76
76
  buttonNav = ref(null),
77
+ formRef = ref(null),
77
78
  canUpdate = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Update)),
78
79
  canDrop = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Drop)),
79
80
  canSwitchEditMode = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.SwitchEditMode));
@@ -176,6 +177,13 @@
176
177
  pickedModificationView.value = ModificationView.Modifications;
177
178
  }
178
179
 
180
+ if (computedHasForm.value) {
181
+ resetFormDifferencesChecker();
182
+ nextTick(() => {
183
+ formRef.value.turnStoredIntoOriginal();
184
+ })
185
+ }
186
+
179
187
  if (typeof props.events?.httpEnd === 'function') {
180
188
  props.events.httpEnd({
181
189
  httpResponse: r,
@@ -320,6 +328,7 @@
320
328
  itemCreated.value = true;
321
329
  debug('onCreate -> turn stored data into original');
322
330
  dataState.value.increment(item.value).turnStoredIntoOriginal();
331
+ modificationsDataState.value.turnStoredIntoOriginal();
323
332
  if (props.notificationType === NotificationType.Toast) {
324
333
  openToast(<ToastConfig>{
325
334
  text: LktSettings.defaultCreateSuccessText,
@@ -347,6 +356,7 @@
347
356
  }
348
357
  debug('onUpdate -> turn stored data into original');
349
358
  dataState.value.turnStoredIntoOriginal();
359
+ modificationsDataState.value.turnStoredIntoOriginal();
350
360
  if (props.notificationType === NotificationType.Toast) {
351
361
  openToast(<ToastConfig>{
352
362
  text: LktSettings.defaultUpdateSuccessText,
@@ -453,7 +463,7 @@
453
463
  ableToUpdate = computed(() => {
454
464
  if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
455
465
  if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
456
- if (computedHasForm.value && !validForm.value) return false;
466
+ if (computedHasForm.value && (!validForm.value || !changedForm.value)) return false;
457
467
 
458
468
  if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled({
459
469
  prop: item.value
@@ -465,7 +475,7 @@
465
475
  ableToCreate = computed(() => {
466
476
  if (props.mode !== ItemCrudMode.Create) return false;
467
477
  if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
468
- if (computedHasForm.value && !validForm.value) return false;
478
+ if (computedHasForm.value && !validForm.value && !changedForm.value) return false;
469
479
 
470
480
  if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled({
471
481
  prop: item.value
@@ -520,6 +530,13 @@
520
530
  const computedHasButtons = computed(() => {
521
531
  return createMode.value || canUpdate.value || canDrop.value;
522
532
  })
533
+
534
+ const computedFormSlots = computed(() => {
535
+ if (computedHasForm.value) {
536
+ return getFormSlotKeys(props.form);
537
+ }
538
+ return [];
539
+ })
523
540
  </script>
524
541
 
525
542
  <template>
@@ -651,6 +668,7 @@
651
668
 
652
669
  <template v-if="computedHasForm">
653
670
  <lkt-form
671
+ ref="formRef"
654
672
  v-model="item"
655
673
  v-model:modifications="itemModifications"
656
674
  v-model:valid="validForm"
@@ -664,7 +682,11 @@
664
682
  editableViews: [computedEditableView],
665
683
  disabled: !editMode,
666
684
  }"
667
- />
685
+ >
686
+ <template v-for="formSlot in computedFormSlots" v-slot:[formSlot]="{}">
687
+ <slot :name="formSlot"/>
688
+ </template>
689
+ </lkt-form>
668
690
  </template>
669
691
 
670
692
  <template v-else>