lkt-item-crud 2.0.35 → 2.0.37

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.37",
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,
@@ -5,9 +5,12 @@
5
5
  import { debug } from '../functions/debug';
6
6
  import {
7
7
  ButtonConfig,
8
- ensureButtonConfig, extractI18nValue, FormUiConfig,
8
+ ensureButtonConfig,
9
+ extractI18nValue,
10
+ FormUiConfig,
9
11
  getDefaultValues,
10
- getFormDataState, getFormSlotKeys,
12
+ getFormDataState,
13
+ getFormSlotKeys,
11
14
  ItemCrud,
12
15
  ItemCrudButtonNavPosition,
13
16
  ItemCrudConfig,
@@ -323,6 +326,7 @@
323
326
  details: LktSettings.defaultCreateErrorDetails,
324
327
  icon: LktSettings.defaultCreateErrorIcon,
325
328
  positionX: ToastPositionX.Right,
329
+ ...r.toast,
326
330
  });
327
331
  }
328
332
  return;
@@ -337,6 +341,7 @@
337
341
  details: LktSettings.defaultCreateSuccessDetails,
338
342
  icon: LktSettings.defaultCreateSuccessIcon,
339
343
  positionX: ToastPositionX.Right,
344
+ ...r.toast,
340
345
  });
341
346
  }
342
347
  doAutoReloadId(r, props.redirectOnCreate);
@@ -352,6 +357,7 @@
352
357
  details: LktSettings.defaultUpdateErrorDetails,
353
358
  icon: LktSettings.defaultUpdateErrorIcon,
354
359
  positionX: ToastPositionX.Right,
360
+ ...r.toast,
355
361
  });
356
362
  }
357
363
  return;
@@ -365,6 +371,7 @@
365
371
  details: LktSettings.defaultUpdateSuccessDetails,
366
372
  icon: LktSettings.defaultUpdateSuccessIcon,
367
373
  positionX: ToastPositionX.Right,
374
+ ...r.toast,
368
375
  });
369
376
  }
370
377
  doAutoReloadId(r);
@@ -379,6 +386,7 @@
379
386
  details: LktSettings.defaultDropErrorDetails,
380
387
  icon: LktSettings.defaultDropErrorIcon,
381
388
  positionX: ToastPositionX.Right,
389
+ ...r.toast,
382
390
  });
383
391
  }
384
392
  return;
@@ -389,6 +397,7 @@
389
397
  details: LktSettings.defaultDropSuccessDetails,
390
398
  icon: LktSettings.defaultDropSuccessIcon,
391
399
  positionX: ToastPositionX.Right,
400
+ ...r.toast,
392
401
  });
393
402
  }
394
403
  emit('drop', r);
@@ -464,7 +473,9 @@
464
473
  }),
465
474
  ableToUpdate = computed(() => {
466
475
  if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
467
- if (!(computedHasForm.value && validForm.value)) return false;
476
+ if (computedHasForm.value) {
477
+ if (!validForm.value) return false;
478
+ }
468
479
  if (!props.enabledSaveWithoutChanges) {
469
480
  if (computedHasForm.value) {
470
481
  if (!changedForm.value) return false;
@@ -482,7 +493,9 @@
482
493
  }),
483
494
  ableToCreate = computed(() => {
484
495
  if (props.mode !== ItemCrudMode.Create || !canCreate.value) return false;
485
- if (!(computedHasForm.value && validForm.value)) return false;
496
+ if (computedHasForm.value) {
497
+ if (!validForm.value) return false;
498
+ }
486
499
  if (!props.enabledSaveWithoutChanges) {
487
500
  if (computedHasForm.value) {
488
501
  if (!changedForm.value) return false;
@@ -613,6 +626,7 @@
613
626
  :nav-start-buttons-editing="navStartButtonsEditing"
614
627
  :nav-end-buttons="navEndButtons"
615
628
  :nav-end-buttons-editing="navEndButtonsEditing"
629
+ :update-config="updateConfig"
616
630
  @create="onCreate"
617
631
  @save="onUpdate"
618
632
  @drop="onDrop"
@@ -681,6 +695,7 @@
681
695
  :nav-start-buttons-editing="navStartButtonsEditing"
682
696
  :nav-end-buttons="navEndButtons"
683
697
  :nav-end-buttons-editing="navEndButtonsEditing"
698
+ :update-config="updateConfig"
684
699
  @create="onCreate"
685
700
  @save="onUpdate"
686
701
  @drop="onDrop"
@@ -700,6 +715,63 @@
700
715
  />
701
716
  </template>
702
717
  </button-nav>
718
+ <template v-else-if="computedHasButtons && buttonNavPosition === ItemCrudButtonNavPosition.Hidden">
719
+ <button-nav
720
+ ref="buttonNav"
721
+ v-show="false"
722
+ v-model:loading="isLoading"
723
+ v-model:editing="editMode"
724
+ v-model:picked-modification-view="pickedModificationView"
725
+ :item="item"
726
+ :modifications="itemModifications"
727
+ :mode="mode"
728
+ :view="view"
729
+ :button-nav-visibility="buttonNavVisibility"
730
+ :create-button="safeCreateButton"
731
+ :create-and-new-button="safeCreateAndNewButton"
732
+ :update-button="safeUpdateButton"
733
+ :drop-button="safeDropButton"
734
+ :edit-mode-button="safeEditModeButton"
735
+ :group-button="safeGroupButton"
736
+ :data-changed="dataChanged"
737
+ :http-success-read="httpSuccessRead"
738
+ :can-create="canCreate"
739
+ :can-update="canUpdate"
740
+ :can-drop="canDrop"
741
+ :can-switch-edit-mode="canSwitchEditMode"
742
+ :group-button-as-modal-actions="groupButtonAsModalActions"
743
+ :able-to-create="ableToCreate"
744
+ :able-to-create-and-new="ableToCreateAndNew"
745
+ :able-to-update="ableToUpdate"
746
+ :able-to-drop="ableToDrop"
747
+ :perms="permissions"
748
+ :modification-view="computedModificationViews"
749
+ :editable-view="computedEditableView"
750
+ :nav-start-buttons="navStartButtons"
751
+ :nav-start-buttons-editing="navStartButtonsEditing"
752
+ :nav-end-buttons="navEndButtons"
753
+ :nav-end-buttons-editing="navEndButtonsEditing"
754
+ :update-config="updateConfig"
755
+ @create="onCreate"
756
+ @save="onUpdate"
757
+ @drop="onDrop"
758
+ >
759
+ <template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
760
+ <slot name="prev-buttons-ever"
761
+ :can-update="canUpdate"
762
+ :can-drop="canDrop"
763
+ :perms="perms"
764
+ />
765
+ </template>
766
+ <template #prev-buttons="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
767
+ <slot name="prev-buttons"
768
+ :can-update="canUpdate"
769
+ :can-drop="canDrop"
770
+ :perms="perms"
771
+ />
772
+ </template>
773
+ </button-nav>
774
+ </template>
703
775
 
704
776
  <div class="lkt-item-crud_content" v-if="!isLoading">
705
777
  <div v-if="httpSuccessRead" class="lkt-grid-1">
@@ -787,6 +859,7 @@
787
859
  :nav-start-buttons-editing="navStartButtonsEditing"
788
860
  :nav-end-buttons="navEndButtons"
789
861
  :nav-end-buttons-editing="navEndButtonsEditing"
862
+ :update-config="updateConfig"
790
863
  @create="onCreate"
791
864
  @save="onUpdate"
792
865
  @drop="onDrop"