NewStartHandler.icl 1.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
implementation module NewStartHandler

import StdEnv
import Http, Session
import JSON
import InternaliTasksCommon


:: NewWorkItem	= 	{ icon		:: String 	// An icon name. The actual icon image is defined in the css. 
					, label		:: String 	// A label of the workflow that is started
					}

derive JSONEncode NewWorkItem

15 16 17 18
handleNewStartRequest :: !(LabeledTask a) !Int !HTTPRequest !Session *HSt -> (!HTTPResponse, !*HSt) | iData a
handleNewStartRequest labeledTask mainuser request session hst	
	# (taskid,hst) = startNewProcess labeledTask hst
	= ({http_emptyResponse & rsp_data = response taskid}, hst)
19 20
where
	workflow = http_getValue "workflow" request.arg_get ""
21
	response taskid = "{\"success\" : true, \"taskid\": \""  +++ (toString taskid) /* workflow */ +++ "\"}"
22
	
23 24 25 26 27 28 29 30 31 32
	thisUser		= session.Session.userId							// fetch user id from the session
	
	startNewProcess labeledTask hst 
	# tst 				= mkTst mainuser LSTxtFile LSTxtFile hst			// create initial tst	
	# (processId, tst) 	= latestProcessId tst
	# (wid,tst=:{hst}) 	= appTaskTSt (spawnWorkflow thisUser True labeledTask) {tst & tasknr = [processId]}
	= (getProcessId wid, hst)
	
	
import iTasksProcessHandling, Combinators, iTasksEditors