@webitel/ui-datalist 26.8.29 → 26.10.2
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 +4 -4
- package/src/modules/card/composables/__tests__/useCardValidation.spec.ts +32 -0
- package/src/modules/permissions-page/scripts/PermissionsApiModule.ts +21 -1
- package/src/modules/permissions-page/scripts/__tests__/PermissionsApiModule.spec.ts +31 -0
- package/types/.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-datalist",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.10.2",
|
|
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.
|
|
43
|
-
"@webitel/styleguide": "~26.
|
|
44
|
-
"@webitel/ui-sdk": "~26.
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { AccessRuleName } from '@webitel/ui-sdk/modules/ObjectPermissions/enums';
|
|
1
2
|
import type { TableApiModule } from '../../types/tableStore.types';
|
|
2
3
|
import type {
|
|
3
4
|
PermissionEntity,
|
|
@@ -13,6 +14,25 @@ import type {
|
|
|
13
14
|
export const PermissionsApiModule = (
|
|
14
15
|
rawApiModule: RawPermissionsApiModule,
|
|
15
16
|
): TableApiModule<PermissionEntity> => {
|
|
17
|
+
/**
|
|
18
|
+
* [Claude] The rule columns are keyed by their letter (`r`, `w`, `d`), so
|
|
19
|
+
* each sorts on its own, but the endpoint has no such attributes in `fields`:
|
|
20
|
+
* it returns the three rules merged into one `granted` string, asked for once.
|
|
21
|
+
*/
|
|
22
|
+
const toAclFields = (fields?: string[]) => {
|
|
23
|
+
if (!fields) return fields;
|
|
24
|
+
const ruleFields = Object.values(AccessRuleName).filter(
|
|
25
|
+
(rule) => rule !== AccessRuleName.X,
|
|
26
|
+
);
|
|
27
|
+
return [
|
|
28
|
+
...new Set(
|
|
29
|
+
fields
|
|
30
|
+
.filter((field) => field !== 'id')
|
|
31
|
+
.map((field) => (ruleFields.includes(field) ? 'granted' : field)),
|
|
32
|
+
),
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
|
|
16
36
|
/**
|
|
17
37
|
* The table store always asks for `id` (every registry needs it to open or
|
|
18
38
|
* delete a row), but an access rule has no such attribute and the endpoint
|
|
@@ -27,7 +47,7 @@ export const PermissionsApiModule = (
|
|
|
27
47
|
} & Record<string, unknown>) =>
|
|
28
48
|
rawApiModule.getPermissionsList?.({
|
|
29
49
|
...params,
|
|
30
|
-
fields: fields
|
|
50
|
+
fields: toAclFields(fields),
|
|
31
51
|
});
|
|
32
52
|
|
|
33
53
|
return {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { PermissionsApiModule } from '../PermissionsApiModule';
|
|
4
|
+
|
|
5
|
+
describe('PermissionsApiModule', () => {
|
|
6
|
+
it('asks for one `granted` in place of the rule columns, and never for `id`', async () => {
|
|
7
|
+
const getPermissionsList = vi.fn();
|
|
8
|
+
const { getList } = PermissionsApiModule({
|
|
9
|
+
getPermissionsList,
|
|
10
|
+
} as never);
|
|
11
|
+
|
|
12
|
+
await getList({
|
|
13
|
+
fields: [
|
|
14
|
+
'id',
|
|
15
|
+
'grantee',
|
|
16
|
+
'r',
|
|
17
|
+
'w',
|
|
18
|
+
'd',
|
|
19
|
+
],
|
|
20
|
+
sort: '+w',
|
|
21
|
+
} as never);
|
|
22
|
+
|
|
23
|
+
expect(getPermissionsList).toHaveBeenCalledWith({
|
|
24
|
+
fields: [
|
|
25
|
+
'grantee',
|
|
26
|
+
'granted',
|
|
27
|
+
],
|
|
28
|
+
sort: '+w',
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|