lkt-item-crud 2.0.35 → 2.0.36

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,4 +1,4 @@
1
- import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudView, LktObject, ModificationView } from 'lkt-vue-kernel';
1
+ import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudSaveConfig, ItemCrudView, LktObject, ModificationView } from 'lkt-vue-kernel';
2
2
  type __VLS_Props = {
3
3
  item: LktObject;
4
4
  modifications: LktObject;
@@ -33,6 +33,7 @@ type __VLS_Props = {
33
33
  navStartButtonsEditing?: Array<ButtonConfig>;
34
34
  navEndButtons?: Array<ButtonConfig>;
35
35
  navEndButtonsEditing?: Array<ButtonConfig>;
36
+ updateConfig: ItemCrudSaveConfig;
36
37
  };
37
38
  declare var __VLS_13: {
38
39
  canUpdate: boolean | undefined;
@@ -21,7 +21,15 @@ declare var __VLS_17: {
21
21
  canUpdate: boolean | undefined;
22
22
  canDrop: boolean | undefined;
23
23
  perms: string[] | undefined;
24
- }, __VLS_59: string, __VLS_60: {}, __VLS_62: {
24
+ }, __VLS_55: {
25
+ canUpdate: boolean | undefined;
26
+ canDrop: boolean | undefined;
27
+ perms: string[] | undefined;
28
+ }, __VLS_57: {
29
+ canUpdate: boolean | undefined;
30
+ canDrop: boolean | undefined;
31
+ perms: string[] | undefined;
32
+ }, __VLS_74: string, __VLS_75: {}, __VLS_77: {
25
33
  item: LktObject;
26
34
  loading: false;
27
35
  editMode: boolean;
@@ -30,9 +38,9 @@ declare var __VLS_17: {
30
38
  canDrop: boolean;
31
39
  itemBeingEdited: boolean;
32
40
  perms: string[];
33
- }, __VLS_83: {}, __VLS_85: {};
41
+ }, __VLS_98: {}, __VLS_100: {};
34
42
  type __VLS_Slots = {} & {
35
- [K in NonNullable<typeof __VLS_59>]?: (props: typeof __VLS_60) => any;
43
+ [K in NonNullable<typeof __VLS_74>]?: (props: typeof __VLS_75) => any;
36
44
  } & {
37
45
  'prev-buttons-ever'?: (props: typeof __VLS_17) => any;
38
46
  } & {
@@ -46,11 +54,15 @@ type __VLS_Slots = {} & {
46
54
  } & {
47
55
  'prev-buttons'?: (props: typeof __VLS_42) => any;
48
56
  } & {
49
- item?: (props: typeof __VLS_62) => any;
57
+ 'prev-buttons-ever'?: (props: typeof __VLS_55) => any;
50
58
  } & {
51
- 'prev-buttons-ever'?: (props: typeof __VLS_83) => any;
59
+ 'prev-buttons'?: (props: typeof __VLS_57) => any;
52
60
  } & {
53
- 'prev-buttons'?: (props: typeof __VLS_85) => any;
61
+ item?: (props: typeof __VLS_77) => any;
62
+ } & {
63
+ 'prev-buttons-ever'?: (props: typeof __VLS_98) => any;
64
+ } & {
65
+ 'prev-buttons'?: (props: typeof __VLS_100) => any;
54
66
  };
55
67
  declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
56
68
  doDrop: () => void;
@@ -94,13 +106,10 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
94
106
  header: import("lkt-vue-kernel").HeaderConfig;
95
107
  title: string;
96
108
  mode: ItemCrudMode;
109
+ modifications: LktObject;
97
110
  modelValue: LktObject;
98
111
  createButton: ButtonConfig | false;
99
- events: {
100
- httpStart?: undefined | Function;
101
- httpEnd?: (data: import("lkt-vue-kernel").ClickEventArgs) => void | undefined;
102
- };
103
- modifications: LktObject;
112
+ events: import("lkt-vue-kernel").ItemCrudEvents;
104
113
  editing: boolean;
105
114
  perms: import("lkt-vue-kernel").ValidTablePermission[];
106
115
  customData: LktObject;
@@ -130,6 +139,7 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
130
139
  navStartButtonsEditing: Array<ButtonConfig>;
131
140
  navEndButtons: Array<ButtonConfig>;
132
141
  navEndButtonsEditing: Array<ButtonConfig>;
142
+ updateConfig: import("lkt-vue-kernel").ItemCrudSaveConfig;
133
143
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
134
144
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
135
145
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "2.0.35",
3
+ "version": "2.0.36",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -4,7 +4,7 @@
4
4
  ButtonConfig,
5
5
  ButtonType,
6
6
  ItemCrudButtonNavVisibility,
7
- ItemCrudMode,
7
+ ItemCrudMode, ItemCrudSaveConfig,
8
8
  ItemCrudView,
9
9
  LktObject,
10
10
  ModificationView,
@@ -61,6 +61,10 @@
61
61
  navStartButtonsEditing?: Array<ButtonConfig>
62
62
  navEndButtons?: Array<ButtonConfig>
63
63
  navEndButtonsEditing?: Array<ButtonConfig>
64
+
65
+ updateConfig: ItemCrudSaveConfig
66
+
67
+
64
68
  }>(), {
65
69
  item: () => ({}),
66
70
  modifications: () => ({}),
@@ -75,12 +79,18 @@
75
79
 
76
80
  const slots: SetupContext['slots'] = useSlots();
77
81
 
82
+ const createButtonRef = ref(<HTMLButtonElement | null>null);
83
+ const createAndNewButtonRef = ref(<HTMLButtonElement | null>null);
78
84
  const saveButtonRef = ref(<HTMLButtonElement | null>null);
79
85
  const dropButtonRef = ref(<HTMLButtonElement | null>null);
80
86
 
81
87
  const isLoading = ref(props.loading);
82
88
  watch(() => props.loading, v => isLoading.value = v);
83
- watch(isLoading, v => emit('update:loading', v));
89
+ watch(isLoading, v => {
90
+ if (props.updateConfig.executionMode === 'blocking') {
91
+ emit('update:loading', v);
92
+ }
93
+ });
84
94
 
85
95
  const isEditing = ref(props.editing);
86
96
  watch(() => props.editing, v => isEditing.value = v);
@@ -111,7 +121,17 @@
111
121
  })
112
122
 
113
123
  const doSave = () => {
114
- if (saveButtonRef.value && typeof saveButtonRef.value.click === 'function') saveButtonRef.value.click();
124
+ if (showSaveButton.value) {
125
+ switch (props.mode) {
126
+ case ItemCrudMode.Update:
127
+ if (saveButtonRef.value && typeof saveButtonRef.value.click === 'function') saveButtonRef.value.click();
128
+ break;
129
+
130
+ case ItemCrudMode.Create:
131
+ if (createButtonRef.value && typeof createButtonRef.value.click === 'function') createButtonRef.value.click();
132
+ break;
133
+ }
134
+ }
115
135
  },
116
136
  doDrop = () => {
117
137
  if (dropButtonRef.value && typeof dropButtonRef.value.click === 'function') dropButtonRef.value.click();
@@ -289,7 +309,7 @@
289
309
  />
290
310
 
291
311
  <lkt-button
292
- ref="saveButtonRef"
312
+ ref="createButtonRef"
293
313
  v-show="mode === ItemCrudMode.Create && showSaveButton"
294
314
  v-bind="{
295
315
  ...createButton,
@@ -305,7 +325,7 @@
305
325
  />
306
326
 
307
327
  <lkt-button
308
- ref="saveButtonRef"
328
+ ref="createAndNewButtonRef"
309
329
  v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
310
330
  v-bind="{
311
331
  ...createAndNewButton,
@@ -401,7 +421,7 @@
401
421
  />
402
422
 
403
423
  <lkt-button
404
- ref="saveButtonRef"
424
+ ref="createButtonRef"
405
425
  v-show="mode === ItemCrudMode.Create && showSaveButton"
406
426
  v-bind="{
407
427
  ...createButton,
@@ -418,7 +438,7 @@
418
438
  />
419
439
 
420
440
  <lkt-button
421
- ref="saveButtonRef"
441
+ ref="createAndNewButtonRef"
422
442
  v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
423
443
  v-bind="{
424
444
  ...createAndNewButton,
@@ -494,7 +514,7 @@
494
514
  />
495
515
 
496
516
  <lkt-button
497
- ref="saveButtonRef"
517
+ ref="createButtonRef"
498
518
  v-show="mode === ItemCrudMode.Create && showSaveButton"
499
519
  v-bind="{
500
520
  ...createButton,
@@ -510,7 +530,7 @@
510
530
  />
511
531
 
512
532
  <lkt-button
513
- ref="saveButtonRef"
533
+ ref="createAndNewButtonRef"
514
534
  v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
515
535
  v-bind="{
516
536
  ...createAndNewButton,
@@ -464,7 +464,9 @@
464
464
  }),
