1) Move the progress bar to a dialog

2) Provide status and error messages back to the user
This commit is contained in:
Tim Almdal
2009-04-23 20:48:09 +00:00
parent 2890eb7589
commit 465182e58f
4 changed files with 116 additions and 54 deletions

View File

@@ -105,11 +105,12 @@ class Organize_Controller extends Controller {
$task = ORM::factory("task", $task_id);
if ($task->done) {
if ($task->context["type"] == "moveTo") {
$item = ORM::factory("item", (int)$task->get("target"));
$type = $task->get("type");
if ($type == "moveTo") {
$task->status = t("Move to '%album' completed", array("album" => $item->title));
} else if ($task->context["type"] == "rearrange") {
} else if ($type == "rearrange") {
try {
$item = ORM::factory("item", $task->context["target"]);
$item->sort_column = "weight";
$item->save();
$task->status = t("Rearrange for '%album' completed", array("album" => $item->title));
@@ -119,10 +120,16 @@ class Organize_Controller extends Controller {
}
}
$task->save();
}
}
batch::stop();
print json_encode(array("result" => "success"));
print json_encode(array("result" => "success",
"task" => array(
"id" => $task->id,
"percent_complete" => $task->percent_complete,
"status" => $task->status,
"state" => $task->state,
"done" => $task->done)));
}
function cancelTask($task_id) {
@@ -133,16 +140,23 @@ class Organize_Controller extends Controller {
if (!$task->done) {
$task->done = 1;
$task->state = "cancelled";
if ($task->context["type"] == "moveTo") {
$type = $task->get("type");
if ($type == "moveTo") {
$task->status = t("Move to album was cancelled prior to completion");
} else if ($task->context["type"] == "rearrange") {
} else if ($type == "rearrange") {
$task->status = t("Rearrange album was cancelled prior to completion");
}
$task->save();
}
}
batch::stop();
print json_encode(array("result" => "success"));
print json_encode(array("result" => "success",
"task" => array(
"id" => $task->id,
"percent_complete" => $task->percent_complete,
"status" => $task->status,
"state" => $task->state,
"done" => $task->done)));
}
function moveStart($id) {