Skip to content

Commit

Permalink
Merge branch 'master' into dh2-beta-release. Moved back to regular im…
Browse files Browse the repository at this point in the history
…port scheme.
  • Loading branch information
kennethbruskiewicz committed Dec 18, 2024
2 parents f10a1d1 + 8712548 commit 7736fe9
Show file tree
Hide file tree
Showing 27 changed files with 192 additions and 112 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
ignorePatterns: [
'.eslintrc.js',
'web/webpack.config.js',
'web/webpack.schemas.js',
'lib/rollup.config.js',
'**/dist/**/*.js',
'.venv',
Expand Down
19 changes: 9 additions & 10 deletions lib/AppContext.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import * as $ from 'jquery';
import i18n from 'i18next';

import { DataHarmonizer } from '@/lib';
import { findLocalesForLangcodes } from '@/lib/utils/i18n';
import { DataHarmonizer } from '.';
import { findLocalesForLangcodes } from './utils/i18n';
import {
Template,
findSlotNamesForClass,
getTemplatePathInScope,
} from '@/lib/utils/templates';
import { wait } from '@/lib/utils/general';
import { invert, removeNumericKeys, consolidate } from '@/lib/utils/objects';
import { createDataHarmonizerContainer, createDataHarmonizerTab } from '@/web';
} from '../lib/utils/templates';
import { wait } from '../lib/utils/general';
import { invert, removeNumericKeys, consolidate } from '../lib/utils/objects';
import { createDataHarmonizerContainer, createDataHarmonizerTab } from '../web';
import { getExportFormats } from 'schemas';

// COMMENTED OUT: WIP FEATURE
import { buildAppContext, setup1M } from '@/lib/utils/1m';
import { buildAppContext, setup1M } from './utils/1m';

