@boarteam/boar-pack-common-frontend 2.9.0 → 2.10.0
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.
|
|
3
|
+
"version": "2.10.0",
|
|
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": "103534abbe12f409d96c929dd462837ec83b4ee7"
|
|
50
50
|
}
|
|
@@ -36,6 +36,7 @@ const Table = <Entity extends Record<string | symbol, any>,
|
|
|
36
36
|
onDelete,
|
|
37
37
|
onDeleteMany,
|
|
38
38
|
exportUrl,
|
|
39
|
+
exportParams,
|
|
39
40
|
onImport,
|
|
40
41
|
pathParams,
|
|
41
42
|
idColumnName = 'id',
|
|
@@ -123,6 +124,7 @@ const Table = <Entity extends Record<string | symbol, any>,
|
|
|
123
124
|
|
|
124
125
|
const { exportButton, importButton, setLastQueryParams } = useImportExport<TPathParams>({
|
|
125
126
|
exportUrl,
|
|
127
|
+
exportParams,
|
|
126
128
|
onImport,
|
|
127
129
|
})
|
|
128
130
|
|
|
@@ -108,6 +108,9 @@ export interface EditableProps<Entity, CreateDto, UpdateDto, TPathParams = {}> {
|
|
|
108
108
|
afterSave?: (record: Entity) => Promise<void>;
|
|
109
109
|
onCreate?: ({}: { requestBody: CreateDto } & TPathParams) => Promise<Entity>;
|
|
110
110
|
exportUrl?: string;
|
|
111
|
+
exportParams?: {
|
|
112
|
+
[key: string]: string | number
|
|
113
|
+
};
|
|
111
114
|
onImport?: (event: React.ChangeEvent<HTMLInputElement>) => Promise<any>;
|
|
112
115
|
onUpdate: ({}: Partial<Entity> & {
|
|
113
116
|
requestBody: UpdateDto,
|
|
@@ -6,9 +6,13 @@ import { Link } from "react-router-dom";
|
|
|
6
6
|
|
|
7
7
|
export function useImportExport<TPathParams = {}>({
|
|
8
8
|
exportUrl,
|
|
9
|
+
exportParams,
|
|
9
10
|
onImport
|
|
10
11
|
}: {
|
|
11
12
|
exportUrl?: string;
|
|
13
|
+
exportParams?: {
|
|
14
|
+
[key: string]: string | number
|
|
15
|
+
}
|
|
12
16
|
onImport?: (event: React.ChangeEvent<HTMLInputElement>) => Promise<any>;
|
|
13
17
|
}) {
|
|
14
18
|
const [isLoadingImport, setIsLoadingImport] = useState(false);
|
|
@@ -25,10 +29,15 @@ export function useImportExport<TPathParams = {}>({
|
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const params = {
|
|
33
|
+
...(lastQueryParams && {
|
|
34
|
+
s: lastQueryParams.s,
|
|
35
|
+
sort: lastQueryParams.sort?.[0],
|
|
36
|
+
}),
|
|
37
|
+
...exportParams
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const url = exportUrl + (Object.keys(params).length ? '?' + new URLSearchParams(params).toString() : '');
|
|
32
41
|
const exportButton = <Tooltip title="Export">
|
|
33
42
|
<Link to={url} target={'_blank'}>
|
|
34
43
|
<Button icon={<DownloadOutlined />}/>
|