Commit 99d3bd02 authored by Bas Lijnse's avatar Bas Lijnse

Updated iTaskconf examples

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1140 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent c29dd994
......@@ -14,7 +14,7 @@ derive bimap Maybe, (,)
manageGroups :: Task Void
manageGroups = buildGroups
>>= \groups -> updateInformation "Please assign users to groups" groups
>>= \groups -> updateInformation "Group assignment" "Please assign users to groups" groups
>>= \ngroups -> getUsers
>>= \users -> removeAllGroupsFromUsers users
>>| assignGroupsToUsers ngroups users
......@@ -53,7 +53,7 @@ where
listGroups :: Task Void
listGroups = buildGroups
>>= showMessageAbout "This is the current assignment of roles"
>>= showMessageAbout "Role assignment" "This is the current assignment of roles" >>| return Void
getUserGroups :: Task [String]
getUserGroups = buildGroups
......
......@@ -24,13 +24,7 @@ lists = [ workflow "List Management/New List" newList
, flagged :: Bool
}
derive gPrint ListDBItem, List, ListItem
derive gParse ListDBItem, List, ListItem
derive gVisualize ListDBItem, List, ListItem
derive gUpdate ListDBItem, List, ListItem
derive gError ListDBItem, List, ListItem
derive gHint ListDBItem, List, ListItem
derive class iTask ListDBItem, List, ListItem
derive gMerge ListDBItem, List, ListItem
derive bimap Maybe, (,)
......@@ -41,11 +35,11 @@ getListDB = mkDBid "ListDB"
newList :: Task Void
newList = readDB getListDB
>>= \ldb -> getCurrentUser
>>= \me -> enterChoice "What kind of list do you want to create?" ["Note","Date","Document"]
>>= \me -> enterChoice "Choose list" "What kind of list do you want to create?" ["Note","Date","Document"]
>>= \ltype -> initList ltype
>>= \list -> createDB list
>>= \dbid -> writeDB getListDB [dbid:ldb]
>>| showMessage "List is succesfully created."
>>| showMessage "Success" "List is succesfully created." Void
where
initList :: String -> Task ListDBItem
initList type = case type of
......@@ -58,9 +52,9 @@ where
_
= initListNote >>= \l -> return (NoteList l)
initListNote = enterInformation "Edit List"
initListDate = enterInformation "Edit List"
initListDoc = enterInformation "Edit List"
initListNote = enterInformation "Note list" "Edit List"
initListDate = enterInformation "Date list" "Edit List"
initListDoc = enterInformation "Document list" "Edit List"
editList :: Task Void
editList = getCurrentUser
......@@ -70,18 +64,12 @@ editList = getCurrentUser
pushList :: Task Void
pushList = getCurrentUser
>>= \me -> selectList me
>>= \id -> enterInformation "To whom do you want to push this list?"
>>= \id -> enterInformation "User" "To whom do you want to push this list?"
>>= \usr -> enterMsg usr
>>= \msg -> usr @: ((showInstructionAbout ("Request to edit list from "+++toString me) "Press 'Done' to continue to the list editor" msg) >>| listEditor id)
where
enterMsg :: User -> Task Note
enterMsg user = enterInformation ("What would you like ask from "+++toString user+++"?")
/*
pushListItem :: Task Void
pushListItem = getCurrentUser
>>= \me -> selectList me
>>= \id ->
*/
enterMsg user = enterInformation "Message" ("What would you like ask from "+++toString user+++"?")
selectList :: User -> Task (DBid (ListDBItem))
selectList user
......@@ -89,7 +77,7 @@ selectList user
= readDB getListDB
>>= \db -> sequence "Reading DB" [getListItem id \\ id <- db]
>>= \items -> sequence "Get Info" [getListInfo item id \\ item <- items & id <- db | isMember user (getOwners item) || isMember "chair" roles]
>>= \info -> enterChoice "Please select the list you wish to edit" info
>>= \info -> enterChoice "Choose list" "Please select the list you wish to edit" info
>>= \choice -> return (fromHidden (snd choice))
where
getListItem :: (DBid ListDBItem) -> Task ListDBItem
......
......@@ -60,7 +60,7 @@ newMessage = getCurrentUser
newMessageToGroup :: Task Void
newMessageToGroup = getCurrentUser
>>= \me -> getUserGroups
>>= \groups -> enterChoice "Select group" groups
>>= \groups -> enterChoice "Choose group" "Select group" groups
>>= \role -> getUsersWithRole role
>>= \users -> writeMessage me "" users [] []
>>= \msg -> sendMessage msg
......@@ -68,36 +68,36 @@ newMessageToGroup = getCurrentUser
sendMessage :: Message -> Task Void
sendMessage msg = allProc [who @>> spawnProcess who True True
((readMessage msg <<@ Subject ("Message from "+++toString (fromHtmlDisplay msg.Message.sender)+++": "+++msg.Message.subject)) <<@ msg.Message.priority) \\ who <- (msg.Message.to ++ if(isJust msg.cc) (fromJust msg.cc) [])] Closed
>>| showMessageAbout "The following message has been sent:" msg
>>| showMessageAbout "Message sent" "The following message has been sent:" msg >>| return Void
writeMessage :: User String [User] [User] [Message] -> Task Message
writeMessage me subj to cc thread = updateInformation "Enter your message" {Message | (mkMsg me) & subject = subj, to = to, cc = if(isEmpty cc) Nothing (Just cc), previousMessages = (HtmlDisplay thread)}
writeMessage me subj to cc thread = updateInformation "Compose" "Enter your message" {Message | (mkMsg me) & subject = subj, to = to, cc = if(isEmpty cc) Nothing (Just cc), previousMessages = (HtmlDisplay thread)}
readMessage :: Message -> Task Void
readMessage msg=:{Message | previousMessages}
= showMessageAboutA "You received a message" [ButtonAction (ActionLabel "Reply",Always),
readMessage msg=:{Message | previousMessages, subject}
= showMessageAboutA subject "You received a message" [ButtonAction (ActionLabel "Reply",Always),
ButtonAction (ActionLabel "Reply All",Always), ButtonAction (ActionLabel "Forward",Always), ButtonAction (ActionLabel "Delete", Always), ButtonAction (ActionLabel "Archive & Close",Always)] msg
>>= \act -> case act of
(ActionLabel "Reply")
(ActionLabel "Reply",_)
= getCurrentUser
>>= \me -> writeMessage me ("Re: "+++msg.Message.subject) [(fromHtmlDisplay msg.sender)] [] [{Message | msg & previousMessages = (HtmlDisplay [])}:fromHtmlDisplay previousMessages]
>>= \msg -> sendMessage msg
(ActionLabel "Reply All")
(ActionLabel "Reply All",_)
= getCurrentUser
>>= \me -> writeMessage me ("Re: "+++msg.Message.subject) [(fromHtmlDisplay msg.sender):[u \\ u <- msg.to | u <> me]] (if(isJust msg.cc) (fromJust msg.cc) []) [{Message | msg & previousMessages = (HtmlDisplay [])}:fromHtmlDisplay previousMessages]
>>= \msg -> sendMessage msg
(ActionLabel "Forward")
(ActionLabel "Forward",_)
= getCurrentUser
>>= \me -> writeMessage me ("Fw: "+++msg.Message.subject) [] [] [{Message | msg & previousMessages = (HtmlDisplay [])}:fromHtmlDisplay previousMessages]
>>= \msg -> sendMessage msg
(ActionLabel "Archive & Close")
(ActionLabel "Archive & Close",_)
= readDB msgDBid
>>= \mdb -> writeDB msgDBid (removeDup [msg:mdb])
>>| showMessage "Message stored in archive"
(ActionLabel "Delete")
>>| showMessage "Archived" "Message stored in archive" Void
(ActionLabel "Delete",_)
= readDB msgDBid
>>= \mdb -> writeDB msgDBid (filter (\dbmsg -> dbmsg <> msg) mdb)
>>| showMessage "Message deleted"
>>| showMessage "Deleted" "Message deleted" Void
viewArchive :: Task Void
viewArchive = getCurrentUser
......@@ -110,8 +110,8 @@ where
selectMsg mdb me
# mdbs = filter (\msg -> (isMember me msg.to) || (isMember me (if(isJust msg.cc) (fromJust msg.cc) []))) mdb
= case mdb of
[] = showMessage "The archive is empty" >>| return []
_ = enterMultipleChoice "Which messages do you want to view?" mdbs
[] = showMessage "Empty archive" "The archive is empty" []
_ = enterMultipleChoice "Select messages" "Which messages do you want to view?" mdbs
//========================================================================================================================================================================
// Broadcasting
......@@ -121,5 +121,5 @@ broadcast :: [User] String (Maybe a) -> Task Void | iTask a
broadcast to msg mbAbout = allProc [spawnProcess who True True show \\ who <- to] Closed >>| return Void
where
show = case mbAbout of
Just a = showMessageAbout msg a
Nothing = showMessage msg
\ No newline at end of file
Just a = showMessageAbout "TODO" msg a >>| return Void
Nothing = showMessage "TODOD" msg Void
\ No newline at end of file
......@@ -40,10 +40,10 @@ derive class iTask DateVote, Vote, VoteCount
derive gEq Date
pickADate :: Task Void
pickADate = enterInformation "What is the subject?"
pickADate = enterInformation "Subject" "What is the subject?"
>>= \subj -> getCurrentUser
>>= \me -> updateInformation "Who should be managing the descision?" me
>>= \ref -> enterInformation "Who else should be involved in the descision?"
>>= \me -> updateInformation "Manager" "Who should be managing the decision?" me
>>= \ref -> enterInformation "Choose people" "Who else should be involved in the decision?"
>>= \oth -> (ref @: datePicker [ref:oth])
>>= \date -> broadcast [ref:oth] ("The chosen date for "+++subj+++": ") (Just date)
......@@ -53,17 +53,17 @@ datePicker users = pickDates
>>= \votes -> pickFinal votes
where
pickDates :: Task [Date]
pickDates = enterInformation "Please select date options"
pickDates = enterInformation "Pick dates" "Please select date options"
voteDates :: [Date] -> Task DateVotes
voteDates dates = updateInformation "Please indicate your preference" (HtmlDisplay [{DateVote | date = d, vote = (Editable Maybe)} \\ d <- dates])
voteDates dates = updateInformation "Date preference" "Please indicate your preference" (HtmlDisplay [{DateVote | date = d, vote = (Editable Maybe)} \\ d <- dates])
pickFinal :: [DateVotes] -> Task Date
pickFinal votes
# v = (map fromHtmlDisplay votes)
# init = [{VoteCount | date = dv.DateVote.date, yes = 0, no = 0, maybe = 0} \\ dv <- (hd v)]
# overview = foldl countVotes init v
= enterChoice "Please select the final option" overview
= enterChoice "Final decision" "Please select the final option" overview
>>= \final -> return final.VoteCount.date
where
countVotes votecount [] = votecount
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment