forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the checked filters count in the browse page
- Loading branch information
1 parent
719e456
commit 75705a6
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
app/javascript/controllers/show_filter_count_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="show-filter-count" | ||
|
||
export default class extends Controller { | ||
static targets = ["countSpan"] | ||
updateCount(){ | ||
const checkInputs = this.element.querySelectorAll('input:checked') | ||
const count = checkInputs.length | ||
this.countSpanTarget.style.display = count === 0 ? "none" : "inline-block" | ||
this.countSpanTarget.innerHTML = count === 0 ? "" : count | ||
} | ||
} |