[Fencommits] fenserve: 'add category' link
Benja Fallenstein
benja.fallenstein at gmail.com
Wed May 23 15:40:55 EEST 2007
Wed May 23 15:40:47 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* 'add category' link
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs 2007-05-23 15:40:55.000000000 +0300
+++ new-fenserve/fendata/Main.hs 2007-05-23 15:40:55.000000000 +0300
@@ -269,7 +269,7 @@
addCategory cat = do
state <- get
put $ state { stateSchema = Map.insert cat [] $ stateSchema state}
- view
+ run showTable ()
expand s (Call n args) = case readFun s n of
Fun _ _ body -> Just $
@@ -392,15 +392,17 @@
concatFor (Map.toList $ stateItems s) $ \(id, Item fields _) ->
(++ "<p><form action='delItem' method=post>\
\<input type=hidden name=item value='"++show id++"'>\
- \<a href='item/"++show id++"'>[Edit item]</a>\
- \<span style='margin-left: 0.7em; margin-right: 0.4em; font-weight: bold'>·</span>\
+ \<a href='item/"++show id++"'>[Edit item]</a>"++mdot++"\
\<button style='cursor: pointer; background: none; border: none; font: inherit; margin: 0; padding: 0'>[Delete item]</button></form><hr>") . ("<p>"++)
. concatFor (Map.toList fields) $ \(f:fs,v) ->
"<b>" ++ (toUpper f : fs) ++ ":</b> " ++ v ++ "<br>",
- s) where new = concatFor (Map.keys $ stateSchema s) $ \cat ->
- "<form action='newItem' method=post>\
- \<input type=hidden name=cat value='"++cat++"'>\
- \<button type=submit>New "++cat++"</button></form>"
+ s) where new = ("<form action='newItem' method=post>" ++) .
+ (++"<a href='addcat'>[Add category]</a></form>") .
+ concatFor (Map.keys $ stateSchema s) $ \cat ->
+ "<button style='cursor: pointer; background: none; border: none; font: inherit; margin: 0; padding: 0' name=cat value='"++cat++"'>[New "++cat++"]</button>"++mdot
+
+
+mdot = "<span style='margin-left: 0.5em; margin-right: 0.5em; font-weight: bold'>·</span>"
showItem :: String -> () -> MyState -> (String, MyState)
showItem item () s = let Item fields cats = stateItems s Map.! read item in (
@@ -450,6 +452,10 @@
, h [""] GET $ ok $ \() () -> view
, h ["addfield"] POST $ ok $ \() (cid,name) -> addField cid name
+ , h ["addcat"] GET $ ok $ \() () -> respond $
+ "<h2>Add category</h2>\
+ \<form method=post>Name: <input name=name>\
+ \<input type=submit value='Submit'></form>"
, h ["addcat"] POST $ ok $ \() name -> addCategory name
, h ["addpotion"] POST $ seeOther $ \() -> runRedirect addPotion
]
More information about the Fencommits
mailing list