Skip to content

Commit

Permalink
fix(popup): popupmenu multiedit
Browse files Browse the repository at this point in the history
* Fix popup menu multi editable options

* Fix multi edit on bearings

* Fix subsequent single clicks edits cancelling next edit

* Add mutliselect to drop down menus

* Try to get publish to work

* Remove console log
  • Loading branch information
matttdawson authored Oct 26, 2022
1 parent 7231861 commit 5bf1124
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 57 deletions.
48 changes: 0 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,3 @@
Home for our reusable ag-grid component

Storybook deployed at: https://linz.github.io/step-ag-grid/


# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
71 changes: 71 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"name": "@linzjs/step-ag-grid",
"repository": "github:linz/step-ag-grid.git",
"license": "MIT",
"version": "0.1.0",
"private": true,
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"module": "dist/step-ag-grid.esm.js",
"files": [
"dist",
"src"
],
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=10"
},
Expand Down Expand Up @@ -66,6 +69,8 @@
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@storybook/builder-webpack5": "^6.5.13",
"@storybook/cli": "^6.5.12",
"@storybook/manager-webpack5": "^6.5.13",
Expand Down Expand Up @@ -112,5 +117,10 @@
"presets": [
"react-app"
]
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
}
}
5 changes: 3 additions & 2 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ export const Grid = (params: GridProps): JSX.Element => {
force: true,
rowNodes: event.api.getSelectedNodes(),
});
const cell = event.api.getFocusedCell();
cell && event.api.setFocusedCell(cell.rowIndex, cell.column);
}, []);

const startCellEditing = useCallback(
Expand Down Expand Up @@ -211,6 +209,9 @@ export const Grid = (params: GridProps): JSX.Element => {
const onCellEditingStopped = useCallback(
(event: CellEvent) => {
refreshSelectedRows(event);
// The grid loses cell focus after editing
const cell = event.api.getFocusedCell();
cell && event.api.setFocusedCell(cell.rowIndex, cell.column);
},
[refreshSelectedRows],
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/gridForm/GridFormPopoutMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(props: GridFormP
);

const selectedRowCount = props.selectedRows.length;
const filteredOptions = options?.filter(
(menuOption) => menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.multiEdit,
);

const filteredOptions = options?.filter((menuOption) => {
return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.multiEdit;
});

const { popoutWrapper } = useGridPopoutHook(props);
return popoutWrapper(
Expand Down
3 changes: 2 additions & 1 deletion src/components/gridPopoverEdit/GridPopoutMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ export const GridPopoutMenu = <RowType extends GridBaseRow>(
maxWidth: 64,
editable: colDef.editable != null ? colDef.editable : true,
cellRenderer: GridRenderPopoutMenuCell,
cellClass: GenericMultiEditCellClass,
cellClass: colDef?.cellEditorParams?.multiEdit !== false ? GenericMultiEditCellClass : undefined,
...colDef,
cellRendererParams: {
// Menus open on single click, this parameter is picked up in Grid.tsx
singleClickEdit: true,
},
...(colDef?.cellEditorParams && {
cellEditorParams: {
multiEdit: true,
...colDef.cellEditorParams,
form: GridFormPopoutMenu,
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/gridPopoverEdit/GridPopoverEditBearing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
maxWidth: 150,
valueFormatter: bearingValueFormatter,
cellRenderer: GridGenericCellRendererComponent,
cellClass: colDef.cellEditor?.multiEdit ? GenericMultiEditCellClass : undefined,
cellClass: colDef.cellEditorParams?.multiEdit ? GenericMultiEditCellClass : undefined,
...colDef,
...(colDef?.cellEditorParams && {
cellEditorParams: {
Expand Down
2 changes: 1 addition & 1 deletion src/stories/components/GridReadOnly.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
await wait(500);
return [
{
label: "Single edit",
label: "Single edit only",
action: async (selectedRows) => {
alert(`Single-edit: ${selectedRows.length} rows`);
await wait(1500);
Expand Down

0 comments on commit 5bf1124

Please sign in to comment.