@@ -6,19 +6,20 @@ import { AbstractTableAction } from "stateManagement/AbstractTableAction";
66export default class AlterColumnLabelHandlerAction extends AbstractTableAction < ColumnsState > {
77 handle ( tableActionResponse : TableActionResponse < ColumnsState > ) : TableActionResponse < ColumnsState > {
88 const { view, set, implementation } = tableActionResponse ;
9- implementation . alterColumnLabel = ( column : TableColumn , label : string ) =>
9+ implementation . alterColumnLabel = async ( column : TableColumn , newLabel : string ) =>
1010 set ( ( updater ) => {
1111 const labelIndex = updater . columns . findIndex (
1212 ( col : TableColumn ) => col . id === column . id
1313 ) ;
14- const newKey = dbTrim ( label ) ;
15- updater . columns [ labelIndex ] . label = label ;
16- updater . columns [ labelIndex ] . id = newKey ;
17- updater . columns [ labelIndex ] . key = newKey ;
18- updater . columns [ labelIndex ] . accessorKey = newKey ;
14+ const alteredColumns = [ ...updater . columns ] ;
15+ const newKey = dbTrim ( newLabel ) ;
16+ alteredColumns [ labelIndex ] . label = newLabel ;
17+ alteredColumns [ labelIndex ] . id = newKey ;
18+ alteredColumns [ labelIndex ] . key = newKey ;
19+ alteredColumns [ labelIndex ] . accessorKey = newKey ;
1920 // Update configuration & row files on disk
20- view . diskConfig . updateColumnKey ( column . id , newKey , label ) ;
21- return { columns : updater . columns } ;
21+ view . diskConfig . updateColumnKey ( column . id , newKey , newLabel ) ;
22+ return { columns : alteredColumns } ;
2223 } ) ;
2324 tableActionResponse . implementation = implementation ;
2425 return this . goNext ( tableActionResponse ) ;
0 commit comments