Skip to content

Commit

Permalink
Merge branch 'dh2-beta-release' into dh2-1m-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Aug 21, 2024
2 parents 436246a + 2cbaebe commit b404d6c
Show file tree
Hide file tree
Showing 9 changed files with 1,103 additions and 796 deletions.
5 changes: 2 additions & 3 deletions lib/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Template, findSlotNamesForClass } from '@/lib/utils/templates';
import { wait } from '@/lib/utils/general';
import { invert, removeNumericKeys } from '@/lib/utils/objects';
import {
buildSchemaTree,
setup1M
setup1M,
buildSchemaTree
} from '@/lib/utils/1m';
import { createDataHarmonizerContainer, createDataHarmonizerTab } from '@/web';

Expand Down Expand Up @@ -475,7 +475,6 @@ export class AppContext {
),
};
context.setDataHarmonizers(dhs);

setup1M(dhs, schema_tree);

return context;
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/1m.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function setupSharedColumn(
);
} else {
// Initialize the row data manager
const rowDataManager = createRowDataManager();
const rowDataManager = createRowDataManager(contex_menu_callback);

// Add the beforeRemoveRow and afterRemoveRow hooks using addHook
hot.addHook('beforeRemoveRow', rowDataManager.beforeRemoveRow);
Expand Down Expand Up @@ -567,7 +567,7 @@ function bindSelectHandlerEvents(data_harmonizers, schema_tree) {
}

// closure to keep track of row data before removal
const createRowDataManager = () => {
const createRowDataManager = (contex_menu_callback) => {
let rowDataBeforeRemoval = {};

return {
Expand Down Expand Up @@ -705,7 +705,7 @@ function parentBroadcastsCRUD(data_harmonizers, schema_tree) {
});
// TODO: row insertion/deletion
// Add the beforeRemoveRow and afterRemoveRow hooks using addHook
// const rowDataManager = createRowDataManager();
// const rowDataManager = createRowDataManager(handleChange);
// hot.addHook('beforeRemoveRow', rowDataManager.beforeRemoveRow);
// hot.addHook('afterRemoveRow', rowDataManager.afterRemoveRow);

Expand Down
21 changes: 11 additions & 10 deletions script/tabular_to_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ def set_enums(enum_path, schema, locale_schemas, export_format, warnings):
reader = csv.DictReader(tsvfile, dialect='excel-tab');

enumerations = schema['enums'];

name = ''; # running title for chunks of enumeration rows
name = ''; # running name for chunks of enumeration rows
choice_path = [];
enum = {};

Expand All @@ -368,11 +367,14 @@ def set_enums(enum_path, schema, locale_schemas, export_format, warnings):
row[field] = row[field].strip();

# Each enumeration begins with a row that provides the name of the enum.
if row.get('name','') > '':
# subsequent rows may not have a name.
if row.get('name','') > '' or row.get('title','') > '':

# Process default language title
name = row.get('name');
title = row.get('title');
if not name: # For enumerations that don't have separate name field
name = title;
if not (name in enumerations):
enum = {
'name': name,
Expand Down Expand Up @@ -401,15 +403,15 @@ def set_enums(enum_path, schema, locale_schemas, export_format, warnings):
# Loop scans through columns until it gets a value
for depth in range(1,6):
menu_x = 'menu_' + str(depth);
choice_value = row.get(menu_x);
choice_text = row.get(menu_x);
# Here there is a menu item to process
if choice_value > '':
if choice_text > '':
del choice_path[depth-1:] # Menu path always points to parent

description = row.get('description','');
meaning = row.get('meaning','');

choice = {'text' : choice_value}
choice = {'text' : choice_text}
if description > '': choice['description'] = description;
if meaning > '': choice['meaning'] = meaning;

Expand All @@ -420,20 +422,19 @@ def set_enums(enum_path, schema, locale_schemas, export_format, warnings):
if len(choice_path) > 0:
choice['is_a'] = choice_path[-1]; # Last item in path

enum['permissible_values'][choice_value] = choice;
choice_path.append(choice_value);
enum['permissible_values'][choice_text] = choice;
choice_path.append(choice_text);

for lcode in locale_schemas.keys():
translation = row.get(menu_x + '_' + lcode, '');

if translation > '' and translation != choice['text']:

local_choice = {'title': translation}
description = row.get(description + '_' + lcode, '');
if description:
local_choice['description': description];

locale_schemas[lcode]['enums'][name]['permissible_values'][choice_value] = local_choice;
locale_schemas[lcode]['enums'][name]['permissible_values'][choice_text] = local_choice;

break;

Expand Down
Loading

0 comments on commit b404d6c

Please sign in to comment.