@@ -43,6 +43,7 @@ class AppConfig {
43
43
44
44
class AppContext {
45
45
46
+ schema_tree = { } ;
46
47
dhs = { } ;
47
48
current_data_harmonizer_name = null ;
48
49
@@ -51,10 +52,13 @@ class AppContext {
51
52
this . appConfig = appConfig ;
52
53
}
53
54
55
+ setSchemaTree ( schema_tree ) {
56
+ this . schema_tree = schema_tree ;
57
+ }
58
+
54
59
setDataHarmonizers ( data_harmonizers ) {
55
60
this . dhs = data_harmonizers ;
56
- // TODO finding the initial parent?
57
- this . setCurrentDataHarmonizer ( data_harmonizers [ 'Container' ] . children [ 0 ] ) ;
61
+ this . setCurrentDataHarmonizer ( this . schema_tree [ 'Container' ] . children [ 0 ] ) ;
58
62
}
59
63
60
64
setCurrentDataHarmonizer ( data_harmonizer_name ) {
@@ -80,9 +84,6 @@ class AppContext {
80
84
} , { } ) ;
81
85
}
82
86
83
- // TODO: memoize?
84
- // setup dependency tree
85
- // TODO: dh_interface superclass
86
87
/*
87
88
Example Data:
88
89
{
@@ -858,34 +859,31 @@ const main = async function () {
858
859
} ;
859
860
860
861
function initializeDataHarmonizers ( data_harmonizers ) {
861
- // TODO
862
- // Object.entries(data_harmonizers).forEach(([cls_key,], index) => {
863
- // new Toolbar(dhToolbarRoot, data_harmonizers[cls_key], menu, {
864
- // context: context,
865
- // templatePath: context.appConfig.template_path, // TODO: a default should be loaded before Toolbar is constructed! then take out all loading in "toolbar" to an outside context
866
- // releasesURL: 'https: // github.com/cidgoh/pathogen-genomics-package/releases',
867
- // getLanguages: context.getLocaleData.bind(context),
868
- // getSchema: async (schema) => Template.create(schema).then(result => result.current.schema),
869
- // getExportFormats: context.getExportFormats.bind(context),
870
- // });
871
- // });
872
- console . log ( 'before attachPropagationEventHandlersToDataHarmonizers' ) ;
862
+ new Toolbar ( dhToolbarRoot , context . getCurrentDataHarmonizer ( ) , menu , {
863
+ context : context ,
864
+ templatePath : context . appConfig . template_path , // TODO: a default should be loaded before Toolbar is constructed! then take out all loading in "toolbar" to an outside context
865
+ releasesURL : 'https: // github.com/cidgoh/pathogen-genomics-package/releases' ,
866
+ getLanguages : context . getLocaleData . bind ( context ) ,
867
+ getSchema : async ( schema ) => Template . create ( schema ) . then ( result => result . current . schema ) ,
868
+ getExportFormats : context . getExportFormats . bind ( context ) ,
869
+ } ) ;
873
870
attachPropagationEventHandlersToDataHarmonizers ( data_harmonizers , schema_tree ) ;
874
871
return data_harmonizers ;
875
872
} ;
876
873
877
874
const schema = ( await context . getSchema ( ) )
878
875
const schema_tree = buildSchemaTree ( schema ) ;
876
+
877
+ context . setSchemaTree ( schema_tree ) ;
878
+
879
879
data_harmonizers = makeDataHarmonizersFromSchemaTree (
880
880
schema ,
881
881
schema_tree ) ;
882
882
// HACK
883
883
delete data_harmonizers [ undefined ] ;
884
- console . log ( 'before initializeDataHarmonizers' ) ;
885
- initializeDataHarmonizers ( data_harmonizers ) ;
886
- // TODO assignment functions
887
- // TODO current dataharmonizer in contexts
888
- context . dhs = data_harmonizers ;
884
+ context . setDataHarmonizers ( data_harmonizers ) ;
885
+ console . log ( context . getCurrentDataHarmonizer ( ) ) ;
886
+ initializeDataHarmonizers ( context . dhs ) ;
889
887
890
888
} else {
891
889
console . log ( 'branch 2' ) ;
0 commit comments