/**
* Finds the shared keys per class in a given schema.
Expand Down Expand Up @@ -409,9 +410,7 @@ export default class AppContext {
}

async loadExportFormats(schema) {
this.exportFormats = (
await import(`@/web/templates/${schema}/export.js`)
).default;
this.exportFormats = await getExportFormats(schema);
return this.exportFormats;
}

Expand Down
36 changes: 19 additions & 17 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import 'jquery-ui/dist/themes/base/jquery-ui.css';

import i18next from 'i18next';
import { utils as XlsxUtils, read as xlsxRead } from 'xlsx/xlsx.js';
import { renderContent, urlToClickableAnchor } from '@/lib/utils/content';
import { readFileAsync, updateSheetRange } from '@/lib/utils/files';
import { findSlotNamesForClass } from '@/lib/utils/templates';
import { renderContent, urlToClickableAnchor } from './utils/content';
import { readFileAsync, updateSheetRange } from '../lib/utils/files';
import { findSlotNamesForClass } from '../lib/utils/templates';
import {
isValidHeaderRow,
rowIsEmpty,
wait,
stripDiv,
isEmptyUnitVal,
pascalToLowerWithSpaces,
} from '@/lib/utils/general';
import { invert, deepMerge, looseMatchInObject } from '@/lib/utils/objects';
} from '../lib/utils/general';
import { invert, deepMerge, looseMatchInObject } from '../lib/utils/objects';

import {
changeCase,
Expand All @@ -31,40 +31,42 @@ import {
MULTIVALUED_DELIMITER,
parseMultivaluedValue,
titleOverText,
} from '@/lib/utils/fields';
} from './utils/fields';

import {
checkProvenance,
itemCompare,
validateValAgainstVocab,
validateValsAgainstVocab,
// validateUniqueValues,
} from '@/lib/utils/validation';
} from './utils/validation';

import 'handsontable/dist/handsontable.full.css';
import '@/lib/data-harmonizer.css';
import './data-harmonizer.css';
import '@selectize/selectize/dist/css/selectize.bootstrap4.css';

import specifyHeadersModal from '@/lib/specifyHeadersModal.html';
import unmappedHeadersModal from '@/lib/unmappedHeadersModal.html';
import fieldDescriptionsModal from '@/lib/fieldDescriptionsModal.html';
import specifyHeadersModal from './specifyHeadersModal.html';
import unmappedHeadersModal from './unmappedHeadersModal.html';
import fieldDescriptionsModal from './fieldDescriptionsModal.html';

import HelpSidebar from '@/lib/HelpSidebar';
import HelpSidebar from './HelpSidebar';

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

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

import { DateEditor, DatetimeEditor, TimeEditor } from '@/lib/editors';
import {
DateEditor,
DatetimeEditor,
TimeEditor,
KeyValueListEditor,
keyValueListValidator,
keyValueListRenderer,
multiKeyValueListRenderer,
} from '@/lib/editors';
} from './editors';

Handsontable.cellTypes.registerCellType('key-value-list', {
editor: KeyValueListEditor,
Expand Down Expand Up @@ -2230,7 +2232,7 @@ class DataHarmonizer {
// if sources exist, fetch transformed Value
if (field.sources) {
if (field.multivalued === true) {
//Map list of semicolon-delimited choices
// Map list of semicolon-delimited choices
// ISSUE: relying on semicolon delimiter in input
for (let cellVal of mappedCellVal.split(';')) {
mappedCell.push(
Expand Down
4 changes: 2 additions & 2 deletions lib/HelpSidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from 'jquery';
import { renderContent } from '@/lib/utils/content';
import '@/lib/HelpSidebar.css';
import { renderContent } from './utils/content';
import './HelpSidebar.css';

const DEFAULT_OPTIONS = {
width: 300,
Expand Down
18 changes: 9 additions & 9 deletions lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import {
exportWorkbook,
importJsonFile,
prependToSheet,
} from '@/lib/utils/files';
import { nullValuesToString, isEmptyUnitVal } from '@/lib/utils/general';
import { MULTIVALUED_DELIMITER, titleOverText } from '@/lib/utils/fields';
import { takeKeys, invert } from '@/lib/utils/objects';
} from '../lib/utils/files';
import { nullValuesToString, isEmptyUnitVal } from '../lib/utils/general';
import { MULTIVALUED_DELIMITER, titleOverText } from '../lib/utils/fields';
import { takeKeys, invert } from '../lib/utils/objects';
import {
findBestLocaleMatch,
templatePathForSchemaURI,
rangeToContainerClass,
LocaleNotSupportedError,
} from '@/lib/utils/templates';
} from '../lib/utils/templates';

import {
findLocalesForLangcodes,
interface_translation,
} from '@/lib/utils/i18n';
} from './utils/i18n';
import i18next from 'i18next';

import template from '@/lib/toolbar.html';
import '@/lib//toolbar.css';
import template from './toolbar.html';
import './/toolbar.css';

import menu from '@/web/templates/menu.json';
import { menu } from 'schemas';
import pkg from '../package.json';

const VERSION = pkg.version;
Expand Down
6 changes: 3 additions & 3 deletions lib/Validator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Datatypes } from '@/lib/utils/datatypes';
import { validateUniqueValues } from '@/lib/utils/validation';
import { rowIsEmpty } from '@/lib/utils/general';
import { Datatypes } from './utils/datatypes';
import { validateUniqueValues } from './utils/validation';
import { rowIsEmpty } from './utils/general';

class Validator {
#schema;
Expand Down
2 changes: 1 addition & 1 deletion lib/editors/DateEditor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
import FlatpickrEditor from './FlatpickrEditor';

class DateEditor extends FlatpickrEditor {
getFlatpickrConfig() {
Expand Down
2 changes: 1 addition & 1 deletion lib/editors/DatetimeEditor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
import FlatpickrEditor from './FlatpickrEditor';

class DatetimeEditor extends FlatpickrEditor {
getFlatpickrConfig() {
Expand Down
4 changes: 2 additions & 2 deletions lib/editors/KeyValueEditor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Handsontable from 'handsontable';
import { MULTIVALUED_DELIMITER, titleOverText } from '@/lib/utils/fields';
import { isEmptyUnitVal } from '@/lib/utils/general';
import { MULTIVALUED_DELIMITER, titleOverText } from '../utils/fields';
import { isEmptyUnitVal } from '../utils/general';

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

Expand Down
2 changes: 1 addition & 1 deletion lib/editors/TimeEditor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FlatpickrEditor from '@/lib/editors/FlatpickrEditor';
import FlatpickrEditor from './FlatpickrEditor';

class TimeEditor extends FlatpickrEditor {
getFlatpickrConfig() {
Expand Down
10 changes: 5 additions & 5 deletions lib/editors/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { default as DateEditor } from '@/lib/editors/DateEditor';
export { default as DatetimeEditor } from '@/lib/editors/DatetimeEditor';
export { default as TimeEditor } from '@/lib/editors/TimeEditor';
export { default as FlatpickrEditor } from '@/lib/editors/FlatpickrEditor';
export { default as DateEditor } from './DateEditor.js';
export { default as DatetimeEditor } from './DatetimeEditor.js';
export { default as TimeEditor } from './TimeEditor.js';
export { default as FlatpickrEditor } from './FlatpickrEditor.js';
export {
default as KeyValueListEditor,
keyValueListRenderer,
keyValueListValidator,
multiKeyValueListRenderer,
} from '@/lib/editors/KeyValueEditor';
} from './KeyValueEditor.js';
10 changes: 5 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export { default as Footer } from '@/lib/Footer';
export { default as Toolbar } from '@/lib/Toolbar';
export { default as DataHarmonizer } from '@/lib/DataHarmonizer';
export { default as AppContext } from '@/lib/AppContext';
export { default as Footer } from './Footer';
export { default as Toolbar } from './Toolbar';
export { default as DataHarmonizer } from './DataHarmonizer';
export { default as AppContext } from './AppContext';
export {
DATE_OBJECT,
JSON_SCHEMA_FORMAT,
INPUT_FORMAT,
} from '@/lib/utils/fields';
} from './utils/fields';
4 changes: 2 additions & 2 deletions lib/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default {
image(),
alias({
entries: [
// Replace '@/lib' with the actual path to the 'lib' directory
{ find: '@/lib', replacement: path.resolve(__dirname, '.') },
// Replace '.' with the actual path to the 'lib' directory
{ find: '.', replacement: path.resolve(__dirname, '.') },
],
}),
string({
Expand Down
30 changes: 15 additions & 15 deletions lib/toolbarGettingStarted.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import editCopyPasteDelete from '@/lib/images/editCopyPasteDelete.gif';
import changeTemplate from '@/lib/images/changeTemplate.gif';
import toggleRequiredCols from '@/lib/images/toggleRequiredCols.gif';
import doubleClickHeaders from '@/lib/images/doubleClickHeaders.gif';
import selectingVals from '@/lib/images/selectingVals.gif';
import validatingCells from '@/lib/images/validatingCells.gif';
import showRows from '@/lib/images/showRows.gif';
import showSection from '@/lib/images/showSection.gif';
import jumpToColumn from '@/lib/images/jumpToColumn.gif';
import fillColumn from '@/lib/images/fillColumn.gif';
import exportingFiles from '@/lib/images/exportingFiles.gif';
import provenance from '@/lib/images/provenance.gif';
import moreInfo from '@/lib/images/moreInfo.gif';
import versionUpdate from '@/lib/images/versionUpdate.gif';
import editCopyPasteDelete from './images/editCopyPasteDelete.gif';
import changeTemplate from './images/changeTemplate.gif';
import toggleRequiredCols from './images/toggleRequiredCols.gif';
import doubleClickHeaders from './images/doubleClickHeaders.gif';
import selectingVals from './images/selectingVals.gif';
import validatingCells from './images/validatingCells.gif';
import showRows from './images/showRows.gif';
import showSection from './images/showSection.gif';
import jumpToColumn from './images/jumpToColumn.gif';
import fillColumn from './images/fillColumn.gif';
import exportingFiles from './images/exportingFiles.gif';
import provenance from './images/provenance.gif';
import moreInfo from './images/moreInfo.gif';
import versionUpdate from './images/versionUpdate.gif';

import { renderContent } from '@/lib/utils/content';
import { renderContent } from '../lib/utils/content';
import i18next from 'i18next';

const slides = [
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/1m.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ On load of a schema the appContext object is filled in, and event triggers are c
*/

