Skip to content

Commit fae3d2e

Browse files
committed
Fixing height readjustment issue
+ popup called "DataHarmonizer Demo + fix to call demoSchema()
1 parent caf4d6f commit fae3d2e

7 files changed

Lines changed: 86 additions & 40 deletions

File tree

lib/AppContext.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,8 @@ export default class AppContext {
627627
let data_harmonizers = {}; // Tacitly ordered attribute object
628628

629629
// If using DH_LinkML schema, this is the Schema Editor schema!
630-
if (schema.name === 'DH_LinkML') { // referenced elsewhere as dh.context.schemaEditor
631-
this.schemaEditor = new SchemaEditor(schema, this);
632-
};
630+
this.schemaEditor = schema.name === 'DH_LinkML' ? new SchemaEditor(schema, this) : null;
631+
633632

634633
Object.entries(schema.classes)
635634
// Container class is only used in input and output file coordination.
@@ -694,7 +693,7 @@ export default class AppContext {
694693
minRows: is_child ? 0 : 10,
695694
minSpareRows: 0,
696695
//minHeight: '200px', // nonsensical if no rows exist
697-
height: '75vh',
696+
height: '100%',
698697
// TODO: Workaround, possibly due to too small section column on child tables
699698
// colWidths: is_child ? 256 : undefined,
700699
colWidths: 200,

lib/DataHarmonizer.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class DataHarmonizer {
8787

8888
// interface layout pass-ins
8989
this.root = root;
90-
this.hotRoot = options.hotRoot || $('<div>').appendTo(this.root)[0];
90+
this.hotRoot = options.hotRoot || $('<div>').addClass('dh-hot-root').appendTo(this.root)[0];
9191
this.modalsRoot = options.modalsRoot || document.querySelector('body');
9292
this.loadingScreenRoot = options.loadingScreenRoot || this.root;
9393

@@ -224,8 +224,7 @@ class DataHarmonizer {
224224
minRows: 5,
225225
minSpareRows: 0,
226226
width: '100%',
227-
// Future: For empty dependent tables, tailor to minimize height.
228-
height: '75vh',
227+
height: '100%',
229228
fixedRowsTop: 0,
230229
// define your custom query method, e.g. queryMethod: searchMatchCriteria
231230
search: {},
@@ -362,7 +361,7 @@ class DataHarmonizer {
362361
hidden() {
363362
return self.template_name != 'Schema';
364363
},
365-
callback() { self.context.schemaEditor.previewSchema(); }
364+
callback() { self.context.schemaEditor.demoSchema(); }
366365
},
367366
copy_to_schema: {
368367
name: 'Copy to schema',
@@ -941,14 +940,9 @@ class DataHarmonizer {
941940
afterRowMove: (movedRows, finalIndex, dropIndex, movePossible, orderChanged) => {
942941
if (!orderChanged) return;
943942
const numMoved = self._pendingMoveCount || 1;
944-
const count = self.hot.countSourceRows();
945-
const reordered = [];
946-
for (let vRow = 0; vRow < count; vRow++) {
947-
const physRow = self.hot.toPhysicalRow(vRow);
948-
if (physRow !== null) {
949-
reordered.push([...self.hot.getSourceDataAtRow(physRow)]);
950-
}
951-
}
943+
// getData() returns the current visual-order rows as plain arrays,
944+
// avoiding HOT-internal wrapper objects from getSourceDataAtRow.
945+
const reordered = self.hot.getData();
952946
self.invalid_cells = {}; // physical row indices will reset; stale cache must be cleared
953947
// Capture scroll position before loadData resets it. Row count and
954948
// heights are unchanged (reorder only), so the same scrollTop pixel

lib/Footer.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import $ from 'jquery';
22

3-
const TEMPLATE = `
4-
<div class="input-group">
5-
<div class="input-group-prepend">
3+
class Footer {
4+
constructor(root, context, options = {}) {
5+
this.root = $(root);
6+
7+
const modeLabel = options.modeLabel || (context.schemaEditor ? 'Schema Editor' : 'DataHarmonizer');
8+
9+
this.root.append(`
10+
<div style="overflow:auto">
11+
<div id="dh-mode-badge" class="badge bg-secondary text-white px-3 py-2" style="float:right; font-size:1rem">${modeLabel}</div>
12+
<div class="input-group" style="width:auto; display:inline-flex">
613
<button class="btn btn-primary add-rows-button" type="submit" id="add-row"
714
data-i18n="add-row">
815
Add
916
</button>
10-
</div>
11-
<input
12-
type="text"
13-
class="form-control add-rows-input"
14-
value="1"
15-
/>
16-
<div class="input-group-append">
17+
<input
18+
type="text"
19+
class="form-control add-rows-input"
20+
value="1"
21+
/>
1722
<span class="input-group-text" id="add-row-text" data-i18n="add-row-text">row(s)</span>
1823
</div>
19-
2024
</div>
21-
`;
25+
`);
2226

23-
class Footer {
24-
constructor(root, context) {
25-
this.root = $(root);
26-
this.root.append(TEMPLATE);
2727
this.root.find('.add-rows-button').on('click', () => {
2828
const numRows = this.root.find('.add-rows-input').val();
2929
context.getCurrentDataHarmonizer().addRows('insert_row_below', numRows);

lib/Toolbar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ class Toolbar {
527527
// INITIALIZATIN: Triggers only for loaded top-level template, rather than
528528
// any dependent.
529529
restartInterface(myContext) {
530+
$('#dh-mode-badge').text(myContext.schemaEditor ? 'Schema Editor' : 'DataHarmonizer');
530531
this.updateGUI(
531532
myContext.getCurrentDataHarmonizer(),
532533
myContext.getTemplateName()
@@ -1378,6 +1379,7 @@ export function titleOverText(enm) {
13781379
if (isMultiTab) {
13791380
$('#concise-view-checkbox').prop('checked', true);
13801381
}
1382+
$('#record-hierarchy-div').toggle(isMultiTab);
13811383
this._syncConciseViewToDisplayMode();
13821384
}
13831385

web/index.css

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,64 @@
11
html,
22
body {
33
width: 100%;
4-
height: 100%;
4+
height: 100vh;
55
margin: 0;
6+
overflow: hidden;
67
/* Prevents track or mouse scroll gestures from triggering page navigation in chrome off of displayed page. */
78
overscroll-behavior: contain;
89
}
910

11+
/* Full-viewport flex column: grid row grows with browser height; toolbar and footer stay content-height */
12+
#dh-layout {
13+
display: flex;
14+
flex-direction: column;
15+
height: 100%;
16+
overflow: hidden;
17+
}
18+
19+
#dh-layout-toolbar {
20+
flex: 0 0 auto;
21+
}
22+
23+
#dh-layout-footer {
24+
flex: 0 0 auto;
25+
padding-top: 6px;
26+
padding-bottom: 8px;
27+
border-top: 1px solid silver;
28+
}
29+
30+
#dh-layout-grid {
31+
flex: 1 1 auto;
32+
min-height: 0;
33+
overflow: hidden;
34+
}
35+
36+
#dh-layout-grid > .col {
37+
display: flex;
38+
flex-direction: column;
39+
height: 100%;
40+
overflow: hidden;
41+
min-height: 0;
42+
}
43+
44+
#data-harmonizer-tabs {
45+
flex: 0 0 auto;
46+
}
47+
48+
#data-harmonizer-grid {
49+
flex: 1 1 auto;
50+
min-height: 0;
51+
overflow: hidden;
52+
}
53+
54+
#data-harmonizer-grid > .tab-pane {
55+
height: 100%;
56+
}
57+
58+
.dh-hot-root {
59+
height: 100%;
60+
}
61+
1062
/* For dh2-i18n-rc1 only! */
1163
#data-harmonizer-tabs {
1264
/* display: none; */

web/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,26 @@
99
<script src="dist-schemas/schemas.js"></script>
1010
</head>
1111
<body>
12-
<div class="container-fluid">
13-
<div class="row mt-3">
12+
<div class="container-fluid" id="dh-layout">
13+
<div class="row mt-3" id="dh-layout-toolbar">
1414
<div class="col">
1515
<div id="data-harmonizer-toolbar"></div>
1616
</div>
1717
</div>
1818

19-
<div class="row mt-3">
19+
<div class="row mt-3" id="dh-layout-grid">
2020
<div class="col">
2121
<ul
2222
id="data-harmonizer-tabs"
2323
class="nav nav-tabs"
24-
id="myTab"
2524
role="tablist"
2625
></ul>
2726
<div id="data-harmonizer-grid" class="tab-content"></div>
2827
</div>
2928
</div>
3029

31-
<div class="row mt-3">
32-
<div class="col"><!-- col-md-6 -->
30+
<div class="row mt-2" id="dh-layout-footer">
31+
<div class="col">
3332
<div id="data-harmonizer-footer"></div>
3433
</div>
3534
</div>

web/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const main = async function () {
7979
getSchema: async (s) =>
8080
Template.create(s).then((result) => result.current.schema),
8181
});
82-
new Footer(dhFooterRoot, context);
82+
new Footer(dhFooterRoot, context, { modeLabel: 'DataHarmonizer Demo' });
8383
});
8484
}
8585
return;

0 commit comments

Comments
 (0)