[Fencommits] fenserve: bit of progress on the table view
Benja Fallenstein
benja.fallenstein at gmail.com
Wed May 30 19:42:58 EEST 2007
Wed May 30 19:41:41 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* bit of progress on the table view
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs 2007-05-30 19:42:58.000000000 +0300
+++ new-fenserve/fendata/Main.hs 2007-05-30 19:42:58.000000000 +0300
@@ -69,7 +69,7 @@
returnTo = fromMaybe ("item/"++item) (lookM req "returnTo")
addCategory req s = ("table",
- s { stateSchema = Map.insert (uncapitalize name) [] $ stateSchema s}) where
+ s { stateSchema = Map.insert (uncapitalize name) ["name"] $ stateSchema s}) where
Just name = lookM req "name"
subst :: Int -> Exp -> Exp -> Exp
@@ -214,21 +214,19 @@
showTable :: (?root :: String) => Request -> MyState -> (HTML, MyState)
showTable req s = (
makePage s ("List of "++plural cat++" in the database") "" $
- (new+++) . (hr+++) . (+++new) .
tag "table" [("border","1")] $
(tag "tr" [] $ catFor cols $ \col -> tag "th" [] $ capitalize col) +++
+ (tag "tr" [] $ tag "td" [("colspan", show $ length cols), ("style", "text-align: center")] new) +++
(catFor (Map.toList $ stateItems s) $ \(id, Item fields cats) ->
if cat `Set.member` cats then tag "tr" [] $
catFor cols $ \col -> tag "td" [] $
link (?root++"item/"++show id++"?returnTo=table") $
fields Map.! col
else toHTML ""),
- s) where new = para . formP (?root++"newItem")
- . (+++ hidden "returnTo" "table")
- . (+++ " " +++ mdot +++ " "
- +++ bold (link (?root++"addCategory") "[Add category]"))
- . mdotted . for (Map.keys $ stateSchema s) $ \cat ->
- button' "cat" cat $ bold ("[New "+++cat+++"]")
+ s) where new = formP (?root++"newItem") $ foldl1 (+++)
+ [ hidden "returnTo" "table"
+ , hidden "cat" cat
+ , button $ bold ("[New "+++cat+++"]") ]
cat = fromMaybe (head $ Map.keys $ stateSchema s) (lookM req "cat")
cols = flip fromMaybe (fmap read $ lookM req "cols") $
take 1 $ stateSchema s Map.! cat
diff -rN -u old-fenserve/fendata/UI.hs new-fenserve/fendata/UI.hs
--- old-fenserve/fendata/UI.hs 2007-05-30 19:42:58.000000000 +0300
+++ new-fenserve/fendata/UI.hs 2007-05-30 19:42:58.000000000 +0300
@@ -30,6 +30,7 @@
\.content {float: right; width: 80% } \
\.sidebar {float: left; width: 15%; font-size: small } \
\h1, h2, h3, h4, h5, h6 { font-family: sans-serif } \
+ \form { display: inline } \
\</style><title>Fenlight demo</title></head>"
makePage state title sidebar body =
@@ -51,7 +52,8 @@
para (link (?root++"potion?exp="++(escape' $ show $ Block [])) "New page") +++
catFor (Map.keys $ stateSchema state) (\cat ->
para (link (?root++"table?cat="++escape' cat)
- ("List of "++plural cat++" in the database")))) +++
+ ("New "++cat++" view"))) +++
+ para (link (?root++"addCategory") "Add category")) +++
tag "div" [("class", "content")] body) +++
tag "div" [("class", "footer")]
("Fenlight (c) 2007 by Benja Fallenstein and Tuukka Hastrup. " +++
More information about the Fencommits
mailing list