Skip to content

Commit 43c6a41

Browse files
Merge branch 'dh2-beta-release' into dh2-i18n-rc1
2 parents e8895b5 + 7736fe9 commit 43c6a41

29 files changed

+227
-152
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
ignorePatterns: [
33
'.eslintrc.js',
44
'web/webpack.config.js',
5+
'web/webpack.schemas.js',
56
'lib/rollup.config.js',
67
'**/dist/**/*.js',
78
'.venv',

lib/AppContext.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import * as $ from 'jquery';
22
import i18n from 'i18next';
33

4-
import { DataHarmonizer } from '@/lib';
5-
import { findLocalesForLangcodes } from '@/lib/utils/i18n';
4+
import { DataHarmonizer } from '.';
5+
import { findLocalesForLangcodes } from './utils/i18n';
66
import {
77
Template,
88
findSlotNamesForClass,
99
getTemplatePathInScope,
10-
} from '@/lib/utils/templates';
11-
import { wait } from '@/lib/utils/general';
12-
import { invert, removeNumericKeys, consolidate } from '@/lib/utils/objects';
13-
import { createDataHarmonizerContainer, createDataHarmonizerTab } from '@/web';
10+
} from '../lib/utils/templates';
11+
import { wait } from '../lib/utils/general';
12+
import { invert, removeNumericKeys, consolidate } from '../lib/utils/objects';
13+
import { createDataHarmonizerContainer, createDataHarmonizerTab } from '../web';
14+
import { getExportFormats } from 'schemas';
1415

1516
// COMMENTED OUT: WIP FEATURE
1617
// import { buildAppContext, setup1M } from '@/lib/utils/1m';
@@ -409,9 +410,7 @@ export default class AppContext {
409410
}
410411

411412
async loadExportFormats(schema) {
412-
this.exportFormats = (
413-
await import(`@/web/templates/${schema}/export.js`)
414-
).default;
413+
this.exportFormats = await getExportFormats(schema);
415414
return this.exportFormats;
416415
}
417416

lib/DataHarmonizer.js

+25-23
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import 'jquery-ui/dist/themes/base/jquery-ui.css';
77

88
import i18next from 'i18next';
99
import { utils as XlsxUtils, read as xlsxRead } from 'xlsx/xlsx.js';
10-
import { renderContent, urlToClickableAnchor } from '@/lib/utils/content';
11-
import { readFileAsync, updateSheetRange } from '@/lib/utils/files';
12-
import { findSlotNamesForClass } from '@/lib/utils/templates';
10+
import { renderContent, urlToClickableAnchor } from './utils/content';
11+
import { readFileAsync, updateSheetRange } from '../lib/utils/files';
12+
import { findSlotNamesForClass } from '../lib/utils/templates';
1313
import {
1414
isValidHeaderRow,
1515
rowIsEmpty,
1616
wait,
1717
stripDiv,
1818
isEmptyUnitVal,
1919
pascalToLowerWithSpaces,
20-
} from '@/lib/utils/general';
21-
import { invert, deepMerge, looseMatchInObject } from '@/lib/utils/objects';
20+
} from '../lib/utils/general';
21+
import { invert, deepMerge, looseMatchInObject } from '../lib/utils/objects';
2222

2323
import {
2424
changeCase,
@@ -31,40 +31,42 @@ import {
3131
MULTIVALUED_DELIMITER,
3232
parseMultivaluedValue,
3333
titleOverText,
34-
} from '@/lib/utils/fields';
34+
} from './utils/fields';
3535

3636
import {
3737
checkProvenance,
3838
itemCompare,
3939
validateValAgainstVocab,
4040
validateValsAgainstVocab,
4141
// validateUniqueValues,
42-
} from '@/lib/utils/validation';
42+
} from './utils/validation';
4343

4444
import 'handsontable/dist/handsontable.full.css';
45-
import '@/lib/data-harmonizer.css';
45+
import './data-harmonizer.css';
4646
import '@selectize/selectize/dist/css/selectize.bootstrap4.css';
4747

48-
import specifyHeadersModal from '@/lib/specifyHeadersModal.html';
49-
import unmappedHeadersModal from '@/lib/unmappedHeadersModal.html';
50-
import fieldDescriptionsModal from '@/lib/fieldDescriptionsModal.html';
48+
import specifyHeadersModal from './specifyHeadersModal.html';
49+
import unmappedHeadersModal from './unmappedHeadersModal.html';
50+
import fieldDescriptionsModal from './fieldDescriptionsModal.html';
5151

