Skip to content

Commit 7620dbe

Browse files
Improve spreadsheet global model editor ui (#3206)
* Improve spreadsheet global model editor ui * column initial focus changed to column name * Remove custom editor for column ID * Fix error message not shown on column name Signed-off-by: Franck LECUYER <[email protected]> Co-authored-by: Achour berrahma <[email protected]>
1 parent 47155a3 commit 7620dbe

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/columnName-editor.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
import { TextInput } from '@gridsuite/commons-ui';
7+
import { TableTextInput } from '@gridsuite/commons-ui';
88
import { useCallback } from 'react';
99
import { useWatch } from 'react-hook-form';
1010

@@ -23,12 +23,13 @@ export default function ColumnNameEditor({ name, rowIndex, generateColumnId }: C
2323
}, [columnName, rowIndex, generateColumnId]);
2424

2525
return (
26-
<TextInput
26+
<TableTextInput
2727
name={name}
28-
formProps={{
28+
inputProps={{
2929
autoFocus: true,
3030
onBlur: onBlurColumnName,
3131
}}
32+
showErrorMsg={true}
3233
/>
3334
);
3435
}

src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/spreadsheet-model-global-editor-table.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import React, { useCallback, useMemo } from 'react';
8+
import React, { useCallback, useEffect, useMemo } from 'react';
99
import { SELECTED } from '../../../../utils/field-constants';
1010
import { DndColumn, DndColumnType, DndTable } from '@gridsuite/commons-ui';
1111
import { useFieldArray, useFormContext } from 'react-hook-form';
@@ -32,7 +32,7 @@ export function SpreadsheetModelGlobalEditorTable() {
3232
const useColumnsModelFieldArrayOutput = useFieldArray({
3333
name: `${COLUMNS_MODEL}`,
3434
});
35-
const { getValues, setValue } = useFormContext();
35+
const { getValues, setValue, setFocus } = useFormContext();
3636

3737
const getAvailableDependencies = useCallback(
3838
(excludeColumnId: string) => {
@@ -45,16 +45,6 @@ export function SpreadsheetModelGlobalEditorTable() {
4545

4646
const COLUMNS_MODEL_DEFINITIONS: (DndColumn & { initialValue?: string | null | string[] })[] = useMemo(() => {
4747
return [
48-
{
49-
label: intl.formatMessage({ id: 'spreadsheet/global-model-edition/column_id' }),
50-
dataKey: COLUMN_ID,
51-
type: DndColumnType.TEXT,
52-
editable: true,
53-
initialValue: '',
54-
showErrorMsg: true,
55-
width: '20%',
56-
maxWidth: '20%',
57-
},
5848
{
5949
label: intl.formatMessage({ id: 'spreadsheet/global-model-edition/column_name' }),
6050
dataKey: COLUMN_NAME,
@@ -78,6 +68,16 @@ export function SpreadsheetModelGlobalEditorTable() {
7868
},
7969
}),
8070
},
71+
{
72+
label: intl.formatMessage({ id: 'spreadsheet/global-model-edition/column_id' }),
73+
dataKey: COLUMN_ID,
74+
type: DndColumnType.TEXT,
75+
editable: true,
76+
initialValue: '',
77+
showErrorMsg: true,
78+
width: '20%',
79+
maxWidth: '20%',
80+
},
8181
{
8282
label: intl.formatMessage({ id: 'spreadsheet/global-model-edition/column_type' }),
8383
dataKey: COLUMN_TYPE,
@@ -139,6 +139,10 @@ export function SpreadsheetModelGlobalEditorTable() {
139139
return [newColumnRowData];
140140
};
141141

142+
useEffect(() => {
143+
setFocus(`${COLUMNS_MODEL}[0].${COLUMN_NAME}`);
144+
}, [setFocus]);
145+
142146
return (
143147
<DndTable
144148
arrayFormName={`${COLUMNS_MODEL}`}
@@ -148,6 +152,7 @@ export function SpreadsheetModelGlobalEditorTable() {
148152
withAddRowsDialog={false}
149153
disableDragAndDrop={false}
150154
showMoveArrow={false}
155+
tableHeight={450}
151156
/>
152157
);
153158
}

0 commit comments

Comments
 (0)