Skip to content

Commit ffd1a23

Browse files
committed
Prettier
1 parent ac0e877 commit ffd1a23

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

lib/Toolbar.js

+36-30
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { MULTIVALUED_DELIMITER, titleOverText } from '../lib/utils/fields';
1919
import { takeKeys, invert } from '../lib/utils/objects';
2020
import {
2121
findBestLocaleMatch,
22-
// templatePathForSchemaURI,
22+
// templatePathForSchemaURI,
2323
rangeToContainerClass,
2424
LocaleNotSupportedError,
2525
} from '../lib/utils/templates';
@@ -228,9 +228,13 @@ class Toolbar {
228228

229229
if (options.templatePath) {
230230
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)) {
232232
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+
) {
234238
this.$selectTemplate.val(options.templatePath);
235239
}
236240
}
@@ -245,7 +249,7 @@ class Toolbar {
245249
this.loadGettingStartedModalContent
246250
);
247251
$('#select-template-load').on('click', () => this.loadSelectedTemplate());
248-
// $('#view-template-drafts').on('change', () => this.updateTemplateOptions());
252+
// $('#view-template-drafts').on('change', () => this.updateTemplateOptions());
249253
$('#upload-template-input').on('change', this.uploadTemplate.bind(this));
250254
$('#new-dropdown-item, #clear-data-confirm-btn').on(
251255
'click',
@@ -313,7 +317,7 @@ class Toolbar {
313317

314318
updateTemplateOptions() {
315319
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)) {
317321
for (const schema_obj of Object.values(this.menu)) {
318322
const templates = schema_obj['templates'];
319323
for (const [template_name, template_obj] of Object.entries(templates)) {
@@ -366,7 +370,6 @@ class Toolbar {
366370
}
367371

368372
async openFile() {
369-
370373
const file = $('#open-file-input')[0].files[0];
371374
const ext = file.name.split('.').pop();
372375
const acceptedExts = ['xlsx', 'xls', 'tsv', 'csv', 'json'];
@@ -377,9 +380,9 @@ class Toolbar {
377380
);
378381
} else {
379382
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.
383386
// It may have several dhs, one for each Container class mentioned.
384387
const contentBuffer = await readFileAsync(file);
385388
//alert("opening " + file.name)
@@ -390,7 +393,7 @@ class Toolbar {
390393
throw new Error('Invalid JSON data', error);
391394
}
392395

393-
const { schema_uri, in_language = null} = importJsonFile(jsonData);
396+
const { schema_uri, in_language = null } = importJsonFile(jsonData);
394397
const translationSelect = $('#select-translation-localization');
395398
const previous_language = i18next.language;
396399
// ensure is localized in the same language as the file
@@ -412,7 +415,9 @@ class Toolbar {
412415

413416
// Currently loaded schema_uri: this.context.template.default.schema.id
414417
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+
);
416421
return false;
417422
}
418423
const locale = in_language;
@@ -483,10 +488,12 @@ class Toolbar {
483488
schema_container.attributes
484489
).reduce((acc, [cls_key, { name, range }]) => {
485490
// 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+
) {
487495
//Or test range against this.context.appConfig.template_path.split('/')[1]
488496
const processedClass = {
489-
490497
[name]: MultiEntityJSON[range]
491498
.map((obj) => nullValuesToString(obj))
492499
.map((entry) => {
@@ -820,8 +827,7 @@ class Toolbar {
820827
}
821828
// Prevents another popup on repeated click if user focuses away from
822829
// previous popup.
823-
return false;
824-
830+
return false;
825831
}
826832

827833
showError(prefix, message) {
@@ -833,23 +839,22 @@ class Toolbar {
833839
$('#next-error-button,#no-error-button').hide();
834840
}
835841

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.
840846
// OR
841-
// 2) loadFromMenu where $selectTemplate.val() contains a schema_name &
847+
// 2) loadFromMenu where $selectTemplate.val() contains a schema_name &
842848
// template_name combo, and we use this.getSchema() to fetch schema,
843849
// and then load template.
844850

845851
async loadSelectedTemplate(file = null) {
846-
847852
// NOTE: Schema Name vs Template Name:
848853
// Example:
849854
// "template_path": "canada_covid19/CanCOGeN Covid-19",
850855
// "schema_name": "canada_covid19", // left side of template path
851856
// "template_name": "CanCOGeN Covid-19", // right side of template path
852-
//
857+
//
853858
// [...]
854859
// "schema": {
855860
// "name": "CanCOGeN_Covid-19", // name of schema in template
@@ -866,14 +871,16 @@ class Toolbar {
866871
template_name = Object.keys(schema.classes).find(
867872
(e) => schema.classes[e].is_a === 'dh_interface'
868873
);
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.
871876
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+
}
875882
}
876-
});
883+
);
877884
}
878885
} catch (err) {
879886
console.error(err);
@@ -883,7 +890,7 @@ class Toolbar {
883890
// TODO: implement template_path, schema_name to make the loader types consistent
884891
// The "local" part is a fake folder but is used in AppContext.js reload()
885892
template_path: `local/${template_name}`,
886-
//schema_name: template_name.toLowerCase(),
893+
//schema_name: template_name.toLowerCase(),
887894
//schema_name: schema.name,
888895
//schema_uri: schema.uri,
889896
//template_name,
@@ -1029,7 +1036,6 @@ class Toolbar {
10291036
}
10301037

10311038
setupJumpToModal(dh) {
1032-
10331039
const columnCoordinates = dh.getColumnCoordinates();
10341040

10351041
// Initialize and reset the jump-to input field

0 commit comments

Comments
 (0)