Commit ee41bed8 authored by ecrombag's avatar ecrombag

Handle 404-response from task-service in case a task no longer exists. This...

Handle 404-response from task-service in case a task no longer exists. This presents a task-is-redundant message to the user an closes the tab.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1131 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 29396a2a
......@@ -46,27 +46,12 @@ itasks.RemoteDataPanel = Ext.extend(Ext.Panel, {
itasks.app.restart(data.error);
return;
}
callback.call(this,data);
callback.call(this,data,true);
} else {
callback.call(this,response.responseText);
}
callback.call(this,response.responseText,true);
}
} else {
var win = new Ext.Window({
title: "Error",
html: response.statusText,
width: 200,
height: 100,
modal: true,
closable: true,
bodyStyle: "padding: 5px",
buttons: [{
text: "Ok",
handler: function() {win.close();}
}],
buttonAlign: "center"
});
win.show();
callback.call(this,response.error,false);
}
this.busy = false;
this.fireEvent("remoteCallEnd");
......@@ -83,7 +68,7 @@ itasks.RemoteDataPanel = Ext.extend(Ext.Panel, {
/*
* This method must be implemented to handle a refresh event
*/
update: function(data) {
update: function(data,success) {
}
});
......
......@@ -94,32 +94,29 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
this.getComponent(0).setBusy(false);
},this);
},
update: function(data) {
update: function(data,success) {
//Check if the task is finished or became redundant
if(data.tui == "done" || data.tui == "redundant") {
if(success == false || data.tui == "done" || data.tui == "redundant") {
var ct = this.getComponent(1);
if(ct.items && ct.items.length) {
ct.remove(0);
}
switch(data.tui) {
case "done":
ct.add({
xtype: 'itasks.ttc.finished',
msg: "This task is completed. Thank you."
});
this.fireEvent("taskDone");
break;
case "redundant":
ct.add({
xtype: 'itasks.ttc.finished',
msg: "The completion of this task is no longer required.<br />It has been removed. Thank you for your effort."
});
this.fireEvent("taskRedundant");
break;
if(!success || data.tui == "redundant"){
msg = "The completion of this task is no longer required.<br />It has been removed. Thank you for your effort.";
this.fireEvent("taskRedundant");
}else{
msg = "This task is completed. Thank you.";
this.fireEvent("taskDone");
}
ct.add({
xtype: 'itasks.ttc.finished',
msg: msg
});
ct.doLayout();
var tp = this.findParentByType("itasks.worktabs");
......@@ -134,7 +131,6 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
}
}
);
return;
}
//Update properties
......@@ -204,7 +200,9 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
var params = {};
var cb = function(data){
if(data.success)
(function(){me.refresh()}).defer(50);
(function(){
me.update({},false); //send a blank update, this will mark the tab as redundant.
}).defer(50);
else
Ext.Msg.alert('Error','Failed to cancel task: '+data.error);
};
......
......@@ -42,8 +42,8 @@ itasks.ttc.ProcessControlContainer = Ext.extend(Ext.Panel,{
var url = itasks.config.serviceUrl+'/json/tasks/'+this.properties.systemProperties.taskId+ '/managerProperties/worker';
var upd = (nv != "")?'["NamedUser",'+Ext.encode(nv)+']':nv;
var cb = function(response){
if(!response.success) {
var cb = function(response,success){
if(!response.success || !success) {
Ext.Msg.alert("Error","An error has occurred: "+response.error);
}else{
ct.fireEvent("propertyChanged");
......@@ -66,8 +66,8 @@ itasks.ttc.ProcessControlContainer = Ext.extend(Ext.Panel,{
var url = itasks.config.serviceUrl+'/json/tasks/'+this.properties.systemProperties.taskId+ '/managerProperties/priority';
var upd = Ext.encode(nv);
var cb = function(response){
if(!response.success) {
var cb = function(response,success){
if(!response.success || !success) {
Ext.Msg.alert("Error","An error has occurred: "+response.error);
}else{
ct.fireEvent("propertyChanged");
......
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