Commit b7c63eb4 authored by Bas Lijnse's avatar Bas Lijnse

Intermediate commit with small cleanup in the task tree filtering

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/fancyTasks@291 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 707a1ea3
......@@ -27,9 +27,9 @@ handleWorkTabRequest :: !(Task a) !HTTPRequest !Session *HSt -> (!HTTPResponse,
handleWorkTabRequest mainTask request session hst
# thisUserId = session.Session.userId // fetch user id from the session
# taskId = http_getValue "taskid" request.arg_get "error" // fetch task id of the tab selecetd
# (toServer, htmlTree, maybeError, maybeTrace, maybeProcessTable, maybeThreadTable, hst)
# (toServer, htmlTree, maybeError, maybeTrace, maybeProcessTable, maybeThreadTable, hst =:{states,world})
= calculateTaskTree thisUserId True True True mainTask hst // calculate the TaskTree given the id of the current user
# (taskDone,html,inputs,hst =:{states,world}) = determineTaskForTab thisUserId taskId htmlTree hst // filter out the code and inputs to display in this tab
# (taskDone,html,inputs) = determineTaskForTab thisUserId taskId htmlTree // filter out the code and inputs to display in this tab
# (htmlstates,states) = getHtmlStates states // Collect states that must be temporarily stored in the browser
# (states,world) = storeServerStates states world // Write states that are stored on the server
......
......@@ -9,12 +9,13 @@ definition module TaskTreeFilters
import iTasksTypes
/*
TODO: Update
noFilter :: Without applying any filter it fetches all html code out of the HtmlTree
Filter :: Filters out the html code for a specific user
Arguments: Bool True if a whole new page has to be generated,
First UserId is id of user logged in,
Second UserId is id of user that owns the thread (if it is a thread),
The HtmlTree to inspects,
The HtmlTree to inspect,
The HSt for generating navigation buttons.
Returns: Whole new page html code for the task (if a whole page is demanded),
header indicating chosen task, buttons to choose a main task, buttons to choose a subtask)
......@@ -22,14 +23,13 @@ Filter :: Filters out the html code for a specific user
*/
noFilter :: !HtmlTree -> [HtmlTag]
Filter :: !Bool !UserId !UserId !HtmlTree !*HSt -> *(![HtmlTag],![HtmlTag],![HtmlTag],![HtmlTag],![HtmlTag],![InputId],!*HSt)
//TODO: Refactor filter function. Does way to much at the same time
mkFilteredTaskTree :: !Bool !UserId !UserId !HtmlTree -> (![HtmlTag],![HtmlTag],![InputId])
mkUnfilteredTaskTree :: !HtmlTree -> ([HtmlTag],[InputId])
collectTaskList :: !(TaskDescription -> Bool) !HtmlTree -> [TaskDescription] // returns who created the task, the tasknr, and taskname
determineTaskForTab :: !UserId !TaskNrId !HtmlTree !*HSt -> (!Bool,![HtmlTag],![InputId],!*HSt)
determineTaskForTab :: !UserId !TaskNrId !HtmlTree -> (!Bool,![HtmlTag],![InputId])
//TODO: merge trace information into the task tree
showTaskTreeOfTask :: !TaskNrId !(Maybe [Trace]) -> HtmlTag
......
......@@ -30,13 +30,13 @@ collectTaskList pred (BT bdtg inputs)
collectTaskList pred (DivCode id tree)
= collectTaskList pred tree
determineTaskForTab :: !UserId !TaskNrId !HtmlTree !*HSt -> (!Bool,![HtmlTag],![InputId],!*HSt)
determineTaskForTab thisuser thistaskid tree hst
determineTaskForTab :: !UserId !TaskNrId !HtmlTree -> (!Bool,![HtmlTag],![InputId])
determineTaskForTab thisuser thistaskid tree
# mytree = determineTaskTree thisuser thistaskid tree
| isNothing mytree = (True,[],[],hst)
# (threadcode,taskname,mainbuts,subbuts,seltask,inputs,hst) = Filter True thisuser thisuser (fromJust mytree) hst
| isEmpty threadcode = (False, seltask, inputs, hst)
= (False, threadcode, inputs, hst)
| isNothing mytree = (True,[],[])
# (threadcode,seltask,inputs) = mkFilteredTaskTree True thisuser thisuser (fromJust mytree)
| isEmpty threadcode = (False, seltask, inputs)
= (False, threadcode, inputs)
determineTaskTree :: !UserId !TaskNrId !HtmlTree -> Maybe HtmlTree
determineTaskTree thisuser thistaskid (taskdescr @@: tree)
......@@ -58,25 +58,17 @@ determineTaskTree thisuser thistaskid (BT bdtg inputs)
determineTaskTree thisuser thistaskid (DivCode id tree)
= determineTaskTree thisuser thistaskid tree
noFilter :: !HtmlTree -> [HtmlTag]
noFilter (BT body inputs) = body
noFilter (_ @@: html) = noFilter html
noFilter (_ -@: html) = noFilter html
noFilter (htmlL +-+ htmlR) = [noFilter htmlL <=> noFilter htmlR]
noFilter (htmlL +|+ htmlR) = noFilter htmlL <|.|> noFilter htmlR
noFilter (DivCode str html) = noFilter html
Filter :: !Bool !UserId !UserId !HtmlTree !*HSt -> *(![HtmlTag],![HtmlTag],![HtmlTag],![HtmlTag],![HtmlTag],![InputId],!*HSt)
Filter wholepage thisUser thrOwner tree hst
mkFilteredTaskTree :: !Bool !UserId !UserId !HtmlTree -> (![HtmlTag],![HtmlTag],![InputId])
mkFilteredTaskTree wholepage thisUser thrOwner tree
# startuser = if wholepage defaultUser thrOwner
# (threadcode,threadinputs,accu) = collect thisUser startuser [](initialTaskDescription @@: tree) // KLOPT DIT WEL ??
| isEmpty accu = (threadcode,[],[],[],[],threadinputs,hst)
# (threadcode,threadinputs,accu) = collect thisUser startuser [] (initialTaskDescription @@: tree) // KLOPT DIT WEL ??
| isEmpty accu = (threadcode,[],threadinputs)
# accu = sortBy (\(i,_,_,_,_) (j,_,_,_,_) -> i < j) accu
# (workflownames,subtasks) = unziptasks accu
# (subtasksnames,tcode) = unzipsubtasks (hd subtasks)
# (selcode, selinputs) = hd tcode
= (threadcode,[],[],[], selcode, selinputs, hst) //TODO: Ditch the three empty lists
= (threadcode, selcode, selinputs)
where
unziptasks :: ![(!ProcessNr,!WorkflowLabel,!TaskLabel,![HtmlTag],![InputId])] -> (![WorkflowLabel],![[(!ProcessNr,!WorkflowLabel,!TaskLabel,![HtmlTag],![InputId])]])
unziptasks [] = ([],[])
......@@ -134,6 +126,21 @@ collect thisuser taskuser accu (DivCode id tree)
| thisuser == taskuser = ([DivTag [IdAttr id, ClassAttr "itasks-thread"] html],inputs,accu)
= ([],[],accu)
mkUnfilteredTaskTree :: !HtmlTree -> ([HtmlTag],[InputId])
mkUnfilteredTaskTree (BT body inputs) = (body, inputs)
mkUnfilteredTaskTree (_ @@: html) = mkUnfilteredTaskTree html
mkUnfilteredTaskTree (_ -@: html) = mkUnfilteredTaskTree html
mkUnfilteredTaskTree (DivCode str html) = mkUnfilteredTaskTree html
mkUnfilteredTaskTree (nodeL +-+ nodeR) = ([htmlL <=> htmlR],inpL ++ inpR)
where
(htmlL,inpL) = mkUnfilteredTaskTree nodeL
(htmlR,inpR) = mkUnfilteredTaskTree nodeR
mkUnfilteredTaskTree (nodeL +|+ nodeR) = (htmlL <|.|> htmlR, inpL ++ inpR)
where
(htmlL,inpL) = mkUnfilteredTaskTree nodeL
(htmlR,inpR) = mkUnfilteredTaskTree nodeR
// ******************************************************************************************************
// Trace Printing ...
// ******************************************************************************************************
......
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