Commit 27af1dd9 authored by Bas Lijnse's avatar Bas Lijnse

Removed the need to explicitly pass initial attributes for all built-in editors

parent 6c563df9
......@@ -249,7 +249,7 @@ where
viewWorkflowDetails :: !(ReadOnlyShared (Maybe Workflow)) -> Task Workflow
viewWorkflowDetails sel
= viewSharedInformation [Att (Title "Task description"), Att IconView] [ViewUsing view (textView 'DM'.newMap)] sel
= viewSharedInformation [Att (Title "Task description"), Att IconView] [ViewUsing view textView] sel
@? onlyJust
where
view = maybe "" (\wf -> wf.Workflow.description)
......
......@@ -104,9 +104,9 @@ JSONDecode{|Time|} _ c = (Nothing, c)
gText{|Time|} _ val = [maybe "" toString val]
gEditor{|Time|} = selectByMode
(bijectEditorValue toString fromString (textView 'DM'.newMap))
(surjectEditorValue toString parseTime (withDynamicHintAttributes "time (hh:mm:ss)" (textField 'DM'.newMap)))
(surjectEditorValue toString parseTime (withDynamicHintAttributes "time (hh:mm:ss)" (textField 'DM'.newMap)))
(bijectEditorValue toString fromString textView)
(surjectEditorValue toString parseTime (withDynamicHintAttributes "time (hh:mm:ss)" textField ))
(surjectEditorValue toString parseTime (withDynamicHintAttributes "time (hh:mm:ss)" textField ))
derive gDefault Time
derive gEq Time
......@@ -174,9 +174,9 @@ gText{|DateTime|} _ (Just ({DateTime|year,mon,day,hour,min,sec}))
= [toSingleLineText {Date|year=year,mon=mon,day=day} +++" "+++ toSingleLineText {Time|hour=hour,min=min,sec=sec}]
gEditor{|DateTime|} = selectByMode
(bijectEditorValue toString fromString (textView 'DM'.newMap))
(surjectEditorValue toString parseDateTime (withDynamicHintAttributes "date/time (yyyy-mm-dd hh:mm:ss)" (textField 'DM'.newMap)))
(surjectEditorValue toString parseDateTime (withDynamicHintAttributes "date/time (yyyy-mm-dd hh:mm:ss)" (textField 'DM'.newMap)))
(bijectEditorValue toString fromString textView)
(surjectEditorValue toString parseDateTime (withDynamicHintAttributes "date/time (yyyy-mm-dd hh:mm:ss)" textField ))
(surjectEditorValue toString parseDateTime (withDynamicHintAttributes "date/time (yyyy-mm-dd hh:mm:ss)" textField ))
derive gDefault DateTime
derive gEq DateTime
......
......@@ -20,11 +20,11 @@ gText{|Document|} _ Nothing = [""]
gEditor {|Document|} = selectByMode viewDocument editDocument editDocument
where
viewDocument = comapEditorValue toView (htmlView 'DM'.newMap)
viewDocument = comapEditorValue toView htmlView
where
toView {Document|contentUrl,name} = ATag [HrefAttr contentUrl, TargetAttr "_blank"] [Text name]
editDocument = bijectEditorValue toView fromView (documentField 'DM'.newMap)
editDocument = bijectEditorValue toView fromView documentField
where
toView {Document|documentId,contentUrl,name,mime,size} = (documentId,contentUrl,name,mime,size)
fromView (documentId,contentUrl,name,mime,size) = {Document|documentId=documentId,contentUrl=contentUrl,name=name,mime=mime,size=size}
......
......@@ -86,6 +86,6 @@ where
pikadayDateField :: Editor Date
pikadayDateField = selectByMode
(bijectEditorValue toString fromString (textView 'DM'.newMap))
(bijectEditorValue toString fromString textView)
(surjectEditorValue toString parseDate (withDynamicHintAttributes "date (yyyy-mm-dd)" pikadayField))
(surjectEditorValue toString parseDate (withDynamicHintAttributes "date (yyyy-mm-dd)" pikadayField))
......@@ -4,7 +4,7 @@ import iTasks.UI.Definition, iTasks.UI.Editor.Controls, iTasks.UI.Editor.Modifie
import Text.HTML
gEditor{|WebImage|} = comapEditorValue (\{WebImage|src,alt,width,height} -> ImgTag [SrcAttr src,AltAttr alt,WidthAttr (toString width), HeightAttr (toString height)])
(htmlView (paddingAttr 0 0 0 0))
(htmlView <<@ paddingAttr 0 0 0 0)
derive gText WebImage
derive JSONEncode WebImage
......
......@@ -73,9 +73,9 @@ JSONDecode{|Username|} _ [JSONString u:c] = (Just (Username u),c)
JSONDecode{|Username|} _ c = (Nothing,c)
gEditor{|Username|} = bijectEditorValue (\(Username u) -> u) (\s -> (Username s)) (selectByMode
(textView 'DM'.newMap)
(withDynamicHintAttributes "username" (withEditModeAttr (textField 'DM'.newMap)))
(withDynamicHintAttributes "username" (withEditModeAttr (textField 'DM'.newMap))))
textView
(withDynamicHintAttributes "username" (withEditModeAttr textField ))
(withDynamicHintAttributes "username" (withEditModeAttr textField )))
derive gDefault Username
derive gEq Username
......@@ -101,9 +101,9 @@ gText{|Password|} AsHeader _ = [""]
gText{|Password|} _ _ = ["********"]
gEditor{|Password|} = bijectEditorValue (\(Password p) -> p) (\s -> (Password s))
(selectByMode (comapEditorValue (const "********") (textView 'DM'.newMap))
(withDynamicHintAttributes "password" (withEditModeAttr (passwordField 'DM'.newMap)))
(withDynamicHintAttributes "password" (withEditModeAttr (passwordField 'DM'.newMap))))
(selectByMode (comapEditorValue (const "********") textView)
(withDynamicHintAttributes "password" (withEditModeAttr passwordField ))
(withDynamicHintAttributes "password" (withEditModeAttr passwordField )))
derive gDefault Password
derive gEq Password
......
......@@ -17,9 +17,9 @@ import qualified Data.List as DL
gText{|URL|} _ val = [maybe "" toString val]
gEditor{|URL|} = selectByMode
(comapEditorValue (\(URL s) -> ATag [HrefAttr s] [Text s]) (htmlView 'DM'.newMap))
(bijectEditorValue (\(URL s) -> s) (\s -> URL s) (withDynamicHintAttributes "uniform resource locator (URL)" (textField 'DM'.newMap)))
(bijectEditorValue (\(URL s) -> s) (\s -> URL s) (withDynamicHintAttributes "uniform resource locator (URL)" (textField 'DM'.newMap)))
(comapEditorValue (\(URL s) -> ATag [HrefAttr s] [Text s]) htmlView)
(bijectEditorValue (\(URL s) -> s) (\s -> URL s) (withDynamicHintAttributes "uniform resource locator (URL)" textField ))
(bijectEditorValue (\(URL s) -> s) (\s -> URL s) (withDynamicHintAttributes "uniform resource locator (URL)" textField ))
derive JSONEncode URL
derive JSONDecode URL
......
......@@ -11,92 +11,92 @@ from Data.Map import :: Map
from Text.JSON import :: JSONNode
//# UIContainer
container :: UIAttributes -> Editor ()
containerl :: UIAttributes (Editor a) -> Editor [a]
container1 :: UIAttributes (Editor a) -> Editor a
container2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
container3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
container4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
container5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
container :: Editor ()
containerl :: (Editor a) -> Editor [a]
container1 :: (Editor a) -> Editor a
container2 :: (Editor a) (Editor b) -> Editor (a,b)
container3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
container4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
container5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIPanel
panel :: UIAttributes -> Editor ()
panell :: UIAttributes (Editor a) -> Editor [a]
panel1 :: UIAttributes (Editor a) -> Editor a
panel2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
panel3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
panel4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
panel5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
panel :: Editor ()
panell :: (Editor a) -> Editor [a]
panel1 :: (Editor a) -> Editor a
panel2 :: (Editor a) (Editor b) -> Editor (a,b)
panel3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
panel4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
panel5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UITabSet
tabset :: UIAttributes -> Editor ()
tabsetl :: UIAttributes (Editor a) -> Editor [a]
tabset1 :: UIAttributes (Editor a) -> Editor a
tabset2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
tabset3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
tabset4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
tabset5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
tabset :: Editor ()
tabsetl :: (Editor a) -> Editor [a]
tabset1 :: (Editor a) -> Editor a
tabset2 :: (Editor a) (Editor b) -> Editor (a,b)
tabset3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
tabset4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
tabset5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIWindow
window :: UIAttributes -> Editor ()
windowl :: UIAttributes (Editor a) -> Editor [a]
window1 :: UIAttributes (Editor a) -> Editor a
window2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
window3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
window4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
window5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
window :: Editor ()
windowl :: (Editor a) -> Editor [a]
window1 :: (Editor a) -> Editor a
window2 :: (Editor a) (Editor b) -> Editor (a,b)
window3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
window4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
window5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIMenu
menu :: UIAttributes -> Editor ()
menul :: UIAttributes (Editor a) -> Editor [a]
menu1 :: UIAttributes (Editor a) -> Editor a
menu2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
menu3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
menu4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
menu5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
menu :: Editor ()
menul :: (Editor a) -> Editor [a]
menu1 :: (Editor a) -> Editor a
menu2 :: (Editor a) (Editor b) -> Editor (a,b)
menu3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
menu4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
menu5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIToolBar
toolbar :: UIAttributes -> Editor ()
toolbarl :: UIAttributes (Editor a) -> Editor [a]
toolbar1 :: UIAttributes (Editor a) -> Editor a
toolbar2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
toolbar3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
toolbar4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
toolbar5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
toolbar :: Editor ()
toolbarl :: (Editor a) -> Editor [a]
toolbar1 :: (Editor a) -> Editor a
toolbar2 :: (Editor a) (Editor b) -> Editor (a,b)
toolbar3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
toolbar4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
toolbar5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIButtonBar
buttonbar :: UIAttributes -> Editor ()
buttonbarl :: UIAttributes (Editor a) -> Editor [a]
buttonbar1 :: UIAttributes (Editor a) -> Editor a
buttonbar2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
buttonbar3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
buttonbar4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
buttonbar5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
buttonbar :: Editor ()
buttonbarl :: (Editor a) -> Editor [a]
buttonbar1 :: (Editor a) -> Editor a
buttonbar2 :: (Editor a) (Editor b) -> Editor (a,b)
buttonbar3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
buttonbar4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
buttonbar5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIList
list :: UIAttributes -> Editor ()
listl :: UIAttributes (Editor a) -> Editor [a]
list1 :: UIAttributes (Editor a) -> Editor a
list2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
list3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
list4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
list5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
list :: Editor ()
listl :: (Editor a) -> Editor [a]
list1 :: (Editor a) -> Editor a
list2 :: (Editor a) (Editor b) -> Editor (a,b)
list3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
list4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
list5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIListItem
listitem :: UIAttributes -> Editor ()
listiteml :: UIAttributes (Editor a) -> Editor [a]
listitem1 :: UIAttributes (Editor a) -> Editor a
listitem2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
listitem3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
listitem4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
listitem5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
listitem :: Editor ()
listiteml :: (Editor a) -> Editor [a]
listitem1 :: (Editor a) -> Editor a
listitem2 :: (Editor a) (Editor b) -> Editor (a,b)
listitem3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
listitem4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
listitem5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
//# UIDebug
debug :: UIAttributes -> Editor ()
debugl :: UIAttributes (Editor a) -> Editor [a]
debug1 :: UIAttributes (Editor a) -> Editor a
debug2 :: UIAttributes (Editor a) (Editor b) -> Editor (a,b)
debug3 :: UIAttributes (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
debug4 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
debug5 :: UIAttributes (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
debug :: Editor ()
debugl :: (Editor a) -> Editor [a]
debug1 :: (Editor a) -> Editor a
debug2 :: (Editor a) (Editor b) -> Editor (a,b)
debug3 :: (Editor a) (Editor b) (Editor c) -> Editor (a,b,c)
debug4 :: (Editor a) (Editor b) (Editor c) (Editor d) -> Editor (a,b,c,d)
debug5 :: (Editor a) (Editor b) (Editor c) (Editor d) (Editor e) -> Editor (a,b,c,d,e)
This diff is collapsed.
......@@ -18,57 +18,57 @@ from Text.JSON import :: JSONNode
* Basic textfield
* Supported attributes:
*/
textField :: UIAttributes -> Editor String
textField :: Editor String
/**
* Multiple line text area
* Supported attributes:
*/
textArea :: UIAttributes -> Editor String
textArea :: Editor String
/**
* Password field that hides what you type
* Supported attributes:
*/
passwordField :: UIAttributes -> Editor String
passwordField :: Editor String
/**
* Textfield that only allows you to enter integer numbers
* Supported attributes:
*/
integerField :: UIAttributes -> Editor Int
integerField :: Editor Int
/**
* Textfield that only allows you to enter decimal (or integer) numbers
* Supported attributes:
*/
decimalField :: UIAttributes -> Editor Real
decimalField :: Editor Real
/**
* Form field that allows you to upload files
* Supported attributes:
*/
documentField :: UIAttributes -> Editor (!String,!String,!String,!String,!Int)
documentField :: Editor (!String,!String,!String,!String,!Int)
/**
* Simple checkbox
* Supported attributes:
*/
checkBox :: UIAttributes -> Editor Bool
checkBox :: Editor Bool
/**
* Slider for integer values in a limited range
* Supported attributes:
*/
slider :: UIAttributes -> Editor Int
slider :: Editor Int
/**
* A basic clickable button
* Supported attributes:
*/
button :: UIAttributes -> Editor Bool
button :: Editor Bool
/**
* A plain text label
* Supported attributes:
*/
label :: UIAttributes -> Editor String
label :: Editor String
/**
* A small icon with a tooltip
* Supported attributes:
*/
icon :: UIAttributes -> Editor (!String,!Maybe String)
icon :: Editor (!String,!Maybe String)
// ## Display components ##
// UITextView, UIHtmlView, UIProgressBar
......@@ -77,17 +77,17 @@ icon :: UIAttributes -> Editor (!String,!Maybe String)
* A component that displays arbitrary text (html is automatically escaped)
* Supported attributes:
*/
textView :: UIAttributes -> Editor String
textView :: Editor String
/**
* A component that displays arbitrary HTML (nothing is escaped)
* Supported attributes:
*/
htmlView :: UIAttributes -> Editor HtmlTag
htmlView :: Editor HtmlTag
/**
* A progress bar with a percentage and a description of the progress
* Supported attributes:
*/
progressBar :: UIAttributes -> Editor (Maybe Int,Maybe String) //Percentage, description
progressBar :: Editor (Maybe Int,Maybe String) //Percentage, description
// ## Selection components ##
// UIDropdown, UIRadioGroup, UICheckboxGroup, UIChoiceList, UIGrid, UITree
......@@ -95,28 +95,28 @@ progressBar :: UIAttributes -> Editor (Maybe Int,Maybe String) //Percentage, d
* A dropdown box
* Supported attributes:
*/
dropdown :: UIAttributes -> Editor ([ChoiceText], [Int])
dropdown :: Editor ([ChoiceText], [Int])
/**
* A group of checkboxes or radiobuttons depending on whether the multiple
* attribute is set or not
* Supported attributes:
*/
checkGroup :: UIAttributes -> Editor ([ChoiceText], [Int])
checkGroup :: Editor ([ChoiceText], [Int])
/**
* A list of text items to choose from
* Supported attributes:
*/
choiceList :: UIAttributes -> Editor ([ChoiceText], [Int])
choiceList :: Editor ([ChoiceText], [Int])
/**
* A typical grid component with a header
* Supported attributes:
*/
grid :: UIAttributes -> Editor (ChoiceGrid, [Int])
grid :: Editor (ChoiceGrid, [Int])
/**
* A typical tree selection component with expanding "folders"
* Supported attributes:
*/
tree :: UIAttributes -> Editor ([ChoiceNode], [Int])
tree :: Editor ([ChoiceNode], [Int])
//Convenient types for describing the values of grids and trees
:: ChoiceText =
......
......@@ -5,70 +5,70 @@ import StdFunc, StdBool, GenEq
import Data.Error, Text.JSON, Text.HTML
import qualified Data.Map as DM
textField :: UIAttributes -> Editor String
textField attr = fieldComponent attr toJSON UITextField
textField :: Editor String
textField = fieldComponent toJSON UITextField
textArea :: UIAttributes -> Editor String
textArea attr = fieldComponent attr toJSON UITextArea
textArea :: Editor String
textArea = fieldComponent toJSON UITextArea
passwordField :: UIAttributes -> Editor String
passwordField attr = fieldComponent attr toJSON UIPasswordField
passwordField :: Editor String
passwordField = fieldComponent toJSON UIPasswordField
integerField :: UIAttributes -> Editor Int
integerField attr = fieldComponent attr toJSON UIIntegerField
integerField :: Editor Int
integerField = fieldComponent toJSON UIIntegerField
decimalField :: UIAttributes -> Editor Real
decimalField attr = fieldComponent attr toJSON UIDecimalField
decimalField :: Editor Real
decimalField = fieldComponent toJSON UIDecimalField
documentField :: UIAttributes -> Editor (!String,!String,!String,!String,!Int)
documentField attr = fieldComponent attr toJSON UIDocumentField
documentField :: Editor (!String,!String,!String,!String,!Int)
documentField = fieldComponent toJSON UIDocumentField
checkBox :: UIAttributes -> Editor Bool
checkBox attr = fieldComponent attr toJSON UICheckbox
checkBox :: Editor Bool
checkBox = fieldComponent toJSON UICheckbox
slider :: UIAttributes -> Editor Int
slider attr = fieldComponent attr toJSON UISlider
slider :: Editor Int
slider = fieldComponent toJSON UISlider
button :: UIAttributes -> Editor Bool
button attr = fieldComponent attr toJSON UIButton
button :: Editor Bool
button = fieldComponent toJSON UIButton
label :: UIAttributes -> Editor String
label attr = viewComponent (\text -> 'DM'.union attr (textAttr text)) UILabel
label :: Editor String
label = viewComponent (\text -> (textAttr text)) UILabel
icon :: UIAttributes -> Editor (!String,!Maybe String)
icon attr = viewComponent (\(iconCls,tooltip) -> 'DM'.unions [iconClsAttr iconCls,maybe 'DM'.newMap tooltipAttr tooltip,attr]) UIIcon
icon :: Editor (!String,!Maybe String)
icon = viewComponent (\(iconCls,tooltip) -> 'DM'.unions [iconClsAttr iconCls,maybe 'DM'.newMap tooltipAttr tooltip]) UIIcon
textView :: UIAttributes -> Editor String
textView attr = viewComponent (\text -> 'DM'.fromList [("value",JSONString text)]) UITextView
textView :: Editor String
textView = viewComponent (\text -> valueAttr (JSONString text)) UITextView
htmlView :: UIAttributes -> Editor HtmlTag
htmlView attr = viewComponent (\html -> 'DM'.union (valueAttr (JSONString (toString html))) attr) UIHtmlView
htmlView :: Editor HtmlTag
htmlView = viewComponent (\html -> valueAttr (JSONString (toString html))) UIHtmlView
progressBar :: UIAttributes -> Editor (Maybe Int, Maybe String)
progressBar attr = viewComponent combine UIProgressBar
progressBar :: Editor (Maybe Int, Maybe String)
progressBar = viewComponent combine UIProgressBar
where
combine (amount,text) = 'DM'.unions ((maybe [] (\t -> [textAttr t]) text) ++ (maybe [] (\v -> [valueAttr (JSONInt v)]) amount) ++ [attr])
combine (amount,text) = 'DM'.unions ((maybe [] (\t -> [textAttr t]) text) ++ (maybe [] (\v -> [valueAttr (JSONInt v)]) amount))
dropdown :: UIAttributes -> Editor ([ChoiceText], [Int])
dropdown attr = choiceComponent (const attr) id toOptionText checkBoundsText UIDropdown
dropdown :: Editor ([ChoiceText], [Int])
dropdown = choiceComponent (const 'DM'.newMap) id toOptionText checkBoundsText UIDropdown
checkGroup :: UIAttributes -> Editor ([ChoiceText], [Int])
checkGroup attr = choiceComponent (const attr) id toOptionText checkBoundsText UICheckGroup
checkGroup :: Editor ([ChoiceText], [Int])
checkGroup = choiceComponent (const 'DM'.newMap) id toOptionText checkBoundsText UICheckGroup
choiceList :: UIAttributes -> Editor ([ChoiceText], [Int])
choiceList attr = choiceComponent (const attr) id toOptionText checkBoundsText UIChoiceList
choiceList :: Editor ([ChoiceText], [Int])
choiceList = choiceComponent (const 'DM'.newMap) id toOptionText checkBoundsText UIChoiceList
toOptionText {ChoiceText|id,text}= JSONObject [("id",JSONInt id),("text",JSONString text)]
checkBoundsText options idx = or [id == idx \\ {ChoiceText|id} <- options]
grid :: UIAttributes -> Editor (ChoiceGrid, [Int])
grid attr = choiceComponent (\{ChoiceGrid|header} -> 'DM'.union attr (columnsAttr header)) (\{ChoiceGrid|rows} -> rows) toOption checkBounds UIGrid
grid :: Editor (ChoiceGrid, [Int])
grid = choiceComponent (\{ChoiceGrid|header} -> columnsAttr header) (\{ChoiceGrid|rows} -> rows) toOption checkBounds UIGrid
where
toOption {ChoiceRow|id,cells}= JSONObject [("id",JSONInt id),("cells",JSONArray (map (JSONString o toString) cells))]
checkBounds options idx = or [id == idx \\ {ChoiceRow|id} <- options]
tree :: UIAttributes -> Editor ([ChoiceNode], [Int])
tree attr = choiceComponent (const attr) id toOption checkBounds UITree
tree :: Editor ([ChoiceNode], [Int])
tree = choiceComponent (const 'DM'.newMap) id toOption checkBounds UITree
where
toOption {ChoiceNode|id,label,icon,expanded,children}
= JSONObject [("text",JSONString label)
......@@ -85,13 +85,13 @@ where
| otherwise = or (map (checkNode idx) children)
//Field like components for which simply knowing the UI type is sufficient
fieldComponent attr toValue type = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
fieldComponent toValue type