Changeset 3124 in subversion


Ignore:
Timestamp:
Nov 21, 2009 1:56:23 PM (4 years ago)
Author:
alec
Message:
  • make possible selecting columns in UI
Location:
branches/devel-threads
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-threads/THREADS

    r3121 r3124  
    1414    - removed 'index_sort' option, now we're using empty 'message_sort_col' for 
    1515      this purpose 
    16     - popup menu for list column/sorting/view selection (not finished yet) 
     16    - popup menu for messages list column/sorting/view selection 
    1717    - added sorting by ARRIVAL 
    1818    - added sorting by CC 
     
    3131      root or child message), 
    3232    - "Expand All Unread" button 
    33     - columns/sort/view selector (popup) with 'default sorting' support 
    3433    - thread tree icons 
    3534    - reset autoexpand feature if collapse-all/expand-all was used. Save state for next page 
     
    4241    - thread css: message row height, thread/status icon alignment 
    4342    - remove 'indexsort' label from localization files 
     43    - use jQuery.inArray instead of find_in_array() (common.js) 
    4444 
    4545KNOWN ISSUES: 
  • branches/devel-threads/program/js/app.js

    r3123 r3124  
    174174          document.onmouseup = function(e){ return p.doc_mouse_up(e); }; 
    175175 
     176          this.set_message_coltypes(this.env.coltypes); 
    176177          this.message_list.init(); 
    177178          this.enable_command('toggle_status', 'toggle_flag', true); 
     
    188189          this.message_list.expand(null); 
    189190          } 
    190  
    191         if (this.env.coltypes) 
    192           this.set_message_coltypes(this.env.coltypes); 
    193191 
    194192        // enable mail commands 
     
    14711469      } 
    14721470 
    1473     // global variable 'subject_col' may be not defined yet 
    1474     if (this.env.subject_col == null && this.env.coltypes) 
    1475       { 
    1476       var found; 
    1477       if((found = find_in_array('subject', this.env.coltypes)) >= 0) 
    1478         this.set_env('subject_col', found); 
    1479       } 
    1480  
    14811471    // set eventhandler to message icon 
    14821472    if (this.env.subject_col != null 
     
    14871477      row.icon._row = row.obj; 
    14881478      row.icon.onmousedown = function(e) { p.command('toggle_status', this); }; 
    1489       } 
    1490  
    1491     // global variable 'flagged_col' may be not defined yet 
    1492     if (this.env.flagged_col == null && this.env.coltypes) 
    1493       { 
    1494       var found; 
    1495       if((found = find_in_array('flag', this.env.coltypes)) >= 0) 
    1496         this.set_env('flagged_col', found); 
    14971479      } 
    14981480 
     
    15971579 
    15981580    // add each submitted col 
    1599     for (var n = 0; n < this.coltypes.length; n++) { 
    1600       var c = this.coltypes[n]; 
     1581    for (var n = 0; n < this.env.coltypes.length; n++) { 
     1582      var c = this.env.coltypes[n]; 
    16011583      col = document.createElement('td'); 
    16021584      col.className = String(c).toLowerCase(); 
     
    16521634  this.set_list_options = function(cols, sort_col, sort_order, threads) 
    16531635    { 
    1654     var update, add_url; 
     1636    var update, add_url = ''; 
    16551637 
    16561638    if (this.env.sort_col != sort_col || this.env.sort_order != sort_order) { 
     
    16611643    if (this.env.threading != threads) { 
    16621644      update = 1; 
    1663       add_url = '&_threads=' + threads;      
     1645      add_url += '&_threads=' + threads;      
     1646      } 
     1647 
     1648    if (cols.join() != this.env.coltypes.join()) { 
     1649      update = 1; 
     1650      add_url += '&_cols=' + cols.join(','); 
    16641651      } 
    16651652 
     
    40844071  }; 
    40854072 
    4086   // for reordering column array, Konqueror workaround 
    4087   this.set_message_coltypes = function(coltypes)  
     4073  // for reordering column array (Konqueror workaround) 
     4074  // and for setting some message list global variables 
     4075  this.set_message_coltypes = function(coltypes, replace)  
    40884076  {  
    4089     this.coltypes = coltypes; 
     4077    this.env.coltypes = coltypes; 
    40904078     
    40914079    // set correct list titles 
    4092     var cell, col; 
     4080    var cell, col, found, n; 
    40934081    var thead = this.gui_objects.messagelist ? this.gui_objects.messagelist.tHead : null; 
    4094     for (var n=0; thead && n<this.coltypes.length; n++)  
    4095       { 
    4096       col = this.coltypes[n]; 
     4082 
     4083    // replace old column headers 
     4084    if (thead && replace) 
     4085      this.gui_objects.messagelist.tHead.innerHTML = replace; 
     4086 
     4087    for (n=0; thead && n<this.env.coltypes.length; n++) 
     4088      { 
     4089      col = this.env.coltypes[n]; 
    40974090      if ((cell = thead.rows[0].cells[n]) && (col=='from' || col=='to')) 
    40984091        { 
     
    41004093        if (cell.firstChild && cell.firstChild.tagName.toLowerCase()=='a') 
    41014094          { 
    4102           cell.firstChild.innerHTML = this.get_label(this.coltypes[n]); 
     4095          cell.firstChild.innerHTML = this.get_label(this.env.coltypes[n]); 
    41034096          cell.firstChild.onclick = function(){ return rcmail.command('sort', this.__col, this); }; 
    41044097          cell.firstChild.__col = col; 
    41054098          } 
    41064099        else 
    4107           cell.innerHTML = this.get_label(this.coltypes[n]); 
     4100          cell.innerHTML = this.get_label(this.env.coltypes[n]); 
    41084101 
    41094102        cell.id = 'rcm'+col; 
    41104103        } 
    4111       else if (col == 'subject' && this.message_list) 
    4112         this.message_list.subject_col = n; 
    4113       } 
     4104      } 
     4105 
     4106    // remove excessive columns 
     4107    for (var i=n; thead && n<thead.rows[0].cells.length; i++) 
     4108      thead.rows[0].removeChild(thead.rows[0].cells[i]); 
     4109 
     4110    this.env.subject_col = null; 
     4111    this.env.flagged_col = null; 
     4112 
     4113    if((found = find_in_array('subject', this.env.coltypes)) >= 0) { 
     4114      this.set_env('subject_col', found); 
     4115      if (this.message_list) 
     4116        this.message_list.subject_col = found; 
     4117      } 
     4118    if((found = find_in_array('flag', this.env.coltypes)) >= 0) 
     4119      this.set_env('flagged_col', found); 
    41144120  }; 
    41154121 
  • branches/devel-threads/program/steps/mail/func.inc

    r3123 r3124  
    132132  $skin_path = $CONFIG['skin_path']; 
    133133  $image_tag = '<img src="%s%s" alt="%s" />'; 
    134   // check to see if we have some settings for sorting 
    135   $sort_col   = $_SESSION['sort_col']; 
    136   $sort_order = $_SESSION['sort_order']; 
    137134   
    138135  // add some labels to client 
     
    157154      $a_show_cols = preg_split('/[\s,;]+/', strip_quotes($attrib['columns'])); 
    158155 
    159   // store column list in a session-variable 
     156  // save some variables for use in ajax list 
    160157  $_SESSION['list_columns'] = $a_show_cols; 
    161    
    162   // define sortable columns 
    163   $a_sort_cols = array('subject', 'date', 'from', 'to', 'size', 'cc'); 
    164  
     158  $_SESSION['list_attrib'] = $attrib; 
     159  $_SESSION['skin_path'] = $skin_path; 
     160   
    165161  $mbox = $IMAP->get_mailbox_name(); 
    166162  $delim = $IMAP->get_hierarchy_delimiter(); 
     
    170166      && ($f = array_search('from', $a_show_cols)) && !array_search('to', $a_show_cols)) 
    171167    $a_show_cols[$f] = 'to'; 
    172    
    173   // add col definition 
    174   $out .= '<colgroup>'; 
    175  
    176   foreach ($a_show_cols as $col) 
    177     $out .= ($col!='attachment') ? sprintf('<col class="%s" />', $col) : '<col class="icon" />'; 
    178  
    179   $out .= "</colgroup>\n"; 
    180  
    181   // add table title 
    182   $out .= "<thead><tr>\n"; 
    183  
    184   $javascript = ''; 
    185   foreach ($a_show_cols as $col) 
    186     { 
    187     // get column name 
    188     switch ($col) 
    189       { 
    190       case 'flag': 
    191         $col_name = sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], ''); 
    192         break; 
    193       case 'attachment': 
    194         $col_name = sprintf($image_tag, $skin_path, $attrib['attachmenticon'], ''); 
    195         break; 
    196       default: 
    197         $col_name = Q(rcube_label($col)); 
    198     } 
    199  
    200     // make sort links 
    201     $sort = ''; 
    202     if (in_array($col, $a_sort_cols)) 
    203       { 
    204       // have buttons configured 
    205       if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton'])) 
    206         { 
    207         $sort = '&nbsp;&nbsp;'; 
    208  
    209         // asc link 
    210         if (!empty($attrib['sortascbutton'])) 
    211           { 
    212           $sort .= $OUTPUT->button(array( 
    213             'command' => 'sort', 
    214             'prop' => $col.'_ASC', 
    215             'image' => $attrib['sortascbutton'], 
    216             'align' => 'absmiddle', 
    217             'title' => 'sortasc')); 
    218           }        
    219          
    220         // desc link 
    221         if (!empty($attrib['sortdescbutton'])) 
    222           { 
    223           $sort .= $OUTPUT->button(array( 
    224             'command' => 'sort', 
    225             'prop' => $col.'_DESC', 
    226             'image' => $attrib['sortdescbutton'], 
    227             'align' => 'absmiddle', 
    228             'title' => 'sortdesc')); 
    229           } 
    230         } 
    231       // just add a link tag to the header 
    232       else 
    233         { 
    234         $col_name = sprintf( 
    235           '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>', 
    236           JS_OBJECT_NAME, 
    237           $col, 
    238           rcube_label('sortby'), 
    239           $col_name); 
    240         } 
    241       } 
    242        
    243     $sort_class = $col==$sort_col ? " sorted$sort_order" : ''; 
    244  
    245     // put it all together 
    246     if ($col != 'attachment') { 
    247       // list options menu link 
    248       if ($col == 'subject' && !empty($attrib['optionsmenuicon'])) { 
    249           $list_menu = $OUTPUT->button(array( 
    250             'name' => 'listmenulink', 
    251             'id' => 'listmenulink', 
    252 //            'command' => '', 
    253 //            'prop' => '', 
    254             'image' => $attrib['optionsmenuicon'], 
    255             'align' => 'absmiddle', 
    256             'style' => 'float: left; padding-right: 5px', 
    257             'title' => 'listoptions')); 
    258         } else 
    259           $list_menu = ''; 
    260  
    261       $out .= '<td class="'.$col.$sort_class.'" id="rcm'.$col.'">' . "$list_menu$col_name$sort</td>\n"; 
    262       } 
    263     else     
    264       $out .= '<td class="icon" id="rcm'.$col.'">' . "$col_name$sort</td>\n"; 
    265     } 
    266  
    267   $out .= "</tr></thead>\n<tbody>\n"; 
     168 
     169  $out .= '<thead>'.rcmail_message_list_head($attrib, $a_show_cols).'</thead>'; 
     170  $out .= "\n<tbody>\n"; 
    268171 
    269172  // no messages in this mailbox 
     
    406309  $OUTPUT->set_env('current_page', $IMAP->list_page); 
    407310  $OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size)); 
    408   $OUTPUT->set_env('sort_col', $sort_col); 
    409   $OUTPUT->set_env('sort_order', $sort_order); 
     311  $OUTPUT->set_env('sort_col', $_SESSION['sort_col']); 
     312  $OUTPUT->set_env('sort_order', $_SESSION['sort_order']); 
    410313   
    411314  if ($attrib['messageicon']) 
     
    443346 * or to replace the whole list (IE only) 
    444347 */ 
    445 function rcmail_js_message_list($a_headers, $insert_top=FALSE, $replace=TRUE) 
     348function rcmail_js_message_list($a_headers, $insert_top=FALSE, $replace=TRUE, $head_replace=FALSE) 
    446349  { 
    447350  global $CONFIG, $IMAP, $OUTPUT; 
     
    461364 
    462365  $browser = new rcube_browser; 
    463  
    464   $OUTPUT->command('set_message_coltypes', $a_show_cols); 
     366   
     367  $thead = $head_replace ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL; 
     368   
     369  $OUTPUT->command('set_message_coltypes', $a_show_cols, $thead); 
    465370 
    466371  // remove 'attachment' and 'flag' columns, we don't need them here 
     
    548453 
    549454 
     455/* 
     456 * Creates <THEAD> for message list table 
     457 */ 
     458function rcmail_message_list_head($attrib, $a_show_cols) 
     459  { 
     460  global $CONFIG; 
     461 
     462  $skin_path = $_SESSION['skin_path']; 
     463  $image_tag = '<img src="%s%s" alt="%s" />'; 
     464 
     465  // check to see if we have some settings for sorting 
     466  $sort_col   = $_SESSION['sort_col']; 
     467  $sort_order = $_SESSION['sort_order']; 
     468 
     469  // define sortable columns 
     470  $a_sort_cols = array('subject', 'date', 'from', 'to', 'size', 'cc'); 
     471   
     472  $out = '<tr>'; 
     473 
     474  foreach ($a_show_cols as $col) 
     475    { 
     476    // get column name 
     477    switch ($col) 
     478      { 
     479      case 'flag': 
     480        $col_name = sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], ''); 
     481        break; 
     482      case 'attachment': 
     483        $col_name = sprintf($image_tag, $skin_path, $attrib['attachmenticon'], ''); 
     484        break; 
     485      default: 
     486        $col_name = Q(rcube_label($col)); 
     487    } 
     488 
     489    // make sort links 
     490    $sort = ''; 
     491    if (in_array($col, $a_sort_cols)) 
     492      { 
     493        $col_name = sprintf( 
     494          '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>', 
     495          JS_OBJECT_NAME, 
     496          $col, 
     497          rcube_label('sortby'), 
     498          $col_name); 
     499      } 
     500       
     501    $sort_class = $col==$sort_col ? " sorted$sort_order" : ''; 
     502 
     503    // put it all together 
     504    if ($col != 'attachment') { 
     505      // list options menu link 
     506      if ($col == 'subject' && !empty($attrib['optionsmenuicon'])) { 
     507          $list_menu = sprintf('<a href="#"><img src="%s%s" id="%s" align="absmiddle" style="%s" title="%s" alt="" /></a>', 
     508            $skin_path, 
     509            $attrib['optionsmenuicon'], 
     510            'listmenulink', 
     511            'float: left; padding-right: 5px', 
     512            rcube_label('listoptions') 
     513            ); 
     514        } else 
     515          $list_menu = ''; 
     516 
     517      $out .= '<td class="'.$col.$sort_class.'" id="rcm'.$col.'">' . "$list_menu$col_name$sort</td>\n"; 
     518      } 
     519    else     
     520      $out .= '<td class="icon" id="rcm'.$col.'">' . "$col_name$sort</td>\n"; 
     521    } 
     522 
     523  $out .= '</tr>'; 
     524 
     525  return $out; 
     526  } 
     527 
     528 
    550529/** 
    551530 * return an HTML iframe for loading mail content 
  • branches/devel-threads/program/steps/mail/list.inc

    r3120 r3124  
    3434  $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col; 
    3535  $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order; 
    36    
    37   $RCMAIL->user->save_prefs($save_arr); 
    3836} 
    3937else 
     
    4341  $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; 
    4442} 
     43 
     44// is there a set of columns for this request? 
     45if ($cols = get_input_value('_cols', RCUBE_INPUT_GET)) 
     46{ 
     47  $save_arr = array(); 
     48  $_SESSION['list_columns'] = $save_arr['list_cols'] = explode(',', $cols); 
     49} 
     50 
     51if ($save_arr)   
     52  $RCMAIL->user->save_prefs($save_arr); 
    4553 
    4654$mbox_name = $IMAP->get_mailbox_name(); 
     
    7381if (isset($a_headers) && count($a_headers)) 
    7482{ 
    75   rcmail_js_message_list($a_headers); 
     83  rcmail_js_message_list($a_headers, FALSE, TRUE, (bool) $cols); 
    7684  if ($search_request) 
    7785    $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); 
  • branches/devel-threads/skins/default/functions.js

    r3112 r3124  
    126126  this.messagemenu = $('#messagemenu'); 
    127127  this.listmenu = $('#listmenu'); 
     128  this.add_listmenulink(); 
     129} 
     130 
     131rcube_mail_ui.prototype = { 
     132 
     133add_listmenulink: function() 
     134{ 
    128135  var ref = rcube_find_object('listmenulink'); 
    129    
    130136  if (ref) 
    131137    ref.onclick = function () { rcmail_ui.show_listmenu() }; 
    132 } 
    133  
    134 rcube_mail_ui.prototype = { 
     138}, 
    135139 
    136140show_markmenu: function(show) 
     
    204208    $('input[name="view"][value="thread"]').attr('checked', rcmail.env.threading ? 1 : 0); 
    205209    $('input[name="view"][value="list"]').attr('checked', rcmail.env.threading ? 0 : 1); 
     210    // list columns 
     211    var cols = $('input[name="list_col[]"]'); 
     212    for (var i=0; i<cols.length; i++) { 
     213      var found = 0; 
     214      if (cols[i].value != 'from') 
     215        found = jQuery.inArray(cols[i].value, rcmail.env.coltypes) != -1; 
     216      else 
     217        found = (jQuery.inArray('from', rcmail.env.coltypes) != -1 
     218            || jQuery.inArray('to', rcmail.env.coltypes) != -1); 
     219      $(cols[i]).attr('checked',found ? 1 : 0); 
     220    } 
    206221  } 
    207222  this.listmenu[show?'show':'hide'](); 
     
    216231  var thread = $('input[name="view"]:checked').val(); 
    217232  var cols = $('input[name="list_col[]"]:checked') 
    218     .map(function(){ return $(this).val(); }).get(); 
     233    .map(function(){ return this.value; }).get(); 
    219234 
    220235  rcmail.set_list_options(cols, sort, ord, thread == 'thread' ? 1 : 0); 
     
    272287  rcube_event.add_listener({ object:rcmail_ui, method:'body_mouseup', event:'mouseup' }); 
    273288  rcube_event.add_listener({ object:rcmail_ui, method:'body_keypress', event:'keypress' }); 
    274 } 
     289  rcube_event.add_listener({ object:rcmail_ui, method:'add_listmenulink', event:'listupdate' }); 
     290} 
Note: See TracChangeset for help on using the changeset viewer.