Skip to content

Commit

Permalink
JNG-5899 save state
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Sep 3, 2024
1 parent 898626d commit d6315e7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,15 @@ export default function GodGodGalaxiesAccessTablePage() {
}
};
const applyRowEdit = async (rowData: ViewGalaxyStored): Promise<any> => {
setIsLoading(true);
alert(JSON.stringify(rowData, null, 2));
setTimeout(() => {
try {
setIsLoading(true);
await godServiceForGalaxiesImpl.update(rowData);
await refresh();
} catch (error) {
return Promise.reject(error);
} finally {
setIsLoading(false);
}, 500);
}
};

const actions: ViewGalaxyTablePageActions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,18 @@ public static boolean isParameterOpenerButton(Button button) {
ActionDefinition actionDefinition = button.getActionDefinition();
return actionDefinition.getIsOpenOperationInputFormAction() || actionDefinition.getIsOpenOperationInputSelectorAction();
}

public static String getCellEditType(Column column) {
DataType dataType = column.getAttributeType().getDataType();

if (dataType instanceof DateType || dataType instanceof TimestampType) {
return "date";
} else if (dataType instanceof EnumerationType) {
return "text";
} else if (dataType instanceof BooleanType) {
return "boolean";
}

return "text";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { styled } from '@mui/material/styles';
import Tooltip, { tooltipClasses, type TooltipProps } from '@mui/material/Tooltip';
import {
GridEditInputCell,
GridEditBooleanCell,
GridEditDateCell,
type GridRenderEditCellParams,
} from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';

Expand All @@ -14,12 +16,23 @@ const StyledTooltip = styled(({ className, ...props }: TooltipProps) => (
},
}));

export function NameEditInputCell(props: GridRenderEditCellParams & { error?: string }) {
const { error } = props;
export type CellEditorType = 'text' | 'boolean' | 'date';

export function CellEditInput(props: GridRenderEditCellParams & { error?: string, cellEditorType: CellEditorType }) {
const { error, cellEditorType } = props;

let EditComponent: any = GridEditInputCell;

if (cellEditorType === 'date') {
EditComponent = GridEditDateCell;
} else if (cellEditorType === 'boolean') {
EditComponent = GridEditBooleanCell;
}

return (
<StyledTooltip open={!!error} title={error}>
<GridEditInputCell {...props} />
{}
<EditComponent {...props} />
</StyledTooltip>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import { OBJECTCLASS } from '@pandino/pandino-api';
import { useTrackComponent, ComponentProxy } from '@pandino/react-hooks';
{{# if (stringValueIsTrue useTableRowHighlighting) }}
import { useTrackService } from '@pandino/react-hooks';
import { RowHighlightLegend, NameEditInputCell } from '~/components/table';
import { RowHighlightLegend, CellEditInput } 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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ renderEditCell: (props: GridRenderEditCellParams) => {
error = errors?.get('{{ column.attributeType.name }}');
}
return (
<NameEditInputCell { ...props } error={error} />
<CellEditInput { ...props } error={error} cellEditorType={'{{ getCellEditType column }}'} />
);
},
{{/ if }}
Expand Down

0 comments on commit d6315e7

Please sign in to comment.