From 5e78701b0b20baa34861664b3b9c66d48b95ab18 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 30 Jun 2022 23:43:16 +1000 Subject: [PATCH] Buttons now render entirely in Giraffe --- Migrations/PopulateTestData.fs | 2 +- OrderScreen/Controller.fs | 40 ++++++++++++--- OrderScreen/View.fs | 76 +++++++++++++++++++++-------- typescript/dredgepos.orderScreen.ts | 1 - 4 files changed, 90 insertions(+), 29 deletions(-) diff --git a/Migrations/PopulateTestData.fs b/Migrations/PopulateTestData.fs index 7d11b33..0567f7c 100644 --- a/Migrations/PopulateTestData.fs +++ b/Migrations/PopulateTestData.fs @@ -310,7 +310,7 @@ let CreateItemFromFileName (index: int) (dirName: string) (file: string) = | "beer" | "dessert" -> "doubleHeight" | "mains" | "wine" | "steak temperatures" -> "doubleHeight doubleWidth" | "entrees" -> "doubleWidth" - | _ -> "" + | _ -> "normal" Entity.Create { id=0 diff --git a/OrderScreen/Controller.fs b/OrderScreen/Controller.fs index 92a4b18..0abd6f3 100644 --- a/OrderScreen/Controller.fs +++ b/OrderScreen/Controller.fs @@ -4,8 +4,10 @@ open DredgePos open DredgeFramework open DredgePos.Types open DredgePos.Global.Controller +open Thoth.Json.Net open Giraffe open Microsoft.AspNetCore.Http +open FSharp.Collections let getOrderScreenData (tableNumber: int) = {| @@ -25,6 +27,24 @@ let loadGrid (gridId: int) = else ajaxSuccess {|grid=grid;gridHtml=gridHtml|} |> json + +let renderGrid (grid: grid) = + let gridData = grid.data |> Decode.Auto.fromString> + match gridData with + | Error message -> failwith message + | Ok data -> + data + |> Map.toArray + |> Array.map snd + |> Array.map( + fun buttonIds -> + buttonIds + |> Array.map Entity.GetById