Skip to content

Commit

Permalink
Pass DH helpSidebar options object to HelpSidebar constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Apr 12, 2023
1 parent a37f3c3 commit d419124
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class DataHarmonizer {
this.loadingScreenRoot = options.loadingScreenRoot || this.root;
this.modalsRoot = options.modalsRoot || document.querySelector('body');
this.field_settings = options.fieldSettings || {};
this.helpSidebarOptions = Object.assign(
{ enabled: true },
options.helpSidebar || {}
);
this.columnHelpEntries = options.columnHelpEntries || [
'column',
'description',
Expand All @@ -69,13 +73,18 @@ class DataHarmonizer {
this.self = this;

// Use help sidebar by default unless turned off by client
if (
options.includeHelpSidebar === undefined ||
options.includeHelpSidebar
) {
this.helpSidebar = new HelpSidebar(this.root, {
onToggle: () => this.hot.render(),
});
if (this.helpSidebarOptions.enabled) {
const opts = Object.assign({}, this.helpSidebarOptions);
opts.onToggle = (open) => {
// always do a HOT rerender on toggle in addition to anything client-specified
if (this.hot) {
this.hot.render();
}
if (typeof this.helpSidebarOptions.onToggle === 'function') {
this.helpSidebarOptions.onToggle(open);
}
};
this.helpSidebar = new HelpSidebar(this.root, opts);
}

this.injectLoadingScreen();
Expand Down

0 comments on commit d419124

Please sign in to comment.