Commit 7c6247c4 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer

cond and task now also terminates properly in all cases..

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/fancyTasks@321 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 858db5d0
......@@ -3544,8 +3544,8 @@ OtherModules
DclOpen: False
Icl
WindowPosition
X: 43
Y: 129
X: 41
Y: -3
SizeX: 1485
SizeY: 768
IclOpen: True
......
......@@ -23,7 +23,9 @@ import TaskTree, TaskTreeFilters, InternaliTasksCommon
, tree_last :: Bool // Is this item the last of a set of siblings
, tree_icon :: String // An icon name. The actual icon image is defined in the css.
// Current possible values: editTask, orTask, andTask, conditionTask, timeTask, systemTask, finishedTask
}
} // And also: andTaskMU, maybeTask
derive JSONEncode WorkList, WorkListItem, TaskPriority
......
......@@ -173,26 +173,22 @@ allTasksCond :: !String !DisplaySubTasks !(FinishPred a) ![LabeledTask a] -> Ta
allTasksCond label displayOption pred taskCollection
= mkTask "andTasksCond" (Task (doandTasks taskCollection))
where
lengthltask = length taskCollection
doandTasks [] tst = return [] tst
doandTasks taskCollection tst=:{tasknr,html,options,userId}
# ((alist,acode),tst=:{activated=finished,html=allhtml})
= checkAllTasks label taskCollection 0 True ([],[]) {tst & html = BT [] [],activated = True}
| finished || pred alist = (alist,{tst & html = html, activated = True}) // stop, all work done so far satisfies predicate
doandTasks taskCollection tst=:{tasknr,html}
# ((alist,acode),tst) = checkAllTasks label taskCollection 0 ([],[]) {tst & html = BT [] [],activated = True}
| and (map fst acode) || pred alist = (alist,{tst & html = html, activated = True}) // stop, all work done so far satisfies predicate
= (alist,{tst & activated = False
, html = html +|+ displayOption label tasknr acode // show previous code
, html = html +|+ displayOption label tasknr acode // show all subtasks using the displayOption function
})
where
checkAllTasks :: !String ![LabeledTask a] !Int !Bool !(![a],![(Bool,HtmlTree)]) !*TSt -> *(!(![a],![(Bool,HtmlTree)]),!*TSt) | iCreateAndPrint a
checkAllTasks traceid taskCollection ctasknr bool (alist,acode) tst=:{tasknr}
| ctasknr == length taskCollection = ((reverse alist,reverse acode),{tst & activated = bool}) // all tasks tested
checkAllTasks :: !String ![LabeledTask a] !Int !(![a],![(Bool,HtmlTree)]) !*TSt -> *(!(![a],![(Bool,HtmlTree)]),!*TSt) | iCreateAndPrint a
checkAllTasks traceid taskCollection ctasknr (alist,acode) tst=:{tasknr}
| ctasknr == length taskCollection = ((reverse alist,reverse acode),tst) // all tasks tested
# (taskname,task) = taskCollection!!ctasknr
# (a,tst=:{activated = adone,html=html})
= appTaskTSt (mkParSubTask traceid ctasknr task) {tst & tasknr = tasknr, activated = True, html = BT [] []} // check tasks
= checkAllTasks traceid taskCollection (inc ctasknr) False (if adone [a:alist] alist,[(adone,html):acode]) {tst & tasknr = tasknr}
= checkAllTasks traceid taskCollection (inc ctasknr) (if adone [a:alist] alist,[(adone,html):acode]) {tst & tasknr = tasknr}
displayAsTab :: DisplaySubTasks
displayAsTab = displayAsTab`
......
......@@ -220,21 +220,21 @@ where
orTasks :: ![LabeledTask a] -> (Task a) | iData a
orTasks [] = Task (return createDefault)
orTasks taskCollection = newTask "orTasks" (andTasksCond "or Tasks" (\list -> length list >= 1) taskCollection)
orTasks taskCollection = newTask "orTasks" (andTasksCond "orTask" (\list -> length list >= 1) taskCollection)
=>> \list -> (Task (return (hd list)))
orTask2 :: !(Task a,Task b) -> Task (EITHER a b) | iData a & iData b
orTask2 (taska,taskb)
= allTasksCond "orTask2" displayAll (\list -> length list > 0) [("orTask.0",taska =>> \a -> return_V (LEFT a)),("orTask.0",taskb =>> \b -> return_V (RIGHT b))]
= allTasksCond "orTask" displayAll (\list -> length list > 0) [("orTask.0",taska =>> \a -> return_V (LEFT a)),("orTask.0",taskb =>> \b -> return_V (RIGHT b))]
=>> \res -> return_V (hd res)
andTasks :: ![LabeledTask a] -> (Task [a]) | iData a
andTasks taskCollection = newTask "andTasks" (andTasksCond "and Tasks" (\_ -> False) taskCollection)
andTasks taskCollection = newTask "andTasks" (andTasksCond "andTask" (\_ -> False) taskCollection)
(-&&-?) infixr 4 :: !(Task (Maybe a)) !(Task (Maybe b)) -> Task (Maybe (a,b)) | iData a & iData b
(-&&-?) t1 t2
= andTasksCond "Maybe Task" noNothing [("Maybe 1",left),("Maybe 2",right)]
= andTasksCond "maybeTask" noNothing [("Maybe 1",left),("Maybe 2",right)]
=>> combineResult
where
left = t1 =>> \tres -> return_V (LEFT tres)
......@@ -250,11 +250,11 @@ where
andTask2 :: !(Task a,Task b) -> Task (a,b) | iData a & iData b
andTask2 (taska,taskb)
= allTasksCond "andTask2" displayAll (\l -> False) [("andTask.0",taska =>> \a -> return_V (LEFT a)),("andTask.0",taskb =>> \b -> return_V (RIGHT b))]
= allTasksCond "andTask" displayAll (\l -> False) [("andTask.0",taska =>> \a -> return_V (LEFT a)),("andTask.0",taskb =>> \b -> return_V (RIGHT b))]
=>> \[LEFT a, RIGHT b] -> return_V (a,b)
andTasks_mu :: !String ![(Int,Task a)] -> (Task [a]) | iData a
andTasks_mu label tasks = newTask "andTasks_mu" (domu_andTasks tasks)
andTasks_mu label tasks = newTask "andTaskMU" (domu_andTasks tasks)
where
domu_andTasks list = andTasks [(label <+++ " " <+++ i, i @:: task) \\ (i,task) <- list]
......
......@@ -25,7 +25,7 @@ where
determineTaskList` thisuser (CondAnd label nr [t=:(condAndDescr,htmlTree):ts]) taskDescr
# collection = determineTaskList` thisuser htmlTree taskDescr
# collections = determineTaskList` thisuser (CondAnd label nr ts) taskDescr
= [{taskDescr & taskNrId = condAndDescr.caTaskNrId, taskLabel = label <+++ condAndDescr.caIndex, curStatus = condAndDescr.caStatus}] ++ collection ++ collections
= [{taskDescr & taskNrId = condAndDescr.caTaskNrId, taskLabel = label, curStatus = condAndDescr.caStatus}] ++ collection ++ collections
determineTaskList` thisuser (tree1 +|+ tree2)taskDescr
# collection1 = determineTaskList` thisuser tree1 taskDescr
# collection2 = determineTaskList` thisuser tree2 taskDescr
......
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