Skip to content

Commit

Permalink
JNG-5963 date cell editor locales
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Oct 11, 2024
1 parent ca13d85 commit 218a23f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {
GridEditBooleanCell,
type GridRenderEditCellParams,
} from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}';
import { AdapterDateFns } from '@mui/x-date-pickers{{ getMUIPickersPlanSuffix }}/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers{{ getMUIPickersPlanSuffix }}/LocalizationProvider';
import { TRINARY_LOGIC } from '~/components-api/components/TrinaryLogic';
import { MdiIcon } from '../MdiIcon';
import { locales, useL10N } from '~/l10n/l10n-context';

const StyledTooltip = styled(({ className, ...props }: TooltipProps) => (
<Tooltip {...props} classes={ { popper: className } } />
Expand Down Expand Up @@ -64,6 +67,7 @@ export function BooleanSelectEditInputCell(props: GridRenderEditCellParams<any>)

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

let EditComponent: any = GridEditInputCell;

Expand All @@ -76,8 +80,10 @@ export function CellEditInput(props: GridRenderEditCellParams & { error?: string
}

return (
<StyledTooltip open={!!error} title={error}>
<EditComponent {...otherProps} error={error !== null && error !== undefined} />
</StyledTooltip>
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={locales[locale]}>
<StyledTooltip open={!!error} title={error}>
<EditComponent {...otherProps} error={error !== null && error !== undefined} />
</StyledTooltip>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { OBJECTCLASS } from '@pandino/pandino-api';
import type { ServiceReference } from '@pandino/pandino-api';
import { useTrackService, useBundleContext } from '@pandino/react-hooks';

const locales = {
export const locales = {
'en-US': enUS,
{{# neq (shortLocale (getDefaultLanguage application)) 'en' }}
'{{ getDefaultLanguage application }}': {{ shortLocale (getDefaultLanguage application) }},
Expand Down

0 comments on commit 218a23f

Please sign in to comment.