diff --git a/lib/AppContext.js b/lib/AppContext.js index 513860a8..36271263 100644 --- a/lib/AppContext.js +++ b/lib/AppContext.js @@ -3,15 +3,16 @@ import i18n from 'i18next'; import { DataHarmonizer } from '@/lib'; import { findLocalesForLangcodes } from '@/lib/utils/i18n'; -import { Template, findSlotNamesForClass, getTemplatePathInScope } from '@/lib/utils/templates'; +import { + Template, + findSlotNamesForClass, + getTemplatePathInScope, +} from '@/lib/utils/templates'; import { wait } from '@/lib/utils/general'; import { invert, removeNumericKeys, consolidate } from '@/lib/utils/objects'; import { setup1M, buildSchemaTree } from '@/lib/utils/1m'; -import { - createDataHarmonizerContainer, - createDataHarmonizerTab, - } from '@/web'; +import { createDataHarmonizerContainer, createDataHarmonizerTab } from '@/web'; class AppConfig { constructor(template_path = null) { this.rootUrl = window.location.host; diff --git a/lib/Toolbar.js b/lib/Toolbar.js index ebb72d5b..7c5c9829 100644 --- a/lib/Toolbar.js +++ b/lib/Toolbar.js @@ -15,7 +15,12 @@ import { prependToSheet, } from '@/lib/utils/files'; import { nullValuesToString, isEmptyUnitVal } from '@/lib/utils/general'; -import { MULTIVALUED_DELIMITER, singleFieldDisplayName, multiFieldDisplayName, mergedPermissibleValues } from '@/lib/utils/fields'; +import { + MULTIVALUED_DELIMITER, + singleFieldDisplayName, + multiFieldDisplayName, + mergedPermissibleValues, +} from '@/lib/utils/fields'; import { takeKeys, invert } from '@/lib/utils/objects'; import { findBestLocaleMatch, diff --git a/lib/utils/1m.js b/lib/utils/1m.js index 0cf77a44..8e173b15 100644 --- a/lib/utils/1m.js +++ b/lib/utils/1m.js @@ -313,7 +313,7 @@ function parentBroadcastsCRUD(data_harmonizers, schema_tree) { (index, rowData, source) => { const prop = data_harmonizers[ node.name - ].getColumnIndexByFieldName(shared_key.name); + ].getColumnIndexByFieldName(sharedKey.name); switch (source) { case 'removeRow': dispatchHandsontableUpdate({ @@ -321,7 +321,7 @@ function parentBroadcastsCRUD(data_harmonizers, schema_tree) { oldValue: rowData[prop], newValue: null, sourceTable: node.name, - sharedKey: shared_key, + sharedKey, }); // TODO: get proper row and prop break; diff --git a/lib/utils/fields.js b/lib/utils/fields.js index 7aa9a6fb..d674a7f5 100644 --- a/lib/utils/fields.js +++ b/lib/utils/fields.js @@ -267,14 +267,23 @@ export function titleOverText(enm) { } } -export const singleFieldDisplayName = permissible_values => key => key in permissible_values ? titleOverText(permissible_values[key]) : key; -export const multiFieldDisplayName = permissible_values => multikey => multikey.split(MULTIVALUED_DELIMITER).map(fieldDisplayName(permissible_values)).join(MULTIVALUED_DELIMITER); +export const singleFieldDisplayName = (permissible_values) => (key) => + key in permissible_values ? titleOverText(permissible_values[key]) : key; +export const multiFieldDisplayName = (permissible_values) => (multikey) => + multikey + .split(MULTIVALUED_DELIMITER) + .map(fieldDisplayName(permissible_values)) + .join(MULTIVALUED_DELIMITER); -export const fieldDisplayName = permissible_values => key => { +export const fieldDisplayName = (permissible_values) => (key) => { const maybeMultiKey = key.split(MULTIVALUED_DELIMITER); const isLikelyMultiKey = maybeMultiKey.length > 1; if (isLikelyMultiKey) return multiFieldDisplayName(permissible_values)(key); return singleFieldDisplayName(permissible_values)(key); -} +}; -export const mergedPermissibleValues = (field) => consolidate(field.sources, (acc, source) => ({ ...acc, ...field.permissible_values[source] })); +export const mergedPermissibleValues = (field) => + consolidate(field.sources, (acc, source) => ({ + ...acc, + ...field.permissible_values[source], + })); diff --git a/lib/utils/i18n.js b/lib/utils/i18n.js index f781b568..101729c8 100644 --- a/lib/utils/i18n.js +++ b/lib/utils/i18n.js @@ -19,14 +19,16 @@ export const interface_translation = transformStructFirstSpec( const withNamespace = (namespace, addons = {}) => (obj) => - consolidate(obj, (acc, [lang, translation]) => Object.assign(acc, { - [lang]: { - [namespace]: { - ...translation, - ...addons, + consolidate(obj, (acc, [lang, translation]) => + Object.assign(acc, { + [lang]: { + [namespace]: { + ...translation, + ...addons, + }, }, - }, - })); + }) + ); const englishIsDefault = (translation_object) => { // if there is an english resource translation, use it as the default translation diff --git a/lib/utils/templates.js b/lib/utils/templates.js index dda2e902..f74977bc 100644 --- a/lib/utils/templates.js +++ b/lib/utils/templates.js @@ -1,7 +1,9 @@ -import template_manifest from '@/web/templates/manifest.json'; import { deepMerge } from '@/lib/utils/objects'; import { fetchFileAsync } from '@/lib/utils/files'; +import template_manifest from '@/web/templates/manifest.json'; +import menu from '@/web/templates/menu.json'; + export function getTemplatePathInScope() { let templatePath; if (window.URLSearchParams) { diff --git a/web/index.js b/web/index.js index f91ab7fa..29445bc0 100644 --- a/web/index.js +++ b/web/index.js @@ -6,7 +6,6 @@ import { initI18n } from '@/lib/utils/i18n'; import { Template } from '@/lib/utils/templates'; import { getGettingStartedMarkup } from '@/lib/toolbarGettingStarted'; import { Footer, Toolbar, AppContext } from '@/lib'; -import menu from '@/web/templates/menu.json'; // Order matters: place this at bottom of imports for CSS overrides import '@/web/index.css';