Commit 8470081e authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

in basic combinators assignTask and chooseTask html dependent part taken apart.

the different kinf of chooseTask combinators (buttons, pull down menu) and the like
are move to the combinator module

I did not do condAnd yet...
parent 35bb2114
......@@ -29,9 +29,9 @@ return_V :: !a -> Task a | iCreateAndPrint a
/*
Assign tasks to user with indicated id:
assignTaskTo :: assign task to indicated user, True for verbose reporting
assignTaskTo :: assign task to indicated user
*/
assignTaskTo :: !Bool !UserId !(LabeledTask a) -> Task a | iData a
assignTaskTo :: !UserId !(LabeledTask a) -> Task a | iData a
/*
Repetition and loops:
......@@ -48,23 +48,10 @@ seqTasks :: do all iTasks one after another, task completed when all done
seqTasks :: ![LabeledTask a] -> Task [a] | iCreateAndPrint a
/*
Choose the tasks you want to do one forehand:
chooseTask_btn :: choose ONE task by pressing a button, True for horizontal buttons, else vertical
chooseTask_pdm :: as chooseTask_btn, depending on pulldownmenu item selected, Int for initial value
chooseTask_radio:: as chooseTask_btn, depending on radio item selected, Int for initial value, htmlcode for option explanation
chooseTask_cb :: choice N tasks out of N, order of chosen task depending on first arg
(initial setting, effect for all when set, explanation) for each option
Select the tasks to do from a given list of tasks:
selectTasks :: the first argument is task yielding the task numbers (index in the list) to do; tasks will be done in this order.
*/
chooseTask_btn :: !HtmlCode !Bool![LabeledTask a] -> Task a | iCreateAndPrint a
chooseTask_pdm :: !HtmlCode !Int ![LabeledTask a] -> Task a | iCreateAndPrint a
chooseTask_radio:: !HtmlCode !Int ![(HtmlCode,LabeledTask a)]
-> Task a | iCreateAndPrint a
chooseTask_cbox :: !([LabeledTask a] -> Task [a])
!HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)]
-> Task [a] | iData a
selectTasks :: !([LabeledTask a] -> Task [Int]) [LabeledTask a] -> Task [a] | iData a
/*
Do m Tasks parallel / interleaved and FINISH as soon as SOME Task completes:
......
......@@ -46,13 +46,13 @@ newTask taskname mytask = mkTask taskname newTask`
where
newTask` tst=:{tasknr,userId,options}
# taskId = iTaskId userId tasknr taskname
# (taskval,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId (False,createDefault)) id) tst // remember if the task has been done
# (taskval,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId (False,createDefault)) id) tst // remember if the task has been done
# (taskdone,taskvalue) = taskval.value // select values
| taskdone = (taskvalue,tst) // if rewritten return stored value
# (val,tst=:{activated}) = mytask {tst & tasknr = [-1:tasknr]} // do task, first shift tasknr
| not activated = (createDefault,{tst & tasknr = tasknr, options = options}) // subtask not ready, return value of subtasks
# tst = deleteSubTasksAndThreads tasknr tst // task ready, garbage collect it
# (_,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId (False,createDefault)) (\_ -> (True,val))) tst // remember if the task has been done
# (_,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId (False,createDefault)) (\_ -> (True,val))) tst // remember if the task has been done
= (val,{tst & tasknr = tasknr, options = options})
......@@ -84,11 +84,11 @@ where
| activated = foreverTask` (deleteSubTasksAndThreads tasknr {tst & tasknr = tasknr, options = options, html = html}) // loop
= (val,tst)
# taskId = iTaskId userId tasknr "ForSt" // create store id
# (currtasknr,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId tasknr) id) tst // fetch actual tasknr
# (currtasknr,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId tasknr) id) tst // fetch actual tasknr
# (val,tst=:{activated}) = task {tst & tasknr = [-1:currtasknr.value]}
| activated // task is completed
# ntasknr = incNr currtasknr.value // incr tasknr
# (currtasknr,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId tasknr) (\_ -> ntasknr)) tst // store next task nr
# (currtasknr,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId tasknr) (\_ -> ntasknr)) tst // store next task nr
= foreverTask` {tst & tasknr = tasknr, options = options, html = html} // initialize new task
= (val,tst)
......@@ -107,8 +107,8 @@ where
// ******************************************************************************************************
// Assigning tasks to users, each user has to be identified by an unique number >= 0
assignTaskTo :: !Bool !UserId !(LabeledTask a) -> Task a | iData a
assignTaskTo verbose nuserId (taskname,taska) = assignTaskTo`
assignTaskTo :: !UserId !(LabeledTask a) -> Task a | iData a
assignTaskTo nuserId (taskname,taska) = assignTaskTo`
where
assignTaskTo` tst=:{html=ohtml,activated,userId,workflowLink=(_,(_,processNr,workflowLabel))}
| not activated = (createDefault,tst)
......@@ -119,19 +119,16 @@ where
, html = ohtml }) // plus new one tagged
= (a,{tst & userId = userId // restore user Id
, html = ohtml +|+ // show old code
if verbose
( BT [showText ("Waiting for Task "), showLabel taskname, showText " from ", showUser nuserId,Br] +|+ // show waiting for
((nuserId,processNr,workflowLabel,taskname) @@: BT [showText "Requested by ", showUser userId,Br,Br] +|+ nhtml))
((nuserId,processNr,workflowLabel,taskname) @@: nhtml)
})
showUser nr = showLabel ("User " <+++ nr)
// ******************************************************************************************************
// sequencingtasks
seqTasks :: ![LabeledTask a] -> (Task [a])| iCreateAndPrint a
seqTasks [(label,task)] = task =>> \na -> return_V [na]
seqTasks options = mkTask "seqTasks" seqTasks`
where
seqTasks` tst=:{tasknr}
......@@ -146,113 +143,14 @@ where
= doseqTasks ts [a:accu] {tst & html = html +|+ ahtml, options = options}
// ******************************************************************************************************
// choose one or more tasks on forehand out of a set
chooseTask_btn :: !HtmlCode !Bool![LabeledTask a] -> Task a | iCreateAndPrint a
chooseTask_btn htmlcode bool ltasks = chooseTask_btn` htmlcode bool ltasks
where
chooseTask_btn` _ _ [] tst = return createDefault tst
chooseTask_btn` prompt horizontal taskOptions tst=:{tasknr,html,options,userId} // choose one subtask out of the list
# taskId = iTaskId userId tasknr ("ChoSt" <+++ length taskOptions)
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
| chosen.value == -1 // no choice made yet
# buttonId = iTaskId userId tasknr "ChoBut"
# allButtons = if horizontal
[[(but txt,\_ -> n) \\ txt <- map fst taskOptions & n <- [0..]]]
[[(but txt,\_ -> n)] \\ txt <- map fst taskOptions & n <- [0..]]
# (choice,tst) = LiftHst (TableFuncBut (Init,pageFormId options buttonId allButtons)) tst
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId -1) choice.value) tst
| chosen.value == -1 = (createDefault,{tst & activated =False,html = html +|+ BT prompt +|+ BT choice.form})
# chosenTask = snd (taskOptions!!chosen.value)
# (a,tst=:{activated=adone,html=ahtml}) = chosenTask {tst & tasknr = [-1:tasknr], activated = True, html = BT []}
= (a,{tst & tasknr = tasknr, activated = adone, html = html +|+ ahtml})
# chosenTask = snd (taskOptions!!chosen.value)
# (a,tst=:{activated=adone,html=ahtml}) = chosenTask {tst & tasknr = [-1:tasknr], activated = True, html = BT []}
= (a,{tst & tasknr = tasknr, activated = adone, html = html +|+ ahtml})
but i = iTaskButton i
chooseTask_pdm :: !HtmlCode !Int ![LabeledTask a] -> (Task a) |iCreateAndPrint a
chooseTask_pdm prompt defaultOn taskOptions = mkTask "chooseTask_pdm" (dochooseTask_pdm taskOptions)
where
dochooseTask_pdm [] tst = return createDefault tst
dochooseTask_pdm 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
| chosen.value == -1 // no choice made yet
# numberOfItems = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfItems - 1) defaultOn 0
# taskPdMenuId = iTaskId userId tasknr ("ChoPdm" <+++ numberOfItems)
# (choice,tst) = LiftHst (FuncMenu (Init,sessionFormId options taskPdMenuId (defaultOn,[(txt,id) \\ txt <- map fst taskOptions]))) tst
# (_,tst=:{activated=adone,html=ahtml})
= editTaskLabel "" "Done" Void {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone = (createDefault,{tst & activated = False, html = html +|+ BT prompt +|+ BT choice.form +|+ ahtml, tasknr = tasknr})
# chosenIdx = snd choice.value
# chosenTask = snd (taskOptions!!chosenIdx)
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId -1) (\_ -> chosenIdx)) tst
# (a,tst=:{activated=bdone,html=bhtml})
= chosenTask {tst & activated = True, html = BT [], tasknr = [0:tasknr]}
= (a,{tst & tasknr = tasknr, activated = bdone, html = html +|+ bhtml})
# chosenTask = snd (taskOptions!!chosen.value)
# (a,tst=:{activated=adone,html=ahtml})
= chosenTask {tst & activated = True, html = BT [], tasknr = [0:tasknr]}
= (a,{tst & activated = adone, html = html +|+ ahtml, tasknr = tasknr})
// Select the tasks to do from a list with help of another task for selecting them:
chooseTask_radio :: !HtmlCode !Int ![(HtmlCode,LabeledTask a)] -> (Task a) |iCreateAndPrint a
chooseTask_radio prompt defaultOn taskOptions = mkTask "chooseTask_radio" (dochooseTask_pdm taskOptions)
selectTasks :: !([LabeledTask a] -> Task [Int]) [LabeledTask a] -> Task [a] | iData a
selectTasks chooser ltasks = newTask "selectTask" selectTasks`
where
dochooseTask_pdm [] tst = return createDefault tst
dochooseTask_pdm taskOptions tst=:{tasknr,html,userId,options} // choose one subtask out of a pulldown menu
# numberOfButtons = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfButtons - 1) defaultOn 0
# taskId = iTaskId userId tasknr ("ChoStRadio" <+++ numberOfButtons)
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId (False,defaultOn)) id) tst
# (done,choice) = chosen.value
| not done // no choice made yet
# taskRadioMenuId = iTaskId userId tasknr ("ChoRadio" <+++ numberOfButtons)
# (nradio,tst) = LiftHst (ListFuncRadio (Init,sessionFormId options taskRadioMenuId (defaultOn,[\i a -> i \\ j <- [0 .. numberOfButtons - 1]]))) tst
# choice = if nradio.changed (snd nradio.value) choice
# (nradio,tst) = LiftHst (ListFuncRadio (Set, sessionFormId options taskRadioMenuId (choice,[\i a -> i \\ j <- [0 .. numberOfButtons - 1]]))) tst
# (_,tst=:{activated=adone,html=ahtml})
= editTaskLabel "" "Done" Void {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
# (_,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId (False,defaultOn)) (\_ -> (adone,choice))) {tst & activated = adone, html = BT []}
# radioform = nradio.form <=|> [[showLabel label] <||> htmlcode \\ (htmlcode,(label,_)) <- taskOptions]
| not adone = (createDefault,{tst & activated = False, html = html +|+ BT prompt +|+ BT [radioform] +|+ ahtml, tasknr = tasknr})
# (_,chosenTask) = snd (taskOptions!!choice)
# (a,tst=:{activated=bdone,html=bhtml})
= chosenTask {tst & activated = True, html = BT [], tasknr = [0:tasknr]}
= (a,{tst & tasknr = tasknr, activated = bdone, html = html +|+ bhtml})
# (_,chosenTask) = snd (taskOptions!!choice)
# (a,tst=:{activated=adone,html=ahtml})
= chosenTask {tst & activated = True, html = BT [], tasknr = [0:tasknr]}
= (a,{tst & activated = adone, html = html +|+ ahtml, tasknr = tasknr})
chooseTask_cbox :: !([LabeledTask a] -> Task [a]) !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
chooseTask_cbox taskorderfun prompt taskOptions = mkTask "mchoiceTask" (domchoiceTasks taskOptions)
where
domchoiceTasks [] tst = ([],{tst& activated = True})
domchoiceTasks taskOptions tst=:{tasknr,html,options,userId} // choose one subtask out of the list
# seltaskId = iTaskId userId tasknr ("MtpChSel" <+++ length taskOptions)
# donetaskId = iTaskId userId tasknr "MtpChSt"
# (cboxes,tst) = LiftHst (ListFuncCheckBox (Init,cFormId options seltaskId initCheckboxes)) tst
# (fun,nblist) = cboxes.value
# nsettings = fun nblist
# (cboxes,tst) = LiftHst (ListFuncCheckBox (Set ,cFormId options seltaskId (setCheckboxes nsettings))) tst
# (done,tst) = LiftHst (mkStoreForm (Init,storageFormId options donetaskId False) id) tst
# optionsform = cboxes.form <=|> [[showLabel label] <||> htmlcode \\ ((_,_,htmlcode),(label,_)) <- taskOptions]
| done.value = taskorderfun [labeledTask \\ (_,labeledTask) <- taskOptions & True <- snd cboxes.value] {tst & tasknr = [0:tasknr]}
# (_,tst=:{html=ahtml,activated = adone})
= (editTaskLabel "" "OK" Void) {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone = ([],{tst & html = html +|+ BT prompt +|+ BT [optionsform] +|+ ahtml})
# (_,tst) = LiftHst (mkStoreForm (Init,storageFormId options donetaskId False) (\_ -> True)) tst
= domchoiceTasks taskOptions {tst & tasknr = tasknr, html = html, options = options, userId =userId, activated = True} // choose one subtask out of the list
initCheckboxes =
[(if set CBChecked CBNotChecked label, \b bs _ -> setfun b bs) \\ ((set,setfun,_),(label,_)) <- taskOptions & i <- [0..]]
setCheckboxes boollist =
[(if set CBChecked CBNotChecked label, \b bs _ -> setfun b bs) \\ ((_,setfun,_),(label,_)) <- taskOptions
& i <- [0..] & set <- boollist]
selectTasks`
= chooser ltasks
=>> \chosen -> seqTasks [ltasks!!i \\ i <- chosen]
// ******************************************************************************************************
// Speculative OR-tasks: task ends as soon as one of its subtasks completes
......@@ -262,7 +160,7 @@ orTask2 (taska,taskb) = mkTask "orTask2" (doorTask2 (taska,taskb))
where
doorTask2 (taska,taskb) tst=:{tasknr,html,options,userId}
# taskId = iTaskId userId tasknr "orTask2St"
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
| chosen.value == 0 // task a was finished first in the past
# (a,tst=:{html=ahtml}) = mkParSubTask "orTask" 0 taska {tst & tasknr = tasknr, html = BT []}
= (LEFT a,{tst & html = html})
......@@ -273,11 +171,11 @@ where
# (b,tst=:{activated=bdone,html=bhtml}) = mkParSubTask "orTask" 1 taskb {tst & tasknr = tasknr, html = BT []}
| adone
# tst = deleteSubTasksAndThreads [1:tasknr] {tst & tasknr = tasknr}
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId options taskId -1) (\_ -> 0)) {tst & html = BT []}
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) (\_ -> 0)) {tst & html = BT []}
= (LEFT a,{tst & html = html, activated = True})
| bdone
# tst = deleteSubTasksAndThreads [0:tasknr] {tst & tasknr = tasknr}
# (chosen,tst) = LiftHst (mkStoreForm (Init,storageFormId tst.options taskId -1) (\_ -> 1)) {tst & html = BT []}
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId tst.options taskId -1) (\_ -> 1)) {tst & html = BT []}
= (RIGHT b,{tst & html = html, activated = True})
= (LEFT a,{tst & activated = False, html = html +|+ ahtml +|+ bhtml})
......@@ -304,7 +202,7 @@ where
| pred myalist = (myalist,{tst & html = html, activated = True}) // stop, all work done so far satisfies predicate
# buttonnames = map fst taskCollection
# ((chosen,buttons,chosenname),tst) // user can select one of the tasks to work on
= LiftHst (mkTaskButtons True "" userId tasknr options buttonnames) tst
= liftHst (mkTaskButtons True "" userId tasknr options buttonnames) tst
# chosenTask = snd (taskCollection!!chosen)
# (a,tst=:{activated=adone,html=ahtml}) // enable the selected task (finished or not)
= mkParSubTask label chosen chosenTask {tst & tasknr = tasknr, activated = True, html = BT []}
......@@ -425,12 +323,7 @@ where
= (val,{tst & html = html /*+|+ BT [showText ("Waiting for completion of "<+++ name)]*/, tasknr = tasknr})
sharedStoreId = iTaskId userId tasknr "Shared_Store"
sharedMem fun = LiftHst (mkStoreForm (Init,storageFormId options sharedStoreId False) fun)
LiftHst fun tst=:{hst}
# (form,hst) = fun hst
= (form,{tst & hst = hst})
sharedMem fun = liftHst (mkStoreForm (Init,storageFormId options sharedStoreId False) fun)
write{|TCl|} write_a (TCl task) wst
= write{|*|} (copy_to_string task) wst
......
......@@ -36,6 +36,26 @@ repeatTask :: repeat Task until predicate is valid
repeatTask :: !(a -> Task a) !(a -> Bool) a -> Task a | iData a
(<|) infixl 6 :: !(Task a) !(a -> (Bool, HtmlCode)) -> Task a | iData a
/*
Choose the tasks you want to do one forehand:
chooseTask_btn :: choose ONE task by pressing a button, True for horizontal buttons, else vertical
chooseTask_pdm :: as chooseTask_btn, depending on pulldownmenu item selected, Int for initial value
chooseTask_radio:: as chooseTask_btn, depending on radio item selected, Int for initial value, htmlcode for option explanation
chooseTask_cb :: choice N tasks out of N, order of chosen task depending on first arg
(initial setting, effect for all when set, explanation) for each option
*/
chooseTask_btn :: !HtmlCode !Bool![LabeledTask a] -> Task a | iData a
chooseTask_pdm :: !HtmlCode !Int ![LabeledTask a] -> Task a | iData a
chooseTask_radio:: !HtmlCode !Int ![(HtmlCode,LabeledTask a)]
-> Task a | iData a
chooseTask_cbox :: !([LabeledTask a] -> Task [a])
!HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)]
-> Task [a] | iData a
/* Choose out the tasks you want to do one forehand, labels are used to make the choice:
button :: return value when button pressed
buttonTask :: do the iTask when button pressed
......@@ -51,10 +71,10 @@ mchoiceTask2 :: as mchoiceTask, boolean used for initial setting of the checks
mchoiceTask3 :: as mchoiceTask2, function can be used to (re)set the checkboxes
*/
button :: !String !a -> Task a | iCreateAndPrint a
buttonTask :: !String !(Task a) -> Task a | iCreateAndPrint a
chooseTask :: !HtmlCode ![LabeledTask a] -> Task a | iCreateAndPrint a
chooseTaskV :: !HtmlCode ![LabeledTask a] -> Task a | iCreateAndPrint a
button :: !String !a -> Task a | iData a
buttonTask :: !String !(Task a) -> Task a | iData a
chooseTask :: !HtmlCode ![LabeledTask a] -> Task a | iData a
chooseTaskV :: !HtmlCode ![LabeledTask a] -> Task a | iData a
mchoiceTasks :: !HtmlCode ![LabeledTask a] -> Task [a] | iData a
mchoiceTasks2 :: !HtmlCode ![(!Bool,LabeledTask a)] -> Task [a] | iData a
......
......@@ -7,9 +7,9 @@ implementation module iTasksCombinators
// iTask & iData Concept and Implementation: (c) 2006,2007,2008 - Rinus Plasmeijer
// *********************************************************************************************************************************
//
import StdList, StdFunc
import iDataTrivial
import iTasksBasicCombinators, iTasksHtmlSupport, iTasksTimeAndDateHandling, iTasksLiftingCombinators
import StdList, StdFunc, StdTuple
import iDataTrivial, iDataFormlib
import iTasksBasicCombinators, iTasksHtmlSupport, iTasksTimeAndDateHandling, iTasksLiftingCombinators, iTasksSettings, iTasksEditors
derive gForm []
derive gUpd []
......@@ -46,7 +46,7 @@ repeatTask :: !(a -> Task a) !(a -> Bool) a -> Task a | iData a
repeatTask task pred a = dorepeatTask a
where
dorepeatTask a
= newTask "doReapeatTask" dorepeatTask`
= newTask "repeatTask" dorepeatTask`
where
dorepeatTask` tst
| pred a = (a,tst)
......@@ -68,31 +68,156 @@ where
// Assigning tasks to users, each user has to be identified by an unique number >= 0
(@:) infix 3 :: !UserId !(LabeledTask a) -> Task a | iData a
(@:) nuserId ltask = assignTaskTo True nuserId ltask
(@:) nuserId ltask=:(taskname,task) = assigntask
where
assigntask tst=:{userId}
= ([showText ("Waiting for Task "), showLabel taskname, showText " from ", showUser nuserId,Br]
?>> assignTaskTo nuserId (taskname,[showText "Requested by ", showUser userId,Br,Br] ?>> task)) tst
showUser nr = showLabel ("User " <+++ nr)
(@::) infix 3 :: !UserId !(Task a) -> (Task a) | iData a
(@::) nuserId taska = assignTaskTo True nuserId ("Task for " <+++ nuserId,taska)
(@::) nuserId taska = nuserId @: ("Task for " <+++ nuserId,taska)
(@:>) infix 3 :: !UserId !(LabeledTask a) -> Task a | iData a
(@:>) nuserId ltask = assignTaskTo False nuserId ltask
(@:>) nuserId ltask = assignTaskTo nuserId ltask
(@::>) infix 3 :: !UserId !(Task a) -> (Task a) | iData a
(@::>) nuserId taska = assignTaskTo False nuserId ("Task for " <+++ nuserId,taska)
(@::>) nuserId taska = nuserId @:> ("Task for " <+++ nuserId,taska)
// ******************************************************************************************************
// choose one or more tasks on forehand out of a set
chooseTask_btn :: !HtmlCode !Bool![LabeledTask a] -> Task a | iData a
chooseTask_btn prompt horizontal ltasks
= selectTasks (\lt -> prompt ?>> selectTask_btn horizontal lt) ltasks =>> \la -> return_V (hd la)
where
selectTask_btn direction ltasks = newTask "selectTask_btn" (selectTask_btn` direction ltasks)
selectTask_btn` _ [] tst = return [] tst
selectTask_btn` horizontal taskOptions tst=:{tasknr,html,options,userId} // choose one subtask out of the list
# taskId = iTaskId userId tasknr ("ChoSt" <+++ length taskOptions)
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) id) tst
| chosen.value == -1 // no choice made yet
# buttonId = iTaskId userId tasknr "ChoBut"
# allButtons = if horizontal
[[(iTaskButton txt,\_ -> n) \\ txt <- map fst taskOptions & n <- [0..]]]
[[(iTaskButton txt,\_ -> n)] \\ txt <- map fst taskOptions & n <- [0..]]
# (choice,tst) = liftHst (TableFuncBut (Init,pageFormId options buttonId allButtons)) tst
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) choice.value) tst
| chosen.value == -1 = ([],{tst & activated = False,html = html +|+ BT choice.form})
= ([chosen.value],{tst & tasknr = tasknr, activated = True, html = html})
= ([chosen.value],{tst & tasknr = tasknr, activated = True, html = html})
chooseTask_pdm :: !HtmlCode !Int ![LabeledTask a] -> Task a | iData a
chooseTask_pdm prompt initial ltasks
= selectTasks (\lt -> prompt ?>> selectTask_pdm initial lt) ltasks =>> \la -> return_V (hd la)
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
| chosen.value == -1 // no choice made yet
# numberOfItems = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfItems - 1) defaultOn 0
# taskPdMenuId = iTaskId userId tasknr ("ChoPdm" <+++ numberOfItems)
# (choice,tst) = liftHst (FuncMenu (Init,sessionFormId options taskPdMenuId (defaultOn,[(txt,id) \\ txt <- map fst taskOptions]))) tst
# (_,tst=:{activated=adone,html=ahtml})
= editTaskLabel "" "Done" Void {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone = ([],{tst & activated = False, html = html +|+ BT prompt +|+ BT choice.form +|+ ahtml, tasknr = tasknr})
# chosenIdx = snd choice.value
# chosenTask = snd (taskOptions!!chosenIdx)
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId -1) (\_ -> chosenIdx)) tst
= ([chosen.value],{tst & tasknr = tasknr, activated = True, html = html})
= ([chosen.value],{tst & activated = True, html = html, tasknr = tasknr})
/*
selectTask_pdm :: !Int ![LabeledTask a] -> Task [Int]
selectTask_pdm defaultOn taskOptions = dochooseTask_pdm taskOptions
where
dochooseTask_pdm [] tst = return createDefault tst
dochooseTask_pdm taskOptions tst=:{tasknr,html,userId,options} // choose one subtask out of a pulldown menu
# numberOfItems = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfItems - 1) defaultOn 0
# taskPdMenuId = iTaskId userId tasknr ("ChoPdm" <+++ numberOfItems)
# (choice,tst) = liftHst (FuncMenu (Init,sessionFormId options taskPdMenuId (defaultOn,[(txt,id) \\ txt <- map fst taskOptions]))) tst
# (_,tst=:{activated=adone,html=ahtml})
= editTaskLabel "" "Done" Void {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone = (createDefault,{tst & activated = False, html = html +|+ BT choice.form +|+ ahtml, tasknr = tasknr})
= ([snd choice.value],{tst & activated = True, html = html, tasknr = tasknr})
*/
chooseTask_radio:: !HtmlCode !Int ![(HtmlCode,LabeledTask a)] -> Task a | iData a
chooseTask_radio prompt initial code_ltasks
= selectTasks (\lt -> prompt ?>> selectTask_radio initial (map fst code_ltasks) lt) (map snd code_ltasks) =>> \la -> return_V (hd la)
where
selectTask_radio :: !Int ![HtmlCode] ![LabeledTask a] -> Task [Int]
selectTask_radio defaultOn htmlcodes taskOptions = dochooseTask_pdm taskOptions
where
dochooseTask_pdm [] tst = return createDefault tst
dochooseTask_pdm taskOptions tst=:{tasknr,html,userId,options} // choose one subtask out of a pulldown menu
# numberOfButtons = length taskOptions
# defaultOn = if (defaultOn >= 0 && defaultOn <= numberOfButtons - 1) defaultOn 0
# taskId = iTaskId userId tasknr ("ChoStRadio" <+++ numberOfButtons)
# taskRadioMenuId = iTaskId userId tasknr ("ChoRadio" <+++ numberOfButtons)
# (chosen,tst) = liftHst (mkStoreForm (Init,storageFormId options taskId defaultOn) id) tst
# (nradio,tst) = liftHst (ListFuncRadio (Init,sessionFormId options taskRadioMenuId (defaultOn,[\i a -> i \\ j <- [0 .. numberOfButtons - 1]]))) tst
# choice = if nradio.changed (snd nradio.value) chosen.value
# (nradio,tst) = liftHst (ListFuncRadio (Set, sessionFormId options taskRadioMenuId (choice,[\i a -> i \\ j <- [0 .. numberOfButtons - 1]]))) tst
# (_,tst=:{activated=adone,html=ahtml})
= editTaskLabel "" "Done" Void {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone
# (chosen,tst) = liftHst (mkStoreForm (Set,storageFormId options taskId choice) id) {tst & activated = adone, html = BT []}
# radioform = nradio.form <=|> [[showLabel label] <||> htmlcode \\ htmlcode <- htmlcodes & (label,_) <- taskOptions]
= (createDefault,{tst & activated = False, html = html +|+ BT [radioform] +|+ ahtml, tasknr = tasknr})
= ([choice],{tst & activated = True, html = html, tasknr = tasknr})
chooseTask_cbox :: !([LabeledTask a] -> Task [a]) !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
chooseTask_cbox whatisthis prompt code_ltasks
= selectTasks (\lt -> prompt ?>> selectTask_cbox (map fst code_ltasks) lt) (map snd code_ltasks)
where
selectTask_cbox :: ![(!Bool,!ChoiceUpdate,!HtmlCode)] ![LabeledTask a] -> Task [Int]
selectTask_cbox htmlcodes taskOptions = domchoiceTasks taskOptions
where
domchoiceTasks [] tst = ([],{tst& activated = True})
domchoiceTasks taskOptions tst=:{tasknr,html,options,userId} // choose one subtask out of the list
# seltaskId = iTaskId userId tasknr ("MtpChSel" <+++ length taskOptions)
# donetaskId = iTaskId userId tasknr "MtpChSt"
# (cboxes,tst) = liftHst (ListFuncCheckBox (Init,cFormId options seltaskId initCheckboxes)) tst
# (fun,nblist) = cboxes.value
# nsettings = fun nblist
# (cboxes,tst) = liftHst (ListFuncCheckBox (Set ,cFormId options seltaskId (setCheckboxes nsettings))) tst
# (done,tst) = liftHst (mkStoreForm (Init,storageFormId options donetaskId False) id) tst
# (_,tst=:{html=ahtml,activated = adone})
= (editTaskLabel "" "OK" Void) {tst & activated = True, html = BT [], tasknr = [-1:tasknr]}
| not adone
# optionsform = cboxes.form <=|> [[showLabel label] <||> htmlcode \\ (_,_,htmlcode) <- htmlcodes & (label,_) <- taskOptions]
= ([],{tst & html = html +|+ BT [optionsform] +|+ ahtml})
# (_,tst) = liftHst (mkStoreForm (Init,storageFormId options donetaskId False) (\_ -> True)) tst
= ([i \\ True <- snd cboxes.value & i <- [0..]],{tst & tasknr = tasknr, html = html, options = options, userId =userId, activated = True}) // choose one subtask out of the list
initCheckboxes =
[(if set CBChecked CBNotChecked label, \b bs _ -> setfun b bs) \\ (set,setfun,_) <- htmlcodes & (label,_) <- taskOptions & i <- [0..]]
setCheckboxes boollist =
[(if set CBChecked CBNotChecked label, \b bs _ -> setfun b bs) \\ (_,setfun,_) <- htmlcodes & (label,_) <- taskOptions
& i <- [0..] & set <- boollist]
// ******************************************************************************************************
// choose one or more tasks on forehand out of a set
button :: !String !a -> (Task a) | iCreateAndPrint a
button s a = mkTask "button" (chooseTask_btn [] True [(s,return_V a)])
button :: !String !a -> (Task a) | iData a
button s a = newTask "button" (chooseTask_btn [] True [(s,return_V a)])
buttonTask :: !String !(Task a) -> (Task a) | iCreateAndPrint a
buttonTask s task = mkTask "buttonTask" (chooseTask_btn [] True [(s,task)])
buttonTask :: !String !(Task a) -> (Task a) | iData a
buttonTask s task = newTask "buttonTask" (chooseTask_btn [] True [(s,task)])
chooseTask :: !HtmlCode ![LabeledTask a] -> (Task a) | iCreateAndPrint a
chooseTask prompt options = mkTask "chooseTask" (chooseTask_btn prompt True options)
chooseTask :: !HtmlCode ![LabeledTask a] -> (Task a) | iData a
chooseTask prompt options = newTask "chooseTask" (chooseTask_btn prompt True options)
chooseTaskV :: !HtmlCode ![LabeledTask a] -> (Task a) | iCreateAndPrint a
chooseTaskV prompt options = mkTask "chooseTask" (chooseTask_btn prompt False options)
chooseTaskV :: !HtmlCode ![LabeledTask a] -> (Task a) | iData a
chooseTaskV prompt options = newTask "chooseTaskV" (chooseTask_btn prompt False options)
mchoiceTasks :: !HtmlCode ![LabeledTask a] -> (Task [a]) | iData a
mchoiceTasks prompt taskOptions
......
......@@ -128,7 +128,7 @@ where
scheduleWorkflows :: !(Task a) -> (Task a) | iData a
scheduleWorkflows maintask
# nmaintask = newTask defaultWorkflowName (assignTaskT