Skip to content

Commit 58a8fff

Browse files
committed
New Schema "Expert" setting
1 parent b410d9c commit 58a8fff

5 files changed

Lines changed: 47 additions & 11 deletions

File tree

lib/DataHarmonizer.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class DataHarmonizer {
382382
colHeaders: true,
383383
rowHeaders: true,
384384
renderallrows: false, // working?
385+
outsideClickDeselects: false, // TESTING
385386
manualRowMove: true,
386387
multiColumnSorting: {
387388
sortEmptyCells: true,
@@ -836,7 +837,7 @@ class DataHarmonizer {
836837
&& row2 === self.current_selection[2]
837838
&& column2 === self.current_selection[3]
838839
) {
839-
console.log('Double event: afterSelectionEnd')
840+
console.log('Double event: afterSelectionEnd', row, column, row2, column2, selectionLayerLevel, action)
840841
return false
841842
}
842843
// ORDER IS IMPORTANT HERE. Must calculate row_change, column_change,
@@ -959,10 +960,11 @@ class DataHarmonizer {
959960
let translatable = '';
960961
for (var column_name of text_columns) {
961962

962-
// Exception is 'permissible_values', 'text' where in default
963+
// DEPRECATED: Exception is 'permissible_values', 'text' where in default
963964
// schema there might not be a title. find 'text' instead of 'title'
964-
if (sub_part === 'permissible_values' && column_name === 'title')
965-
column_name = 'text';
965+
// NOW INSIST ON "text" column for all schemas
966+
//if (sub_part === 'permissible_values' && column_name === 'title')
967+
// column_name = 'text';
966968
let col = tab_dh.slot_name_to_column[column_name];
967969
let text = tab_dh.hot.getDataAtCell(row, col, 'lookup') || '';
968970
default_row_text += `<td>${text}</td>`;
@@ -975,6 +977,10 @@ class DataHarmonizer {
975977
let key2 = null;
976978
if (sub_part_key_name) {
977979
key2 = tab_dh.hot.getDataAtCell(row, tab_dh.slot_name_to_column[sub_part_key_name], 'lookup');
980+
if (!key2) {
981+
console.log("key2",key2, "lookup from", TRANSLATABLE[tab_dh.template_name]);
982+
alert("unable to get key2 from lookup of:" + sub_part_key_name)
983+
}
978984
}
979985

980986
// DISPLAY locale for each schema in_language menu item
@@ -1156,7 +1162,7 @@ class DataHarmonizer {
11561162
if (focus_row < 0)
11571163
focus_row = 0;
11581164
}
1159-
1165+
11601166
// Find an empty row
11611167
if (!focus_cell) {
11621168
for (focus_row = 0; focus_row < this.hot.countRows(); focus_row ++) {
@@ -1227,7 +1233,7 @@ class DataHarmonizer {
12271233
case 'imports':
12281234
value = this.getDelimitedString(schema.imports);
12291235
break;
1230-
1236+
12311237
default:
12321238
value = schema[dep_slot.name] ??= '';
12331239
}
@@ -2185,7 +2191,9 @@ class DataHarmonizer {
21852191
addRows(row_where, numRows, startRowIndex = false) {
21862192
numRows = parseInt(numRows); // Coming from form string input.
21872193
// Get the starting row index where the new rows will be added
2188-
if (startRowIndex === false) startRowIndex = this.hot.countSourceRows();
2194+
// ISSUE HERE IS THAT VISUAL ROW doesn't CORRESPOND TO
2195+
if (startRowIndex === false)
2196+
startRowIndex = this.hot.countSourceRows();
21892197

21902198
let parents = this.context.crudGetParents(this.template_name);
21912199
// If this has no foreign key parent table(s) then go ahead and add x rows.
@@ -2207,7 +2215,8 @@ class DataHarmonizer {
22072215
return;
22082216
}
22092217

2210-
this.hot.alter(row_where, startRowIndex, numRows);
2218+
// NEW ROWS ARE ADDED HERE.
2219+
//this.hot.alter(row_where, startRowIndex, numRows);
22112220

22122221
// Populate new rows with selected foreign key value(s)
22132222
// "add_row" is critical so we can ignore that in before_change event.

lib/Toolbar.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { menu } from 'schemas';
4545
import pkg from '../package.json';
4646

4747
const VERSION = pkg.version;
48+
const SCHEMA_EDITOR_EXPERT_TABS = '#tab-bar-Prefix, #tab-bar-UniqueKey, #tab-bar-Annotation, #tab-bar-EnumSource, #tab-bar-Extension';
4849

4950
class Toolbar {
5051
constructor(root, context, options = {}) {
@@ -268,6 +269,11 @@ class Toolbar {
268269
// SCHEMA EDITOR
269270
// Load a DH schema.yaml file into this slot.
270271
// Prompt user for schema file name.
272+
$('#schema_expert').on('click', (event) => {
273+
let expert_visibility = $('#schema_expert').is(':checked');
274+
$(SCHEMA_EDITOR_EXPERT_TABS).toggle(expert_visibility);
275+
});
276+
271277
$('#schema_upload').on('change', (event) => {
272278
const reader = new FileReader();
273279
reader.addEventListener('load', (event2) => {
@@ -1209,8 +1215,11 @@ class Toolbar {
12091215
helpSop.hide();
12101216
}
12111217

1212-
$('#schema-editor-menu')
1213-
$('#schema-editor-menu').toggle(this.context.getCurrentDataHarmonizer().schema.name === 'DH_LinkML')
1218+
let schema_editor = this.context.getCurrentDataHarmonizer().schema.name === 'DH_LinkML';
1219+
let expert_visibility = $('#schema_expert').is(':checked');
1220+
$('#schema-editor-menu').toggle(schema_editor);
1221+
$(SCHEMA_EDITOR_EXPERT_TABS).toggle(expert_visibility);
1222+
12141223
this.setupJumpToModal(dh);
12151224
this.setupSectionMenu(dh);
12161225
this.setupFillModal(dh);

lib/toolbar.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
<div style="padding: 0.25rem 1.5rem" id="schema-editor-menu">
4444
<span data-i18n="schema-editor-menu">Schema Editor options:</span>
4545
<div>
46+
47+
<label
48+
for="schema_expert"
49+
class="dropdown-item mb-0"
50+
id="schema-editor-expert-user"
51+
><span data-i18n="schema-editor-expert-options">Toggle expert user mode</span>
52+
<input
53+
type="checkbox"
54+
class="form-control"
55+
style="width:1rem;height:1.5rem;float:right"
56+
id="schema_expert"
57+
/>
58+
</label
59+
>
4660
<label
4761
for="schema_upload"
4862
class="dropdown-item mb-0"

web/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function createDataHarmonizerContainer(dhId, isActive) {
3232

3333
export function createDataHarmonizerTab(dhId, tab_title, class_name, tooltip, isActive) {
3434
const template = document.createElement('template');
35-
template.innerHTML = `<li role="tab" class="nav-item ${tooltip.length ? 'tooltipy' :''}"><a class="nav-link${(isActive ? ' active' : '')}" id="tab-${dhId}" href=#${dhId} data-bs-target="#${dhId}" data-name="${class_name}" data-toggle="tab">${tab_title}</a>${tooltip.length ? '<span class="tooltipytext tinytip">' + tooltip + '</span>' : ''}</li>`;
35+
template.innerHTML = `<li role="tab" id="tab-bar-${class_name}" class="nav-item ${tooltip.length ? 'tooltipy' :''}"><a class="nav-link${(isActive ? ' active' : '')}" id="tab-${dhId}" href=#${dhId} data-bs-target="#${dhId}" data-name="${class_name}" data-toggle="tab">${tab_title}</a>${tooltip.length ? '<span class="tooltipytext tinytip">' + tooltip + '</span>' : ''}</li>`;
3636

3737
const dhTab = template.content.firstChild;
3838

web/translations/translations.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"en": "Schema Editor options",
2222
"fr": "Options de l'éditeur de schéma"
2323
},
24+
"schema-editor-expert-options": {
25+
"en": "Toggle expert user mode",
26+
"fr": "Activer/désactiver le mode utilisateur expert"
27+
},
2428
"upload-template-yaml-dropdown-item": {
2529
"en": "Load Schema from file (.yaml format)",
2630
"fr": "Charger le schéma à partir du fichier (format .yaml)"

0 commit comments

Comments
 (0)