@boarteam/boar-pack-common-frontend 2.1.0 → 2.3.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": "@boarteam/boar-pack-common-frontend",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.3.1",
|
|
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>",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"yalc:push": "yalc push"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "441251d33aa4c5b62f82c351811c581c8c8113a3"
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@ import { TDescriptionsCreateModalProps } from "./descriptionTypes";
|
|
|
4
4
|
import { ProDescriptions } from "@ant-design/pro-components";
|
|
5
5
|
import { columnsToDescriptionItemProps } from "./useDescriptionColumns";
|
|
6
6
|
import { useForm } from "antd/es/form/Form";
|
|
7
|
-
import {
|
|
7
|
+
import { buildFieldsFromColumnsForDescriptionsDisplay } from "../Table";
|
|
8
8
|
|
|
9
9
|
const DescriptionsCreateModal = <Entity extends Record<string | symbol, any>>({
|
|
10
10
|
idColumnName,
|
|
@@ -19,7 +19,7 @@ const DescriptionsCreateModal = <Entity extends Record<string | symbol, any>>({
|
|
|
19
19
|
|
|
20
20
|
const editableKeys = useMemo(() => {
|
|
21
21
|
return [
|
|
22
|
-
...
|
|
22
|
+
...buildFieldsFromColumnsForDescriptionsDisplay(
|
|
23
23
|
columns,
|
|
24
24
|
idColumnName,
|
|
25
25
|
),
|
|
@@ -68,6 +68,7 @@ const Table = <Entity extends Record<string | symbol, any>,
|
|
|
68
68
|
popupCreation = false,
|
|
69
69
|
toolBarRender,
|
|
70
70
|
params,
|
|
71
|
+
popupDataState,
|
|
71
72
|
...rest
|
|
72
73
|
}: TTableProps<Entity,
|
|
73
74
|
CreateDto,
|
|
@@ -77,7 +78,7 @@ const Table = <Entity extends Record<string | symbol, any>,
|
|
|
77
78
|
) => {
|
|
78
79
|
const actionRefComponent = useRef<ActionType>();
|
|
79
80
|
const actionRef = actionRefProp || actionRefComponent;
|
|
80
|
-
const [createPopupData, setCreatePopupData] = useState<Partial<Entity> | undefined>();
|
|
81
|
+
const [createPopupData, setCreatePopupData] = popupDataState ?? useState<Partial<Entity> | undefined>();
|
|
81
82
|
const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
|
|
82
83
|
const [selectedRecords, setSelectedRecords] = useState<Entity[]>([]);
|
|
83
84
|
const [lastRequest, setLastRequest] = useState<[TGetAllParams & TPathParams, any] | []>([]);
|
|
@@ -253,6 +254,7 @@ const Table = <Entity extends Record<string | symbol, any>,
|
|
|
253
254
|
}
|
|
254
255
|
},
|
|
255
256
|
async onDelete(id, row) {
|
|
257
|
+
if (isRecordNew(row)) return;
|
|
256
258
|
await onDelete({ ...row, ...pathParams });
|
|
257
259
|
},
|
|
258
260
|
deletePopconfirmMessage: intl.formatMessage({ id: 'table.deletePopconfirmMessage' }),
|
|
@@ -113,6 +113,21 @@ export function collectFieldsFromColumns<T>(
|
|
|
113
113
|
return [Array.from(buildFieldsFromColumns<T>(columns, idColumnName, joinFields, fields)).join(',')];
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
export function buildFieldsFromColumnsForDescriptionsDisplay<T>(
|
|
117
|
+
columns: TIndexableRecord[] | undefined,
|
|
118
|
+
idColumnName: string | string[],
|
|
119
|
+
fields: Set<string> = new Set,
|
|
120
|
+
): Set<string> {
|
|
121
|
+
columns?.forEach(col => {
|
|
122
|
+
if ('children' in col && Array.isArray(col.children)) {
|
|
123
|
+
buildFieldsFromColumnsForDescriptionsDisplay(col.children, idColumnName, fields);
|
|
124
|
+
}
|
|
125
|
+
fields.add(String(Array.isArray(col.dataIndex) ? col.dataIndex[0] : col.dataIndex));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return fields;
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
export function buildFieldsFromColumns<T>(
|
|
117
132
|
columns: TIndexableRecord[] | undefined,
|
|
118
133
|
idColumnName: string | string[],
|
|
@@ -98,6 +98,7 @@ interface BaseProps<Entity,
|
|
|
98
98
|
popupCreation?: boolean;
|
|
99
99
|
columnsState?: ColumnStateType;
|
|
100
100
|
columnsSetSelect?: () => React.ReactNode;
|
|
101
|
+
popupDataState?: [Partial<Entity>, React.Dispatch<React.SetStateAction<Partial<Entity>>>]
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
interface EditableProps<Entity, CreateDto, UpdateDto, TPathParams = {}> {
|