1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static targets = ["calendarView", "listView", "calendarTab", "listTab"] 5 static values = { 6 storageKey: { type: String, default: "practitioner_dashboard_view" } 7 } 8 9 connect() { 10 const savedView = localStorage.getItem(this.storageKeyValue) || "calendar" 11 this.showView(savedView) 12 } 13 14 showCalendar(event) { 15 event?.preventDefault() 16 this.showView("calendar") 17 localStorage.setItem(this.storageKeyValue, "calendar") 18 } 19 20 showList(event) { 21 event?.preventDefault() 22 this.showView("list") 23 localStorage.setItem(this.storageKeyValue, "list") 24 } 25 26 showView(view) { 27 const isCalendar = view === "calendar" 28 29 // Toggle view visibility 30 if (this.hasCalendarViewTarget) { 31 this.calendarViewTarget.classList.toggle("hidden", !isCalendar) 32 } 33 if (this.hasListViewTarget) { 34 this.listViewTarget.classList.toggle("hidden", isCalendar) 35 } 36 37 // Update tab styles 38 if (this.hasCalendarTabTarget) { 39 this.calendarTabTarget.classList.toggle("view-tab-active", isCalendar) 40 this.calendarTabTarget.classList.toggle("view-tab-inactive", !isCalendar) 41 } 42 if (this.hasListTabTarget) { 43 this.listTabTarget.classList.toggle("view-tab-active", !isCalendar) 44 this.listTabTarget.classList.toggle("view-tab-inactive", isCalendar) 45 } 46 } 47}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.