Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
also hide column summaries when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromedockes committed Jun 28, 2024
1 parent e67e7ac commit 3f5f2f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/skrubview/_data/templates/dataframe-columns.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% from "utils.j2" import collapse_const_id with context %}
{% set selected_cols_id = "{}_selected_cols_box".format(report_id) %}

<div class="skrubview-if-else skrubview-column-summaries-toggle" data-predicate="true">
<article class="skrubview-wrapper">
{% set selected_cols_id = "{}_selected_cols_box".format(report_id) %}
<div class="skrubview-flex skrubview-wrapper-vert">
<div class="skrubview-box">
<pre class="selected-columns-box" id="{{ selected_cols_id }}"></pre>
Expand Down Expand Up @@ -40,3 +42,7 @@ <h3>Constant columns</h3>
{% endfor %}
</div>
</article>
<div class="skrubview-text skrubview-announcement skrubview-wrapper">
No columns match the selected filter: <strong class="skrubview-selected-filter-display"></strong>. Change the column filter in the dropdown menu above to display some columns.
</div>
</div>
10 changes: 6 additions & 4 deletions src/skrubview/_data/templates/skrubview.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ function onFilterChange(colFilterId) {
if (!acceptedCols.includes(tableElem.dataset.selectedColumn)){
clearTableCellSelection(tableElem);
}
const tableToggle = reportElem.querySelector(".skrubview-table-sample-toggle");
tableToggle.dataset.predicate = acceptedCols.length === 0 ? "false": "true";
const filterDisplay = tableToggle.querySelector(".skrubview-selected-filter-display");
filterDisplay.textContent = '"' + colFilters[filterName]["display_name"] + '"';
for (let toggleSelector of [".skrubview-table-sample-toggle", ".skrubview-column-summaries-toggle"]){
const toggle = reportElem.querySelector(toggleSelector);
toggle.dataset.predicate = acceptedCols.length === 0 ? "false": "true";
const filterDisplay = toggle.querySelector(".skrubview-selected-filter-display");
filterDisplay.textContent = '"' + colFilters[filterName]["display_name"] + '"';
}
}

0 comments on commit 3f5f2f5

Please sign in to comment.