Skip to content

Commit

Permalink
Add button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
waracci authored and milafrerichs committed Apr 13, 2021
1 parent b9557fd commit c712ed1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/js/profile/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const typeIndex = {
'Value': 1
}

const MAX_RICH_TABLE_ROWS = 7

export class Chart extends Observable {
constructor(config, subindicators, groups, indicators, _subCategoryNode, title) {
Expand Down Expand Up @@ -108,12 +109,17 @@ export class Chart extends Observable {
}
$(table).append(tbody);
this.containerParent.append(table);
// Append button
if (data.length > 7) { // TODO: make this row count a constant
if (data.length > MAX_RICH_TABLE_ROWS) {
let showExtraRows = false;
let btnDiv = document.createElement('div');
$(btnDiv).addClass('profile-indicator__table_show-more profile-indicator__table_showing profile-indicator__table_load-more');
let btn = document.createElement('button');
$(btn).text('Load more rows');
$(btn).on("click", () => {
showExtraRows = !showExtraRows;
showExtraRows ? $(btn).text('Show less rows') : $(btn).text('Load more rows');
showExtraRows ? $(table).removeClass("profile-indicator__table_content") : $(table).addClass("profile-indicator__table_content");
})
btnDiv.append(btn);
this.containerParent.append(btnDiv);
}
Expand Down

0 comments on commit c712ed1

Please sign in to comment.