// Example:
// import grdi_json from '@/web/templates/grdi/schema.json';
// import schema_editor_json from '@/web/templates/schema_editor/schema.json';
// import grdi_json from '../templates/grdi/schema.json';
// import schema_editor_json from '../templates/schema_editor/schema.json';
// const AppContext = buildAppContext(grdi_json);
// const AppContext2 = buildAppContext(schema_editor_json);

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/content.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MarkdownIt from 'markdown-it';
import linkifyIt from 'linkify-it';
import { formatEscapeHTML } from '@/lib/utils/fields';
import { formatEscapeHTML } from './fields';

const linkify = linkifyIt();
const md = new MarkdownIt({
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
parseJsonSchemaDate,
parseJsonDate,
datatypeIsDateOrTime,
} from '@/lib/utils/datatypes';
import { consolidate } from '@/lib/utils/objects';
} from './datatypes.js';
import { consolidate } from './objects.js';

export const MULTIVALUED_DELIMITER = '; ';

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/general.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { consolidate } from '@/lib/utils/objects';
import { consolidate } from './objects';

export function wait(ms) {
return new Promise((r) => setTimeout(r, ms));
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import i18next from 'i18next';
import jqueryI18next from 'jquery-i18next';
// import tags from 'language-tags';

import { flattenObject } from '@/lib/utils/objects';
import label_translations_file from '@/web/translations/translations.json';
import { flattenObject } from './objects';
import label_translations_file from '../../web/translations/translations.json';
import {
MULTIVALUED_DELIMITER,
formatMultivaluedValue,
} from '@/lib/utils/fields';
import { renderContent } from '@/lib/utils/content';
} from './fields';
import { renderContent } from './content';

