Commit 99761b38 authored by Bas Lijnse's avatar Bas Lijnse

Updated buildTaskPanel. It is now a pure function again. The second pass user...

Updated buildTaskPanel. It is now a pure function again. The second pass user interface generation is now done in a function called normalizeInteractiveTasks as part of evaluateTaskInstance.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1100 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 36d8d4f1
......@@ -16,8 +16,6 @@ derive JSONDecode ManagerProperties, TaskPriority, User, UserDetails, Password
JSONEncode{|Timestamp|} (Timestamp x) = JSONEncode{|*|} x
JSONDecode{|Timestamp|} [JSONInt x:c] = (Just (Timestamp x),c)
import StdDebug
taskService :: !String !Bool ![String] !HTTPRequest *TSt -> (!HTTPResponse, !*TSt)
taskService url html path req tst
# (mbSessionErr,tst) = initSession sessionParam tst
......@@ -77,10 +75,13 @@ taskService url html path req tst
Just proc
# task = taskItem proc
# menu = proc.Process.menus
# (tree,tst) = calculateTaskTree taskId [] tst //TODO Add update events as parameter
# (tui,tst) = buildTaskPanel tree Nothing session.Session.user tst //TODO: Clean up this conversion. TSt should be irrelevant
//The menusChanged parameter is a global flag that is set when any task in the tree has
//changed the menu and thus the menu needs to be replaced
# (tree,tst=:{TSt|menusChanged})
= calculateTaskTree taskId [] tst //TODO Add update events as parameter
# tui = buildTaskPanel tree menu menusChanged session.Session.user
# json = JSONObject [("success",JSONBool True),("task",toJSON task),("menu",toJSON menu),("tui",toJSON tui)]
= (serviceResponse html "task user interface" url tuiParams json, tst)
= (serviceResponse html "task user interface" url tuiParams json, {TSt|tst & menusChanged = menusChanged})
//Show / update Manager properties
[taskId,"managerProperties"]
......
......@@ -12,14 +12,14 @@ import TaskPanel
from TaskTree import :: TaskParallelType{..}
handleWorkTabRequest :: !HTTPRequest !*TSt -> (!HTTPResponse, !*TSt)
handleWorkTabRequest req tst=:{staticInfo}
handleWorkTabRequest req tst=:{staticInfo,menusChanged}
# tst = {TSt | tst & request = req}
# (tree, tst) = calculateTaskTree taskId [] tst // Calculate the task tree TODO : add updates
= case tree of
(TTMainTask ti properties menus _ task)
# subject = [properties.managerProperties.ManagerProperties.subject]
# user = staticInfo.currentSession.Session.user
# (panel,tst) = buildTaskPanel task menus user tst
# panel = buildTaskPanel task menus menusChanged user
// Collect debug information
# (debuginfo,tst) = if debug (collectDebugInfo tree tst) (Nothing, tst)
// Check the user who has to do the work: if not the correct user, give task redundant message.
......
......@@ -234,6 +234,9 @@ evaluateTaskInstance process=:{Process | taskId, properties, menus, changeCount,
// The tasktree of this process is the tree as it has been constructed, but with updated properties
# (TTMainTask ti _ _ _ tasks,tst) = getTaskTree tst
# tree = TTMainTask ti properties menus inParallelType tasks
// Normalize the tree by evaluating all interactive task nodes that contain functions
// These can only be evaluated after the complete tree has been evaluated because of mutual dependencies
# (tree,tst) = normalizeInteractiveTasks tree tst
// Store the adapted persistent changes
# tst = if isTop (storePersistentChanges taskId tst) tst
# tst = restoreTSt parentUpdates parentProperties parentMenus tst
......@@ -431,7 +434,49 @@ where
storeChanges [(label,dyn):cs] tst=:{TSt|iworld=iworld=:{IWorld|store}}
# store = storeValueAs SFDynamic ("iTask_change-" +++ label) dyn store
= storeChanges cs {TSt|tst & iworld = {IWorld|iworld & store = store}}
/*
* Evaluate all functions in interactive task nodes
*/
normalizeInteractiveTasks :: !TaskTree !*TSt -> (!TaskTree,!*TSt)
//The interactive task leaves that are normalized
normalizeInteractiveTasks (TTInteractiveTask ti it) tst
= case it of
(Func f)
# (it,tst) = f tst
= (TTInteractiveTask ti it, tst)
_
= (TTInteractiveTask ti it, tst)
//For grouped tasks the actions are also normalized
normalizeInteractiveTasks (TTGroupedTask ti tasks actions s) tst
# (actions,tst) = mapSt normalizeAction actions tst
# (tasks,tst) = mapSt normalizeInteractiveTasks tasks tst
= (TTGroupedTask ti tasks actions s, tst)
where
normalizeAction (action, Left b) tst = ((action,Left b), tst)
normalizeAction (action, Right f) tst
# (b,tst) = f tst
= ((action,Left b), tst)
//Tree traversal
normalizeInteractiveTasks (TTMainTask ti properties menus pt task) tst
# (task,tst) = normalizeInteractiveTasks task tst
= (TTMainTask ti properties menus pt task, tst)
normalizeInteractiveTasks (TTSequenceTask ti tasks) tst
# (tasks,tst) = mapSt normalizeInteractiveTasks tasks tst
= (TTSequenceTask ti tasks, tst)
normalizeInteractiveTasks (TTParallelTask ti pi tasks) tst
# (tasks,tst) = mapSt normalizeInteractiveTasks tasks tst
= (TTParallelTask ti pi tasks, tst)
//All other leaf cases
normalizeInteractiveTasks tree tst = (tree,tst)
mapSt f [] st = ([], st)
mapSt f [x:xs] st
# (y, st) = f x st
# (ys, st) = mapSt f xs st
= ([y:ys], st)
applyChangeToTaskTree :: !ProcessId !ChangeInjection !*TSt -> *TSt
applyChangeToTaskTree pid (lifetime,change) tst=:{taskNr,taskInfo,tree,staticInfo,currentChange,pendingChanges, properties, menus}
# (mbProcess,tst) = getProcess pid tst
......
......@@ -122,5 +122,5 @@ derive JSONEncode TTCFormContainer, TTCMonitorContainer, TTCResultContainer, TTC
, description :: !String
}
buildTaskPanel :: !TaskTree !(Maybe [Menu]) !User !*TSt -> (!TaskPanel,!*TSt)
buildResultPanel :: !TaskTree -> TaskPanel
\ No newline at end of file
buildTaskPanel :: !TaskTree !(Maybe [Menu]) !Bool !User -> TaskPanel
buildResultPanel :: !TaskTree -> TaskPanel
\ No newline at end of file
This diff is collapsed.
......@@ -15,11 +15,12 @@ from JSON import :: JSONNode
from TUIDefinition import :: TUIDef, :: TUIUpdate
// give definition/updates or determine it after entire tree is build, needed for updateShared, ...
:: InteractiveTask = Definition ([TUIDef],[TUIButton]) [(Action,Bool)]
| Updates [TUIUpdate] [(Action,Bool)]
| Func (*TSt -> *(!InteractiveTask, !*TSt))
| Message ([TUIDef],[TUIButton]) [(Action,Bool)]
:: InteractiveTask = Definition ([TUIDef],[TUIButton]) [(Action,Bool)] //Definition for rendering a user interface
| Updates [TUIUpdate] [(Action,Bool)] //Update an already rendered user interface
| Message ([TUIDef],[TUIButton]) [(Action,Bool)] //Just show a message
| Func (*TSt -> *(!InteractiveTask, !*TSt)) //Function for delayed generation of an interface definition.
//These functions are evaluated after the full tree has been built.
:: TaskTree = TTMainTask TaskInfo TaskProperties (Maybe [Menu]) !(Maybe TaskParallelType) TaskTree //A task that is treated as a main chunk of work
| TTInteractiveTask TaskInfo InteractiveTask //A task that can be worked on through a gui
| TTMonitorTask TaskInfo [HtmlTag] //A task that upon evaluation monitors a condition and may give status output
......
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