summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/organize/controllers/organize.php15
-rw-r--r--modules/organize/views/organize_frame.html.php53
2 files changed, 65 insertions, 3 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 62417525..4e6178b6 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -159,6 +159,21 @@ class Organize_Controller extends Controller {
json::reply(null);
}
+ function delete() {
+ access::verify_csrf();
+
+ $input = Input::instance();
+
+ foreach (explode(",", $input->post("item_ids")) as $item_id) {
+ $item = ORM::factory("item", $item_id);
+ if (access::can("edit", $item)) {
+ $item->delete();
+ }
+ }
+
+ json::reply(null);
+ }
+
private function _get_tree($item, $selected) {
$tree = array();
$children = $item->viewable()
diff --git a/modules/organize/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php
index 0354fa1d..6dfa54d6 100644
--- a/modules/organize/views/organize_frame.html.php
+++ b/modules/organize/views/organize_frame.html.php
@@ -11,6 +11,13 @@
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "<?= url::file("modules/organize/vendor/ext/images/default/s.gif") ?>";
Ext.Ajax.timeout = 1000000; // something really large
+ // I18N for dialog boxes.
+ Ext.Msg.buttonText = {
+ ok: <?= t("OK")->for_js() ?>,
+ cancel: <?= t("Cancel")->for_js() ?>,
+ yes: <?= t("Yes")->for_js() ?>,
+ no: <?= t("No")->for_js() ?>
+ };
Ext.onReady(function() {
/*
@@ -94,6 +101,29 @@
});
}
+ var delete_items = function() {
+ var nodes = thumb_data_view.getSelectedNodes();
+ item_ids = [];
+ for (var i = 0; i != nodes.length; i++) {
+ var node = Ext.fly(nodes[i]);
+ item_ids.push(node.getAttribute("rel"));
+ }
+ start_busy(<?= t("Deleting...")->for_js() ?>);
+ Ext.Ajax.request({
+ url: '<?= url::site("organize/delete") ?>',
+ method: "post",
+ success: function() {
+ stop_busy();
+ reload_album_data();
+ },
+ failure: show_generic_error,
+ params: {
+ item_ids: item_ids.join(","),
+ csrf: '<?= access::csrf_token() ?>'
+ }
+ });
+ };
+
/*
* ********************************************************************************
* JsonStore, DataView and Panel for viewing albums
@@ -222,7 +252,7 @@
/*
* ********************************************************************************
- * Toolbar with sort column, sort order and a close button.
+ * Toolbar with sort column, sort order, delete and close buttons.
* ********************************************************************************
*/
@@ -296,13 +326,30 @@
sort_column_combobox,
sort_order_combobox
]
- },
- {
+ }, {
xtype: "spacer",
flex: 10
}, {
xtype: "button",
flex: 2,
+ text: <?= t("Delete")->for_js() ?>,
+ listeners: {
+ "click": function() {
+ Ext.Msg.show({
+ title: <?= t("Are you sure you want to delete the selected items?")->for_js() ?>,
+ buttons: Ext.Msg.YESNO,
+ fn: function(buttonId) {
+ if (buttonId == "yes") {
+ delete_items();
+ }
+ }
+ });
+ return true;
+ }
+ }
+ }, {
+ xtype: "button",
+ flex: 2,
text: <?= t("Close")->for_js() ?>,
listeners: {
"click": function() {