summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-12-09 19:16:14 +0100
committerAleksander Machniak <alec@alec.pl>2013-12-09 19:16:14 +0100
commit7eecf873da8d2f28e20dc8fd0e949e6abc5762b4 (patch)
treeabe9ca22edc5ab1f6089421fbd8fffc997ac2640
parentae4717cb6c9b9fe1f64f8d228087892c48621860 (diff)
Fix issue where children of selected and collapsed thread were skipped on various actions (#1489457)
-rw-r--r--CHANGELOG1
-rw-r--r--program/js/app.js17
-rw-r--r--program/js/list.js40
3 files changed, 32 insertions, 26 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3f1bcf39d..cb3221d30 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix issue where children of selected and collapsed thread were skipped on various actions (#1489457)
- Fix issue where groups were not deleted when "Replace entire addressbook" option on contacts import was used (#1489420)
- Fix unreliable mimetype tests in Installer (#1489453)
- Fix performance of listing writeable folders (#1489451)
diff --git a/program/js/app.js b/program/js/app.js
index 398417a69..bad8a2f9c 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2662,20 +2662,7 @@ function rcube_webmail()
// delete selected messages from the current mailbox
this.delete_messages = function(event)
{
- var uid, i, len, trash = this.env.trash_mailbox,
- list = this.message_list,
- selection = list ? list.get_selection() : [];
-
- // exit if no mailbox specified or if selection is empty
- if (!this.env.uid && !selection.length)
- return;
-
- // also select childs of collapsed rows
- for (i=0, len=selection.length; i<len; i++) {
- uid = selection[i];
- if (list.rows[uid].has_children && !list.rows[uid].expanded)
- list.select_children(uid);
- }
+ var list = this.message_list, trash = this.env.trash_mailbox;
// if config is set to flag for deletion
if (this.env.flag_for_deletion) {
@@ -2715,7 +2702,7 @@ function rcube_webmail()
this._with_selected_messages('delete', post_data);
};
- // Send a specifc move/delete request with UIDs of all selected messages
+ // Send a specific move/delete request with UIDs of all selected messages
// @private
this._with_selected_messages = function(action, post_data, lock)
{
diff --git a/program/js/list.js b/program/js/list.js
index f33be87b3..8677f029d 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -542,17 +542,18 @@ expand_row: function(e, id)
collapse: function(row)
{
+ var r, depth = row.depth,
+ new_row = row ? row.obj.nextSibling : null;
+
row.expanded = false;
this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj });
- var depth = row.depth;
- var new_row = row ? row.obj.nextSibling : null;
- var r;
while (new_row) {
if (new_row.nodeType == 1) {
- var r = this.rows[new_row.uid];
+ r = this.rows[new_row.uid];
if (r && r.depth <= depth)
break;
+
$(new_row).css('display', 'none');
if (r.expanded) {
r.expanded = false;
@@ -564,6 +565,7 @@ collapse: function(row)
this.resize();
this.triggerEvent('listupdate');
+
return false;
},
@@ -961,7 +963,7 @@ _rowIndex: function(obj)
in_selection: function(id)
{
for (var n in this.selection)
- if (this.selection[n]==id)
+ if (this.selection[n] == id)
return true;
return false;
@@ -1057,9 +1059,26 @@ clear_selection: function(id)
/**
* Getter for the selection array
*/
-get_selection: function()
+get_selection: function(deep)
{
- return this.selection;
+ var res = $.merge([], this.selection);
+
+ // return children of selected threads even if only root is selected
+ if (deep !== false && res.length) {
+ for (var uid, uids, i=0, len=res.length; i<len; i++) {
+ uid = res[i];
+ if (this.rows[uid].has_children && !this.rows[uid].expanded) {
+ uids = this.row_children(uid);
+ for (var j=0, uids_len=uids.length; j<uids_len; j++) {
+ uid = uids[j];
+ if (!this.in_selection(uid))
+ res.push(uid);
+ }
+ }
+ }
+ }
+
+ return res;
},
@@ -1325,7 +1344,7 @@ drag_mouse_move: function(e)
this.draglayer.html('');
// get subjects of selected messages
- var i, n, obj, me;
+ var n, obj, me = this;
for (n=0; n<this.selection.length; n++) {
// only show 12 lines
if (n>12) {
@@ -1333,9 +1352,8 @@ drag_mouse_move: function(e)
break;
}
- me = this;
if (obj = this.rows[this.selection[n]].obj) {
- $('> '+this.col_tagname(), obj).each(function(i,elem){
+ $('> '+this.col_tagname(), obj).each(function(i, elem) {
if (n == 0)
me.drag_start_pos = $(elem).offset();
@@ -1541,7 +1559,7 @@ row_children: function(uid)
while (row) {
if (row.nodeType == 1) {
- if ((r = this.rows[row.uid])) {
+ if (r = this.rows[row.uid]) {
if (!r.depth || r.depth <= depth)
break;
res.push(r.uid);