465
465
  ableToUpdate = computed(() => {
466
466
  if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
467
- if (!(computedHasForm.value && validForm.value)) return false;
467
+ if (computedHasForm.value) {
468
+ if (!validForm.value) return false;
469
+ }
468
470
  if (!props.enabledSaveWithoutChanges) {
469
471
  if (computedHasForm.value) {
470
472
  if (!changedForm.value) return false;
@@ -482,7 +484,9 @@
482
484
  }),
483
485
  ableToCreate = computed(() => {
484
486
  if (props.mode !== ItemCrudMode.Create || !canCreate.value) return false;
485
- if (!(computedHasForm.value && validForm.value)) return false;
487
+ if (computedHasForm.value) {
488
+ if (!validForm.value) return false;
489
+ }
486
490
  if (!props.enabledSaveWithoutChanges) {
487
491
  if (computedHasForm.value) {
488
492
  if (!changedForm.value) return false;
@@ -613,6 +617,7 @@
613
617
  :nav-start-buttons-editing="navStartButtonsEditing"
614
618
  :nav-end-buttons="navEndButtons"
615
619
  :nav-end-buttons-editing="navEndButtonsEditing"
620
+ :update-config="updateConfig"
616
621
  @create="onCreate"
617
622
  @save="onUpdate"
618
623
  @drop="onDrop"
@@ -681,6 +686,7 @@
681
686
  :nav-start-buttons-editing="navStartButtonsEditing"
682
687
  :nav-end-buttons="navEndButtons"
683
688
  :nav-end-buttons-editing="navEndButtonsEditing"
689
+ :update-config="updateConfig"
684
690
  @create="onCreate"
685
691
  @save="onUpdate"
686
692
  @drop="onDrop"
@@ -700,6 +706,63 @@
700
706
  />
701
707
  </template>
702
708
  </button-nav>
709
+ <template v-else-if="computedHasButtons && buttonNavPosition === ItemCrudButtonNavPosition.Hidden">
710
+ <button-nav
711
+ ref="buttonNav"
712
+ v-show="false"
713
+ v-model:loading="isLoading"
714
+ v-model:editing="editMode"
715
+ v-model:picked-modification-view="pickedModificationView"
716
+ :item="item"
717
+ :modifications="itemModifications"
718
+ :mode="mode"
719
+ :view="view"
720
+ :button-nav-visibility="buttonNavVisibility"
721
+ :create-button="safeCreateButton"
722
+ :create-and-new-button="safeCreateAndNewButton"
723
+ :update-button="safeUpdateButton"
724
+ :drop-button="safeDropButton"
725
+ :edit-mode-button="safeEditModeButton"
726
+ :group-button="safeGroupButton"
727
+ :data-changed="dataChanged"
728
+ :http-success-read="httpSuccessRead"
729
+ :can-create="canCreate"
730
+ :can-update="canUpdate"
731
+ :can-drop="canDrop"
732
+ :can-switch-edit-mode="canSwitchEditMode"
733
+ :group-button-as-modal-actions="groupButtonAsModalActions"
734
+ :able-to-create="ableToCreate"
735
+ :able-to-create-and-new="ableToCreateAndNew"
736
+ :able-to-update="ableToUpdate"
737
+ :able-to-drop="ableToDrop"
738
+ :perms="permissions"
739
+ :modification-view="computedModificationViews"
740
+ :editable-view="computedEditableView"
741
+ :nav-start-buttons="navStartButtons"
742
+ :nav-start-buttons-editing="navStartButtonsEditing"
743
+ :nav-end-buttons="navEndButtons"
744
+ :nav-end-buttons-editing="navEndButtonsEditing"
745
+ :update-config="updateConfig"
746
+ @create="onCreate"
747
+ @save="onUpdate"
748
+ @drop="onDrop"
749
+ >
750
+ <template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
751
+ <slot name="prev-buttons-ever"
752
+ :can-update="canUpdate"
753
+ :can-drop="canDrop"
754
+ :perms="perms"
755
+ />
756
+ </template>
757
+ <template #prev-buttons="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
758
+ <slot name="prev-buttons"
759
+ :can-update="canUpdate"
760
+ :can-drop="canDrop"
761
+ :perms="perms"
762
+ />
763
+ </template>
764
+ </button-nav>
765
+ </template>
703
766
 
704
767
  <div class="lkt-item-crud_content" v-if="!isLoading">
705
768
  <div v-if="httpSuccessRead" class="lkt-grid-1">
@@ -787,6 +850,7 @@
787
850
  :nav-start-buttons-editing="navStartButtonsEditing"
788
851
  :nav-end-buttons="navEndButtons"
789
852
  :nav-end-buttons-editing="navEndButtonsEditing"
853
+ :update-config="updateConfig"
790
854
  @create="onCreate"
791
855
  @save="onUpdate"
792
856
  @drop="onDrop"