Updated to F# 6 arrays
This commit is contained in:
@@ -17,15 +17,13 @@ let getLanguageVars = ajaxSuccess languageVars
|
|||||||
|
|
||||||
let getActiveTables venue = Floorplan.getActiveTables venue |> ajaxSuccess |> json
|
let getActiveTables venue = Floorplan.getActiveTables venue |> ajaxSuccess |> json
|
||||||
|
|
||||||
let getRoomData roomId = Floorplan.getRoom roomId |> ajaxSuccess |> json
|
|
||||||
|
|
||||||
let mergeTables (tables: floorplan_table[]) =
|
let mergeTables (tables: floorplan_table[]) =
|
||||||
let status =
|
let status =
|
||||||
if mergeTables tables.[0].table_number tables.[1].table_number then
|
if mergeTables tables[0].table_number tables[1].table_number then
|
||||||
let outputTables = map [
|
let outputTables = map [
|
||||||
"parent", tables.[0];
|
"parent", tables[0];
|
||||||
"child", tables.[1];
|
"child", tables[1];
|
||||||
"merged", getTable tables.[0].table_number;
|
"merged", getTable tables[0].table_number;
|
||||||
]
|
]
|
||||||
ajaxSuccess outputTables
|
ajaxSuccess outputTables
|
||||||
else ajaxFail "Could Not Merge Tables"
|
else ajaxFail "Could Not Merge Tables"
|
||||||
@@ -36,7 +34,7 @@ let unmergeTable tableNumber =
|
|||||||
let unmergedTables =
|
let unmergedTables =
|
||||||
match unmerged with
|
match unmerged with
|
||||||
| Some (parent, child) ->
|
| Some (parent, child) ->
|
||||||
map["parent", parent; "child", child] |> ajaxSuccess
|
map ["parent", parent; "child", child] |> ajaxSuccess
|
||||||
| None -> ajaxFail "Could not Unmerge Table"
|
| None -> ajaxFail "Could not Unmerge Table"
|
||||||
|
|
||||||
unmergedTables |> json
|
unmergedTables |> json
|
||||||
@@ -64,7 +62,8 @@ let getOrderScreenData (id: int) =
|
|||||||
|> json
|
|> json
|
||||||
|
|
||||||
let getKeyboardLayout (language: string) =
|
let getKeyboardLayout (language: string) =
|
||||||
let layout = $"""wwwroot/languages/{language}/keyboardLayout.json""" |> GetFileContents
|
let layout = $"""wwwroot/languages/{language}/keyboardLayout.json"""
|
||||||
|
|> GetFileContents
|
||||||
map [
|
map [
|
||||||
"status", "success"
|
"status", "success"
|
||||||
"data", layout
|
"data", layout
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ let deleteCookie name (context: HttpContext) =
|
|||||||
if cookieExists name context then context.Response.Cookies.Delete(name)
|
if cookieExists name context then context.Response.Cookies.Delete(name)
|
||||||
|
|
||||||
let getCookie cookieName (context: HttpContext) =
|
let getCookie cookieName (context: HttpContext) =
|
||||||
context.Request.Cookies.[cookieName] |? ""
|
context.Request.Cookies[cookieName] |? ""
|
||||||
|
|
||||||
let setCookie name value (expiry: DateTimeOffset) (context: HttpContext) =
|
let setCookie name value (expiry: DateTimeOffset) (context: HttpContext) =
|
||||||
deleteCookie name context
|
deleteCookie name context
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ let GetFileContents (file: string) = File.ReadAllText file
|
|||||||
let GetFileName (file: string) = Path.GetFileName file
|
let GetFileName (file: string) = Path.GetFileName file
|
||||||
|
|
||||||
let length (variable: 'T[]) = variable.Length
|
let length (variable: 'T[]) = variable.Length
|
||||||
let first (array: 'a[]) = array.[0]
|
let first (array: 'a[]) = array[0]
|
||||||
let last (array: 'a[]) = array.[array.Length-1]
|
let last (array: 'a[]) = array[array.Length-1]
|
||||||
|
|
||||||
|
|
||||||
let removeFalseValues (variable: bool[]) = variable |> Array.filter id
|
let removeFalseValues (variable: bool[]) = variable |> Array.filter id
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<Compile Include="Theme.module.fs" />
|
<Compile Include="Theme.module.fs" />
|
||||||
<Compile Include="Reservations.module.fs" />
|
<Compile Include="Reservations.module.fs" />
|
||||||
<Compile Include="Floorplan.module.fs" />
|
<Compile Include="Floorplan.module.fs" />
|
||||||
|
<Compile Include="Printer.module.fs" />
|
||||||
<Compile Include="OrderScreen.module.fs" />
|
<Compile Include="OrderScreen.module.fs" />
|
||||||
<Compile Include="Decorations.module.fs" />
|
<Compile Include="Decorations.module.fs" />
|
||||||
<Compile Include="Clerk.module.fs" />
|
<Compile Include="Clerk.module.fs" />
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||||
<PackageReference Include="Dapper.FSharp" Version="2.4.1" />
|
<PackageReference Include="Dapper.FSharp" Version="2.4.1" />
|
||||||
<PackageReference Include="FSharp.Data" Version="4.0.1" />
|
<PackageReference Include="FSharp.Data" Version="4.0.1" />
|
||||||
|
<PackageReference Include="Giraffe" Version="6.0.0-alpha-2" />
|
||||||
<PackageReference Include="Npgsql" Version="6.0.0" />
|
<PackageReference Include="Npgsql" Version="6.0.0" />
|
||||||
<PackageReference Include="Pluralize.NET.Core" Version="1.0.0" />
|
<PackageReference Include="Pluralize.NET.Core" Version="1.0.0" />
|
||||||
<PackageReference Include="Saturn" Version="0.15.0-preview03" />
|
<PackageReference Include="Saturn" Version="0.15.0-preview03" />
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ let tableIsOpen (table: floorplan_table) = tableNumberIsOpen table.table_number
|
|||||||
|
|
||||||
let fileNameToTableNumber (fileName: string) = //Takes a file name for a floorplan table and returns the table number
|
let fileNameToTableNumber (fileName: string) = //Takes a file name for a floorplan table and returns the table number
|
||||||
if fileName.Contains ".table" then
|
if fileName.Contains ".table" then
|
||||||
let fileName = (fileName.Split ".").[0]
|
let fileName = (fileName.Split ".")[0]
|
||||||
(fileName.Split "/table").[1] |> int
|
(fileName.Split "/table")[1] |> int
|
||||||
else 0
|
else 0
|
||||||
|
|
||||||
let openTables () = //Get a list of all open tables.
|
let openTables () = //Get a list of all open tables.
|
||||||
@@ -121,7 +121,7 @@ let updateTablePosition (floorplanTable: floorplan_table) = Entity.updateInDatab
|
|||||||
let createEmptyReservation (reservation: reservation) =
|
let createEmptyReservation (reservation: reservation) =
|
||||||
update {
|
update {
|
||||||
table "floorplan_tables"
|
table "floorplan_tables"
|
||||||
set {| status = 2 |}Target
|
set {| status = 2 |}
|
||||||
where(eq "id" reservation.reservation_table_id)
|
where(eq "id" reservation.reservation_table_id)
|
||||||
} |> db.Update |> ignore
|
} |> db.Update |> ignore
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ let tableExists (tableNumber: int) =
|
|||||||
match allTables.Length with
|
match allTables.Length with
|
||||||
| 0 -> false |> string //Table does not exist
|
| 0 -> false |> string //Table does not exist
|
||||||
| _ ->
|
| _ ->
|
||||||
let parentTableData = getTable allTables.[0]
|
let parentTableData = getTable allTables[0]
|
||||||
let parentRoom = getRoom parentTableData.room_id
|
let parentRoom = getRoom parentTableData.room_id
|
||||||
let parentRoomName = parentRoom.room_name
|
let parentRoomName = parentRoom.room_name
|
||||||
language.getAndReplace "error_table_exists_merged" [parentRoomName; parentTableData.table_number.ToString()]
|
language.getAndReplace "error_table_exists_merged" [parentRoomName; parentTableData.table_number.ToString()]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ let languageVars =
|
|||||||
//Gets a value of a language variable
|
//Gets a value of a language variable
|
||||||
let get var =
|
let get var =
|
||||||
if languageVars.ContainsKey var then
|
if languageVars.ContainsKey var then
|
||||||
languageVars.[var]
|
languageVars[var]
|
||||||
else
|
else
|
||||||
"Missing language variable: " + var
|
"Missing language variable: " + var
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ let renderButton (buttonId: int) =
|
|||||||
| "spacer" -> {|extra_data=""; text=""|}
|
| "spacer" -> {|extra_data=""; text=""|}
|
||||||
| _ -> {|extra_data=""; text=""|}
|
| _ -> {|extra_data=""; text=""|}
|
||||||
|
|
||||||
let vars = map[
|
let vars = map [
|
||||||
"extra_classes", button.extra_classes + " " + extraClasses
|
"extra_classes", button.extra_classes + " " + extraClasses
|
||||||
"extra_styles", extra_styles
|
"extra_styles", extra_styles
|
||||||
"primary_action", button.primary_action
|
"primary_action", button.primary_action
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ open Giraffe
|
|||||||
open DredgeFramework
|
open DredgeFramework
|
||||||
|
|
||||||
let loadHomePage(): HttpHandler =
|
let loadHomePage(): HttpHandler =
|
||||||
let variables = map["title", "Log In"]
|
let variables = map ["title", "Log In"]
|
||||||
let scripts = ["dredgepos.authenticate.js"]
|
let scripts = ["dredgepos.authenticate.js"]
|
||||||
let styles = ["dredgepos.authenticate.css"]
|
let styles = ["dredgepos.authenticate.css"]
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ let loadFloorplan (ctx: HttpContext) : HttpHandler =
|
|||||||
let scripts = ["../external/konva.min.js" ; "dredgepos.floorplan.js"]
|
let scripts = ["../external/konva.min.js" ; "dredgepos.floorplan.js"]
|
||||||
let currentClerk = recordToMap <| Session.getCurrentClerk ctx
|
let currentClerk = recordToMap <| Session.getCurrentClerk ctx
|
||||||
|
|
||||||
let arrays = map["clerk", currentClerk]
|
let arrays = map ["clerk", currentClerk]
|
||||||
|
|
||||||
htmlString <| Theme.loadTemplateWithVarsArraysScriptsAndStyles "floorplan" variables arrays scripts styles
|
htmlString <| Theme.loadTemplateWithVarsArraysScriptsAndStyles "floorplan" variables arrays scripts styles
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ let loadOrderScreen (ctx: HttpContext) : HttpHandler =
|
|||||||
let styles = ["dredgepos.orderScreen.css"]
|
let styles = ["dredgepos.orderScreen.css"]
|
||||||
let scripts = ["dredgepos.orderScreen.js"]
|
let scripts = ["dredgepos.orderScreen.js"]
|
||||||
let currentClerk = recordToMap <| Session.getCurrentClerk ctx
|
let currentClerk = recordToMap <| Session.getCurrentClerk ctx
|
||||||
let arrays = map["clerk", currentClerk]
|
let arrays = map ["clerk", currentClerk]
|
||||||
|
|
||||||
htmlString <| Theme.loadTemplateWithVarsArraysScriptsAndStyles "orderScreen" variables arrays scripts styles
|
htmlString <| Theme.loadTemplateWithVarsArraysScriptsAndStyles "orderScreen" variables arrays scripts styles
|
||||||
|
|
||||||
|
|||||||
2
Printer.module.fs
Normal file
2
Printer.module.fs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module Printer
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ module Program =
|
|||||||
use_warbler
|
use_warbler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let floorplanRouter = router {
|
let floorplanRouter = router {
|
||||||
pipe_through browser
|
pipe_through browser
|
||||||
post "/authenticateClerk" (bindJson<int> (handlePostRoute AjaxController.loginWithLoginCode) )
|
post "/authenticateClerk" (bindJson<int> (handlePostRoute AjaxController.loginWithLoginCode) )
|
||||||
@@ -32,7 +31,6 @@ module Program =
|
|||||||
post "/updateReservation" (bindJson<reservation> AjaxController.updateReservation)
|
post "/updateReservation" (bindJson<reservation> AjaxController.updateReservation)
|
||||||
post "/getReservation" (bindJson<int> (fun reservation -> json <| GetReservationById reservation) )
|
post "/getReservation" (bindJson<int> (fun reservation -> json <| GetReservationById reservation) )
|
||||||
post "/unreserveTable" (bindJson<floorplan_table> AjaxController.unreserveTable )
|
post "/unreserveTable" (bindJson<floorplan_table> AjaxController.unreserveTable )
|
||||||
getf "/getRoomData/%i" AjaxController.getRoomData
|
|
||||||
getf "/getKeyboardLayout/%s" AjaxController.getKeyboardLayout
|
getf "/getKeyboardLayout/%s" AjaxController.getKeyboardLayout
|
||||||
get "/languageVars" (json <| AjaxController.getLanguageVars)
|
get "/languageVars" (json <| AjaxController.getLanguageVars)
|
||||||
get "/getOpenTables" (json <| Floorplan.getActiveTables (DredgeFramework.getCurrentVenue()))
|
get "/getOpenTables" (json <| Floorplan.getActiveTables (DredgeFramework.getCurrentVenue()))
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ let ParseVariables (varArray: Map<string, string>) (html:string) =
|
|||||||
Regex.Replace(html, "<!--\[var\:(.*?)\]-->",
|
Regex.Replace(html, "<!--\[var\:(.*?)\]-->",
|
||||||
MatchEvaluator(
|
MatchEvaluator(
|
||||||
fun matchedVar ->
|
fun matchedVar ->
|
||||||
let varName = matchedVar.Groups.[1] |> string |> StringTrim
|
let varName = matchedVar.Groups[1] |> string |> StringTrim
|
||||||
|
|
||||||
if varArray.ContainsKey varName then
|
if varArray.ContainsKey varName then
|
||||||
if varName |> ToLowerCase = "title" then titlePrefix varArray.[varName]
|
if varName |> ToLowerCase = "title" then titlePrefix varArray[varName]
|
||||||
else varArray.[varName]
|
else varArray[varName]
|
||||||
else
|
else
|
||||||
"<!--[Undefined Variable: " + varName + "]-->"
|
"<!--[Undefined Variable: " + varName + "]-->"
|
||||||
))
|
))
|
||||||
@@ -56,11 +56,11 @@ let ParseArrays (arrayArray: Map<string, Map<string, string>>) (string:string) =
|
|||||||
Regex.Replace(string, "<!--\[arr\:(.*?)\|(.*?)\]-->",
|
Regex.Replace(string, "<!--\[arr\:(.*?)\|(.*?)\]-->",
|
||||||
MatchEvaluator(
|
MatchEvaluator(
|
||||||
fun matchedVar ->
|
fun matchedVar ->
|
||||||
let arrayName = matchedVar.Groups.[1].ToString() |> StringTrim
|
let arrayName = matchedVar.Groups[1].ToString() |> StringTrim
|
||||||
let keyName = matchedVar.Groups.[2].ToString()
|
let keyName = matchedVar.Groups[2].ToString()
|
||||||
|
|
||||||
if arrayArray.ContainsKey arrayName && arrayArray.[arrayName].ContainsKey keyName then
|
if arrayArray.ContainsKey arrayName && arrayArray[arrayName].ContainsKey keyName then
|
||||||
arrayArray.[arrayName].[keyName]
|
arrayArray[arrayName][keyName]
|
||||||
else
|
else
|
||||||
"<!--[Undefined Array: " + arrayName + "]-->"
|
"<!--[Undefined Array: " + arrayName + "]-->"
|
||||||
)
|
)
|
||||||
@@ -70,7 +70,7 @@ let ParseSimpleLanguageVariables (string:string) =
|
|||||||
Regex.Replace(string, "<!--\[lang\:(.*?)\]-->",
|
Regex.Replace(string, "<!--\[lang\:(.*?)\]-->",
|
||||||
new MatchEvaluator(
|
new MatchEvaluator(
|
||||||
fun matchedVar ->
|
fun matchedVar ->
|
||||||
let varName = matchedVar.Groups.[1].ToString()
|
let varName = matchedVar.Groups[1].ToString()
|
||||||
|> StringTrim
|
|> StringTrim
|
||||||
|
|
||||||
language.get varName
|
language.get varName
|
||||||
@@ -80,8 +80,8 @@ let ParseLanguageVariablesWithReplacements (string: string) =
|
|||||||
Regex.Replace(string, "<!--\[lang\:(.*?)\|(.*?)\]-->",
|
Regex.Replace(string, "<!--\[lang\:(.*?)\|(.*?)\]-->",
|
||||||
new MatchEvaluator(
|
new MatchEvaluator(
|
||||||
fun matchedVar ->
|
fun matchedVar ->
|
||||||
let varName = matchedVar.Groups.[1].ToString()
|
let varName = matchedVar.Groups[1].ToString()
|
||||||
let replacements = matchedVar.Groups.[2].ToString()
|
let replacements = matchedVar.Groups[2].ToString()
|
||||||
|> StringSplit ","
|
|> StringSplit ","
|
||||||
|> Array.toList
|
|> Array.toList
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ let rec loadTemplateWithVarsArraysScriptsAndStyles templateName vars arrays scri
|
|||||||
and ParseTemplates vars arrays scripts styles (string: string) =
|
and ParseTemplates vars arrays scripts styles (string: string) =
|
||||||
Regex.Replace(string, "<!--\[template\:(.*?)\]-->",
|
Regex.Replace(string, "<!--\[template\:(.*?)\]-->",
|
||||||
new MatchEvaluator( fun template ->
|
new MatchEvaluator( fun template ->
|
||||||
let templateName = template.Groups.[1].ToString() |> StringTrim
|
let templateName = template.Groups[1].ToString() |> StringTrim
|
||||||
loadTemplateWithVarsArraysScriptsAndStyles templateName vars arrays scripts styles
|
loadTemplateWithVarsArraysScriptsAndStyles templateName vars arrays scripts styles
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ let showVirtualNumpad = (heading: string, maxlength = 4, isPassword: boolean, al
|
|||||||
}
|
}
|
||||||
|
|
||||||
let setKeyboardLayout = (layout: string, modifier = '') => {
|
let setKeyboardLayout = (layout: string, modifier = '') => {
|
||||||
|
|
||||||
if (modifier != '') modifier = `_${modifier}`
|
if (modifier != '') modifier = `_${modifier}`
|
||||||
Application.keyboard.currentLayout = layout
|
Application.keyboard.currentLayout = layout
|
||||||
let layoutToLoad = Application.keyboard.layouts[layout]
|
let layoutToLoad = Application.keyboard.layouts[layout]
|
||||||
@@ -226,9 +225,8 @@ let showVirtualNumpad = (heading: string, maxlength = 4, isPassword: boolean, al
|
|||||||
We start at 1 instead of 0. Makes it easier for non-programmers
|
We start at 1 instead of 0. Makes it easier for non-programmers
|
||||||
and translators making their own language packs
|
and translators making their own language packs
|
||||||
*/
|
*/
|
||||||
index = index + 1;
|
index = index + 1
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
let currentRow : string[] = layoutToLoad[`row${index}${modifier}`]
|
let currentRow : string[] = layoutToLoad[`row${index}${modifier}`]
|
||||||
|
|
||||||
$(row).children('a').each((keyIndex, button) => {
|
$(row).children('a').each((keyIndex, button) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user