From 1bbf8c48868efb87baab7ae71721f2c9ad408e65 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 20 Jan 2014 10:05:36 +0100 Subject: - Make search scope selectable in UI - Disable thread mode when searching over multiple folders - Encode UID values for HTML message row identifiers --- skins/larry/ui.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'skins/larry/ui.js') diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 44fc727f6..2030b05cd 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -41,6 +41,7 @@ function rcube_mail_ui() this.show_popup = show_popup; this.add_popup = add_popup; this.set_searchmod = set_searchmod; + this.set_searchscope = set_searchscope; this.show_uploadform = show_uploadform; this.show_header_row = show_header_row; this.hide_header_row = hide_header_row; @@ -731,11 +732,10 @@ function rcube_mail_ui() */ function switch_view_mode(mode) { - if (rcmail.env.threading != (mode == 'thread')) - rcmail.set_list_options(null, undefined, undefined, mode == 'thread' ? 1 : 0); - - $('#maillistmode, #mailthreadmode').removeClass('selected'); - $('#mail'+mode+'mode').addClass('selected'); + if (!$('#mail'+mode+'mode').hasClass('disabled')) { + $('#maillistmode, #mailthreadmode').removeClass('selected'); + $('#mail'+mode+'mode').addClass('selected'); + } } @@ -761,11 +761,15 @@ function rcube_mail_ui() obj = popups['searchmenu'], list = $('input:checkbox[name="s_mods[]"]', obj), mbox = rcmail.env.mailbox, - mods = rcmail.env.search_mods; + mods = rcmail.env.search_mods, + scope = rcmail.env.search_scope || 'base'; if (rcmail.env.task == 'mail') { + if (scope == 'all') + mbox = '*'; mods = mods[mbox] ? mods[mbox] : mods['*']; all = 'text'; + $('#s_scope_'+scope).prop('checked', true); } else { all = '*'; @@ -896,7 +900,11 @@ function rcube_mail_ui() { var all, m, task = rcmail.env.task, mods = rcmail.env.search_mods, - mbox = rcmail.env.mailbox; + mbox = rcmail.env.mailbox, + scope = $('input[name="s_scope"]:checked').val(); + + if (scope == 'all') + mbox = '*'; if (!mods) mods = {}; @@ -937,6 +945,11 @@ function rcube_mail_ui() }); } + function set_searchscope(elem) + { + rcmail.env.search_scope = elem.value; + } + function push_contactgroup(p) { // lets the contacts list swipe to the left, nice! -- cgit v1.2.3 From 6884f3f1f7542eb1dab8bb39cab33888d3fd84c5 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 20 Jan 2014 11:41:58 +0100 Subject: Re-submit search query when switching folders --- program/js/app.js | 28 ++++++++++++++++++---------- program/steps/mail/search.inc | 2 ++ skins/larry/ui.js | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'skins/larry/ui.js') diff --git a/program/js/app.js b/program/js/app.js index 2401e1e0c..e276f6f96 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -697,9 +697,17 @@ function rcube_webmail() break; case 'list': - // TODO: don't reset search but re-send for the new folder - if (props && props != '') - this.reset_qsearch(); + // re-send for the selected folder + if (props && props != '' && this.env.search_request) { + var oldmbox = this.env.search_scope == 'all' ? '*' : this.env.mailbox; + this.env.search_mods[props] = this.env.search_mods[oldmbox]; // copy search mods from active search + this.env.mailbox = props; + this.env.search_scope = 'base'; + this.qsearch(this.gui_objects.qsearchbox.value); + this.select_folder(this.env.mailbox, '', true); + break; + } + if (this.env.action == 'compose' && this.env.extwin) window.close(); else if (this.task == 'mail') { @@ -4100,11 +4108,11 @@ function rcube_webmail() }; // send remote request to search mail or contacts - this.qsearch = function(value) + this.qsearch = function(value, mods) { if (value != '') { var r, lock = this.set_busy(true, 'searching'), - url = this.search_params(value); + url = this.search_params(value, null, mods); if (this.message_list) this.clear_message_list(); @@ -4128,7 +4136,7 @@ function rcube_webmail() }; // build URL params for search - this.search_params = function(search, filter) + this.search_params = function(search, filter, smods) { var n, url = {}, mods_arr = [], mods = this.env.search_mods, @@ -4147,11 +4155,11 @@ function rcube_webmail() if (search) { url._q = search; - if (mods && this.message_list) - mods = mods[mbox] ? mods[mbox] : mods['*']; + if (!smods && mods && this.message_list) + smods = mods[mbox] || mods['*']; - if (mods) { - for (n in mods) + if (smods) { + for (n in smods) mods_arr.push(n); url._headers = mods_arr.join(','); } diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 88bbe6eda..51dab7dc4 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -21,6 +21,8 @@ $REMOTE_REQUEST = TRUE; +@set_time_limit(170); // extend default max_execution_time to ~3 minutes + // reset list_page and old search results $RCMAIL->storage->set_page(1); $RCMAIL->storage->set_search_set(NULL); diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 2030b05cd..e5fce9197 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -769,7 +769,7 @@ function rcube_mail_ui() mbox = '*'; mods = mods[mbox] ? mods[mbox] : mods['*']; all = 'text'; - $('#s_scope_'+scope).prop('checked', true); + $('#s_scope_'+scope).attr('checked',true); } else { all = '*'; -- cgit v1.2.3 From 1d6082c5e2ad4f12986c59fee49bec5bc68bd829 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 20 Jan 2014 12:12:21 +0100 Subject: Fix thread/list mode update and display --- program/lib/Roundcube/rcube_imap.php | 4 ++++ program/steps/mail/search.inc | 1 + skins/larry/ui.js | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'skins/larry/ui.js') diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 794f25a37..6bb922d90 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -332,6 +332,10 @@ class rcube_imap extends rcube_storage $this->search_sort_field = $set[3]; $this->search_sorted = $set[4]; $this->search_threads = is_a($this->search_set, 'rcube_result_thread'); + + if (is_a($this->search_set, 'rcube_result_multifolder')) { + $this->set_threading(false); + } } diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index 51dab7dc4..e13bc2ce5 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -181,6 +181,7 @@ else { // update message count display $OUTPUT->set_env('search_request', $search_str ? $search_request : ''); +$OUTPUT->set_env('threading', $RCMAIL->storage->get_threading()); $OUTPUT->set_env('messagecount', $count); $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize())); $OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS')); diff --git a/skins/larry/ui.js b/skins/larry/ui.js index e5fce9197..b95e1f1c6 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -139,7 +139,8 @@ function rcube_mail_ui() if (rcmail.env.task == 'mail') { rcmail.addEventListener('menu-open', menu_open) .addEventListener('menu-save', menu_save) - .addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') }); + .addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) }) + .addEventListener('responseaftersearch', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list', true) }); var dragmenu = $('#dragmessagemenu'); if (dragmenu.length) { @@ -730,9 +731,9 @@ function rcube_mail_ui() /** * */ - function switch_view_mode(mode) + function switch_view_mode(mode, force) { - if (!$('#mail'+mode+'mode').hasClass('disabled')) { + if (force || !$('#mail'+mode+'mode').hasClass('disabled')) { $('#maillistmode, #mailthreadmode').removeClass('selected'); $('#mail'+mode+'mode').addClass('selected'); } -- cgit v1.2.3 From c83535876c0a8903f1e77effef90d765eb96ab7f Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 7 Apr 2014 12:53:06 +0200 Subject: Small refactoring of message list column configuration; fixes table column resorting issues with hidden 'folder' column --- program/js/app.js | 86 +++++++++++++++++++++++++++++++-------------- program/steps/mail/func.inc | 27 +++++++++----- skins/larry/ui.js | 39 ++++++++++---------- 3 files changed, 97 insertions(+), 55 deletions(-) (limited to 'skins/larry/ui.js') diff --git a/program/js/app.js b/program/js/app.js index f548ad850..7c27d21b3 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -213,6 +213,11 @@ function rcube_webmail() .addEventListener('listupdate', function(o) { p.triggerEvent('listupdate', o); }) .init(); + // TODO: this should go into the list-widget code + $(this.message_list.thead).on('click', 'a.sortcol', function(e){ + return rcmail.command('sort', $(this).attr('rel'), this); + }); + document.onmouseup = function(e){ return p.doc_mouse_up(e); }; this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); }; @@ -1687,21 +1692,21 @@ function rcube_webmail() { var i, found, name, cols = list.thead.rows[0].cells; - this.env.coltypes = []; + this.env.listcols = []; for (i=0; i= 0) + if ((found = $.inArray('flag', this.env.listcols)) >= 0) this.env.flagged_col = found; - if ((found = $.inArray('subject', this.env.coltypes)) >= 0) + if ((found = $.inArray('subject', this.env.listcols)) >= 0) this.env.subject_col = found; - this.command('save-pref', { name: 'list_cols', value: this.env.coltypes, session: 'list_attrib/columns' }); + this.command('save-pref', { name: 'list_cols', value: this.env.listcols, session: 'list_attrib/columns' }); }; this.check_droptarget = function(id) @@ -1927,10 +1932,14 @@ function rcube_webmail() } // add each submitted col - for (n in this.env.coltypes) { - c = this.env.coltypes[n]; + for (n in this.env.listcols) { + c = this.env.listcols[n]; col = { className: String(c).toLowerCase() }; + if (this.env.coltypes[c] && this.env.coltypes[c].hidden) { + col.className += ' hidden'; + } + if (c == 'flag') { css_class = (flags.flagged ? 'flagged' : 'unflagged'); html = ' '; @@ -2019,7 +2028,7 @@ function rcube_webmail() if (cols && cols.length) { // make sure new columns are added at the end of the list - var i, idx, name, newcols = [], oldcols = this.env.coltypes; + var i, idx, name, newcols = [], oldcols = this.env.listcols; for (i=0; i= 0) { + if (this.env.coltypes.folder) + this.env.coltypes.folder.hidden = !(this.env.search_request || this.env.search_id) || this.env.search_scope == 'base'; + + if ((n = $.inArray('subject', this.env.listcols)) >= 0) { this.env.subject_col = n; if (list) list.subject_col = n; } - if ((n = $.inArray('flag', this.env.coltypes)) >= 0) + if ((n = $.inArray('flag', this.env.listcols)) >= 0) this.env.flagged_col = n; - if ((n = $.inArray('status', this.env.coltypes)) >= 0) + if ((n = $.inArray('status', this.env.listcols)) >= 0) this.env.status_col = n; if (list) { - list.hide_column('folder', !(this.env.search_request || this.env.search_id) || this.env.search_scope == 'base'); + list.hide_column('folder', this.env.coltypes.folder && this.env.coltypes.folder.hidden); list.init_header(); } }; diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 066d38151..7c9b491a2 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -346,7 +346,7 @@ function rcmail_message_list($attrib) $OUTPUT->set_env('sort_col', $_SESSION['sort_col']); $OUTPUT->set_env('sort_order', $_SESSION['sort_order']); $OUTPUT->set_env('messages', array()); - $OUTPUT->set_env('coltypes', $a_show_cols); + $OUTPUT->set_env('listcols', $a_show_cols); $OUTPUT->include_script('list.js'); @@ -549,7 +549,7 @@ function rcmail_message_list_head($attrib, $a_show_cols) $list_menu = ''; } - $cells = array(); + $cells = $coltypes = array(); // get name of smart From/To column in folder context if (array_search('fromto', $a_show_cols) !== false) { @@ -557,32 +557,39 @@ function rcmail_message_list_head($attrib, $a_show_cols) } foreach ($a_show_cols as $col) { + $label = ''; + $sortable = false; + // get column name switch ($col) { case 'flag': - $col_name = ' '; + $col_name = html::span('flagged', ' '); break; case 'attachment': case 'priority': case 'status': - $col_name = ' '; + $col_name = html::span($col, ' '); break; case 'threads': $col_name = $list_menu; break; case 'fromto': - $col_name = rcube::Q($RCMAIL->gettext($smart_col)); + $label = $RCMAIL->gettext($smart_col); + $col_name = rcube::Q($label); break; default: - $col_name = rcube::Q($RCMAIL->gettext($col)); + $label = $RCMAIL->gettext($col); + $col_name = rcube::Q($label); } // make sort links if (in_array($col, $a_sort_cols)) { + $sortable = true; $col_name = html::a(array( - 'href' => "./#sort", - 'onclick' => 'return '.rcmail_output::JS_OBJECT_NAME.".command('sort','".$col."',this)", - 'title' => $RCMAIL->gettext('sortby') + 'href' => "./#sort", + 'class' => 'sortcol', + 'rel' => $col, + 'title' => $RCMAIL->gettext('sortby') ), $col_name); } else if ($col_name[0] != '<') { @@ -594,8 +601,10 @@ function rcmail_message_list_head($attrib, $a_show_cols) // put it all together $cells[] = array('className' => $class_name, 'id' => "rcm$col", 'html' => $col_name); + $coltypes[$col] = array('className' => $class_name, 'id' => "rcm$col", 'label' => $label, 'sortable' => $sortable); } + $RCMAIL->output->set_env('coltypes', $coltypes); return $cells; } diff --git a/skins/larry/ui.js b/skins/larry/ui.js index 74aef8d8e..b00231183 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -770,7 +770,7 @@ function rcube_mail_ui() mbox = '*'; mods = mods[mbox] ? mods[mbox] : mods['*']; all = 'text'; - $('#s_scope_'+scope).attr('checked',true); + $('input:radio[name="s_scope"]').prop('checked', false).filter('#s_scope_'+scope).prop('checked', true); } else { all = '*'; @@ -861,7 +861,7 @@ function rcube_mail_ui() // set checkboxes $('input[name="list_col[]"]').each(function() { - $(this).prop('checked', $.inArray(this.value, rcmail.env.coltypes) != -1); + $(this).prop('checked', $.inArray(this.value, rcmail.env.listcols) != -1); }); $dialog.dialog({ @@ -927,28 +927,29 @@ function rcube_mail_ui() m[elem.value] = 1; // mark all fields - if (elem.value != all) - return; - - $('input:checkbox[name="s_mods[]"]').map(function() { - if (this == elem) - return; + if (elem.value == all) { + $('input:checkbox[name="s_mods[]"]').map(function() { + if (this == elem) + return; + + this.checked = true; + if (elem.checked) { + this.disabled = true; + delete m[this.value]; + } + else { + this.disabled = false; + m[this.value] = 1; + } + }); + } - this.checked = true; - if (elem.checked) { - this.disabled = true; - delete m[this.value]; - } - else { - this.disabled = false; - m[this.value] = 1; - } - }); + rcmail.set_searchmods(m); } function set_searchscope(elem) { - rcmail.env.search_scope = elem.value; + rcmail.set_searchscope(elem.value); } function push_contactgroup(p) -- cgit v1.2.3