@webitel/ui-datalist 26.8.28 → 26.10.1

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.10.1",
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",
@@ -39,9 +39,9 @@
39
39
  "@vuelidate/core": "^2.0.3",
40
40
  "@vuelidate/validators": "^2.0.4",
41
41
  "@vueuse/core": "^14.0",
42
- "@webitel/api-services": "~26.8",
43
- "@webitel/styleguide": "~26.8",
44
- "@webitel/ui-sdk": "~26.8",
42
+ "@webitel/api-services": "~26.10",
43
+ "@webitel/styleguide": "~26.10",
44
+ "@webitel/ui-sdk": "~26.10",
45
45
  "axios": "^1.15.2",
46
46
  "date-fns": "^4",
47
47
  "lodash-es": "^4.17.21",
@@ -6,6 +6,7 @@ import {
6
6
  caseCloseFieldsChecks,
7
7
  caseSchema,
8
8
  queueSchema,
9
+ resourceSchema,
9
10
  } from '@webitel/api-services/validations';
10
11
  import { describe, expect, it } from 'vitest';
11
12
  import { effectScope, nextTick, ref } from 'vue';
@@ -134,3 +135,34 @@ describe('card validation of the close reason on a new final case', () => {
134
135
  expect(r$.$fields.closeResult.$error).toBe(true);
135
136
  });
136
137
  });
138
+
139
+ /**
140
+ * [Claude] A required lookup cleared by the select becomes `{}`. regle builds a
141
+ * nested status for it, so the required issue has to land on `id` — otherwise
142
+ * the field shows no error and save stays enabled.
143
+ *
144
+ * [WTEL-10632](https://webitel.atlassian.net/browse/WTEL-10632)
145
+ */
146
+ describe('card validation of a cleared required lookup', () => {
147
+ it('reports a cleared resource gateway on the field', async () => {
148
+ const state = ref({
149
+ ...getDefaultsFromZodSchema(resourceSchema, {}),
150
+ name: 'a resource',
151
+ gateway: {},
152
+ });
153
+ const scope = effectScope(true);
154
+ // biome-ignore lint/suspicious/noExplicitAny: regle's inferred state type
155
+ let r$: any;
156
+
157
+ scope.run(() => {
158
+ ({ r$ } = useRegleSchema(state, resourceSchema as never));
159
+ });
160
+
161
+ const result = await r$.$validate();
162
+
163
+ expect(result.valid).toBe(false);
164
+ expect(r$.$error).toBe(true);
165
+ expect(r$.$fields.gateway.$error).toBe(true);
166
+ expect(r$.$fields.gateway.$errors.id).toHaveLength(1);
167
+ });
168
+ });
@@ -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();