Skip to content

Commit

Permalink
Merge pull request #381 from cidgoh/feat-help-options
Browse files Browse the repository at this point in the history
Add columnHelpEntries constructor option
  • Loading branch information
pkalita-lbl authored Mar 2, 2023
2 parents 25316d8 + 52c2226 commit 31ec2ef
Showing 1 changed file with 63 additions and 20 deletions.
83 changes: 63 additions & 20 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class DataHarmonizer {
this.loadingScreenRoot = options.loadingScreenRoot || this.root;
this.modalsRoot = options.modalsRoot || document.querySelector('body');
this.field_settings = options.fieldSettings || {};
this.columnHelpEntries = options.columnHelpEntries || [
'column',
'description',
'guidance',
'examples',
'menus',
];
this.self = this;

this.injectLoadingScreen();
Expand Down Expand Up @@ -633,20 +640,31 @@ class DataHarmonizer {
let row_html = '';
for (const section of this.template) {
row_html += `<tr class="section">
<td colspan="5"><h3>${section.title || section.name}</h3></td>
<td colspan="${this.columnHelpEntries.length}"><h3>${
section.title || section.name
}</h3></td>
</tr>
`;
for (const slot of section.children) {
const slot_dict = this.getCommentDict(slot);

row_html += `<tr>
<td class="label">${slot_dict.title}</td>
<td>${slot_dict.description}</td>
<td>${slot_dict.guidance}</td>
<td>${slot_dict.examples}</td>
<td>${slot_dict.sources || ''}</td>
</tr>
`;
row_html += '<tr>';
if (this.columnHelpEntries.includes('column')) {
row_html += `<td class="label">${slot_dict.title}</td>`;
}
if (this.columnHelpEntries.includes('description')) {
row_html += `<td>${slot_dict.description}</td>`;
}
if (this.columnHelpEntries.includes('guidance')) {
row_html += `<td>${slot_dict.guidance}</td>`;
}
if (this.columnHelpEntries.includes('examples')) {
row_html += `<td>${slot_dict.examples}</td>`;
}
if (this.columnHelpEntries.includes('menus')) {
row_html += ` <td>${slot_dict.sources || ''}</td>`;
}
row_html += '</tr>';
}
}

Expand Down Expand Up @@ -676,11 +694,31 @@ class DataHarmonizer {
<table>
<thead>
<tr>
<th class="label">Field</th>
<th class="description">Description</th>
<th class="guidance">Guidance</th>
<th class="example">Examples</th>
<th class="data_status">Menus</th>
${
this.columnHelpEntries.includes('column')
? '<th class="label">Column</th>'
: ''
}
${
this.columnHelpEntries.includes('description')
? '<th class="description">Description</th>'
: ''
}
${
this.columnHelpEntries.includes('guidance')
? '<th class="guidance">Guidance</th>'
: ''
}
${
this.columnHelpEntries.includes('examples')
? '<th class="example">Examples</th>'
: ''
}
${
this.columnHelpEntries.includes('menus')
? '<th class="data_status">Menus</th>'
: ''
}
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -1223,23 +1261,28 @@ class DataHarmonizer {
getComment(field) {
let slot_dict = this.getCommentDict(field);

let ret = `<p><strong>Label</strong>: ${field.title}</p>`;
ret += `<p><strong>Name</strong>: ${field.name}</p>`;
let ret = '';

if (field.description) {
if (this.columnHelpEntries.includes('column')) {
ret += `<p><strong>Column</strong>: ${field.title || field.name}</p>`;
}

if (field.description && this.columnHelpEntries.includes('description')) {
ret += `<p><strong>Description</strong>: ${field.description}</p>`;
}

if (slot_dict.guidance) {
if (slot_dict.guidance && this.columnHelpEntries.includes('guidance')) {
ret += `<p><strong>Guidance</strong>: ${slot_dict.guidance}</p>`;
}

if (slot_dict.examples) {
if (slot_dict.examples && this.columnHelpEntries.includes('examples')) {
ret += `<p><strong>Examples</strong>: </p>${slot_dict.examples}`;
}
if (slot_dict.sources) {

if (slot_dict.sources && this.columnHelpEntries.includes('menus')) {
ret += `<p><strong>Menus</strong>: </p>${slot_dict.sources}`;
}

return ret;
}

Expand Down

0 comments on commit 31ec2ef

Please sign in to comment.