From 418596ac5d1e508e070ebeed450fdac3589fab59 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 25 Oct 2017 16:59:22 +0200 Subject: Start with assignment 7 --- assignment-7/appointments.icl | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 assignment-7/appointments.icl (limited to 'assignment-7/appointments.icl') 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 -- cgit v1.2.3