52-
import HelpSidebar from '@/lib/HelpSidebar';
52+
import HelpSidebar from './HelpSidebar';
5353

5454
// NOTE: this is odd! package.json is a developer file. why should a UI component care about it?
55-
import pkg from '@/package.json';
56-
import Validator from '@/lib/Validator';
55+
import pkg from '../package.json';
56+
import Validator from './Validator';
5757

5858
const VERSION = pkg.version;
5959
const VERSION_TEXT = 'DataHarmonizer v' + VERSION;
6060

61-
import { DateEditor, DatetimeEditor, TimeEditor } from '@/lib/editors';
6261
import {
62+
DateEditor,
63+
DatetimeEditor,
64+
TimeEditor,
6365
KeyValueListEditor,
6466
keyValueListValidator,
6567
keyValueListRenderer,
6668
multiKeyValueListRenderer,
67-
} from '@/lib/editors';
69+
} from './editors';
6870

6971
Handsontable.cellTypes.registerCellType('key-value-list', {
7072
editor: KeyValueListEditor,
@@ -2236,7 +2238,7 @@ class DataHarmonizer {
22362238
// if sources exist, fetch transformed Value
22372239
if (field.sources) {
22382240
if (field.multivalued === true) {
2239-
//Map list of semicolon-delimited choices
2241+
// Map list of semicolon-delimited choices
22402242
// ISSUE: relying on semicolon delimiter in input
22412243
for (let cellVal of mappedCellVal.split(';')) {
22422244
mappedCell.push(
@@ -2655,7 +2657,6 @@ class DataHarmonizer {
26552657
if (number >= 0) {
26562658
// Here we have the 3 field call, with units sandwitched in the middle
26572659
if (binOffset === 2) {
2658-
26592660
const unit = matrix[row][hotRowNextCol];
26602661
// Host age unit is interpreted by default to be year.
26612662
// If user selects month, value is converted into years for binning.
@@ -2693,7 +2694,7 @@ class DataHarmonizer {
26932694
const bin_values = fields[hotRowBinCol].flatVocabulary;
26942695
if (value in bin_values && (!bin_value || bin_value === '')) {
26952696
selection = value;
2696-
console.log("no bin value", value);
2697+
console.log('no bin value', value);
26972698
}
26982699
// If a unit field exists, then set that to metadata too.
26992700
if (binOffset == 2) {
@@ -2742,7 +2743,7 @@ class DataHarmonizer {
27422743
doPreValidationRepairs(data) {
27432744
return new Promise((resolve) => {
27442745
const cellChanges = [];
2745-
const whitespace_minimized_re = new RegExp(/\s+/,'g');
2746+
const whitespace_minimized_re = new RegExp(/\s+/, 'g');
27462747
let fullVersion =
27472748
VERSION_TEXT +
27482749
', ' +
@@ -2762,15 +2763,16 @@ class DataHarmonizer {
27622763
const datatype = field.datatype;
27632764

27642765
if (cellVal && datatype === 'xsd:token') {
2765-
2766-
const minimized = cellVal.replace(whitespace_minimized_re, ' ').trim();
2766+
const minimized = cellVal
2767+
.replace(whitespace_minimized_re, ' ')
2768+
.trim();
27672769
// Update cellVal in advance of validateVal(s) below
27682770
if (minimized !== cellVal) {
27692771
cellVal = minimized;
27702772
data[row][col] = cellVal;
27712773
cellChanges.push([row, col, minimized, 'thisChange']);
27722774
}
2773-
};
2775+
}
27742776

27752777
if (datatype === 'Provenance') {
27762778
checkProvenance(cellChanges, fullVersion, cellVal, row, col);

lib/HelpSidebar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from 'jquery';
2-
import { renderContent } from '@/lib/utils/content';
3-
import '@/lib/HelpSidebar.css';
2+
import { renderContent } from './utils/content';
3+
import './HelpSidebar.css';
44

55
const DEFAULT_OPTIONS = {
66
width: 300,

lib/Toolbar.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,24 @@ import {
1313
exportWorkbook,
1414
importJsonFile,
1515
prependToSheet,
16-
} from '@/lib/utils/files';
17-
import { nullValuesToString, isEmptyUnitVal } from '@/lib/utils/general';
18-
import { MULTIVALUED_DELIMITER, titleOverText } from '@/lib/utils/fields';
19-
import { takeKeys, invert } from '@/lib/utils/objects';
16+
} from '../lib/utils/files';
17+
import { nullValuesToString, isEmptyUnitVal } from '../lib/utils/general';
18+
import { MULTIVALUED_DELIMITER, titleOverText } from '../lib/utils/fields';
19+
import { takeKeys, invert } from '../lib/utils/objects';
2020
import {
2121
findBestLocaleMatch,
2222
templatePathForSchemaURI,
2323
rangeToContainerClass,
2424
LocaleNotSupportedError,
25-
} from '@/lib/utils/templates';
25+
} from '../lib/utils/templates';
2626

27-
import {
28-
findLocalesForLangcodes,
29-
interface_translation,
30-
} from '@/lib/utils/i18n';
27+
import { findLocalesForLangcodes, interface_translation } from './utils/i18n';
3128
import i18next from 'i18next';
3229

33-
import template from '@/lib/toolbar.html';
34-
import '@/lib//toolbar.css';
30+
import template from './toolbar.html';
31+
import './/toolbar.css';
3532

36-
import menu from '@/web/templates/menu.json';
33+
import { menu } from 'schemas';
3734
import pkg from '../package.json';
3835

3936
const VERSION = pkg.version;

lib/Validator.js

+25-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Datatypes } from '@/lib/utils/datatypes';
2-
import { validateUniqueValues } from '@/lib/utils/validation';
3-
import { rowIsEmpty } from '@/lib/utils/general';
1+
import { Datatypes } from './utils/datatypes';
2+
import { validateUniqueValues } from './utils/validation';
3+
import { rowIsEmpty } from './utils/general';
44

55
class Validator {
66
#schema;
@@ -58,7 +58,7 @@ class Validator {
5858
return;
5959
}
6060
// todos is an array of strings.
61-
const slotType = this.getSlotType(slotDefinition);// LinkML schema.type object
61+
const slotType = this.getSlotType(slotDefinition); // LinkML schema.type object
6262

6363
// Slot type could be:
6464
// a number, string, date ...
@@ -74,11 +74,15 @@ class Validator {
7474
}
7575
}
7676

77-
// Cycle through each slotDefinition any_of etc. object entries and get
77+
// Cycle through each slotDefinition any_of etc. object entries and get
7878
// the datatype of its .range (or recurse) and in LinkML fashion attach
7979
// minimum_value and maximum_value to the slotDefinition OR its any_of
8080
// etc array BASED ON top level todos. E.g. inheriting min/max criteria.
81-
for (const def of slotDefinition.any_of ?? slotDefinition.all_of ?? slotDefinition.exactly_one_of ?? slotDefinition.none_of ?? []) {
81+
for (const def of slotDefinition.any_of ??
82+
slotDefinition.all_of ??
83+
slotDefinition.exactly_one_of ??
84+
slotDefinition.none_of ??
85+
[]) {
8286
processTodos(def, todos);
8387
}
8488
};
@@ -248,8 +252,7 @@ class Validator {
248252

249253
const validate = (value) => {
250254
if (!value) {
251-
if (slotDefinition.required)
252-
return 'This field is required';
255+
if (slotDefinition.required) return 'This field is required';
253256
// value_presence is subject to dynamic rules?
254257
if (slotDefinition.value_presence === 'PRESENT')
255258
return 'Value is not present';
@@ -283,7 +286,8 @@ class Validator {
283286
// Message needs
284287
for (const value of splitValues) {
285288
let parse_error = false;
286-
if (slotType) {// Doesn't pertain to slots which are ONLY enumerations.
289+
if (slotType) {
290+
// Doesn't pertain to slots which are ONLY enumerations.
287291
const parsed = this.#parser.parse(value, slotType.uri);
288292

289293
// Issue: parse can fail on decimal but menu has "Missing"
@@ -297,15 +301,14 @@ class Validator {
297301
// All these cases have encountered an item which matches basic data
298302
// datatype and so sudden death is ok.
299303
else {
300-
301304
if (slotMinimumValue !== undefined && parsed < slotMinimumValue) {
302305
return 'Value is less than minimum value';
303306
}
304-
307+
305308
if (slotMaximumValue !== undefined && parsed > slotMaximumValue) {
306309
return 'Value is greater than maximum value';
307310
}
308-
311+
309312
if (
310313
(slotDefinition.equals_string !== undefined &&
311314
parsed !== slotDefinition.equals_string) ||
@@ -322,14 +325,12 @@ class Validator {
322325
return 'Value does not match pattern';
323326
}
324327

325-
// Here slotType value tested and is ok!
328+
// Here slotType value tested and is ok!
326329
continue;
327330
}
328331

329332
// Here value didn't parse to slotType
330-
331-
}
332-
else {
333+
} else {
333334
// No basic slot type here so only enumeration handling.
334335
}
335336

@@ -378,17 +379,20 @@ class Validator {
378379
}
379380
}
380381

381-
if (anyOfValidators.length || allOfValidators.length || exactlyOneOfValidators.length || noneOfValidators.length) {
382+
if (
383+
anyOfValidators.length ||
384+
allOfValidators.length ||
385+
exactlyOneOfValidators.length ||
386+
noneOfValidators.length
387+
) {
382388
// We passed validation here which means a parse error can be overriden
383-
}
384-
else if (parse_error.length) {
385-
//There were no other ranges besides basic slotType so
389+
} else if (parse_error.length) {
390+
//There were no other ranges besides basic slotType so
386391
return parse_error;
387392
}
388393
}
389394
};
390395

391-
392396
return validate;
393397
}
394398

lib/editors/DateEditor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
1+
import FlatpickrEditor from './FlatpickrEditor';
22

33
class DateEditor extends FlatpickrEditor {
44
getFlatpickrConfig() {

lib/editors/DatetimeEditor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
1+
import FlatpickrEditor from './FlatpickrEditor';
22

33
class DatetimeEditor extends FlatpickrEditor {
44
getFlatpickrConfig() {

lib/editors/KeyValueEditor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Handsontable from 'handsontable';
2-
import { MULTIVALUED_DELIMITER, titleOverText } from '@/lib/utils/fields';
3-
import { isEmptyUnitVal } from '@/lib/utils/general';
2+
import { MULTIVALUED_DELIMITER, titleOverText } from '../utils/fields';
3+
import { isEmptyUnitVal } from '../utils/general';
44

55
// Derived from: https://jsfiddle.net/handsoncode/f0b41jug/
66

lib/editors/TimeEditor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
1+
import FlatpickrEditor from './FlatpickrEditor';
22

33
class TimeEditor extends FlatpickrEditor {
44
getFlatpickrConfig() {

lib/editors/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
export { default as DateEditor } from '@/lib/editors/DateEditor';
2-
export { default as DatetimeEditor } from '@/lib/editors/DatetimeEditor';
3-
export { default as TimeEditor } from '@/lib/editors/TimeEditor';
4-
export { default as FlatpickrEditor } from '@/lib/editors/FlatpickrEditor';
1+
export { default as DateEditor } from './DateEditor.js';
2+
export { default as DatetimeEditor } from './DatetimeEditor.js';
3+
export { default as TimeEditor } from './TimeEditor.js';
4+
export { default as FlatpickrEditor } from './FlatpickrEditor.js';
55
export {
66
default as KeyValueListEditor,
77
keyValueListRenderer,
88
keyValueListValidator,
99
multiKeyValueListRenderer,
10-
} from '@/lib/editors/KeyValueEditor';
10+
} from './KeyValueEditor.js';

lib/index.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
export { default as Footer } from '@/lib/Footer';
2-
export { default as Toolbar } from '@/lib/Toolbar';
3-
export { default as DataHarmonizer } from '@/lib/DataHarmonizer';
4-
export { default as AppContext } from '@/lib/AppContext';
5-
export {
6-
DATE_OBJECT,
7-
JSON_SCHEMA_FORMAT,
8-
INPUT_FORMAT,
9-
} from '@/lib/utils/fields';
1+
export { default as Footer } from './Footer';
2+
export { default as Toolbar } from './Toolbar';
3+
export { default as DataHarmonizer } from './DataHarmonizer';
4+
export { default as AppContext } from './AppContext';
5+
export { DATE_OBJECT, JSON_SCHEMA_FORMAT, INPUT_FORMAT } from './utils/fields';

0 commit comments

Comments
 (0)