@boarteam/boar-pack-common-frontend 2.6.0-alpha.4 → 2.6.0-alpha.6

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": "@boarteam/boar-pack-common-frontend",
3
- "version": "2.6.0-alpha.4",
3
+ "version": "2.6.0-alpha.6",
4
4
  "description": "Common frontend package for Boar Pack",
5
5
  "repository": "git@github.com:boarteam/boar-pack.git",
6
6
  "author": "Andrew Balakirev <balakirev.andrey@gmail.com>",
@@ -26,7 +26,8 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@nestjsx/crud-request": "^5.0.0-alpha.3",
29
- "lodash": "^4.17.21"
29
+ "lodash": "^4.17.21",
30
+ "uuid": "^11.1.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@ant-design/icons": "^4.8.3",
@@ -46,5 +47,5 @@
46
47
  "scripts": {
47
48
  "yalc:push": "yalc push"
48
49
  },
49
- "gitHead": "32ad0f5a9dbba644c5a01e53f0d83f43cddd7ee2"
50
+ "gitHead": "66eb6a7fdf64efc00aba0e65762919d878cd7762"
50
51
  }
@@ -3,12 +3,16 @@ import React, { Key, useEffect, useImperativeHandle, useMemo, useRef, useState }
3
3
  import { Badge, Button, Result, Tabs, TabsProps, Tooltip } from "antd";
4
4
  import { DeleteOutlined, StopOutlined } from "@ant-design/icons";
5
5
  import { FormattedMessage, useIntl } from "react-intl";
6
- import { DescriptionsRefType, TDescriptionsProps, TGetOneParams } from "./descriptionTypes";
6
+ import { DescriptionsRefType, FieldsEdit, TDescriptionsProps, TGetOneParams } from "./descriptionTypes";
7
7
  import { PageLoading, ProDescriptions } from "@ant-design/pro-components";
8
8
  import { columnsToDescriptionItemProps, TDescriptionSection } from "./useDescriptionColumns";
9
9
  import pick from "lodash/pick";
10
10
  import safetyRun from "../../tools/safetyRun";
11
- import { buildJoinFields, collectFieldsFromColumns } from "../Table";
11
+ import {
12
+ buildFieldsFromColumnsForDescriptionsDisplay,
13
+ buildJoinFields,
14
+ collectFieldsFromColumns,
15
+ } from "../Table";
12
16
  import { RowEditableConfig } from "@ant-design/pro-utils";
13
17
  import { useForm } from "antd/es/form/Form";
14
18
  import useContentViewMode, { VIEW_MODE_TYPE } from "./useContentViewMode";
@@ -54,6 +58,7 @@ const DescriptionsComponent = <Entity extends Record<string | symbol, any>,
54
58
  actionRef: actionRefProp,
55
59
  editable,
56
60
  canEdit = false,
61
+ fieldsEditType = FieldsEdit.Single,
57
62
  columns,
58
63
  params,
59
64
  onEntityChange,
@@ -271,6 +276,10 @@ const DescriptionsComponent = <Entity extends Record<string | symbol, any>,
271
276
  cancelText: <Tooltip title={intl.formatMessage({ id: 'table.cancelText' })}><StopOutlined /></Tooltip>,
272
277
  deleteText: <Tooltip title={intl.formatMessage({ id: 'table.deleteText' })}><DeleteOutlined /></Tooltip>,
273
278
  saveText: <Button size={"small"} type={"primary"}><FormattedMessage id={'table.saveText'} /></Button>,
279
+ ...(fieldsEditType === FieldsEdit.All && {
280
+ editableKeys: [...buildFieldsFromColumnsForDescriptionsDisplay(columns, idColumnName)],
281
+ actionRender: () => [],
282
+ }),
274
283
  ...editable,
275
284
  } : undefined}
276
285
  columns={section.columns}
@@ -30,6 +30,11 @@ export type DescriptionsRefType<Entity> = {
30
30
  setFieldErrors: (fields: FieldData<Entity>[]) => void;
31
31
  };
32
32
 
33
+ export enum FieldsEdit {
34
+ Single = 'single',
35
+ All = 'all'
36
+ }
37
+
33
38
  export type TDescriptionsProps<Entity, CreateDto, UpdateDto, TPathParams = object> = {
34
39
  mainTitle?: ProColumns<Entity>['title'] | null,
35
40
  entity?: Partial<Entity>,
@@ -48,6 +53,7 @@ export type TDescriptionsProps<Entity, CreateDto, UpdateDto, TPathParams = objec
48
53
  actionRef?: MutableRefObject<ActionType | undefined>,
49
54
  editable?: RowEditableConfig<Entity>,
50
55
  canEdit?: boolean,
56
+ fieldsEditType?: FieldsEdit,
51
57
  params?: TDescriptionGetRequestParams,
52
58
  columns: ProColumns<Entity>[],
53
59
  onEntityChange?: (entity: Entity | null) => void;
@@ -1,4 +1,5 @@
1
1
  import { CondOperator, QueryJoin, SCondition } from "@nestjsx/crud-request";
2
+ import { validate as uuidValidate } from 'uuid';
2
3
  import { IWithId, TFilters, TSearchableColumn } from "./tableTypes";
3
4
  import React, { Key } from "react";
4
5
  import { TColumnsStates } from "./useColumnsSets";
@@ -20,7 +21,12 @@ export function getFiltersSearch({
20
21
  let operator = col.filterOperator || col.operator;
21
22
  let value = filters[colDataIndex] || baseFilters[colDataIndex];
22
23
  filterKeys.delete(colDataIndex);
23
- if (value === '' || value === undefined || col.numeric && !Number.isFinite(Number(value))) {
24
+ if (
25
+ value === '' ||
26
+ value === undefined ||
27
+ col.numeric && !Number.isFinite(Number(value)) ||
28
+ col.uuid && (typeof value !== 'string' || !uuidValidate(value))
29
+ ) {
24
30
  return;
25
31
  }
26
32
 
@@ -126,7 +132,10 @@ export function applyKeywordToSearch(
126
132
  const field = col.searchField || (Array.isArray(col.field) ? col.field.join('.') : col.field);
127
133
  const operator = col.operator;
128
134
 
129
- if (!col.numeric || Number.isFinite(Number(word))) {
135
+ const wrongNumeric = col.numeric && !Number.isFinite(Number(word));
136
+ const wrongUuid = col.uuid && (typeof word !== 'string' || !uuidValidate(word));
137
+
138
+ if (!wrongNumeric && !wrongUuid) {
130
139
  keywordSearch.$or.push({ [field]: { [operator]: word } });
131
140
  }
132
141
  });
@@ -78,6 +78,7 @@ export type TSearchableColumn = {
78
78
  filterField?: string,
79
79
  filterOperator?: typeof Operators[keyof typeof Operators],
80
80
  numeric?: boolean,
81
+ uuid?: boolean,
81
82
  }
82
83
 
83
84
  interface BaseProps<Entity,