@webitel/ui-datalist 26.8.28 → 26.8.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-datalist",
3
- "version": "26.8.28",
3
+ "version": "26.8.29",
4
4
  "description": "Toolkit for building data lists in webitel ui system",
5
5
  "scripts": {
6
6
  "build:types": "vue-tsc -b tsconfig.build.json",
@@ -1,7 +1,14 @@
1
1
  import type { RegleSchema } from '@regle/schemas';
2
2
  import { refDebounced } from '@vueuse/core';
3
3
  import { type StoreDefinition, storeToRefs } from 'pinia';
4
- import { onUnmounted, type Ref, watch } from 'vue';
4
+ import {
5
+ computed,
6
+ type MaybeRefOrGetter,
7
+ onUnmounted,
8
+ type Ref,
9
+ toValue,
10
+ watch,
11
+ } from 'vue';
5
12
 
6
13
  import { useCardAnyFieldEditedWatcher } from './useCardAnyFieldEditedWatcher';
7
14
  import { useCardIsNew } from './useCardIsNew';
@@ -21,6 +28,7 @@ export const useCardComponent = <
21
28
  useCardStore,
22
29
  onLoadErrorHandler,
23
30
  manualSetup = false,
31
+ hasSaveAccess,
24
32
  }: {
25
33
  useCardStore: StoreDefinition;
26
34
  onLoadErrorHandler?: (err: unknown) => void;
@@ -32,6 +40,13 @@ export const useCardComponent = <
32
40
  * @default false
33
41
  */
34
42
  manualSetup?: boolean;
43
+ /**
44
+ * [Claude] Save access from the app's access control, folded into
45
+ * `disabledSave`. Omitted means access is granted.
46
+ *
47
+ * @default true
48
+ */
49
+ hasSaveAccess?: MaybeRefOrGetter<boolean>;
35
50
  }) => {
36
51
  const cardStore = useCardStore();
37
52
 
@@ -71,6 +86,13 @@ export const useCardComponent = <
71
86
  isAnyFieldEdited,
72
87
  });
73
88
 
89
+ const disabledSave = computed<boolean>(
90
+ () =>
91
+ !(toValue(hasSaveAccess) ?? true) ||
92
+ !isAnyFieldEdited.value ||
93
+ hasValidationErrors.value,
94
+ );
95
+
74
96
  const { save } = useCardSaveAction<CardEntity>({
75
97
  validate, // fixme: type
76
98
  saveItem,
@@ -106,6 +128,7 @@ export const useCardComponent = <
106
128
  saveText,
107
129
  hasValidationErrors,
108
130
  isAnyFieldEdited,
131
+ disabledSave,
109
132
  validationFields,
110
133
 
111
134
  // actions
@@ -33,16 +33,19 @@ export const useNestedCardComponent = <
33
33
  onLoadErrorHandler,
34
34
  routeParamName,
35
35
  parentId,
36
+ hasSaveAccess,
36
37
  }: {
37
38
  useCardStore: StoreDefinition;
38
39
  onLoadErrorHandler?: (err: unknown) => void;
39
40
  routeParamName: string;
40
41
  parentId?: MaybeRefOrGetter<CardParentId>;
42
+ hasSaveAccess?: MaybeRefOrGetter<boolean>;
41
43
  }) => {
42
44
  const cardSetup = useCardComponent<CardEntity>({
43
45
  useCardStore,
44
46
  onLoadErrorHandler,
45
47
  manualSetup: true,
48
+ hasSaveAccess,
46
49
  });
47
50
 
48
51
  const cardStore = useCardStore();