mirror of
https://github.com/we-promise/sure.git
synced 2026-04-10 15:54:48 +00:00
feat: Add toggle on mobile to show/hide checkboxes in transaction page
This commit is contained in:
32
app/javascript/controllers/checkbox_toggle_controller.js
Normal file
32
app/javascript/controllers/checkbox_toggle_controller.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["selectionEntry", "toggleButton"]
|
||||
|
||||
toggle() {
|
||||
const shouldShow = this.selectionEntryTargets[0].classList.contains("hidden")
|
||||
|
||||
this.selectionEntryTargets.forEach((el) => {
|
||||
if (shouldShow) {
|
||||
el.classList.remove("hidden")
|
||||
} else {
|
||||
el.classList.add("hidden")
|
||||
}
|
||||
})
|
||||
|
||||
if (!shouldShow) {
|
||||
const bulkSelectElement = this.element.closest("[data-controller~='bulk-select']");
|
||||
if (bulkSelectElement) {
|
||||
const bulkSelectController = this.application.getControllerForElementAndIdentifier(
|
||||
bulkSelectElement,
|
||||
"bulk-select"
|
||||
);
|
||||
if (bulkSelectController) {
|
||||
bulkSelectController.deselectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.toggleButtonTarget.classList.toggle("bg-surface", shouldShow)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user