From 2a44e3ef5f720c1015f81da4e6fc56e8a45cefd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20S=C5=82ysz?= Date: Tue, 17 Nov 2026 21:30:13 +0100 Subject: [PATCH] - the Sort items button of the enum items has the UnfoldMore icon; the Move up/down arrows are gone - rows are moved by dragging (enum items, columns, properties, task actions); the enum items window shows all the items without pages, so any item can be dragged anywhere --- .../src/components/dialogs/EditEnumDialog.jsx | 39 +++---------------- .../utils/ActionPropertiesTable.jsx | 18 --------- .../src/components/utils/ColumnsTable.jsx | 19 --------- .../src/components/utils/DraggableBodyRow.jsx | 3 +- .../src/components/utils/PropertiesTable.jsx | 17 -------- frontend/src/utils/MaterialTableHelper.jsx | 19 +-------- 6 files changed, 9 insertions(+), 106 deletions(-) diff --git a/frontend/src/components/dialogs/EditEnumDialog.jsx b/frontend/src/components/dialogs/EditEnumDialog.jsx index 9b0b121..005b5fc 100644 --- a/frontend/src/components/dialogs/EditEnumDialog.jsx +++ b/frontend/src/components/dialogs/EditEnumDialog.jsx @@ -12,20 +12,15 @@ import { useTheme } from '@mui/material'; import { - ArrowDropDown, - ArrowDropUp, Close as CloseIcon, MoreHoriz, - SortByAlpha + UnfoldMore } from '@mui/icons-material'; import { getDialogTableHeight, - getPageSizeOptionsOnDialog, getTableHeaderBackgroundColor, getTableRowBackgroundColor, - moveDown, movedRow, - moveUp, removeRow, replaceRow, sortedRows, @@ -35,7 +30,6 @@ import MaterialTable from '@material-table/core'; import PropTypes from 'prop-types'; import EditIconDialog from "./SelectIconDialog"; import {MessageBox} from "../utils/MessageBox"; -import {getLastPageSizeOnDialog, setLastPageSizeOnDialog} from "../../utils/ConfigurationStorage"; import StyledIcon from "../utils/StyledIcon"; import DraggableBodyRow from "../utils/DraggableBodyRow"; @@ -96,8 +90,6 @@ export default function EditEnumDialog(props) { {open: false, severity: 'error', title: '', message: ''}); const [open, setOpen] = useState(false); const [data, setData] = useState(props.items != null ? props.items : []); - // the rows per page of the dialogs, remembered - const [pageSize, setPageSize] = useState(getLastPageSizeOnDialog); // the Sort menu: sorts the items for good (the order of the list in the data); opened at the position of the // button, because material-table renders its actions again and the button element itself doesn't stay const [sortMenuPosition, setSortMenuPosition] = useState(null); @@ -196,15 +188,9 @@ export default function EditEnumDialog(props) { tableRef={tableRef} columns={getColumns()} data={data} - onRowsPerPageChange={size => { - setPageSize(size); - setLastPageSizeOnDialog(size); - }} options={{ - paging: true, - pageSize: pageSize, - paginationType: 'stepped', - pageSizeOptions: getPageSizeOptionsOnDialog(), + // one list without pages, so that any item can be dragged anywhere + paging: false, actionsColumnIndex: -1, selection: false, filtering: false, @@ -252,27 +238,12 @@ export default function EditEnumDialog(props) { }} actions={[ { - icon: () => , + icon: () => , tooltip: 'Sort items', isFreeAction: true, disabled: data.length < 2, onClick: openSortMenu - }, - rowData => ({ - icon: () => , - tooltip: 'Move down', - onClick: (event, rowData) => setData( - moveDown(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === data.length - - 1) - }), - rowData => ({ - icon: () => , - tooltip: 'Move up', - onClick: (event, rowData) => setData( - moveUp(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === 0) - }) + } ]} /> setData(movedRow(data, from, to))}/> }} editable={getEditable()} - actions={[ - rowData => ({ - icon: ArrowDropDown, - tooltip: 'Move down', - onClick: (event, rowData) => setData(moveDown(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === data.length - 1) - }), - rowData => ({ - icon: ArrowDropUp, - tooltip: 'Move up', - onClick: (event, rowData) => setData(moveUp(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === 0) - }) - ]} /> ({ - icon: () => , - tooltip: 'Move down', - onClick: (event, rowData) => setData( - moveDown(columns, rowData.tableData.id)), - disabled: (rowData.tableData.id === columns.length - 1) - }), - rowData => ({ - icon: () => , - tooltip: 'Move up', - onClick: (event, rowData) => setData( - moveUp(columns, rowData.tableData.id)), - disabled: (rowData.tableData.id === 0) - }) - ]} /> setData(movedRow(data, from, to))}/>}} // Native HTML drag and drop: material-table passes the other props on to the . The row isn't draggable while a row // is edited (the inputs need the mouse). diff --git a/frontend/src/components/utils/PropertiesTable.jsx b/frontend/src/components/utils/PropertiesTable.jsx index 9ec45e2..8d8f823 100644 --- a/frontend/src/components/utils/PropertiesTable.jsx +++ b/frontend/src/components/utils/PropertiesTable.jsx @@ -3,16 +3,13 @@ import { getTableBodyHeight, getTableHeaderBackgroundColor, getTableRowBackgroundColor, - moveDown, movedRow, - moveUp, withoutHeaderSorting, removeRow, replaceRow } from "../../utils/MaterialTableHelper"; import SelectEnumDialog from "../dialogs/SelectEnumDialog"; import {isItemChanged, uuidV4, validateItem} from "../../utils/JsonHelper"; -import {ArrowDropDown, ArrowDropUp} from "@mui/icons-material"; import MaterialTable from '@material-table/core'; import DraggableBodyRow from "./DraggableBodyRow"; import React, {useEffect, useState} from "react"; @@ -234,20 +231,6 @@ export default function PropertiesTable(props) { } }), }} - actions={[ - rowData => ({ - icon: () => , - tooltip: 'Move down', - onClick: (event, rowData) => setData(moveDown(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === data.length - 1) - }), - rowData => ({ - icon: () => , - tooltip: 'Move up', - onClick: (event, rowData) => setData(moveUp(data, rowData.tableData.id)), - disabled: (rowData.tableData.id === 0) - }) - ]} /> { } } -export const moveUp = (dataCollection, itemId) => { - return swappedArray(dataCollection, itemId, itemId - 1); -} - // A row edited or removed in a table whose rows are kept in a state: material-table 6 passes copies of the rows (with // tableData) and leaves the objects of the state as they are, so the row is found by its position (tableData.index) const withoutTableData = ({tableData, ...row}) => row; @@ -224,10 +220,6 @@ export const replaceRow = (rows, oldData, newData) => export const removeRow = (rows, oldData) => rows.filter((row, index) => index !== oldData.tableData.index); -export const moveDown = (dataCollection, itemId) => { - return swappedArray(dataCollection, itemId, itemId + 1); -} - // Rows sorted for good by a text field: natural order ("item2" before "item10"), letters with diacritics in place, a // stable sort (rows with the same value keep their order) const naturalCollator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'}); @@ -246,17 +238,10 @@ export const movedRow = (rows, from, to) => { return newRows; } -// Columns of a table whose rows have an order of their own (Move up/down, dragging): the headers don't sort, because -// that would only sort the view, while the arrows and dragging move the rows in the data (options.sorting is not -// enough in material-table 6) +// Columns of a table whose rows have an order of their own (dragging): the headers don't sort, because that would only +// sort the view, while dragging moves the rows in the data (options.sorting is not enough in material-table 6) export const withoutHeaderSorting = columns => columns.map(column => ({...column, sorting: false})); -function swappedArray(arr, index1, index2) { - const newArr = [...arr]; - [newArr[index1], newArr[index2]] = [newArr[index2], newArr[index1]]; - return newArr; -} - export const getTableHeight = () => { // Total Height - Appbar (72) - Toolbar (64) - Footer (52) const staticElements = 72 + 64 + 52 + 2;