Skip to content

Commit

Permalink
linting and bad var names
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Aug 23, 2024
1 parent 774612d commit 62a7304
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
11 changes: 6 additions & 5 deletions lib/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/1m.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ 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({
prop,
oldValue: rowData[prop],
newValue: null,
sourceTable: node.name,
sharedKey: shared_key,
sharedKey,
});
// TODO: get proper row and prop
break;
Expand Down
19 changes: 14 additions & 5 deletions lib/utils/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}));
16 changes: 9 additions & 7 deletions lib/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/templates.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
1 change: 0 additions & 1 deletion web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 62a7304

Please sign in to comment.