diff options
author | Camil Staps | 2017-10-25 16:59:22 +0200 |
---|---|---|
committer | Camil Staps | 2017-10-25 16:59:22 +0200 |
commit | 418596ac5d1e508e070ebeed450fdac3589fab59 (patch) | |
tree | d044c3086a3210e711f6053b83e71a0904bd1b6e /assignment-7/appointments.icl | |
parent | Student numbers (diff) |
Start with assignment 7
Diffstat (limited to 'assignment-7/appointments.icl')
-rw-r--r-- | assignment-7/appointments.icl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/assignment-7/appointments.icl b/assignment-7/appointments.icl new file mode 100644 index 0000000..9de3c26 --- /dev/null +++ b/assignment-7/appointments.icl @@ -0,0 +1,48 @@ +module appointments + +from StdFunc import flip +from Data.Func import $ +import iTasks + +:: Appointment = + { title :: String + , when :: DateTime + , duration :: Time + , owner :: User + , participants :: [User] + } + +derive class iTask Appointment + +appointments :: Shared [Appointment] +appointments = sharedStore "appointments" [] + +Start :: *World -> *World +Start w = startEngine + ( addWorkFlows + >>| loginAndManageWorkList "Scheduler" worklist + ) w +where + addWorkFlows :: Task [Workflow] + addWorkFlows = upd (flip (++) newwfs) workflows + where + newwfs = + [ transientWorkflow "Show appointments" "Show appointments" showAppointments + , transientWorkflow "Make appointment" "Make appointment" makeAppointment + ] + + worklist :: [Workflow] + worklist = [workflow "Manage users" "Manage users" manageUsers] + +showAppointments :: Task [Appointment] +showAppointments = + get currentUser >>= \user -> + viewSharedInformation + (Title "Future appointments") + [ViewAs $ filter (\a -> a.owner == user)] + appointments + +makeAppointment :: Task [Appointment] +makeAppointment = + enterInformation (Title "Make appointment") [] >>= \app -> + upd (flip (++) [app]) appointments |