Commit add30b19 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer

cond and sub tasks now start counting at 0

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/fancyTasks@327 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 66e4f9ff
......@@ -94,7 +94,8 @@ where
# (v,tst) = appTaskTSt (mkTaskNoInc (name <+++ "." <+++ i) (Task mysubtask)) {tst & tasknr = [i:tasknr],activated = True} // shift task
= (v,{tst & tasknr = tasknr, options = options})
where
mysubtask tst=:{tasknr} = appTaskTSt task {tst & tasknr = [-1:tasknr], activated = True} // shift once again!
mysubtask tst=:{tasknr} = appTaskTSt task {tst & tasknr = [0:tasknr], activated = True} // shift once again!
// ******************************************************************************************************
// iTask Storage Utilities
......
......@@ -66,6 +66,7 @@ Once :: task will be done only once, the value of the task will be remembered,
newTask :: !String !(Task a) -> Task a | iData a
Once :: !String !(Task a) -> Task a | iData a
newTaskTrace :: !String !(Task a) -> (Task a) | iData a
/* Operations on Task state
taskId :: give id of user assigned to task
userId :: give id of application user
......
......@@ -68,6 +68,9 @@ where
# (done,value) = store.Form.value
= (value,{tst & activated = done, hst = hst}) // task is now completed, handle as previously
newTaskTrace :: !String !(Task a) -> (Task a) | iData a // used to insert a task trace later MJP BUG
newTaskTrace taskname mytask = newTask taskname mytask
// ******************************************************************************************************
// looping tasks
......@@ -113,7 +116,7 @@ where
| not activated = (createDefault,tst)
# (currtime,tst=:{html=ohtml}) = appTaskTSt (appWorldOnce ("Task " +++ taskname +++ " for " +++ toString nuserId) time) tst
# tst = IF_Ajax (administrateNewThread userId tst) tst
# (a,tst=:{html=nhtml,activated}) = appTaskTSt (IF_Ajax (UseAjax @>> taska) taska) {tst & html = BT [] [],userId = nuserId} // activate task of indicated user NEWTRACE
# (a,tst=:{html=nhtml,activated}) = appTaskTSt (IF_Ajax (UseAjax @>> taska) taska) {tst & html = BT [] [],userId = nuserId, tasknr = tasknr} // activate task of indicated user NEWTRACE
| activated = (a,{tst & activated = True // work is done
, userId = userId // restore previous user id
, html = ohtml +|+ (taskDescriptor currtime activated @@: nhtml)}) // plus new one tagged
......
......@@ -114,8 +114,8 @@ where
selectTask_pdm` _ [] tst = return createDefault tst
selectTask_pdm` defaultOn taskOptions tst=:{tasknr,html,userId,options} // choose one subtask out of a pulldown menu
# taskId = iTaskId userId tasknr ("ChoStPdm" <+++ length taskOptions)
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
# taskId = iTaskId userId tasknr ("ChoStPdm" <+++ length taskOptions)
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
| chosen.Form.value == -1 // no choice made yet
# numberOfItems = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfItems - 1) defaultOn 0
......@@ -167,16 +167,16 @@ where
// choose one or more tasks on forehand out of a set
button :: !String !a -> (Task a) | iData a
button s a = newTask "button" (chooseTask_btn [] True [(s,return_V a)])
button s a = newTaskTrace "button" (chooseTask_btn [] True [(s,return_V a)])
buttonTask :: !String !(Task a) -> (Task a) | iData a
buttonTask s task = newTask "buttonTask" (chooseTask_btn [] True [(s,task)])
buttonTask s task = newTaskTrace "buttonTask" (chooseTask_btn [] True [(s,task)])
chooseTask :: ![HtmlTag] ![LabeledTask a] -> (Task a) | iData a
chooseTask prompt options = newTask "chooseTask" (chooseTask_btn prompt True options)
chooseTask prompt options = newTaskTrace "chooseTask" (chooseTask_btn prompt True options)
chooseTaskV :: ![HtmlTag] ![LabeledTask a] -> (Task a) | iData a
chooseTaskV prompt options = newTask "chooseTaskV" (chooseTask_btn prompt False options)
chooseTaskV prompt options = newTaskTrace "chooseTaskV" (chooseTask_btn prompt False options)
mchoiceTasks :: ![HtmlTag] ![LabeledTask a] -> (Task [a]) | iData a
mchoiceTasks prompt taskOptions
......@@ -206,7 +206,7 @@ mchoiceAndTasks3 prompt taskOptions
// Speculative OR-tasks: task ends as soon as one of its subtasks completes
(-||-) infixr 3 :: !(Task a) !(Task a) -> (Task a) | iData a
(-||-) taska taskb = newTask "-||-" (doOrTask (taska,taskb))
(-||-) taska taskb = newTaskTrace "-||-" (doOrTask (taska,taskb))
where
doOrTask :: !(Task a,Task a) -> (Task a) | iData a
doOrTask (taska,taskb)
......@@ -216,11 +216,11 @@ where
(RIGHT b) -> return_V b
(-&&-) infixr 4 :: !(Task a) !(Task b) -> (Task (a,b)) | iData a & iData b
(-&&-) taska taskb = newTask "-&&-" (andTask2 (taska,taskb))
(-&&-) taska taskb = newTaskTrace "-&&-" (andTask2 (taska,taskb))
orTasks :: ![LabeledTask a] -> (Task a) | iData a
orTasks [] = Task (return createDefault)
orTasks taskCollection = newTask "orTasks" (andTasksCond "orTask" (\list -> length list >= 1) taskCollection)
orTasks taskCollection = newTaskTrace "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
......@@ -230,7 +230,7 @@ orTask2 (taska,taskb)
andTasks :: ![LabeledTask a] -> (Task [a]) | iData a
andTasks taskCollection = newTask "andTasks" (andTasksCond "andTask" (\_ -> False) taskCollection)
andTasks taskCollection = newTaskTrace "andTasks" (andTasksCond "andTask" (\_ -> False) taskCollection)
(-&&-?) infixr 4 :: !(Task (Maybe a)) !(Task (Maybe b)) -> Task (Maybe (a,b)) | iData a & iData b
(-&&-?) t1 t2
......@@ -254,7 +254,7 @@ andTask2 (taska,taskb)
=>> \[LEFT a, RIGHT b] -> return_V (a,b)
andTasks_mu :: !String ![(Int,Task a)] -> (Task [a]) | iData a
andTasks_mu label tasks = newTask "andTaskMU" (domu_andTasks tasks)
andTasks_mu label tasks = newTaskTrace "andTaskMU" (domu_andTasks tasks)
where
domu_andTasks list = andTasks [(label <+++ " " <+++ i, i @:: task) \\ (i,task) <- list]
......
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