Skip to content

Commit b9310c0

Browse files
Merge pull request #200 from tulibraries/hide-mode-as-default
Hide mode as default
2 parents 6785c95 + 325364b commit b9310c0

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

app/javascript/controllers/wunderbaum_controller.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class extends Controller {
1010
currentFilterPredicate = null;
1111
currentFilterOpts = null;
1212
currentQuery = "";
13-
filterMode = "dim";
13+
filterMode = "hide";
1414
folderCache = new Map();
1515
assetCache = new Map();
1616
loadedFolders = new Set();
@@ -536,18 +536,15 @@ export default class extends Controller {
536536
_updateFilterModeButton() {
537537
const btn = document.getElementById("filter-mode-toggle");
538538
if (!btn) return;
539-
const hasActiveFilter = Boolean(this.currentFilterPredicate);
540-
btn.disabled = !hasActiveFilter;
541-
btn.classList.toggle("active", hasActiveFilter && this.filterMode === "hide");
542-
btn.setAttribute("title", this.filterMode === "hide" ? "Hide unmatched nodes" : "Dim unmatched nodes");
543539
const icon = btn.querySelector("i");
540+
const isHideMode = this.filterMode === "hide";
541+
542+
btn.classList.toggle("active", isHideMode);
543+
btn.setAttribute("title", isHideMode ? "Hide unmatched nodes" : "Dim unmatched nodes");
544+
544545
if (icon) {
545546
icon.classList.remove("bi-filter-square", "bi-filter-square-fill");
546-
if (this.filterMode === "hide") {
547-
icon.classList.add("bi-filter-square-fill");
548-
} else {
549547
icon.classList.add("bi-filter-square");
550-
}
551548
}
552549
}
553550

spec/system/file_tree_column_filter_spec.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,20 @@
5959
expect(page).to have_selector(".wb-popup", count: 1)
6060
end
6161

62-
it "allows switching between dim and hide filter modes" do
63-
expect(page).to have_selector("#filter-mode-toggle[disabled]")
62+
it "allows switching between hide and dim filter modes" do
63+
expect(page).to have_no_selector("#filter-mode-toggle[disabled]")
6464

6565
fill_in "tree-filter", with: match_asset.isilon_name
6666

67-
expect(page).to have_selector("#tree.wb-ext-filter-dim")
68-
expect(page).to have_no_selector("#filter-mode-toggle[disabled]", wait: 10)
69-
70-
find("#filter-mode-toggle").click
7167
expect(page).to have_selector("#tree.wb-ext-filter-hide")
72-
expect(page).to have_selector("#filter-mode-toggle.active")
7368

7469
find("#filter-mode-toggle").click
75-
expect(page).to have_no_selector("#tree.wb-ext-filter-hide")
7670
expect(page).to have_selector("#tree.wb-ext-filter-dim")
71+
expect(page).to have_no_selector("#filter-mode-toggle.active")
72+
73+
find("#filter-mode-toggle").click
74+
expect(page).to have_selector("#tree.wb-ext-filter-hide")
75+
expect(page).to have_no_selector("#tree.wb-ext-filter-dim")
7776
end
7877

7978
it "clears column filter indicators when clearing all filters at once" do
@@ -94,7 +93,7 @@
9493
click_button "Clear All Filters"
9594

9695
expect(page).to have_no_selector(".wb-header [data-command='filter'].wb-helper-invalid", wait: 10)
97-
expect(page).to have_selector("#filter-mode-toggle[disabled]", wait: 10)
96+
expect(page).to have_no_selector("#filter-mode-toggle[disabled]", wait: 10)
9897
expect(page).to have_no_selector("#tree.wb-ext-filter-dim", wait: 10)
9998
end
10099
end

0 commit comments

Comments
 (0)