mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
Add inline category selection (#541)
* Implement inline category selection * Add turbo frame to refresh updated transaction * Improve styles * Fix category assignment * Reorganize code * Revert event propagation * Remove unused frames * Make only the transaction name clickable * Add custom scrollbar class
This commit is contained in:
parent
2c3752668a
commit
2c257a2a4b
13 changed files with 177 additions and 205 deletions
|
@ -4,20 +4,32 @@ import { Controller } from "@hotwired/stimulus"
|
|||
export default class extends Controller {
|
||||
static targets = ["menu"]
|
||||
|
||||
toggleMenu(event) {
|
||||
event.stopPropagation(); // Prevent event from closing the menu immediately
|
||||
this.menuTarget.classList.toggle("hidden");
|
||||
toggleMenu = (e) => {
|
||||
e.stopPropagation(); // Prevent event from closing the menu immediately
|
||||
this.menuTarget.classList.contains("hidden") ? this.showMenu() : this.hideMenu();
|
||||
}
|
||||
|
||||
showMenu = () => {
|
||||
document.addEventListener("click", this.onDocumentClick);
|
||||
this.menuTarget.classList.remove("hidden");
|
||||
}
|
||||
|
||||
hideMenu = () => {
|
||||
document.removeEventListener("click", this.onDocumentClick);
|
||||
this.menuTarget.classList.add("hidden");
|
||||
}
|
||||
|
||||
connect() {
|
||||
document.addEventListener("click", this.hideMenu);
|
||||
disconnect = () => {
|
||||
this.hideMenu();
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
document.removeEventListener("click", this.hideMenu);
|
||||
onDocumentClick = (e) => {
|
||||
if (this.menuTarget.contains(e.target)) {
|
||||
// user has clicked inside of the dropdown
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
||||
this.hideMenu();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ export default class extends Controller {
|
|||
}
|
||||
|
||||
// Hide the dialog when the user clicks outside of it
|
||||
click_outside(e) {
|
||||
clickOutside(e) {
|
||||
if (e.target === this.element) {
|
||||
this.element.close();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue