@@ -12,16 +12,17 @@ import PropTypes from 'prop-types';
12
12
import Reaction from 'src/models/Reaction' ;
13
13
import {
14
14
createVariationsRow , copyVariationsRow , updateVariationsRow ,
15
- materialTypes , instantiateSelectedColumns ,
15
+ materialTypes , getVariationsColumns ,
16
16
addMissingColumnsToVariations , removeObsoleteColumnsFromVariations ,
17
+ getMetadataColumnGroupChild , getPropertyColumnGroupChild
17
18
} from 'src/apps/mydb/elements/details/reactions/variationsTab/ReactionVariationsUtils' ;
18
19
import {
19
20
getReactionAnalyses , updateAnalyses
20
21
} from 'src/apps/mydb/elements/details/reactions/variationsTab/ReactionVariationsAnalyses' ;
21
22
import {
22
23
updateVariationsGasTypes ,
23
24
getReactionMaterials , getReactionMaterialsIDs , getReactionMaterialsGasTypes ,
24
- removeObsoleteMaterialColumns
25
+ removeObsoleteMaterialColumns , getMaterialColumnGroupChild
25
26
} from 'src/apps/mydb/elements/details/reactions/variationsTab/ReactionVariationsMaterials' ;
26
27
import {
27
28
PropertyFormatter , PropertyParser ,
@@ -43,9 +44,7 @@ export default function ReactionVariations({ reaction, onReactionChange, isActiv
43
44
const [ gasMode , setGasMode ] = useState ( reaction . gaseous ) ;
44
45
const [ allReactionAnalyses , setAllReactionAnalyses ] = useState ( getReactionAnalyses ( reaction ) ) ;
45
46
const [ reactionMaterials , setReactionMaterials ] = useState ( getReactionMaterials ( reaction ) ) ;
46
- const [ selectedColumns , setSelectedColumns ] = useState (
47
- instantiateSelectedColumns
48
- ) ;
47
+ const [ selectedColumns , setSelectedColumns ] = useState ( getVariationsColumns ( reactionVariations ) ) ;
49
48
const [ columnDefinitions , setColumnDefinitions ] = useReducer ( columnDefinitionsReducer , [
50
49
{
51
50
headerName : 'Tools' ,
@@ -59,20 +58,26 @@ export default function ReactionVariations({ reaction, onReactionChange, isActiv
59
58
headerName : 'Metadata' ,
60
59
groupId : 'metadata' ,
61
60
marryChildren : true ,
62
- children : [ ]
61
+ children : selectedColumns . metadata . map ( ( entry ) => getMetadataColumnGroupChild ( entry ) )
63
62
} ,
64
63
{
65
64
headerName : 'Properties' ,
66
65
groupId : 'properties' ,
67
66
marryChildren : true ,
68
- children : [ ]
67
+ children : selectedColumns . properties . map ( ( entry ) => getPropertyColumnGroupChild ( entry , gasMode ) )
69
68
} ,
70
69
] . concat (
71
70
Object . entries ( materialTypes ) . map ( ( [ materialType , { label } ] ) => ( {
72
71
headerName : label ,
73
72
groupId : materialType ,
74
73
marryChildren : true ,
75
- children : [ ]
74
+ children : selectedColumns [ materialType ] . map (
75
+ ( materialID ) => getMaterialColumnGroupChild (
76
+ reactionMaterials [ materialType ] . find ( ( material ) => material . id . toString ( ) === materialID ) ,
77
+ materialType ,
78
+ gasMode
79
+ )
80
+ )
76
81
} ) )
77
82
) ) ;
78
83
0 commit comments