From a587423d3e8dc09052ac4c2c8ff31df800fc9721 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 7 Mar 2022 21:36:38 +1000 Subject: [PATCH] view progression --- DredgePos.fsproj | 1 + Floorplan/View.fs | 4 +- Global/View.fs | 12 ++++- OrderScreen/Controller.fs | 2 +- OrderScreen/Model.fs | 2 +- OrderScreen/View.fs | 108 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 OrderScreen/View.fs diff --git a/DredgePos.fsproj b/DredgePos.fsproj index dfd31b3..a5df94d 100644 --- a/DredgePos.fsproj +++ b/DredgePos.fsproj @@ -36,6 +36,7 @@ + diff --git a/Floorplan/View.fs b/Floorplan/View.fs index 7dc3a7d..5e6d51f 100644 --- a/Floorplan/View.fs +++ b/Floorplan/View.fs @@ -8,9 +8,7 @@ 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 = diff --git a/Global/View.fs b/Global/View.fs index 543800d..fc7c93c 100644 --- a/Global/View.fs +++ b/Global/View.fs @@ -1,12 +1,18 @@ module DredgePos.Global.View -open Giraffe.ViewEngine open DredgeFramework +open Giraffe.ViewEngine let Value = attr "data-value" + +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 innerText = str let lang key = language.get key |> str +let template = tag "template" + let scriptToHTML (scriptFile: string) = let scriptPath = $"/scripts/{scriptFile}" match FileExists ("wwwroot" + scriptPath) with @@ -89,6 +95,10 @@ let keyboards = [| alert |] +let posButton (extraClasses: string) attrs content = + let allAttrs = [_class $"posButton {extraClasses}"] |> List.append attrs + a allAttrs content + let HtmlPage pageTitle scripts styles tags content = html [] [ head [] [ diff --git a/OrderScreen/Controller.fs b/OrderScreen/Controller.fs index 803f170..77548fb 100644 --- a/OrderScreen/Controller.fs +++ b/OrderScreen/Controller.fs @@ -11,7 +11,7 @@ let getOrderScreenData (tableNumber: int) = order_screen_pages = Entity.GetAllInVenue sales_categories = Entity.GetAllInVenue print_groups = Entity.GetAllInVenue - custom_item = Entity.GetAllByColumn "item_code" "OPEN000" |> first + custom_item = Entity.GetAllByColumn "code" "OPEN000" |> first table = Floorplan.Model.getTable tableNumber |} |> ajaxSuccess diff --git a/OrderScreen/Model.fs b/OrderScreen/Model.fs index 36337bf..027eb7d 100644 --- a/OrderScreen/Model.fs +++ b/OrderScreen/Model.fs @@ -17,7 +17,7 @@ let getImageButtonData (button: button) = if button.primary_action = "item" then button.primary_action_value else button.secondary_action_value - let item = Entity.GetAllByColumn "item_code" itemCode + let item = Entity.GetAllByColumn "code" itemCode |> first let extraData = diff --git a/OrderScreen/View.fs b/OrderScreen/View.fs new file mode 100644 index 0000000..e5f66a7 --- /dev/null +++ b/OrderScreen/View.fs @@ -0,0 +1,108 @@ +module DredgePos.OrderScreen.View + +open DredgePos.Types +open DredgePos.Global.View +open DredgePos.Global.Controller +open Giraffe.ViewEngine +open language + +let pageContainer orderNumber (clerk: clerk) = + div [_id "pageContainer"] [ + div [_id "leftColumn"] [ + h1 [_class "tableHeading"] [str (string orderNumber)] + div [_class "tableInfo"] [ + (* Cover Change Button *) + posButton "" [] [str (getAndReplace "logged_in_as" [clerk.name])] + ] + div [_class "orderBox"] [ + table [_class "orderBoxTable"] [ + thead [] [ + tr [] [ + th [_class "orderBoxCell qtyCell"] [str (get "qty_header")] + th [_class "orderBoxCell itemIdCell"] [str (get "id_header")] + th [_class "orderBoxCell itemCell"] [str (get "item_header")] + th [_class "orderBoxCell unitPriceCell"] [str (get "price_header")] + th [_class "orderBoxCell totalPriceCell"] [str (get "total_price_header")] + th [_class "orderBoxCell printGroupCell"] [str (get "printgroup_header")] + ] + ] + tbody [] [] + ] + ] + div [_class "orderBoxInfo"] [ + span [_class "voidModeWarning"; VisibleInMode ["void"]] [str (get "void_mode")] + ] + div [_class "orderBoxFooter"] [ + span [_class "totalPrice"] [str (getAndReplace "totalPrice" ["0.00"])] + small [_class "selectedPrice"] [str (getAndReplace "selectedPrice" ["0.00"])] + + ] + ] + div [_id "rightColumn"] [ + div [_id "topHalf"] [ + div [_class "functionButtons"] [ + div [_class "printGroupButtons toggleGroup"] [ + input [_type "hidden"; _class "value"] + (* Sales category override buttons *) + ] + div [_class "functionColumn"] [ + posButton "accumulateButton" [ActiveInMode "accumulate"] [str (get "accumulate_function")] + posButton "showCoverSelectorButton" [] [str (get "select_covers")] + ] + div [_class "functionColumn"] [ + posButton "voidButton" [ActiveInMode "void"] [str (get "void")] + posButton "open_item_button" [] [str (get "custom_item_button")] + posButton "freetextButton" [] [str (get "freetext_button")] + posButton "numpadButton" [] [str (get "numpad_button")] + ] + div [_class "functionColumn"] [ + posButton "" [] ["pay_function" |> get |> str] + posButton "" [] ["print_function" |> get |> str] + ] + ] + div [_id "pageList"] [ + (* Category List *) + ] + div [_id "pageGroupContainer"] [ + (* Page Groups *) + ] + div [_class "pagNavigation"] [ + posButton "prevButton" [] ["prev_page" |> get |> str] + posButton "nextButton" [] ["next_page" |> get |> str] + ] + ] + ] + ] + (* Grid Container, Cover Selector *) + +let posButtonTemplate = + template [_id "posButtonTemplate"] [ + posButton "" [] [] + ] + +let gridContainer = + div [_class "gridContainer"] [ + div [_class "gridContainerHeader"] [ + span [] [] + div [_class "posButton closeGrid"] [str "×"] + ] + div [_class "gridContainerGrid"] [ + div [_class "pageGroup"] [] + ] + div [_class "pageNavigation"] [ + posButton "prevButton" [] ["prev_page" |> get |> str] + posButton "nextButton" [] ["next_page" |> get |> str] + ] + ] + +let coverSelector = + div [_class "coverSelector"] [] + +let index orderNumber clerk styles scripts tags = + [| + pageContainer orderNumber clerk + posButtonTemplate + gridContainer + coverSelector + |] + |> HtmlPage "Order" (GetScripts scripts) (GetStyles styles) (GetMetaTags tags) \ No newline at end of file