Files
eminuxCRM/app/javascript/controllers/sheet_controller.js
T
eminuxandCursor 0e8730b889
CI / scan_ruby (push) Failing after 11m43s
CI / scan_js (push) Successful in 11m18s
CI / lint (push) Failing after 11m56s
Rende il CRM comodo da usare anche da cellulare.
Aggiunge navigazione mobile dedicata e trasforma le principali liste operative in layout più leggibili e facili da toccare.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 10:55:50 +02:00

36 lines
828 B
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["panel"]
connect() {
this.boundKey = this.onKey.bind(this)
document.addEventListener("keydown", this.boundKey)
}
disconnect() {
document.removeEventListener("keydown", this.boundKey)
document.body.classList.remove("overflow-hidden")
}
toggle(event) {
event?.preventDefault()
event?.stopPropagation()
this.panelTarget.classList.contains("hidden") ? this.show() : this.hide()
}
show() {
this.panelTarget.classList.remove("hidden")
document.body.classList.add("overflow-hidden")
}
hide() {
this.panelTarget.classList.add("hidden")
document.body.classList.remove("overflow-hidden")
}
onKey(event) {
if (event.key === "Escape") this.hide()
}
}