@@ -100,7 +100,7 @@ export function databaseReducer(state: TableDataType, action: ActionType) {
100100 // trim label will get a valid yaml key
101101 const update_col_key : string = dbTrim ( action . label ) ;
102102 // Update configuration & row files on disk
103-
103+ console . log ( "option label" , action . label ) ;
104104 state . view . diskConfig
105105 . updateColumnKey ( action . columnId , update_col_key , action . label )
106106 . then ( async ( ) => {
@@ -117,33 +117,30 @@ export function databaseReducer(state: TableDataType, action: ActionType) {
117117 ) ;
118118 } )
119119 ) ;
120- // Update state
121- return {
122- ...state ,
123- skipReset : true ,
124- // Add column visually into the new label
125- columns : [
126- ...state . columns . slice ( 0 , update_column_label_index ) ,
127- {
128- ...state . columns [ update_column_label_index ] ,
129- label : action . label ,
130- id : update_col_key ,
131- key : update_col_key ,
132- accessor : update_col_key ,
133- } ,
134- ...state . columns . slice (
135- update_column_label_index + 1 ,
136- state . columns . length
137- ) ,
138- ] ,
139- // Add data visually into the new label
140- data : state . data . map ( ( row : RowDataType ) => {
141- row [ update_col_key ] = row [ action . columnId ] ;
142- delete row [ action . columnId ] ;
143- return row ;
144- } ) ,
145- } ;
146120 } ) ;
121+ // Update state
122+ return update ( state , {
123+ skipReset : { $set : true } ,
124+ // Add column visually into the new label
125+ columns : {
126+ [ update_column_label_index ] : {
127+ $merge : {
128+ label : action . label ,
129+ id : update_col_key ,
130+ key : update_col_key ,
131+ accessor : update_col_key ,
132+ } ,
133+ } ,
134+ } ,
135+ // Add data visually into the new label
136+ data : {
137+ $set : state . data . map ( ( row : RowDataType ) => {
138+ row [ update_col_key ] = row [ action . columnId ] ;
139+ delete row [ action . columnId ] ;
140+ return row ;
141+ } ) ,
142+ } ,
143+ } ) ;
147144
148145 /**
149146 * Modify type of column and adapt the data.
0 commit comments