@@ -19,7 +19,7 @@ import { MULTIVALUED_DELIMITER, titleOverText } from '../lib/utils/fields';
19
19
import { takeKeys , invert } from '../lib/utils/objects' ;
20
20
import {
21
21
findBestLocaleMatch ,
22
- // templatePathForSchemaURI,
22
+ // templatePathForSchemaURI,
23
23
rangeToContainerClass ,
24
24
LocaleNotSupportedError ,
25
25
} from '../lib/utils/templates' ;
@@ -228,9 +228,13 @@ class Toolbar {
228
228
229
229
if ( options . templatePath ) {
230
230
const [ schema_folder , template_name ] = options . templatePath . split ( '/' ) ;
231
- //for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
231
+ //for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
232
232
for ( const schema_obj of Object . values ( this . menu ) ) {
233
- if ( 'folder' in schema_obj && schema_obj [ 'folder' ] == schema_folder && template_name in schema_obj [ 'templates' ] ) {
233
+ if (
234
+ 'folder' in schema_obj &&
235
+ schema_obj [ 'folder' ] == schema_folder &&
236
+ template_name in schema_obj [ 'templates' ]
237
+ ) {
234
238
this . $selectTemplate . val ( options . templatePath ) ;
235
239
}
236
240
}
@@ -245,7 +249,7 @@ class Toolbar {
245
249
this . loadGettingStartedModalContent
246
250
) ;
247
251
$ ( '#select-template-load' ) . on ( 'click' , ( ) => this . loadSelectedTemplate ( ) ) ;
248
- // $('#view-template-drafts').on('change', () => this.updateTemplateOptions());
252
+ // $('#view-template-drafts').on('change', () => this.updateTemplateOptions());
249
253
$ ( '#upload-template-input' ) . on ( 'change' , this . uploadTemplate . bind ( this ) ) ;
250
254
$ ( '#new-dropdown-item, #clear-data-confirm-btn' ) . on (
251
255
'click' ,
@@ -313,7 +317,7 @@ class Toolbar {
313
317
314
318
updateTemplateOptions ( ) {
315
319
this . $selectTemplate . empty ( ) ;
316
- //for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
320
+ //for (const [schema_name, schema_obj] of Object.entries(this.menu)) {
317
321
for ( const schema_obj of Object . values ( this . menu ) ) {
318
322
const templates = schema_obj [ 'templates' ] ;
319
323
for ( const [ template_name , template_obj ] of Object . entries ( templates ) ) {
@@ -366,7 +370,6 @@ class Toolbar {
366
370
}
367
371
368
372
async openFile ( ) {
369
-
370
373
const file = $ ( '#open-file-input' ) [ 0 ] . files [ 0 ] ;
371
374
const ext = file . name . split ( '.' ) . pop ( ) ;
372
375
const acceptedExts = [ 'xlsx' , 'xls' , 'tsv' , 'csv' , 'json' ] ;
@@ -377,9 +380,9 @@ class Toolbar {
377
380
) ;
378
381
} else {
379
382
if ( ext === 'json' ) {
380
- // JSON is the only format that contains reference to schema to
381
- // utilize by "schema" URI, as well as "in_language" locale, and
382
- // its Container class contains template spec itself.
383
+ // JSON is the only format that contains reference to schema to
384
+ // utilize by "schema" URI, as well as "in_language" locale, and
385
+ // its Container class contains template spec itself.
383
386
// It may have several dhs, one for each Container class mentioned.
384
387
const contentBuffer = await readFileAsync ( file ) ;
385
388
//alert("opening " + file.name)
@@ -390,7 +393,7 @@ class Toolbar {
390
393
throw new Error ( 'Invalid JSON data' , error ) ;
391
394
}
392
395
393
- const { schema_uri, in_language = null } = importJsonFile ( jsonData ) ;
396
+ const { schema_uri, in_language = null } = importJsonFile ( jsonData ) ;
394
397
const translationSelect = $ ( '#select-translation-localization' ) ;
395
398
const previous_language = i18next . language ;
396
399
// ensure is localized in the same language as the file
@@ -412,7 +415,9 @@ class Toolbar {
412
415
413
416
// Currently loaded schema_uri: this.context.template.default.schema.id
414
417
if ( schema_uri != this . context . template . default . schema . id ) {
415
- alert ( `The current json file's schema "${ schema_uri } " is required, but one must select this template from menu first, if available. Online retrieval is not yet available.` ) ;
418
+ alert (
419
+ `The current json file's schema "${ schema_uri } " is required, but one must select this template from menu first, if available. Online retrieval is not yet available.`
420
+ ) ;
416
421
return false ;
417
422
}
418
423
const locale = in_language ;
@@ -483,10 +488,12 @@ class Toolbar {
483
488
schema_container . attributes
484
489
) . reduce ( ( acc , [ cls_key , { name, range } ] ) => {
485
490
// TODO: check if container attributes always have ranges?
486
- if ( typeof range !== 'undefined' && range == this . context . current_data_harmonizer_name ) {
491
+ if (
492
+ typeof range !== 'undefined' &&
493
+ range == this . context . current_data_harmonizer_name
494
+ ) {
487
495
//Or test range against this.context.appConfig.template_path.split('/')[1]
488
496
const processedClass = {
489
-
490
497
[ name ] : MultiEntityJSON [ range ]
491
498
. map ( ( obj ) => nullValuesToString ( obj ) )
492
499
. map ( ( entry ) => {
@@ -820,8 +827,7 @@ class Toolbar {
820
827
}
821
828
// Prevents another popup on repeated click if user focuses away from
822
829
// previous popup.
823
- return false ;
824
-
830
+ return false ;
825
831
}
826
832
827
833
showError ( prefix , message ) {
@@ -833,23 +839,22 @@ class Toolbar {
833
839
$ ( '#next-error-button,#no-error-button' ) . hide ( ) ;
834
840
}
835
841
836
- // LoadSelectedTemplate either comes from
837
- // 1) loadFromFile reference to a whole schema file in which case template
838
- // menu is redone based on schema's templates, and FIRST 'dh_interface'
839
- // template is selected.
842
+ // LoadSelectedTemplate either comes from
843
+ // 1) loadFromFile reference to a whole schema file in which case template
844
+ // menu is redone based on schema's templates, and FIRST 'dh_interface'
845
+ // template is selected.
840
846
// OR
841
- // 2) loadFromMenu where $selectTemplate.val() contains a schema_name &
847
+ // 2) loadFromMenu where $selectTemplate.val() contains a schema_name &
842
848
// template_name combo, and we use this.getSchema() to fetch schema,
843
849
// and then load template.
844
850
845
851
async loadSelectedTemplate ( file = null ) {
846
-
847
852
// NOTE: Schema Name vs Template Name:
848
853
// Example:
849
854
// "template_path": "canada_covid19/CanCOGeN Covid-19",
850
855
// "schema_name": "canada_covid19", // left side of template path
851
856
// "template_name": "CanCOGeN Covid-19", // right side of template path
852
- //
857
+ //
853
858
// [...]
854
859
// "schema": {
855
860
// "name": "CanCOGeN_Covid-19", // name of schema in template
@@ -866,14 +871,16 @@ class Toolbar {
866
871
template_name = Object . keys ( schema . classes ) . find (
867
872
( e ) => schema . classes [ e ] . is_a === 'dh_interface'
868
873
) ;
869
- // We need to get template name from first Container attributes'
870
- // class's range.
874
+ // We need to get template name from first Container attributes'
875
+ // class's range.
871
876
if ( ! template_name && 'Container' in schema . classes ) {
872
- Object . entries ( schema . classes . Container . attributes ) . forEach ( ( [ class_name , class_obj ] ) => {
873
- if ( class_obj . range in schema . classes ) {
874
- template_name = class_obj . range ;
877
+ Object . entries ( schema . classes . Container . attributes ) . forEach (
878
+ ( [ class_name , class_obj ] ) => {
879
+ if ( class_obj . range in schema . classes ) {
880
+ template_name = class_obj . range ;
881
+ }
875
882
}
876
- } ) ;
883
+ ) ;
877
884
}
878
885
} catch ( err ) {
879
886
console . error ( err ) ;
@@ -883,7 +890,7 @@ class Toolbar {
883
890
// TODO: implement template_path, schema_name to make the loader types consistent
884
891
// The "local" part is a fake folder but is used in AppContext.js reload()
885
892
template_path : `local/${ template_name } ` ,
886
- //schema_name: template_name.toLowerCase(),
893
+ //schema_name: template_name.toLowerCase(),
887
894
//schema_name: schema.name,
888
895
//schema_uri: schema.uri,
889
896
//template_name,
@@ -1029,7 +1036,6 @@ class Toolbar {
1029
1036
}
1030
1037
1031
1038
setupJumpToModal ( dh ) {
1032
-
1033
1039
const columnCoordinates = dh . getColumnCoordinates ( ) ;
1034
1040
1035
1041
// Initialize and reset the jump-to input field
0 commit comments