summaryrefslogtreecommitdiff
path: root/assignment-7/appointments.icl
diff options
context:
space:
mode:
authorCamil Staps2017-10-25 16:59:22 +0200
committerCamil Staps2017-10-25 16:59:22 +0200
commit418596ac5d1e508e070ebeed450fdac3589fab59 (patch)
treed044c3086a3210e711f6053b83e71a0904bd1b6e /assignment-7/appointments.icl
parentStudent numbers (diff)
Start with assignment 7
Diffstat (limited to 'assignment-7/appointments.icl')
-rw-r--r--assignment-7/appointments.icl48
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