export const interface_translation = transformStructFirstSpec(
label_translations_file
Expand Down
18 changes: 6 additions & 12 deletions lib/utils/templates.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { deepMerge } from '@/lib/utils/objects';
import { fetchFileAsync } from '@/lib/utils/files';
import { deepMerge } from './objects';
import { fetchFileAsync } from './files';

import template_manifest from '@/web/templates/manifest.json';
import menu from '@/web/templates/menu.json';
import template_manifest from '../../web/templates/manifest.json';
import { menu, getSchema } from 'schemas';

export function getTemplatePathInScope() {
let templatePath;
Expand All @@ -26,7 +26,7 @@ export async function templatePathForSchemaURI(schemaURI) {
for (let i = 0; i < template_manifest.children.length; i++) {
const template = template_manifest.children[i];
if (typeof template.children !== 'undefined' && template.children.length > 0 && template.children.some(c => c.name.includes("schema.json"))) {
const schema = await importSchema(template.name);
const schema = await getSchema(template.name);
if (schema.id === schemaURI) {
const templatePath = `${template.path.split('/').slice(-1)}/${schemaURI
.split('/')
Expand All @@ -47,14 +47,8 @@ const isLocale = (el) => el.name === 'locales';
const schemaFromChildPath = (childPath) =>
childPath.replace(/\/templates\/(.+)\/schema.json/, '$1');

async function importSchema(schema_name) {
const schema = (
await import(`../../web/templates/${schema_name}/schema.json`)
).default;
return schema;
}
const importSchemaFromChildPath = (childPath) =>
importSchema(schemaFromChildPath(childPath));
getSchema(schemaFromChildPath(childPath));

const templateFetcher = async (childPath) => {
if (window.location.protocol.startsWith('file')) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/validation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
formatMultivaluedValue,
parseMultivaluedValue,
} from '@/lib/utils/fields';
} from './fields';

/**
* Test cellVal against "DataHarmonizer provenance: vX.Y.Z" pattern and if it
Expand Down
Loading

0 comments on commit 7736fe9

Please sign in to comment.