diff --git a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot index b03142965..3100aeed0 100644 --- a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot +++ b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot @@ -249,6 +249,13 @@ export default function GodGodGalaxiesAccessTablePage() { await refresh(); } }; + const applyRowEdit = async (rowData: ViewGalaxyStored): Promise => { + setIsLoading(true); + alert(JSON.stringify(rowData, null, 2)); + setTimeout(() => { + setIsLoading(false); + }, 500); + }; const actions: ViewGalaxyTablePageActions = { getPageTitle, @@ -263,6 +270,7 @@ export default function GodGodGalaxiesAccessTablePage() { createIntergalacticDustAction, createInterstellarMediumAction, getMask, + applyRowEdit, ...(customActions ?? {}), }; diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiWidgetHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiWidgetHelper.java index 621d9edd0..0253f775c 100644 --- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiWidgetHelper.java +++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiWidgetHelper.java @@ -381,9 +381,9 @@ public static String tableButtonVisibilityConditions(Button button, Table table, public static String tableRowButtonDisabledConditions(Button button, Table table, PageContainer container) { if (table.getIsRelationType() && table.getRelationType().isIsInlineCreatable() && (button.getActionDefinition().getIsRemoveAction()) || button.getActionDefinition().getIsBulkRemoveAction()) { if (button.getActionDefinition().getIsRemoveAction()) { - return "isLoading"; + return "isLoading || isRowInEditMode"; } else if (button.getActionDefinition().getIsBulkRemoveAction()) { - return "getSelectedRows && getSelectedRows().length > 0 || isLoading"; + return "(getSelectedRows && getSelectedRows().length > 0) || isLoading || isRowInEditMode"; } } String result = "getSelectedRows && getSelectedRows().length > 0 ||"; @@ -421,7 +421,7 @@ public static String tableRowButtonDisabledConditions(Button button, Table table result += "!row." + button.getEnabledBy().getName() + " || "; } - return result + "isLoading"; + return result + "isLoading || isRowInEditMode"; } public static String checkboxLabelPlacement(Checkbox checkbox) { diff --git a/judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs index 41fc5bd0a..a74f14fe9 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs @@ -91,6 +91,7 @@ interface EagerTableProps void; handleRowEditStop?: GridEventListener<'rowEditStop'>; @@ -132,6 +133,7 @@ export function EagerTable { const cols = [ ...columns, - ...columnsActionCalculator(dataElementId, tableRowActions, t, isLoading, getSelectedRows, ownerData, { crudOperationsDisplayed: crudOperationsDisplayed, transferOperationsDisplayed: transferOperationsDisplayed }) + ...columnsActionCalculator(dataElementId, tableRowActions, t, isLoading, editable, rowModesModel, getSelectedRows, ownerData, { crudOperationsDisplayed: crudOperationsDisplayed, transferOperationsDisplayed: transferOperationsDisplayed }) ]; {{# if isMUILicensePlanPro }} if (columnState.length) { diff --git a/judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs index 35614db81..c9156ad52 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs @@ -104,6 +104,7 @@ interface LazyTableProps Promise; } export function LazyTable>(props: LazyTableProps) { @@ -150,6 +151,7 @@ export function LazyTable(); const [isNextButtonEnabled, setIsNextButtonEnabled] = useState(true); const [rowModesModel, setRowModesModel] = useState({}); - const [rowEditingData, setRowEditingData] = useState>({}); const isLoading = useMemo(() => isInternalLoading || !!isOwnerLoading, [isInternalLoading, isOwnerLoading]); @@ -242,14 +243,10 @@ export function LazyTable, isCRUD: true, - forceKeep: true, + isEditAction: true, hidden: (row: any) => rowModesModel[row.__identifier]?.mode === GridRowModes.Edit, disabled: () => false, - action: async (rowData: any) => { - setRowEditingData({ - ...rowEditingData, - [rowData.__identifier]: simpleCloneDeep(rowData), - }); + action: async (rowData: TStored) => { setRowModesModel({ ...rowModesModel, [rowData.__identifier!]: { mode: GridRowModes.Edit } }); }, }, @@ -257,45 +254,35 @@ export function LazyTable, isCRUD: true, - forceKeep: true, + isEditAction: true, hidden: (row: any) => !(rowModesModel[row.__identifier]?.mode === GridRowModes.Edit), disabled: () => false, - action: async (rowData: any) => { - + action: async (rowData: TStored) => { + setRowModesModel({ ...rowModesModel, [rowData.__identifier!]: { mode: GridRowModes.View } }); + /*try { + const validationResult = await applyRowEdit!(rowData); + } catch(e) { + console.error(e); + }*/ }, }, { id: `${uniqueId}-row-cancel`, icon: , isCRUD: true, - forceKeep: true, + isEditAction: true, hidden: (row: any) => !(rowModesModel[row.__identifier]?.mode === GridRowModes.Edit), disabled: () => false, - action: async (rowData: any) => { - setRowModesModel({ - ...rowModesModel, - [rowData.__identifier!]: { mode: GridRowModes.View, ignoreModifications: true } - }); - const tmp = { - ...rowEditingData, - }; - const original = tmp[rowData.__identifier]; - delete rowEditingData[rowData.__identifier]; - setData((prevData) => { - const ttt = [...prevData]; - const idx = ttt.findIndex(d => d.__identifier === rowData.__identifier); - ttt[idx] = original; - // debugger; - return [...ttt]; - }); + action: async (rowData: TStored) => { + setRowModesModel({ ...rowModesModel, [rowData.__identifier!]: { mode: GridRowModes.View, ignoreModifications: true } }); }, }, - ], [rowEditingData, tableRowActions, rowModesModel]); + ], [tableRowActions, rowModesModel, applyRowEdit]); const effectiveTableColumns = useMemo(() => { const cols = [ ...columns, - ...columnsActionCalculator(dataElementId, [...(editable ? editActions: []), ...tableRowActions], t, isLoading, getSelectedRows, ownerData, { crudOperationsDisplayed: crudOperationsDisplayed, transferOperationsDisplayed: transferOperationsDisplayed }) + ...columnsActionCalculator(dataElementId, [...(editable ? editActions: []), ...tableRowActions], t, isLoading, editable, rowModesModel, getSelectedRows, ownerData, { crudOperationsDisplayed, transferOperationsDisplayed }) ]; {{# if isMUILicensePlanPro }} if (columnState.length) { @@ -313,7 +300,7 @@ export function LazyTable { @@ -600,25 +587,14 @@ export function LazyTable { - console.warn(newRow); - //const updatedRow = { ...newRow, isNew: false }; - //setRows(rows.map((row) => (row.id === newRow.id ? updatedRow : row))); - //return updatedRow; - }; - - const handleRowModesModelChange = (newRowModesModel: GridRowModesModel) => { - // setRowModesModel(newRowModesModel); - }; - - const handleRowEditStop: GridEventListener<'rowEditStop'> = (params, event) => { - if (params.reason === GridRowEditStopReasons.rowFocusOut) { - event.defaultMuiPrevented = true; - } - }; + const processRowUpdate = useCallback(async (newRow: GridRowModel) => { + await applyRowEdit!(newRow as TStored); + throw new Error('lmao'); + }, [applyRowEdit]); const handleProcessRowUpdateError = useCallback((error: Error) => { console.error(error); + setRowModesModel({ ...rowModesModel, [error.message]: { mode: GridRowModes.Edit } }); }, []); return ( @@ -651,10 +627,8 @@ export function LazyTable ( + +))(({ theme }) => ({ + [`& .${tooltipClasses.tooltip}`]: { + backgroundColor: theme.palette.error.main, + color: theme.palette.error.contrastText, + }, +})); + +export function NameEditInputCell(props: GridRenderEditCellParams & { error?: string }) { + const { error } = props; + + return ( + + + + ); +} diff --git a/judo-ui-react/src/main/resources/actor/src/components/table/table-row-actions.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/table/table-row-actions.tsx.hbs index 441b980c0..70f6e48e5 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/table/table-row-actions.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/table/table-row-actions.tsx.hbs @@ -2,14 +2,18 @@ import Button from '@mui/material/Button'; import ButtonGroup from '@mui/material/ButtonGroup'; -import type { GridActionsColDef, GridRowParams } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; +import { type GridActionsColDef, type GridRowParams, type GridRowModesModel, GridRowModes } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; import type { TFunction } from 'i18next'; +import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable'; import { baseColumnConfig, characterMultiplier, iconAndDropdownIconExtra, onlyDropdownWidth } from '../../config'; import type { ColumnActionsProvider, ColumnsActionsOptions, TableRowAction } from '../../utilities'; import { DropdownButton } from '../DropdownButton'; import { MdiIcon } from '../MdiIcon'; -export const calculateMinWidth = (entry: TableRowAction[]) => entry.length ? ((entry.map(a => (a.label ?? '').length).reduce((p, c) => p + c, 0) * characterMultiplier) + iconAndDropdownIconExtra) : onlyDropdownWidth; +export const calculateMinWidth = (entry: TableRowAction[], editable = false) => { + const baseWidth = entry.length ? ((entry.map(a => (a.label ?? '').length).reduce((p, c) => p + c, 0) * characterMultiplier) + iconAndDropdownIconExtra) : onlyDropdownWidth; + return baseWidth + (editable ? 90 : 0); +}; const findLastIndex = (array: T[], predicate: (e: T) => boolean): number => { for (let i = array.length - 1; i >= 0; i--) { @@ -20,11 +24,18 @@ const findLastIndex = (array: T[], predicate: (e: T) => boolean): number => return -1; }; +const isRowInEditMode = ,>(row: T, gridRowModesModel: GridRowModesModel): boolean => { + const rowData = gridRowModesModel[row.__identifier!]; + return rowData?.mode === GridRowModes.Edit; +}; + export const columnsActionCalculator: ColumnActionsProvider = ( id: string, actions: TableRowAction[], t: TFunction, isLoading: boolean, + editable: boolean, + rowModesModel: GridRowModesModel, getSelectedRows: () => any[], ownerData?: any, options?: ColumnsActionsOptions, @@ -35,7 +46,7 @@ export const columnsActionCalculator: ColumnActionsProvider = ( }; const originalCrudActions = actions.filter((a) => !!a.action && a.isCRUD); const originalOperationActions = actions.filter((a) => !!a.action && !a.isCRUD); - const keptCrudActions = originalCrudActions.splice(0, (findLastIndex>(actions, a => !!a.forceKeep) + 1) + (safeOptions.crudOperationsDisplayed || 0)); + const keptCrudActions = originalCrudActions.splice(0, (findLastIndex>(actions, a => !!a.isEditAction) + 1) + (safeOptions.crudOperationsDisplayed || 0)); const keptOperationActions = originalOperationActions.splice(0, safeOptions.transferOperationsDisplayed); const splitActions = [...keptCrudActions, ...keptOperationActions]; const dropdownActions = [...originalCrudActions, ...originalOperationActions]; @@ -50,7 +61,7 @@ export const columnsActionCalculator: ColumnActionsProvider = ( field: 'actions', sortable: false, disableColumnMenu: true, - minWidth: calculateMinWidth(splitActions), + minWidth: calculateMinWidth(splitActions, editable), headerName: t('judo.pages.table.column.actions', { defaultValue: 'Actions' }) as string, type: 'actions', getActions: (params: GridRowParams) => [ @@ -61,7 +72,7 @@ export const columnsActionCalculator: ColumnActionsProvider = ( key={a.id} variant="text" startIcon={a.icon} - disabled={a.disabled ? a.disabled(params.row, isLoading, getSelectedRows, ownerData) : false} + disabled={a.disabled ? a.disabled(params.row, isLoading, isRowInEditMode(params.row, rowModesModel), getSelectedRows, ownerData) : false} onClick={() => a.action!(params.row)} > {a.label ?? ''} @@ -76,7 +87,7 @@ export const columnsActionCalculator: ColumnActionsProvider = ( label: action.label, startIcon: action.icon, onClick: () => action.action!(params.row), - disabled: action.disabled ? action.disabled(params.row, isLoading, getSelectedRows, ownerData) : false, + disabled: action.disabled ? action.disabled(params.row, isLoading, isRowInEditMode(params.row, rowModesModel), getSelectedRows, ownerData) : false, }))} > diff --git a/judo-ui-react/src/main/resources/actor/src/containers/components/table/index.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/containers/components/table/index.tsx.hbs index de6b73089..d8f1351f0 100644 --- a/judo-ui-react/src/main/resources/actor/src/containers/components/table/index.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/containers/components/table/index.tsx.hbs @@ -26,6 +26,7 @@ import type { GridRowClassNameParams, GridRowParams, GridValidRowModel, + GridRenderEditCellParams, } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; import { baseColumnConfig, baseTableConfig, basePageSizeOptions{{# unless table.isEager }}, filterDebounceMs{{/ unless }} } from '~/config'; import { MdiIcon{{# unless table.isEager }}, CustomTablePagination{{/ unless }} } from '~/components'; @@ -84,13 +85,15 @@ import { {{# unless table.isEager }} useErrorHandler, {{/ unless }} + type ServerError, + validateWithNestedErrors, } from '~/utilities'; import type { SidekickComponentProps, DialogResult, TableRowAction, ToolBarActionProps, ColumnCustomizerHook, FiltersSerializer{{# if isMUILicensePlanPro }}, PersistedColumnInfo{{/ if }} } from '~/utilities'; import { OBJECTCLASS } from '@pandino/pandino-api'; import { useTrackComponent, ComponentProxy } from '@pandino/react-hooks'; {{# if (stringValueIsTrue useTableRowHighlighting) }} import { useTrackService } from '@pandino/react-hooks'; -import { RowHighlightLegend } from '~/components/table'; +import { RowHighlightLegend, NameEditInputCell } from '~/components/table'; import { TABLE_ROW_HIGHLIGHTING_HOOK_INTERFACE_KEY, transformRowStylings } from '~/theme/table-row-highlighting'; import type { RowStylerConfigured, TableRowHighlightingHook } from '~/theme/table-row-highlighting'; {{/ if }} @@ -141,6 +144,33 @@ export function {{ componentName table }}(props: {{ componentName table }}Props) {{# if (tableHasBinaryColumn table) }} const { downloadFile, extractFileNameFromToken } = fileHandling(); {{/ if }} + const [rowValidation, setRowValidation] = useState>>(new Map>()); + + const applyRowEdit = useCallback(async (rowData: {{ classDataName (getReferenceClassType table) 'Stored' }}) => { + try { + await actions.apply{{ firstToUpper table.relationName }}RowEdit!(rowData); + } catch(e: any) { + if (e?.response?.status === 400) { + // setRowValidation(rowData.__identifier, e.response.data); + const errorMap: Map = new Map(); + const errorList = e.response.data as ServerError<{{ classDataName (getReferenceClassType table) 'Stored' }}>[]; + if (errorList && errorList.length && errorList[0].location) { + validateWithNestedErrors(errorList, errorMap, t); + } + setRowValidation((prevValidation) => { + const copy = new Map>(prevValidation); + copy.set(rowData.__identifier!, errorMap); + return copy; + }); + } else { + setRowValidation((prevValidation) => { + const copy = new Map>(prevValidation); + copy.delete(rowData.__identifier!); + return copy; + }); + } + } + }, [actions]); {{# each (customizableColumns table) as |column| }} const { service: {{ column.name }}ColumnCustomizerHook } = useTrackService>(`(&(${OBJECTCLASS}=${TABLE_COLUMN_CUSTOMIZER_HOOK_INTERFACE_KEY})(component={{~ componentName table ~}})(column={{ column.name }})`); @@ -207,7 +237,7 @@ export function {{ componentName table }}(props: {{ componentName table }}Props) isCRUD: true, {{/ if }} hidden: (row: any) => false, - disabled: (row: {{ classDataName (getReferenceClassType table) 'Stored' }}, isLoading: boolean, getSelectedRows: () => {{# with (getReferenceClassType table) as |classType| }}{{# if classType.isMapped }}{{ classDataName (getReferenceClassType table) 'Stored' }}[]{{ else }}{{ classDataName (getReferenceClassType table) '' }}[]{{/ if }}{{/ with }}, ownerdata?: any): boolean => {{{ tableRowButtonDisabledConditions button table container }}}, + disabled: (row: {{ classDataName (getReferenceClassType table) 'Stored' }}, isLoading: boolean, isRowInEditMode: boolean, getSelectedRows: () => {{# with (getReferenceClassType table) as |classType| }}{{# if classType.isMapped }}{{ classDataName (getReferenceClassType table) 'Stored' }}[]{{ else }}{{ classDataName (getReferenceClassType table) '' }}[]{{/ if }}{{/ with }}, ownerdata?: any): boolean => {{{ tableRowButtonDisabledConditions button table container }}}, action: actions.{{ simpleActionDefinitionName button.actionDefinition }} ? async (rowData) => { {{# unless (isParameterOpenerButton button) }} {{> actor/src/fragments/container/action-call-confirm-check.fragment.hbs button=button dataParam='rowData' }} @@ -367,6 +397,7 @@ export function {{ componentName table }}(props: {{ componentName table }}Props) enabledByName='{{ table.enabledBy.name }}' relationName='{{ table.relationName }}' filtersSerializer={filtersSerializer} + applyRowEdit={applyRowEdit} {{# if container.isSelector }} selectionDiff={selectionDiff} setSelectionDiff={setSelectionDiff} diff --git a/judo-ui-react/src/main/resources/actor/src/containers/components/table/types.ts.hbs b/judo-ui-react/src/main/resources/actor/src/containers/components/table/types.ts.hbs index 18190f05c..545bdc9b0 100644 --- a/judo-ui-react/src/main/resources/actor/src/containers/components/table/types.ts.hbs +++ b/judo-ui-react/src/main/resources/actor/src/containers/components/table/types.ts.hbs @@ -21,6 +21,7 @@ import type { DialogResult } from '~/utilities'; export interface {{ componentName table }}ActionDefinitions { get{{ firstToUpper table.relationName }}Mask?: () => string; get{{ firstToUpper table.relationName }}RowRepresentation?: (row: {{ classDataName (getReferenceClassType table) 'Stored' }}) => string; + apply{{ firstToUpper table.relationName }}RowEdit?: (rowData: {{ classDataName (getReferenceClassType table) 'Stored' }}) => Promise; {{# each table.tableActionDefinitions as |actionDefinition| }} {{# if actionDefinition.isFilterAction }} {{ simpleActionDefinitionName actionDefinition }}?: (id: string, filterOptions: FilterOption[], model?: GridFilterModel, filters?: Filter[]) => Promise<{ model?: GridFilterModel; filters?: Filter[] }>; diff --git a/judo-ui-react/src/main/resources/actor/src/fragments/relation/column.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/fragments/relation/column.fragment.hbs index 6f8928841..6cda90371 100644 --- a/judo-ui-react/src/main/resources/actor/src/fragments/relation/column.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/fragments/relation/column.fragment.hbs @@ -2,6 +2,16 @@ width: {{ columnWidth column }}, type: '{{ columnType column }}', {{# if (isColumnEditable column) }} editable: true, +renderEditCell: (props: GridRenderEditCellParams) => { + let error: string | undefined; + if (rowValidation.has(props.row.__identifier)) { + const errors = rowValidation.get(props.row.__identifier); + error = errors?.get('{{ column.attributeType.name }}'); + } + return ( + + ); +}, {{/ if }} filterable: {{ isUseInlineColumnFilters }} && {{# if (isColumnFilterable column) }}true{{ else }}false{{/ if }}, {{# unless (isColumnSortable column) }} diff --git a/judo-ui-react/src/main/resources/actor/src/pages/index.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/pages/index.tsx.hbs index 44a0bb807..90a9aa687 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/index.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/index.tsx.hbs @@ -238,6 +238,17 @@ export default function {{ pageName page }}() { return sp; } {{/ if }} + {{# each page.container.tables as |table| }} + {{# if table.isInlineEditable }} + const apply{{ firstToUpper table.relationName }}RowEdit = async (rowData: {{ classDataName (getReferenceClassType table) 'Stored' }}): Promise => { + setIsLoading(true); + alert(JSON.stringify(rowData, null, 2)); + setTimeout(() => { + setIsLoading(false); + }, 500); + }; + {{/ if }} + {{/ each }} const actions: {{ containerComponentName page.container }}PageActions = { getPageTitle, @@ -255,6 +266,11 @@ export default function {{ pageName page }}() { get{{ firstToUpper table.relationName }}Mask, {{/ each }} {{/ unless }} + {{# each page.container.tables as |table| }} + {{# if table.isInlineEditable }} + apply{{ firstToUpper table.relationName }}RowEdit, + {{/ if }} + {{/ each }} ...(customActions ?? {}), }; diff --git a/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs b/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs index 89965b6d0..011918ac2 100644 --- a/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs +++ b/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs @@ -159,7 +159,7 @@ function validateRelationErrors(errorList: ServerError[], dataPath: string }); } -function validateWithNestedErrors(errorList: ServerError[], validation: Map, t: any): void { +export function validateWithNestedErrors(errorList: ServerError[], validation: Map, t: any): void { const errorRelations: Record> = {}; errorList.forEach((error) => { diff --git a/judo-ui-react/src/main/resources/actor/src/utilities/interfaces.ts.hbs b/judo-ui-react/src/main/resources/actor/src/utilities/interfaces.ts.hbs index 4694e653d..1f8b374da 100644 --- a/judo-ui-react/src/main/resources/actor/src/utilities/interfaces.ts.hbs +++ b/judo-ui-react/src/main/resources/actor/src/utilities/interfaces.ts.hbs @@ -1,13 +1,16 @@ {{> fragment.header.hbs }} -import type { GridColDef } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; +import type { GridColDef, GridRowModesModel } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; import type { TFunction } from 'i18next'; import { ColumnsActionsOptions, TableRowAction } from './table-row-actions'; export type ColumnActionsProvider = ( id: string, - actions: TableRowAction[], t: TFunction, + actions: TableRowAction[], + t: TFunction, isLoading: boolean, + editable: boolean, + rowModesModel: GridRowModesModel, getSelectedRows: () => RStored[], ownerData?: RStored, options?: ColumnsActionsOptions, diff --git a/judo-ui-react/src/main/resources/actor/src/utilities/table-row-actions.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/utilities/table-row-actions.tsx.hbs index 30e0eab5f..508952ae6 100644 --- a/judo-ui-react/src/main/resources/actor/src/utilities/table-row-actions.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/utilities/table-row-actions.tsx.hbs @@ -11,12 +11,13 @@ export interface TableRowAction { disabled: ( row: RStored, isLoading: boolean, + isRowInEditMode: boolean, getSelectedRows: () => R[], ownerData?: any, ) => boolean, disabledExpression?: string; isCRUD?: boolean; - forceKeep?: boolean; + isEditAction?: boolean; } export interface ColumnsActionsOptions { diff --git a/judo-ui-react/src/main/resources/ui-react.yaml b/judo-ui-react/src/main/resources/ui-react.yaml index 65f1ba200..877c1a390 100644 --- a/judo-ui-react/src/main/resources/ui-react.yaml +++ b/judo-ui-react/src/main/resources/ui-react.yaml @@ -443,6 +443,10 @@ templates: pathExpression: "'src/components/table/table-column-operators.tsx'" templateName: actor/src/components/table/table-column-operators.tsx.hbs + - name: actor/src/components/table/table-editor.tsx + pathExpression: "'src/components/table/table-editor.tsx'" + templateName: actor/src/components/table/table-editor.tsx.hbs + - name: actor/src/components/table/table-row-actions.tsx pathExpression: "'src/components/table/table-row-actions.tsx'" templateName: actor/src/components/table/table-row-actions.tsx.hbs