Separated models, controllers and routers
This commit is contained in:
27
Entities/Floorplan_Decorations/Controller.fs
Normal file
27
Entities/Floorplan_Decorations/Controller.fs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.chunkBySize 4
|
||||
|> Array.map getImageRowHtml
|
||||
|> JoinArray ""
|
||||
24
Entities/Floorplan_Decorations/Model.fs
Normal file
24
Entities/Floorplan_Decorations/Model.fs
Normal file
@@ -0,0 +1,24 @@
|
||||
module DredgePos.Entities.Floorplan_Decorations.Model
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open System.Text.RegularExpressions
|
||||
open DredgeFramework
|
||||
|
||||
let decorationsInRoom (roomId: int) = Entity.GetAllByColumn "decoration_room" roomId
|
||||
|
||||
let getImageName (image: string, path: string) =
|
||||
let imageName =
|
||||
image
|
||||
|> StringReplace "-" " "
|
||||
|> StringReplace "_" " "
|
||||
|> ToTitleCase
|
||||
|
||||
imageName, path
|
||||
|
||||
let isImageFile (fileName: string) = Regex.IsMatch(fileName |> ToLowerCase, @"^.+\.(jpg|jpeg|png|gif)$")
|
||||
|
||||
let GetFileNameWithoutExtension (path: string) =
|
||||
let name = Path.GetFileNameWithoutExtension path
|
||||
name, path |> Path.GetFileName
|
||||
|
||||
2
Entities/Floorplan_Decorations/Router.fs
Normal file
2
Entities/Floorplan_Decorations/Router.fs
Normal file
@@ -0,0 +1,2 @@
|
||||
module DredgePos.Entities.Floorplan_Decorations.Router
|
||||
|
||||
Reference in New Issue
Block a user