diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 48d2cd2c..89315323 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -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) { diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index c29f334f..0a66d0ad 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -1,4 +1,19 @@ /* @todo move to theme css */ +/******************************************************************* + * Dialog wide stylings + */ +#gOrganizeStatus { + height: 6em; + border: 1px solid #999; + margin-top: .5em; + margin-bottom: .5em; + overflow-y: auto; +} + +#gOrganizeProgressDialog { + text-align: left; +} + /******************************************************************* * Album Tree styling */ diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index ac3984d5..1eac785b 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -112,7 +112,7 @@ var treeDroppable = { var moveItems = ""; var targetItemId = $(this).attr("ref"); if ($(this).hasClass("gBranchSelected")) { - // @todo Error message for moving onto self + $("#gOrganizeStatus").append(INVALID_DROP_TARGET); ui.draggable.trigger("stop", event); return false; } @@ -122,7 +122,7 @@ var treeDroppable = { okToMove &= targetItemId != $(this).attr("ref"); }); if (!okToMove) { - // @todo Error message for moving onto self + $("#gOrganizeStatus").append(INVALID_DROP_TARGET); ui.draggable.trigger("stop", event); return false; } @@ -223,9 +223,10 @@ var getMicroThumbsCallback = function(json, textStatus) { // as they are basically the same. var startMoveCallback = function (data, textStatus) { if (!paused) { - $("#gDialog #ft").css("visibility", "visible"); - $(".gProgressBar").progressbar("value", 0); + createProgressDialog(OPERATION_RUNNING); task = data.task; + task.pauseMsg = MOVE_PAUSED; + task.resumeMSg = MOVE_RESUMED; } $(".gMicroThumbContainer").draggable("disable"); var done = false; @@ -246,9 +247,12 @@ var startMoveCallback = function (data, textStatus) { }); } if (!paused) { - $("#gDialog #ft").css("visibility", "hidden"); + $("#gOrganizeProgressDialog").dialog("destroy").remove(); $.ajax({async: false, success: function(data, textStatus) { + task = null; + transitItems = []; + $("#gOrganizeStatus").append("