summaryrefslogtreecommitdiff
path: root/modules/organize
diff options
context:
space:
mode:
Diffstat (limited to 'modules/organize')
-rw-r--r--modules/organize/controllers/organize.php25
-rw-r--r--modules/organize/js/organize.js21
-rw-r--r--modules/organize/views/organize.html.php1
3 files changed, 31 insertions, 16 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 129fb8bb..48d2cd2c 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -105,11 +105,9 @@ class Organize_Controller extends Controller {
$task = ORM::factory("task", $task_id);
if ($task->done) {
- switch ($task->context["type"]) {
- case "moveTo":
+ if ($task->context["type"] == "moveTo") {
$task->status = t("Move to '%album' completed", array("album" => $item->title));
- break;
- case "rearrange":
+ } else if ($task->context["type"] == "rearrange") {
try {
$item = ORM::factory("item", $task->context["target"]);
$item->sort_column = "weight";
@@ -119,7 +117,6 @@ class Organize_Controller extends Controller {
$task->state = "error";
$task->status = $e->getMessage();
}
- break;
}
$task->save();
}
@@ -133,16 +130,16 @@ class Organize_Controller extends Controller {
$task = ORM::factory("task", $task_id);
- if ($task->done) {
- switch ($task->context["type"]) {
- case "moveTo":
- message::warning(t("Move to album was cancelled prior to completion"));
- break;
- case "rearrange":
- message::warning(t("Rearrange album was cancelled prior to completion"));
- break;
+ if (!$task->done) {
+ $task->done = 1;
+ $task->state = "cancelled";
+ if ($task->context["type"] == "moveTo") {
+ $task->status = t("Move to album was cancelled prior to completion");
+ } else if ($task->context["type"] == "rearrange") {
+ $task->status = t("Rearrange album was cancelled prior to completion");
}
- }
+ $task->save();
+ }
batch::stop();
print json_encode(array("result" => "success"));
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 4ca7e844..ac3984d5 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -1,7 +1,5 @@
/*
* @todo Trap resize of dialog and resize the child areas (tree, grid and edit form)
- * @todo Create a cancel button that leaves the task in pending but clears the task info
- * and resets the paused.
* @todo Create a message area in the footer for all the organize messages
*/
var url;
@@ -350,12 +348,31 @@ function organize_dialog_init() {
paused = true;
$("#gOrganizeTaskPause").hide();
$("#gOrganizeTaskResume").show();
+ $("#gOrganizeTaskCancel").show();
});
$("#gOrganizeTaskResume").click(function(event) {
$("#gOrganizeTaskPause").show();
$("#gOrganizeTaskResume").hide();
+ $("#gOrganizeTaskCancel").hide();
startRearrangeCallback();
});
+ $("#gOrganizeTaskCancel").click(function(event) {
+ $("#gDialog #ft").css("visibility", "hidden");
+ $("#gOrganizeTaskPause").show();
+ $("#gOrganizeTaskResume").hide();
+ $("#gOrganizeTaskCancel").hide();
+ // @todo reset the state (i.e pause, do ajax call pause to delete task)
+ $.ajax({async: false,
+ success: function(data, textStatus) {
+ task = null;
+ paused = false;
+ transitItems = [];
+ },
+ dataType: "json",
+ type: "POST",
+ url: get_url("organize/cancelTask", {task_id: task.id})
+ });
+ });
}
function retrieveMicroThumbs() {
diff --git a/modules/organize/views/organize.html.php b/modules/organize/views/organize.html.php
index e679f907..95bab1ea 100644
--- a/modules/organize/views/organize.html.php
+++ b/modules/organize/views/organize.html.php
@@ -36,6 +36,7 @@
<div id="ft" style="visibility: hidden">
<a id="gOrganizeTaskPause" href="#" class="submit"><?= t("Pause") ?></a>
<a id="gOrganizeTaskResume" href="#" style="display: none" class="submit"><?= t("Resume") ?></a>
+ <a id="gOrganizeTaskCancel" href="#" style="display: none" class="submit"><?= t("Cancel") ?></a>
<div class="gProgressBar">
</div>
</div>