Moved to Giraffe View Engine
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
|
||||
open DredgeFramework
|
||||
open DredgePos
|
||||
open DredgePos.Global.Controller
|
||||
open DredgePos.Entities
|
||||
open DredgePos.Types
|
||||
open Giraffe
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Model
|
||||
open System.IO
|
||||
|
||||
let makeRoomButton (room: floorplan_room) =
|
||||
let vars = map [
|
||||
@@ -70,7 +73,7 @@ let deleteTable (table: floorplan_table) =
|
||||
table |> ajaxSuccess |> json
|
||||
|
||||
let transferTable (origin, destination) =
|
||||
Model.transferTable origin destination
|
||||
transferTable origin destination
|
||||
let data = map ["origin", getTable origin ; "destination", getTable destination]
|
||||
ajaxSuccess data |> json
|
||||
|
||||
@@ -105,23 +108,12 @@ let DeleteDecoration (decorationToDelete: floorplan_decoration) =
|
||||
|> ajaxSuccess
|
||||
|> json
|
||||
|
||||
let loadFloorplan (ctx: HttpContext) : HttpHandler =
|
||||
let loadFloorplanView (ctx: HttpContext) =
|
||||
Authenticate.Model.RequireClerkAuthentication ctx
|
||||
let roomMenu = Entity.GetAllInVenue<floorplan_room> |> Array.map View.roomButton
|
||||
let currentClerk = Authenticate.Model.getCurrentClerk ctx
|
||||
let styles = [|"dredgepos.floorplan.css"|] |> addDefaultStyles
|
||||
let scripts = [|"./external/konva.min.js" ; "dredgepos.floorplan.js"|] |> addDefaultScripts
|
||||
let metaTags = [|"viewport", "user-scalable = no, initial-scale=0.8,maximum-scale=0.8 ,shrink-to-fit=yes"|] |> addDefaultMetaTags
|
||||
|
||||
let roomMenu =
|
||||
Entity.GetAllInVenue<floorplan_room>
|
||||
|> Array.map makeRoomButton
|
||||
|> joinWithNewLine
|
||||
|
||||
let variables = map [
|
||||
"title", "Floorplan"
|
||||
"roomMenu", roomMenu
|
||||
"decorator", Entities.Floorplan_Decorations.Controller.generateDecorator()
|
||||
]
|
||||
let styles = ["dredgepos.floorplan.css"]
|
||||
let scripts = ["./external/konva.min.js" ; "dredgepos.floorplan.js"]
|
||||
let currentClerk = recordToMap <| Authenticate.Model.getCurrentClerk ctx
|
||||
|
||||
let arrays = map ["clerk", currentClerk]
|
||||
|
||||
htmlString <| Theme.loadTemplateWithVarsArraysScriptsAndStyles "floorplan" variables arrays scripts styles
|
||||
View.index styles scripts metaTags currentClerk (Floorplan_Decorations.Controller.generateDecorator ()) roomMenu
|
||||
@@ -1,16 +1,17 @@
|
||||
module DredgePos.Floorplan.Router
|
||||
|
||||
open DredgePos
|
||||
open DredgePos.Global.Router
|
||||
open DredgePos.Types
|
||||
open Saturn
|
||||
open Giraffe
|
||||
|
||||
let floorplan = (warbler (fun ctx -> DredgePos.Floorplan.Controller.loadFloorplan (snd ctx)))
|
||||
let floorplan = (htmlViewWithContext Controller.loadFloorplanView)
|
||||
|
||||
let router = router {
|
||||
pipe_through Ajax.Router.pipeline
|
||||
get "/" floorplan
|
||||
get "" floorplan
|
||||
get "/" floorplan
|
||||
post "/mergeTables" (bindJson<floorplan_table[]> Controller.mergeTables)
|
||||
post "/transformTable" (bindJson<floorplan_table> Controller.transformTable)
|
||||
post "/createTable" (bindJson<floorplan_table> Controller.createTable)
|
||||
|
||||
88
Floorplan/View.fs
Normal file
88
Floorplan/View.fs
Normal file
@@ -0,0 +1,88 @@
|
||||
module DredgePos.Floorplan.View
|
||||
|
||||
open DredgePos.Global
|
||||
open DredgePos.Global.View
|
||||
open DredgePos.Entities
|
||||
open DredgePos.Types
|
||||
open Giraffe.ViewEngine
|
||||
open DredgeFramework
|
||||
|
||||
|
||||
let VisibleInMode (value: string list) = value |> jsonEncode |> (attr "data-visible-in-mode")
|
||||
let InvisibleInMode (value: string list) = value |> jsonEncode |> (attr "data-invisible-in-mode")
|
||||
let ActiveInMode (value: string) = value |> (attr "data-active-in-mode")
|
||||
|
||||
|
||||
let pageContainer (clerk: clerk) roomMenu =
|
||||
let loggedInText = str (language.getAndReplace "logged_in_as" [clerk.clerk_name])
|
||||
|
||||
div [_id "pageContainer"] [
|
||||
div [_id "floorplanLeftColumn"] [
|
||||
div [_class "topCell"] [
|
||||
a [_class "posHeader"] [loggedInText]
|
||||
]
|
||||
div [_class "middleCell"] []
|
||||
div [_class "bottomCell"] []
|
||||
]
|
||||
|
||||
div [_id "floorplanCenterColumn"] [
|
||||
div [_class "topCell"] [
|
||||
yield! roomMenu
|
||||
]
|
||||
div [_class "middleCell"] [
|
||||
div [_id "floorplanCanvas"] []
|
||||
div [_id "floorplanCanvas"] []
|
||||
]
|
||||
|
||||
div [_class "bottomCell"] [
|
||||
div [_class "editControls" ; VisibleInMode ["tableSelected"]] [
|
||||
div [_class "posHeader currentTable"] [
|
||||
b [_class "selectedTableNumber"] []
|
||||
a [_class "reservationStatus"; VisibleInMode ["reservedTableSelected"]] []
|
||||
small [_class "selectedTableCovers"] []
|
||||
]
|
||||
|
||||
a [_class "posButton placeOrderButton"] [lang "order_table"]
|
||||
a [_class "posButton reserveTableButton"; InvisibleInMode ["reservedTableSelected"; "activeTableSelected"]] [lang "reserve_table"]
|
||||
a [_class "posButton unreserveTableButton"; VisibleInMode ["reservedTableSelected"]] [lang "unreserve_table"]
|
||||
a [_class "posButton payTableButton"; VisibleInMode ["activeTableSelected"]] [lang "pay_table"]
|
||||
a [_class "posButton viewTableButton"; VisibleInMode ["activeTableSelected"]] [lang "view_table"]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
div [_id "floorplanRightColumn"] [
|
||||
div [_class "topCell"] [
|
||||
a [_class "posButton logOut"] [str "×"]
|
||||
]
|
||||
|
||||
div [_class "middleCell"] [
|
||||
a [_class "posButton editModeButton"] [lang "edit_floorplan"]
|
||||
div [_class "floorplanControls useVisibility"; VisibleInMode ["edit"]] [
|
||||
a [_class "posButton addTableButton"] [lang "add_table"]
|
||||
a [_class "posButton addDecoration"] [lang "add_decoration"]
|
||||
a [_class "posButton deleteDecoration useVisibility"; VisibleInMode ["decorationSelected"; "edit"] ] [lang "delete_decoration"]
|
||||
a [_class "posButton deleteTableButton useVisibility"; VisibleInMode ["tableSelected"; "edit"]] [lang "delete_table"]
|
||||
a [_class "posButton changeShapeButton useVisibility"; VisibleInMode ["tableSelected"; "edit"]] [lang "change_shape"]
|
||||
]
|
||||
|
||||
div [_class "mergeControls useVisibility"; VisibleInMode ["tableSelected"]] [
|
||||
a [_class "posButton mergeButton"; ActiveInMode "merge"] [lang "merge_table"]
|
||||
a [_class "posButton unmergeButton"; VisibleInMode ["tableSelected"]] [lang "unmerge_table"]
|
||||
a [_class "posButton transferTableButton" ; ActiveInMode "transfer" ; VisibleInMode ["activeTableSelected"]] [lang "transfer_table"]
|
||||
]
|
||||
]
|
||||
|
||||
div [_class "bottomCell"] []
|
||||
]
|
||||
]
|
||||
|
||||
let roomButton (room: floorplan_room) = a [_class "posButton roomButton"; Value (string room.id)] [str room.room_name ]
|
||||
|
||||
let index styles scripts tags clerk decoratorRows roomMenu =
|
||||
[|
|
||||
pageContainer clerk roomMenu
|
||||
decoratorRows |> Floorplan_Decorations.View.decorator
|
||||
|]
|
||||
|> HtmlPage "Floorplan" (GetScripts scripts) (GetStyles styles) (GetMetaTags tags)
|
||||
|
||||
Reference in New Issue
Block a user