@webitel/ui-datalist 1.1.70 → 1.1.72

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": "1.1.70",
3
+ "version": "1.1.72",
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,5 +1,12 @@
1
- import type { RegleSchemaFieldStatus } from '@regle/schemas';
1
+ import type { InferRegleSchemaStatusType } from '@regle/schemas';
2
2
 
3
+ /**
4
+ * Validation statuses of a card entity, as handed to the form tabs.
5
+ *
6
+ * Mirrors what regle actually builds: an array field resolves to a collection
7
+ * status (`$each`), a nested object to a status with `$fields`. Typing every
8
+ * field as a plain field status hides both.
9
+ */
3
10
  export type CardValidationFields<T> = {
4
- [K in keyof T]: RegleSchemaFieldStatus<T[K]>;
11
+ [K in keyof T]: InferRegleSchemaStatusType<T[K]>;
5
12
  };
@@ -90,6 +90,34 @@ describe('tableHeadersStoreBody', () => {
90
90
  ]);
91
91
  });
92
92
 
93
+ it('asks for a field once when several columns render from it', () => {
94
+ const store = tableHeadersStoreBody({
95
+ rawHeaders: [
96
+ {
97
+ field: 'grantee',
98
+ show: true,
99
+ sort: null,
100
+ },
101
+ {
102
+ field: 'granted',
103
+ show: true,
104
+ sort: null,
105
+ },
106
+ {
107
+ field: 'granted',
108
+ show: true,
109
+ sort: null,
110
+ },
111
+ ] as DatalistTableHeader[],
112
+ id,
113
+ });
114
+
115
+ expect(store.fields.value).toEqual([
116
+ 'grantee',
117
+ 'granted',
118
+ ]);
119
+ });
120
+
93
121
  it('has no sort by default', () => {
94
122
  expect(createStore().sort.value).toBeNull();
95
123
  });
@@ -45,8 +45,11 @@ export const tableHeadersStoreBody = ({
45
45
  return headers.value.filter((header) => header.show);
46
46
  });
47
47
 
48
+ /* several columns may render from one api field, ask for it once */
48
49
  const fields = computed(() => {
49
- return shownHeaders.value.map((header) => header.field);
50
+ return [
51
+ ...new Set(shownHeaders.value.map((header) => header.field)),
52
+ ];
50
53
  });
51
54
 
52
55
  const sort = computed(() => {
@@ -13,8 +13,25 @@ import type {
13
13
  export const PermissionsApiModule = (
14
14
  rawApiModule: RawPermissionsApiModule,
15
15
  ): TableApiModule<PermissionEntity> => {
16
+ /**
17
+ * The table store always asks for `id` (every registry needs it to open or
18
+ * delete a row), but an access rule has no such attribute and the endpoint
19
+ * answers `400 app.search.fields.invalid` — a rule is addressed by its
20
+ * grantee. Rows are patched through the parent id, so nothing here needs it.
21
+ */
22
+ const getList = ({
23
+ fields,
24
+ ...params
25
+ }: {
26
+ fields?: string[];
27
+ } & Record<string, unknown>) =>
28
+ rawApiModule.getPermissionsList?.({
29
+ ...params,
30
+ fields: fields?.filter((field) => field !== 'id'),
31
+ });
32
+
16
33
  return {
17
- getList: rawApiModule.getPermissionsList,
34
+ getList,
18
35
  patch: rawApiModule.patchPermissions,
19
36
  } as unknown as TableApiModule<PermissionEntity>;
20
37
  };
@@ -146,6 +146,9 @@ export const createPermissionsStore = (
146
146
  },
147
147
  ) => {
148
148
  const normalizedConfig: useTableStoreConfig<PermissionEntity> = {
149
+ /* a fixed 4-column tab: nothing worth persisting, and a `fields` list
150
+ saved by an older version would keep being sent to the api */
151
+ disablePersistence: true,
149
152
  ...config,
150
153
  apiModule: PermissionsApiModule(config.apiModule),
151
154
  headers: config.headers || headers,
@@ -103,12 +103,16 @@ export const tableStoreBody = <Entity extends Identifiable>(
103
103
  selected.value = value;
104
104
  };
105
105
 
106
+ // Always request `id` (Vuex REQUIRED_FIELDS default) — needed for select/delete/open
106
107
  const getLoadDataParams = () => ({
107
108
  ...filtersManager.value.getAllValues(),
108
109
  page: page.value,
109
110
  size: size.value,
110
111
  sort: sort.value,
111
- fields: fields.value,
112
+ fields: [
113
+ 'id',
114
+ ...fields.value.filter((field) => field !== 'id'),
115
+ ],
112
116
  parentId: parentId.value,
113
117
  });
114
118