Commit 550328ea authored by ecrombag's avatar ecrombag

Added possibility to Cancel tasks.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1121 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent c3b82fda
......@@ -32,7 +32,7 @@ itasks.RemoteDataPanel = Ext.extend(Ext.Panel, {
url: url,
params: params,
scripts: false,
callback: function (el,success,response, options) {
callback: function (options,success,response) {
if(success) {
var data;
try {
......
......@@ -35,16 +35,34 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
anchor: 'bottom 0'
},
tbar: [{
text: "Refresh task",
iconCls: "x-tbar-loading",
listeners: {
click: {
scope: this,
fn: function (btn) {
text: 'Task Actions',
iconCls: 'icon-properties',
menu: {
id: 'taskMenu',
items: [{
text: 'Refresh Task',
iconCls: 'x-tbar-loading',
scope: this,
handler: function(item,evt){
this.refresh();
}
},{
text: 'Task Properties' ,
iconCls: 'icon-properties',
disabled: true
},{
text: 'Discuss Task',
iconCls: 'icon-chat',
disabled: true
},'-',{
text: 'Cancel Task',
iconCls: 'icon-trash',
scope: this,
handler: function(item,evt){
this.cancel();
}
}
}]
}
}]
}]
});
......@@ -124,9 +142,8 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
this.updateTitle(data.subject);
//Update content
this.updateContent(data.content);
//Update status
//this.updateStatus(data.properties);
//Update Toolbar
this.updateToolbar(data.properties);
//Reset params, events and states
this.params =
{ _maintask : this.taskId
......@@ -157,8 +174,9 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
this.initialized = true;
}
},
updateStatus: function(properties) {
this.getComponent(1).getComponent(1).update(properties);
updateToolbar: function(properties) {
// var cancelMI = this.getComponent(1).getTopToolbar().getComponent(0).getComponent(3);
// console.log(cancelMI);
},
sendTaskUpdates: function(target,updates) {
//Add task updates to params
......@@ -184,6 +202,25 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
},
scope: this
});
},
cancel : function(){
var me = this;
var doCancel = function(btn){
if(btn == "yes"){
var url = itasks.config.servicesUrl + "/json/tasks/" + me.taskId + "/cancel";
var params = {};
var cb = function(data){
if(data.success)
(function(){me.refresh()}).defer(50);
else
Ext.Msg.alert('Error','Failed to cancel task: '+data.error);
};
me.remoteCall(url,params,cb);
}
}
Ext.Msg.confirm("Cancel Task","Are you sure you wish to cancel this task?",doCancel);
}
});
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
......@@ -137,6 +137,15 @@ button.icon-expand-tree, .icon-expand-tree {
.icon-edit{
background-image: url('img/icons/pencil.png') !important;
}
.icon-properties{
background-image: url('img/icons/table_gear.png') !important;
}
.icon-chat{
background-image: url('img/icons/comment.png') !important;
}
.icon-trash {
background-image: url('img/icons/trash.png') !important;
}
#userdisplay {
color: #3a81ad;
......
......@@ -93,8 +93,24 @@ taskService url html path req tst
_
# json = JSONObject [("success",JSONBool True),("task",toJSON task),("menu",JSONNull),("tui",JSONNull)]
= (serviceResponse html "task user interface" url tuiParams json, {TSt|tst & menusChanged = menusChanged})
//Cancel / Abort / Delete the current task
[taskId,"cancel"]
| isJust mbSessionErr
= (serviceResponse html "task user interface" url tuiParams (jsonSessionErr mbSessionErr), tst)
# (mbProcess, tst) = getProcessForTask taskId tst
= case mbProcess of
Nothing
= (notFoundResponse req, tst)
Just proc
// check whether the current user is allowed to cancel the task (user == manager)
# (mbUProcess, tst) = case session.Session.user of
RootUser = (Just proc,tst)
user = getProcessForManager user proc.Process.taskId tst
| not (isJust mbUProcess)
= (serviceResponse html "cancel task" url tuiParams (JSONObject [("success",JSONBool False),("error",JSONString "You do not have permission to cancel this task")]), tst)
# tst = deleteTaskInstance proc.Process.taskId tst
= (serviceResponse html "cancel task" url tuiParams (JSONObject [("success",JSONBool True),("message",JSONString "Task deleted")]), tst)
//Show / update Manager properties
[taskId,"managerProperties"]
| isJust mbSessionErr
......
......@@ -384,7 +384,6 @@ setStatus :: ![HtmlTag] !*TSt -> *TSt //Only for monitor tasks
setGroupActions :: ![(Action, (Either Bool (*TSt -> *(!Bool,!*TSt))))] !*TSt -> *TSt //Only for group tasks
setFocusCommand :: !String !*TSt -> *TSt //Only for group tasks
//EVENTS
/**
* Get the events (name/value pairs) for the current task
......
......@@ -175,9 +175,9 @@ where
deleteTaskInstance :: !ProcessId !*TSt -> *TSt
deleteTaskInstance procId tst
# (_,tst) = deleteProcess procId tst
# (_,tst) = deleteProcess procId tst
# tst=:{TSt | iworld=iworld=:{store,world}} = deleteSubProcesses procId tst
# (store,world) = deleteValues (iTaskId (taskNrFromString procId) "") store world
# (store,world) = deleteValues (iTaskId (taskNrFromString procId) "") store world
= {TSt | tst & iworld = {iworld & world = world, store = store}}
garbageCollectTaskInstance :: !ProcessId !*TSt -> (!Bool,!*TSt)
......
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