Moved to Giraffe View Engine
This commit is contained in:
@@ -1,27 +1,13 @@
|
||||
module DredgePos.Entities.Floorplan_Decorations.Controller
|
||||
|
||||
open DredgeFramework
|
||||
open System
|
||||
open System.IO
|
||||
|
||||
let getImageHTML (imageName: string, imageUrl: string) =
|
||||
let vars = map [
|
||||
"image_name", imageName
|
||||
"image_url", imageUrl
|
||||
]
|
||||
Theme.loadTemplateWithVars "decoratorItem" vars
|
||||
|
||||
let getImageRowHtml (imagesInRow: string[]) =
|
||||
let vars = map ["decorations", String.Join("", imagesInRow)]
|
||||
Theme.loadTemplateWithVars "decoratorRow" vars
|
||||
|
||||
let generateDecorator () =
|
||||
"wwwroot/images/decorations"
|
||||
|> Directory.GetFiles
|
||||
|> Array.filter Model.isImageFile
|
||||
|> Array.map Model.GetFileNameWithoutExtension
|
||||
|> Array.map Model.getImageName
|
||||
|> Array.map getImageHTML
|
||||
|> Array.map View.decoratorItem
|
||||
|> Array.chunkBySize 4
|
||||
|> Array.map getImageRowHtml
|
||||
|> JoinArray ""
|
||||
|> Array.map View.decoratorRow
|
||||
24
Entities/Floorplan_Decorations/View.fs
Normal file
24
Entities/Floorplan_Decorations/View.fs
Normal file
@@ -0,0 +1,24 @@
|
||||
module DredgePos.Entities.Floorplan_Decorations.View
|
||||
|
||||
open Giraffe.ViewEngine
|
||||
open DredgePos.Global.View
|
||||
|
||||
let decoratorItem (imageName, imageUrl) =
|
||||
let image = attr "data-image"
|
||||
div [_class "decoratorItem"; image imageUrl] [
|
||||
a [_style $"background-image:url('/images/decorations/{imageUrl}')"] []
|
||||
a [] [str imageName]
|
||||
]
|
||||
|
||||
let decoratorRow decoratorItems = div [_class "decoratorRow"] [yield! decoratorItems]
|
||||
|
||||
let decorator (decorationRows: XmlNode[]) =
|
||||
div [_id "decorator"] [
|
||||
div [_id "decoratorHeader"] [
|
||||
h2 [] [lang "choose_decoration"]
|
||||
a [_class "posButton hideDecorator"] [str "×"]
|
||||
]
|
||||
div [_id "decoratorContent"] [
|
||||
yield! decorationRows
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user