@@ -59,6 +59,8 @@ import pickBy from 'lodash/pickBy'
5959import every from 'lodash/every'
6060import isEmpty from 'lodash/isEmpty'
6161import findIndex from 'lodash/findIndex'
62+ import isString from 'lodash/isString'
63+ import isNaN from 'lodash/isNaN'
6264
6365import { OperationsContext } from '../app/LayoutContext' ;
6466
@@ -140,6 +142,7 @@ const MapProject = () => {
140142 const [ autoMatchUnmappedOnly , setAutoMatchUnmappedOnly ] = React . useState ( true )
141143 const [ alert , setAlert ] = React . useState ( false )
142144 const [ columnVisibilityModel , setColumnVisibilityModel ] = React . useState ( { } )
145+ const [ columnWidth , setColumnWidth ] = React . useState ( { } )
143146
144147 // repo state
145148 const [ repo , setRepo ] = React . useState ( false )
@@ -195,11 +198,21 @@ const MapProject = () => {
195198 return _col
196199 } ) )
197200 let colVisibility = { }
201+ let colWidth = { }
198202 response . data . columns . forEach ( col => {
199203 if ( col . hidden )
200204 colVisibility [ col . dataKey ] = false
205+ if ( col . width ) {
206+ if ( isString ( col . width ) ) {
207+ let _width = parseInt ( col . width . replace ( 'px' ) )
208+ if ( ! isNaN ( _width ) )
209+ col . width = _width
210+ }
211+ colWidth [ col . dataKey ] = col . width
212+ }
201213 } )
202214 setColumnVisibilityModel ( colVisibility )
215+ setColumnWidth ( colWidth )
203216 }
204217 setTimeout ( ( ) => {
205218 let _file = getFileObjectFromRows ( response . data . input_file_name )
@@ -252,6 +265,8 @@ const MapProject = () => {
252265 let widthParams = { }
253266 if ( columns . length < 2 )
254267 widthParams . flex = 1
268+ if ( columnWidth [ column . dataKey ] )
269+ widthParams . width = columnWidth [ column . dataKey ]
255270 else if ( column . label . toLowerCase ( ) . includes ( 'name' ) || column . label . toLowerCase ( ) . includes ( 'description' ) || column . label . toLowerCase ( ) . includes ( 'synonyms' ) )
256271 widthParams . width = 300
257272 else if ( column . label . toLowerCase ( ) . includes ( 'uuid' ) || column . label . toLowerCase ( ) . includes ( 'external' ) )
@@ -418,7 +433,7 @@ const MapProject = () => {
418433 formData . append ( 'matches' , JSON . stringify ( selected ) )
419434 formData . append ( 'name' , name || f . name )
420435 formData . append ( 'description' , description )
421- formData . append ( 'columns' , JSON . stringify ( map ( columns , col => ( { ...col , hidden : columnVisibilityModel [ col . dataKey ] === false } ) ) ) )
436+ formData . append ( 'columns' , JSON . stringify ( map ( columns , col => ( { ...col , hidden : columnVisibilityModel [ col . dataKey ] === false , width : columnWidth [ col . dataKey ] || undefined } ) ) ) )
422437 if ( repoVersion ?. version_url )
423438 formData . append ( 'target_repo_url' , repoVersion . version_url )
424439 formData . append ( 'matching_algorithm' , algo )
@@ -1231,6 +1246,7 @@ const MapProject = () => {
12311246 }
12321247 } }
12331248 columnHeaderHeight = { 64 }
1249+ onColumnWidthChange = { ( params ) => params ?. colDef ?. field ? setColumnWidth ( { ...columnWidth , [ params ?. colDef ?. field ] : params . width } ) : null }
12341250 getRowHeight = { ( ) => 'auto' }
12351251 getRowId = { row => row . __index }
12361252 rows = { rows }
0 commit comments