Skip to content

Commit 00c9a32

Browse files
prettier
1 parent bd1f811 commit 00c9a32

File tree

6 files changed

+88
-85
lines changed

6 files changed

+88
-85
lines changed

lib/Toolbar.js

+35-29
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,11 @@ class Toolbar {
429429
// Allows columnCoordinates to be accessed within select() below.
430430
const columnCoordinates = this.dh.getColumnCoordinates();
431431

432-
console.log('empty the section')
432+
console.log('empty the section');
433433
$('#section-menu').empty();
434434
let section_ptr = 0;
435435
for (const section of this.dh.template) {
436-
console.log('section add')
436+
console.log('section add');
437437
$('#section-menu').append(
438438
`<div id="show-section-${section_ptr}" class="dropdown-item show-section-dropdown-item" data-i18n="${section.title}">${section.title}</div>`
439439
);
@@ -453,34 +453,40 @@ class Toolbar {
453453
options: options,
454454
openOnFocus: true,
455455
render: {
456-
item: function (data, escape) {
457-
// Some `data.text` input is already prepended with spaces, so we replace the translation
458-
// ISSUE: a more consistent approach might use a formatter but this is simple. ;[prepend]indent
459-
460-
const item_name = data.value.replace(/\. /g, '').trim();
461-
const identifier_name = item_name.replace(/ /g, '_');
462-
const canonical_name = data.value.match(/ \. /g) ? identifier_name : item_name;
463-
const label = data.text.replace(item_name, i18next.t(canonical_name));
464-
465-
// TODO: not rerendering
466-
return `<div data-i18n='${canonical_name}'>` + escape(label) + `</div>`;
467-
},
468-
option: (data, escape) => {
469-
// Some `data.text` input is already prepended with spaces, so we replace the translation
470-
// ISSUE: a more consistent approach might use a formatter but this is simple. ;[prepend]indent
471-
472-
const item_name = data.value.replace(/\. /g, '').trim();
473-
const identifier_name = item_name.replace(/ /g, '_');
474-
const canonical_name = data.value.match(/ \. /g) ? identifier_name : item_name;
475-
const label = data.text.replace(item_name, i18next.t(canonical_name));
476-
477-
let indentation = 12 + label.search(/\S/) * 8; // pixels
478-
479-
return `<div style="padding-left:${indentation}px" class="option ${
480-
data.value === '' ? 'selectize-dropdown-emptyoptionlabel' : ''
481-
}" data-i18n='${canonical_name}'>${escape(label)}</div>`;
482-
},
456+
item: function (data, escape) {
457+
// Some `data.text` input is already prepended with spaces, so we replace the translation
458+
// ISSUE: a more consistent approach might use a formatter but this is simple. ;[prepend]indent
459+
460+
const item_name = data.value.replace(/\. /g, '').trim();
461+
const identifier_name = item_name.replace(/ /g, '_');
462+
const canonical_name = data.value.match(/ \. /g)
463+
? identifier_name
464+
: item_name;
465+
const label = data.text.replace(item_name, i18next.t(canonical_name));
466+
467+
// TODO: not rerendering
468+
return (
469+
`<div data-i18n='${canonical_name}'>` + escape(label) + `</div>`
470+
);
483471
},
472+
option: (data, escape) => {
473+
// Some `data.text` input is already prepended with spaces, so we replace the translation
474+
// ISSUE: a more consistent approach might use a formatter but this is simple. ;[prepend]indent
475+
476+
const item_name = data.value.replace(/\. /g, '').trim();
477+
const identifier_name = item_name.replace(/ /g, '_');
478+
const canonical_name = data.value.match(/ \. /g)
479+
? identifier_name
480+
: item_name;
481+
const label = data.text.replace(item_name, i18next.t(canonical_name));
482+
483+
let indentation = 12 + label.search(/\S/) * 8; // pixels
484+
485+
return `<div style="padding-left:${indentation}px" class="option ${
486+
data.value === '' ? 'selectize-dropdown-emptyoptionlabel' : ''
487+
}" data-i18n='${canonical_name}'>${escape(label)}</div>`;
488+
},
489+
},
484490
});
485491
$jumpToInput.off('change').on('change', (e) => {
486492
if (!e.target.value) {

lib/toolbar.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@
102102
data-i18n="show-recommended-cols-dropdown-item"
103103
>Show required + recommended columns</span
104104
>
105-
<div
106-
style="padding: 0.25rem 1.5rem"
107-
id="show-section-menu">
108-
<span id="section-label" data-i18n="show-section-menu">Show section:</span>
105+
<div style="padding: 0.25rem 1.5rem" id="show-section-menu">
106+
<span id="section-label" data-i18n="show-section-menu"
107+
>Show section:</span
108+
>
109109
<div id="section-menu"></div>
110110
</div>
111111

lib/utils/i18n.js

+29-23
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,28 @@ const withNamespace =
3030
);
3131

3232
const englishIsDefault = (translation_object) => {
33-
console.log(translation_object)
33+
console.log(translation_object);
3434
// if there is an english resource translation, use it as the default translation
3535
// direct assignment
36-
return typeof translation_object['en'] !== 'undefined' ?
37-
{
38-
...translation_object,
39-
'default': translation_object['en']
40-
}
41-
: translation_object
42-
}
43-
44-
console.log(englishIsDefault(withNamespace('translation', {
45-
multiselect: {
46-
label: '{{ item_value, multiselectFormatter }}',
47-
arrow: '<div class="htAutocompleteArrow">▼</div>',
48-
},
49-
indent: '&nbsp;',
50-
})(labels)))
36+
return typeof translation_object['en'] !== 'undefined'
37+
? {
38+
...translation_object,
39+
default: translation_object['en'],
40+
}
41+
: translation_object;
42+
};
43+
44+
console.log(
45+
englishIsDefault(
46+
withNamespace('translation', {
47+
multiselect: {
48+
label: '{{ item_value, multiselectFormatter }}',
49+
arrow: '<div class="htAutocompleteArrow">▼</div>',
50+
},
51+
indent: '&nbsp;',
52+
})(labels)
53+
)
54+
);
5155

5256
// langChangeCallback takes "lang" as argument
5357
export function initI18n(langChangeCallback) {
@@ -64,13 +68,15 @@ export function initI18n(langChangeCallback) {
6468
debug: false,
6569
fallbackLng: 'default',
6670
resources: {
67-
...englishIsDefault(withNamespace('translation', {
68-
multiselect: {
69-
label: '{{ item_value, multiselectFormatter }}',
70-
arrow: '<div class="htAutocompleteArrow">▼</div>',
71-
},
72-
indent: '&nbsp;',
73-
})(labels)),
71+
...englishIsDefault(
72+
withNamespace('translation', {
73+
multiselect: {
74+
label: '{{ item_value, multiselectFormatter }}',
75+
arrow: '<div class="htAutocompleteArrow">▼</div>',
76+
},
77+
indent: '&nbsp;',
78+
})(labels)
79+
),
7480
}, // initial resources
7581
interpolation: {
7682
escapeValue: false,

lib/utils/templates.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ class TemplateProxy {
263263
_defaultData: template.default,
264264
_localizedData: template.locales,
265265
default: template.default,
266-
localized: locale ? locale === 'default' ? template.default : template.locales[locale] : null,
266+
localized: locale
267+
? locale === 'default'
268+
? template.default
269+
: template.locales[locale]
270+
: null,
267271
});
268272
}
269273

web/index.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', function () {
2222
// TODO: connect to locale of schema!
2323
// Takes `lang` as argument
2424
initI18n((lang) => {
25-
console.log('lang changed to', lang)
25+
console.log('lang changed to', lang);
2626
// localizing twice HACK!
2727
// $(document).localize();
2828
dh.hot.render();
@@ -60,14 +60,16 @@ document.addEventListener('DOMContentLoaded', function () {
6060
template.locales.forEach((locale) => {
6161
const langcode = locale.split('-')[0];
6262
const nativeName =
63-
langcode !== 'default' ? tags.language(langcode).data.record.Description[0] : 'Default';
63+
langcode !== 'default'
64+
? tags.language(langcode).data.record.Description[0]
65+
: 'Default';
6466
locales[langcode] = { langcode, nativeName };
6567
});
6668

6769
const template_translations = {
6870
...template.translations,
69-
'default': template.default
70-
}
71+
default: template.default,
72+
};
7173

7274
Object.entries(template_translations).forEach(
7375
([langcode, translation]) => {
@@ -93,16 +95,19 @@ document.addEventListener('DOMContentLoaded', function () {
9395
);
9496
/* eslint-enable */
9597
const translated_sections = consolidate(
96-
translation.schema.classes[template.default.schema.name.replace('_', ' ')].slot_usage,
98+
translation.schema.classes[
99+
template.default.schema.name.replace('_', ' ')
100+
].slot_usage,
97101
(acc, [translation_slot_name, { slot_group }]) => ({
98102
...acc,
99103
[translation_slot_name]: slot_group,
100104
})
101105
);
102106

103107
const default_sections = consolidate(
104-
template.default.schema.classes[template.default.schema.name.replace('_', ' ')]
105-
.slot_usage,
108+
template.default.schema.classes[
109+
template.default.schema.name.replace('_', ' ')
110+
].slot_usage,
106111
(acc, [default_slot_name, { slot_group }]) => ({
107112
...acc,
108113
[default_slot_name]: slot_group,
@@ -126,7 +131,6 @@ document.addEventListener('DOMContentLoaded', function () {
126131
}
127132
);
128133

129-
130134
return locales;
131135
},
132136
getSchema: async (schema) => {

web/templates/test/export.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -78,34 +78,17 @@ export default {
7878
['DataHarmonizer provenance', []],
7979
]);
8080

81-
// various null options to recognize for "null reason" fields
82-
const // Conversion of all cancogen metadata keywords to NML LIMS version
83-
nullOptionsMap = new Map([
84-
['not applicable', 'Not Applicable'],
85-
['missing', 'Missing'],
86-
['not collected', 'Not Collected'],
87-
['not provided', 'Not Provided'],
88-
['restricted access', 'Restricted Access'],
89-
]);
90-
9181
const sourceFields = dh.getFields(dh.table);
92-
const sourceFieldNameMap = dh.getFieldNameMap(sourceFields);
9382
// Fills in the above mapping (or just set manually above)
9483
dh.getHeaderMap(ExportHeaders, sourceFields, 'TEST');
9584

9685
// Copy headers to 1st row of new export table
9786
const outputMatrix = [[...ExportHeaders.keys()]];
98-
99-
100-
const numeric_datatypes = new Set([
101-
'xs:nonNegativeInteger',
102-
'xs:decimal',
103-
]);
104-
87+
10588
for (const inputRow of dh.getTrimmedData(dh.hot)) {
10689
const outputRow = [];
107-
var skip = false;
108-
for (const [headerName, sources] of ExportHeaders) {
90+
/* eslint-disable */
91+
for (const a of ExportHeaders) {
10992
outputRow.push(...inputRow);
11093
}
11194
outputMatrix.push(outputRow);

0 commit comments

Comments
 (0)