@linzjs/step-ag-grid 1.5.3 → 2.0.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/dist/index.d.ts +9 -9
- package/dist/index.js +410 -358
- package/dist/index.js.map +1 -1
- package/dist/src/components/Grid.d.ts +1 -1
- package/dist/src/components/GridCell.d.ts +18 -27
- package/dist/src/components/GridPopoverHook.d.ts +4 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -3
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -4
- package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -10
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -4
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -3
- package/dist/src/contexts/GridContext.d.ts +1 -0
- package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
- package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
- package/dist/src/stories/components/FormTest.d.ts +1 -2
- package/dist/step-ag-grid.esm.js +404 -356
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +20 -15
- package/src/components/GridCell.tsx +57 -79
- package/src/components/GridLoadableCell.tsx +4 -1
- package/src/components/GridPopoverHook.tsx +10 -14
- package/src/components/gridForm/GridFormDropDown.tsx +41 -30
- package/src/components/gridForm/GridFormEditBearing.tsx +13 -13
- package/src/components/gridForm/GridFormMessage.tsx +8 -13
- package/src/components/gridForm/GridFormMultiSelect.tsx +27 -29
- package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +19 -18
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +17 -16
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +17 -16
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +20 -21
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
- package/src/components/gridRender/GridRenderGenericCell.tsx +3 -5
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
- package/src/contexts/GridContext.tsx +4 -0
- package/src/contexts/GridContextProvider.tsx +13 -5
- package/src/contexts/GridPopoverContext.tsx +32 -0
- package/src/contexts/GridPopoverContextProvider.tsx +53 -0
- package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
- package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
- package/src/stories/components/FormTest.tsx +4 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +28 -25
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +91 -50
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -13
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +76 -61
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +58 -51
- package/src/stories/components/GridReadOnly.stories.tsx +73 -57
- package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridFormMessage, GridFormMessageProps } from "../gridForm/GridFormMessage";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
|
-
import {
|
|
4
|
+
import { ColDef } from "ag-grid-community";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverMessage = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...colDef.cellEditorParams,
|
|
18
|
-
form: GridFormMessage,
|
|
7
|
+
colDef: ColDef,
|
|
8
|
+
props: GenericCellEditorProps<GridFormMessageProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> => {
|
|
10
|
+
return GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 140,
|
|
13
|
+
...colDef,
|
|
14
|
+
cellRendererParams: {
|
|
15
|
+
singleClickEdit: true,
|
|
16
|
+
...colDef.cellRendererParams,
|
|
19
17
|
},
|
|
20
|
-
}
|
|
21
|
-
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
editor: GridFormMessage,
|
|
21
|
+
...props,
|
|
22
|
+
},
|
|
23
|
+
);
|
|
22
24
|
};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
3
|
import { GridFormTextArea, GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
|
|
4
|
+
import { ColDef } from "ag-grid-community";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextArea = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
});
|
|
20
|
-
};
|
|
7
|
+
colDef: ColDef,
|
|
8
|
+
params: GenericCellEditorProps<GridFormTextAreaProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> =>
|
|
10
|
+
GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 260,
|
|
13
|
+
...colDef,
|
|
14
|
+
},
|
|
15
|
+
{ editor: GridFormTextArea, ...params },
|
|
16
|
+
);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
3
|
import { GridFormTextInput, GridFormTextInputProps } from "../gridForm/GridFormTextInput";
|
|
4
|
+
import { ColDef } from "ag-grid-community";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextInput = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
7
|
+
colDef: ColDef,
|
|
8
|
+
params: GenericCellEditorProps<GridFormTextInputProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> => {
|
|
10
|
+
return GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 140,
|
|
13
|
+
...colDef,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
editor: GridFormTextInput,
|
|
17
|
+
...params,
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
20
|
};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import "./GridRenderGenericCell.scss";
|
|
2
2
|
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
|
|
5
5
|
import { GridLoadableCell } from "../GridLoadableCell";
|
|
6
6
|
import { GridIcon } from "../GridIcon";
|
|
7
7
|
import { ColDef, ICellRendererParams } from "ag-grid-community";
|
|
8
8
|
import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
9
|
-
import { GenericCellEditorParams } from "../GridCell";
|
|
10
9
|
import { GridBaseRow } from "../Grid";
|
|
11
10
|
|
|
12
11
|
export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
|
|
13
12
|
data: RowType;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export interface GenericCellColDef<RowType extends GridBaseRow
|
|
15
|
+
export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDef {
|
|
17
16
|
cellRendererParams?: GenericCellRendererParams<RowType>;
|
|
18
|
-
cellEditorParams?: GenericCellEditorParams<RowType> & FormProps;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
@@ -25,7 +23,7 @@ export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export const GridRendererGenericCell = <RowType extends GridBaseRow>(props: ICellRendererParams): JSX.Element => {
|
|
28
|
-
const { checkUpdating } = useContext(
|
|
26
|
+
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
29
27
|
|
|
30
28
|
const colDef = props.colDef as ColDef;
|
|
31
29
|
const cellRendererParams = colDef.cellRendererParams as GenericCellRendererParams<RowType> | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { ColDef, ICellRendererParams } from "ag-grid-community";
|
|
3
|
-
import {
|
|
3
|
+
import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
|
|
4
4
|
import { GridLoadableCell } from "../GridLoadableCell";
|
|
5
5
|
import { LuiIcon } from "@linzjs/lui";
|
|
6
6
|
import { Column } from "ag-grid-community/dist/lib/entities/column";
|
|
7
7
|
|
|
8
8
|
export const GridRenderPopoutMenuCell = (props: ICellRendererParams) => {
|
|
9
|
-
const { checkUpdating } = useContext(
|
|
9
|
+
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
10
10
|
const isLoading = checkUpdating(props.colDef?.field ?? "", props.data.id);
|
|
11
11
|
const editable = props.colDef?.editable;
|
|
12
12
|
const disabled = !(typeof editable === "function"
|
|
@@ -17,6 +17,7 @@ export interface GridContextType {
|
|
|
17
17
|
flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
|
|
18
18
|
ensureRowVisible: (id: number) => void;
|
|
19
19
|
ensureSelectedRowIsVisible: () => void;
|
|
20
|
+
sizeColumnsToFit: () => void;
|
|
20
21
|
stopEditing: () => void;
|
|
21
22
|
updatingCells: (
|
|
22
23
|
props: { selectedRows: GridBaseRow[]; field?: string },
|
|
@@ -68,6 +69,9 @@ export const GridContext = createContext<GridContextType>({
|
|
|
68
69
|
ensureSelectedRowIsVisible: () => {
|
|
69
70
|
console.error("no context provider for ensureSelectedRowIsVisible");
|
|
70
71
|
},
|
|
72
|
+
sizeColumnsToFit: () => {
|
|
73
|
+
console.error("no context provider for sizeColumnsToFit");
|
|
74
|
+
},
|
|
71
75
|
editingCells: () => {
|
|
72
76
|
console.error("no context provider for editingCells");
|
|
73
77
|
return false;
|
|
@@ -3,7 +3,7 @@ import { GridApi, RowNode } from "ag-grid-community";
|
|
|
3
3
|
import { GridContext } from "./GridContext";
|
|
4
4
|
import { delay, difference, isEmpty, last, sortBy } from "lodash-es";
|
|
5
5
|
import { isNotEmpty } from "@utils/util";
|
|
6
|
-
import {
|
|
6
|
+
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
7
7
|
import { GridBaseRow } from "@components/Grid";
|
|
8
8
|
|
|
9
9
|
interface GridContextProps {
|
|
@@ -16,7 +16,7 @@ interface GridContextProps {
|
|
|
16
16
|
* Also, make sure the provider is created in a separate component, otherwise it won't be found.
|
|
17
17
|
*/
|
|
18
18
|
export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
19
|
-
const { modifyUpdating } = useContext(
|
|
19
|
+
const { modifyUpdating } = useContext(GridUpdatingContext);
|
|
20
20
|
const gridApiRef = useRef<GridApi>();
|
|
21
21
|
const idsBeforeUpdate = useRef<number[]>([]);
|
|
22
22
|
|
|
@@ -48,9 +48,7 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
|
48
48
|
noApiFn = (() => {}) as () => R;
|
|
49
49
|
}
|
|
50
50
|
const gridApi = gridApiRef.current;
|
|
51
|
-
|
|
52
|
-
console.error("GridApi not ready");
|
|
53
|
-
return noApiFn();
|
|
51
|
+
return gridApi ? hasApiFn(gridApi) : noApiFn();
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
/**
|
|
@@ -220,6 +218,15 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
|
220
218
|
});
|
|
221
219
|
};
|
|
222
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Resize columns to fit container
|
|
223
|
+
*/
|
|
224
|
+
const sizeColumnsToFit = (): void => {
|
|
225
|
+
gridApiOp((gridApi) => {
|
|
226
|
+
gridApi.sizeColumnsToFit();
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
223
230
|
const stopEditing = (): void => gridApiOp((gridApi) => gridApi.stopEditing());
|
|
224
231
|
|
|
225
232
|
const updatingCells = async (
|
|
@@ -283,6 +290,7 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
|
283
290
|
editingCells,
|
|
284
291
|
ensureRowVisible,
|
|
285
292
|
ensureSelectedRowIsVisible,
|
|
293
|
+
sizeColumnsToFit,
|
|
286
294
|
stopEditing,
|
|
287
295
|
updatingCells,
|
|
288
296
|
}}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createContext, RefObject } from "react";
|
|
2
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
3
|
+
|
|
4
|
+
export interface PropsType {
|
|
5
|
+
value: any;
|
|
6
|
+
data: any;
|
|
7
|
+
field: string;
|
|
8
|
+
selectedRows: any[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type GridPopoverContextType = {
|
|
12
|
+
anchorRef: RefObject<Element>;
|
|
13
|
+
updateValueRef: RefObject<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
setSaving: (saving: boolean) => void;
|
|
16
|
+
setProps: (props: ICellEditorParams, multiEdit: boolean) => void;
|
|
17
|
+
propsRef: RefObject<PropsType>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const GridPopoverContext = createContext<GridPopoverContextType>({
|
|
21
|
+
anchorRef: { current: null },
|
|
22
|
+
updateValueRef: {
|
|
23
|
+
current: async () => {
|
|
24
|
+
console.error("Missing GridPopoverContext updateValueRef");
|
|
25
|
+
return false;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
saving: false,
|
|
29
|
+
setSaving: () => {},
|
|
30
|
+
setProps: () => {},
|
|
31
|
+
propsRef: { current: null },
|
|
32
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode, RefObject, useContext, useRef, useState } from "react";
|
|
2
|
+
import { GridPopoverContext, PropsType } from "./GridPopoverContext";
|
|
3
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
4
|
+
import { GridBaseRow } from "@components/Grid";
|
|
5
|
+
import { GridContext } from "@contexts/GridContext";
|
|
6
|
+
|
|
7
|
+
interface GridPopoverContextProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
|
|
12
|
+
const { getSelectedRows, updatingCells } = useContext(GridContext);
|
|
13
|
+
const anchorRef = useRef<Element>();
|
|
14
|
+
const propsRef = useRef<PropsType>({} as PropsType);
|
|
15
|
+
const updateValueRef = useRef<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>(async () => {
|
|
16
|
+
console.error("updateValueRef.current is not set");
|
|
17
|
+
return false;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const [saving, setSaving] = useState(false);
|
|
21
|
+
|
|
22
|
+
const setProps = (props: ICellEditorParams, multiEdit: boolean) => {
|
|
23
|
+
const selectedRows = multiEdit ? getSelectedRows<GridBaseRow>() : [props.data];
|
|
24
|
+
const field = props.colDef?.field ?? "";
|
|
25
|
+
|
|
26
|
+
anchorRef.current = props.eGridCell;
|
|
27
|
+
propsRef.current = {
|
|
28
|
+
value: props.value,
|
|
29
|
+
data: props.data,
|
|
30
|
+
field,
|
|
31
|
+
selectedRows,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
updateValueRef.current = async (saveFn: (selectedRows: any[]) => Promise<boolean>): Promise<boolean> => {
|
|
35
|
+
return !saving && (await updatingCells({ selectedRows, field }, saveFn, setSaving));
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<GridPopoverContext.Provider
|
|
41
|
+
value={{
|
|
42
|
+
anchorRef: anchorRef as any as RefObject<Element>,
|
|
43
|
+
saving,
|
|
44
|
+
setSaving,
|
|
45
|
+
updateValueRef,
|
|
46
|
+
propsRef,
|
|
47
|
+
setProps,
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{props.children}
|
|
51
|
+
</GridPopoverContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type GridUpdatingContextType = {
|
|
4
4
|
checkUpdating: (fields: string | string[], id: number | string) => boolean;
|
|
5
5
|
modifyUpdating: (field: string, ids: (number | string)[], fn: () => void | Promise<void>) => Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const GridUpdatingContext = createContext<GridUpdatingContextType>({
|
|
9
9
|
checkUpdating: () => {
|
|
10
10
|
console.error("Missing UpdatingContext");
|
|
11
11
|
return false;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ReactNode, useRef } from "react";
|
|
2
2
|
import { castArray, flatten, remove } from "lodash-es";
|
|
3
|
-
import {
|
|
3
|
+
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
4
4
|
|
|
5
5
|
interface UpdatingContextProviderProps {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type GridUpdatingContextStatus = Record<string, (number | string)[] | undefined>;
|
|
10
10
|
|
|
11
11
|
type FieldName = string;
|
|
12
12
|
type IdList = (number | string)[];
|
|
13
13
|
type UpdatingBlock = Record<FieldName, IdList[]>;
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const GridUpdatingContextProvider = (props: UpdatingContextProviderProps) => {
|
|
16
16
|
const updatingBlocks = useRef<UpdatingBlock>({});
|
|
17
|
-
const updating = useRef<
|
|
17
|
+
const updating = useRef<GridUpdatingContextStatus>({});
|
|
18
18
|
|
|
19
19
|
const resetUpdating = () => {
|
|
20
|
-
const mergedUpdatingBlocks:
|
|
20
|
+
const mergedUpdatingBlocks: GridUpdatingContextStatus = {};
|
|
21
21
|
for (const key in updatingBlocks.current) {
|
|
22
22
|
mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
|
|
23
23
|
}
|
|
@@ -38,6 +38,8 @@ export const UpdatingContextProvider = (props: UpdatingContextProviderProps) =>
|
|
|
38
38
|
castArray(fields).some((f) => updating.current[f]?.includes(id));
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<
|
|
41
|
+
<GridUpdatingContext.Provider value={{ modifyUpdating, checkUpdating }}>
|
|
42
|
+
{props.children}
|
|
43
|
+
</GridUpdatingContext.Provider>
|
|
42
44
|
);
|
|
43
45
|
};
|
|
@@ -3,7 +3,7 @@ import "./FormTest.scss";
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { LuiTextInput } from "@linzjs/lui";
|
|
5
5
|
import { wait } from "@utils/util";
|
|
6
|
-
import {
|
|
6
|
+
import { CellParams } from "@components/GridCell";
|
|
7
7
|
import { useGridPopoverHook } from "@components/GridPopoverHook";
|
|
8
8
|
import { GridBaseRow } from "@components/Grid";
|
|
9
9
|
|
|
@@ -16,7 +16,8 @@ export interface IFormTestRow {
|
|
|
16
16
|
distance: number | null;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const FormTest = <RowType extends GridBaseRow>(
|
|
19
|
+
export const FormTest = <RowType extends GridBaseRow>(_props: any): JSX.Element => {
|
|
20
|
+
const props = _props as CellParams<RowType>;
|
|
20
21
|
const [v1, v2, ...v3] = props.value.split(" ");
|
|
21
22
|
|
|
22
23
|
const [nameType, setNameType] = useState(v1);
|
|
@@ -34,7 +35,7 @@ export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowTy
|
|
|
34
35
|
// Close form
|
|
35
36
|
return true;
|
|
36
37
|
}, [nameType, numba, plan, props.selectedRows]);
|
|
37
|
-
const { popoverWrapper } = useGridPopoverHook(
|
|
38
|
+
const { popoverWrapper } = useGridPopoverHook({ save });
|
|
38
39
|
|
|
39
40
|
return popoverWrapper(
|
|
40
41
|
<div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
|
|
@@ -4,10 +4,10 @@ import "../../lui-overrides.scss";
|
|
|
4
4
|
|
|
5
5
|
import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
|
|
6
6
|
import { useMemo, useState } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { GridUpdatingContextProvider } from "@contexts/GridUpdatingContextProvider";
|
|
8
8
|
import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
9
9
|
import { Grid, GridProps } from "@components/Grid";
|
|
10
|
-
import { GridCell } from "@components/GridCell";
|
|
10
|
+
import { ColDefT, GridCell } from "@components/GridCell";
|
|
11
11
|
import {
|
|
12
12
|
GridPopoverEditBearing,
|
|
13
13
|
GridPopoverEditBearingCorrection,
|
|
@@ -24,11 +24,11 @@ export default {
|
|
|
24
24
|
decorators: [
|
|
25
25
|
(Story) => (
|
|
26
26
|
<div style={{ width: 1200, height: 400, display: "flex" }}>
|
|
27
|
-
<
|
|
27
|
+
<GridUpdatingContextProvider>
|
|
28
28
|
<GridContextProvider>
|
|
29
29
|
<Story />
|
|
30
30
|
</GridContextProvider>
|
|
31
|
-
</
|
|
31
|
+
</GridUpdatingContextProvider>
|
|
32
32
|
</div>
|
|
33
33
|
),
|
|
34
34
|
],
|
|
@@ -42,7 +42,7 @@ interface ITestRow {
|
|
|
42
42
|
|
|
43
43
|
const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
44
44
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
45
|
-
const columnDefs = useMemo(
|
|
45
|
+
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
46
46
|
() => [
|
|
47
47
|
GridCell({
|
|
48
48
|
field: "id",
|
|
@@ -50,31 +50,34 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
50
50
|
initialWidth: 65,
|
|
51
51
|
maxWidth: 85,
|
|
52
52
|
}),
|
|
53
|
-
GridPopoverEditBearing
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
GridPopoverEditBearing(
|
|
54
|
+
{
|
|
55
|
+
field: "bearing1",
|
|
56
|
+
headerName: "Bearing GCE",
|
|
57
|
+
cellRendererParams: {
|
|
58
|
+
warning: (props: any) => props.data.id == 1002 && "Testers are testing",
|
|
59
|
+
info: (props: any) => props.data.id == 1001 && "Developers are developing",
|
|
60
|
+
},
|
|
59
61
|
},
|
|
60
|
-
|
|
62
|
+
{
|
|
61
63
|
multiEdit: false,
|
|
62
|
-
placeHolder: "Enter Bearing",
|
|
63
64
|
},
|
|
64
|
-
|
|
65
|
-
GridPopoverEditBearingCorrection
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
),
|
|
66
|
+
GridPopoverEditBearingCorrection(
|
|
67
|
+
{
|
|
68
|
+
field: "bearingCorrection",
|
|
69
|
+
headerName: "Bearing Correction",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
editorParams: {
|
|
73
|
+
onSave: async (selectedRows, value: ITestRow["bearingCorrection"]) => {
|
|
74
|
+
await wait(1000);
|
|
75
|
+
selectedRows.forEach((row) => (row["bearingCorrection"] = value));
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
75
78
|
},
|
|
76
79
|
},
|
|
77
|
-
|
|
80
|
+
),
|
|
78
81
|
],
|
|
79
82
|
[],
|
|
80
83
|
);
|