www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 6166d35c4295ab39b7610bddfe47dbff6734159c
parent 5261a3f3c075bc6f8e475074e062af202e992479
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Wed,  7 Aug 2024 12:20:59 -0700

Fix view not being aligned with button state initially

Diffstat:
Mfiles/floorplans/main.js | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/files/floorplans/main.js b/files/floorplans/main.js @@ -10,16 +10,11 @@ function init() { if (!display_button) { throw new Error("Expected #display_method") } + gridview() display_button.replaceWith( ui.toggle( - ui.button("List", "Switch to list view", "list"), - function() { - document.getElementById("floorplans").removeAttribute("class") - }, - ui.button("Grid", "Switch to grid view", "grid"), - function() { - document.getElementById("floorplans").setAttribute("class", "grid") - } + ui.button("List", "Switch to list view", "list"), listview, + ui.button("Grid", "Switch to grid view", "grid"), gridview, ) ) @@ -27,6 +22,14 @@ function init() { .then(show_floorplans) } +function listview() { + document.getElementById("floorplans").removeAttribute("class") +} + +function gridview() { + document.getElementById("floorplans").setAttribute("class", "grid") +} + function edit_floorplan_func(item, floorplan) { return function() { etc.error("Edit not implemented", item)