Skip to content

Commit 8c788ee

Browse files
committed
finished translation save
+ added nested-property + version bump + hidden load schema from URL + display tabs and tooltips with class title instead of name.
1 parent fed9123 commit 8c788ee

File tree

6 files changed

+243
-164
lines changed

6 files changed

+243
-164
lines changed

lib/AppContext.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { getExportFormats } from 'schemas';
1212
import { range as arrayRange } from 'lodash';
1313
import { deepMerge } from '../lib/utils/objects';
1414
import Validator from './Validator';
15+
import i18next from 'i18next';
16+
17+
const SCHEMAMENUS = ['SchemaTypeMenu','SchemaClassMenu','SchemaSlotMenu','SchemaSlotGroupMenu','SchemaEnumMenu'];
1518

1619
class AppConfig {
1720
constructor(template_path = null) {
@@ -20,7 +23,6 @@ class AppConfig {
2023
}
2124
}
2225
export default class AppContext {
23-
//schema_tree = {};
2426
dhs = {};
2527
current_data_harmonizer_name = null;
2628
currentSelection = null;
@@ -100,13 +102,9 @@ export default class AppContext {
100102
// Ensure dynamic Enums are added so picklist source / range references are
101103
// detected and pulldown/multiselect menus are crafted; and validation works
102104
if (schema.name === 'DH_LinkML') {
103-
['SchemaTypeMenu','SchemaClassMenu','SchemaEnumMenu','SchemaSlotGroupMenu']
104-
.forEach((item) => {
105+
SCHEMAMENUS.forEach((item) => {
105106
if (!(item in schema.enums)) {
106-
schema.enums[item] = {
107-
name: item,
108-
permissible_values: {test: {text: 'test', title: 'a title'}}
109-
}
107+
schema.enums[item] = {name: item} //, permissible_values: {}
110108
}
111109
});
112110
};
@@ -117,11 +115,6 @@ export default class AppContext {
117115
this.crudGetDependentRows(this.current_data_harmonizer_name);
118116
this.crudUpdateRecordPath();
119117
$("#record-hierarchy-div").toggle(Object.keys(this.relations).length > 1);
120-
121-
// Upgrade to Handsontable 15.0.0 causes following to error out?!
122-
// undefined "schema.enums.SchemaSlotGroupMenu"
123-
//schema.enums.SchemaSlotGroupMenu.permissible_values['testo'] = {text: 'testo', title: 'a title'};
124-
125118
return this;
126119
}
127120

@@ -141,7 +134,7 @@ export default class AppContext {
141134
* @param {Array} enums list of special enumeration menus. Default list
142135
* covers all menus that schema editor might have changed dynamically.
143136
*/
144-
refreshSchemaEditorMenus(enums = ['SchemaTypeMenu','SchemaClassMenu','SchemaEnumMenu','SchemaSlotGroupMenu']) {
137+
refreshSchemaEditorMenus(enums = SCHEMAMENUS) {
145138
const schema = this.template.current.schema;
146139
if (schema.name === 'DH_LinkML') {
147140
for (const enum_name of enums) {
@@ -191,6 +184,12 @@ export default class AppContext {
191184
this.getDynamicMenu(schema, schema.enums, 'Enum', user_schema_name, permissible_values);
192185
break;
193186

187+
case 'SchemaSlotMenu':
188+
// Get the enums from the Enums tab, filtered for schema
189+
// selected in Schema tab.
190+
this.getDynamicMenu(schema, schema.slots, 'Slot', user_schema_name, permissible_values);
191+
break;
192+
194193
case 'SchemaSlotGroupMenu':
195194
/** Fabricate list of active class's SchemaSlotGroupMenu
196195
* slot_group values and make menu for it. To prepare SlotGroup
@@ -312,13 +311,15 @@ export default class AppContext {
312311
.forEach((obj, index) => {
313312
if (obj.length > 0) {
314313
const [class_name, class_obj] = obj;
315-
316-
// Move createDataHarmonizerTab to HTML utilities, and move prep there.
317-
// If it shares a key with another class which is its parent, this DH must be a child
318-
const is_child = !(class_name == template_name); // && isEmpty(this.crudGetParents(class_name)) && !();
319-
let tooltip = Object.keys(this.relations[class_name]?.parent).join(', ');
320-
if (tooltip.length)
321-
tooltip = `Requires key selection from: ${tooltip}`;
314+
// Move createDataHarmonizerTab() to HTML utilities, and move prep there.
315+
// Tooltip lists any parents of this class whose keys must be satisfied.
316+
const is_child = !(class_name == template_name);
317+
let tooltip = Object.keys(this.relations[class_name]?.parent)
318+
.map((parent_name) => schema.classes[parent_name].title)
319+
.join(', ');
320+
if (tooltip.length) {
321+
tooltip = `<span data-i18n="tooltip-require-selection">${i18next.t('tooltip-require-selection')}</span>: ${tooltip}`; //Requires key selection from
322+
}
322323
const dhId = `data-harmonizer-grid-${index}`;
323324
const tab_label = class_obj.title ? class_obj.title : class_name;
324325
const dhTab = createDataHarmonizerTab(dhId, tab_label, class_name, tooltip, index === 0);
@@ -1125,12 +1126,14 @@ export default class AppContext {
11251126
}
11261127

11271128
/**
1128-
* Show path from root to current template that user has made a selection in.
1129-
* A complexity is that a class's keys may be composed of slots from have two
1130-
* (or more) separate parents, each with parent(s) etc.
1129+
* In focus display (usually in footer), show path from root to current
1130+
* template that user has made a selection in. A complexity is that a
1131+
* class's keys may be composed of slots from have two (or more) separate
1132+
* parents, each with parent(s) etc.
11311133
*
11321134
*/
11331135
crudUpdateRecordPath() {
1136+
const schema = this.template.current.schema;
11341137
const current_template_name = this.getCurrentDataHarmonizer().template_name;
11351138
let class_name = current_template_name; // current tab
11361139
let hierarchy_text = [];
@@ -1140,6 +1143,7 @@ export default class AppContext {
11401143
class_name = stack.pop(); // pop class_name
11411144
if (class_name in done)
11421145
continue;
1146+
const class_title = schema.classes[class_name].title;
11431147
const dependent = this.dependent_rows.get(class_name);
11441148
let key_string = '';
11451149
let tooltip = '';
@@ -1151,8 +1155,8 @@ export default class AppContext {
11511155
key_string = value + (key_string ? ', ' : '') + key_string;
11521156
tooltip = key + (tooltip ? ', ' : '') + tooltip;
11531157
});
1154-
let tooltip_text = `<span class="tooltipytext">${class_name} [ ${tooltip} ]</span>`;
1155-
done[class_name] = `<b>${class_name}</b>&nbsp;<span class="tooltipy">[${key_string}]${tooltip_text}</span> `;
1158+
let tooltip_text = `<span class="tooltipytext">${class_title} [ ${tooltip} ]</span>`;
1159+
done[class_name] = `<b>${class_title}</b>&nbsp;<span class="tooltipy">[${key_string}]${tooltip_text}</span> `;
11561160

11571161
// SEVERAL parents are possible - need them all displayed.
11581162
let parents = Object.keys(this.relations[class_name].parent);

0 commit comments

Comments
 (0)