first attempt to toggle certain flags on actions, instead of e.g.: setting flagged and setting unflagged explizitly

This commit is contained in:
Klaus Leithoff 2013-12-05 15:09:35 +00:00
parent 2ac548d0b8
commit fd6e7648d6
3 changed files with 66 additions and 18 deletions

View File

@ -1883,6 +1883,11 @@ class mail_bo
continue; continue;
} }
$allMailBoxesExtSorted = array(); $allMailBoxesExtSorted = array();
if (!is_array($allMailboxesExt))
{
error_log(__METHOD__.__LINE__.' Expected Array but got:'.array2string($allMailboxesExt));
$allMailboxesExt=array();
}
foreach ($allMailboxesExt as $mbx) { foreach ($allMailboxesExt as $mbx) {
//echo __METHOD__;_debug_array($mbx); //echo __METHOD__;_debug_array($mbx);
//error_log(__METHOD__.__LINE__.array2string($mbx)); //error_log(__METHOD__.__LINE__.array2string($mbx));

View File

@ -193,6 +193,7 @@ class mail_ui
$this->mail_bo->reopen($sessionFolder); // needed to fetch full set of capabilities $this->mail_bo->reopen($sessionFolder); // needed to fetch full set of capabilities
$toSchema = $this->mail_bo->isDraftFolder($sessionFolder)||$this->mail_bo->isSentFolder($sessionFolder)||$this->mail_bo->isTemplateFolder($sessionFolder); $toSchema = $this->mail_bo->isDraftFolder($sessionFolder)||$this->mail_bo->isSentFolder($sessionFolder)||$this->mail_bo->isTemplateFolder($sessionFolder);
} }
//error_log(__METHOD__.__LINE__.' SessionFolder:'.$sessionFolder.' isToSchema:'.$toSchema);
//_debug_array($content); //_debug_array($content);
if (!is_array($content)) if (!is_array($content))
{ {
@ -222,6 +223,7 @@ class mail_ui
//$content[self::$nm_index]['path'] = self::get_home_dir(); //$content[self::$nm_index]['path'] = self::get_home_dir();
} }
} }
$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,'.($toSchema?'toaddress':'fromaddress').',date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
$content[self::$nm_index]['csv_fields'] = false; $content[self::$nm_index]['csv_fields'] = false;
if ($msg) if ($msg)
{ {
@ -933,7 +935,7 @@ class mail_ui
), ),
), ),
'mark' => array( 'mark' => array(
'caption' => 'Mark as', 'caption' => 'Set / Remove Flags',
'icon' => 'read_small', 'icon' => 'read_small',
'group' => ++$group, 'group' => ++$group,
'children' => array( 'children' => array(
@ -942,7 +944,7 @@ class mail_ui
// Iconset Homepage: http://led24.de/iconset // Iconset Homepage: http://led24.de/iconset
// License: CC Attribution 3.0 // License: CC Attribution 3.0
'setLabel' => array( 'setLabel' => array(
'caption' => 'Set Label', 'caption' => 'Set / Remove Labels',
'icon' => 'tag_message', 'icon' => 'tag_message',
'group' => ++$group, 'group' => ++$group,
'children' => array( 'children' => array(
@ -971,9 +973,16 @@ class mail_ui
'icon' => 'mail_label5', 'icon' => 'mail_label5',
'onExecute' => 'javaScript:app.mail.mail_flag', 'onExecute' => 'javaScript:app.mail.mail_flag',
), ),
'unlabel' => array(
'group' => ++$group,
'caption' => "<font color='#ff0000'>".lang('remove all')."</font>",
'icon' => 'mail_label',
'onExecute' => 'javaScript:app.mail.mail_flag',
),
), ),
), ),
// modified icons from http://creativecommons.org/licenses/by-sa/3.0/ // modified icons from http://creativecommons.org/licenses/by-sa/3.0/
/*
'unsetLabel' => array( 'unsetLabel' => array(
'caption' => 'Remove Label', 'caption' => 'Remove Label',
'icon' => 'untag_message', 'icon' => 'untag_message',
@ -1006,15 +1015,17 @@ class mail_ui
), ),
), ),
), ),
*/
'flagged' => array( 'flagged' => array(
'group' => ++$group, 'group' => ++$group,
'caption' => 'Flagged', 'caption' => 'Flagged / Unflagged',
'icon' => 'unread_flagged_small', 'icon' => 'unread_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag', 'onExecute' => 'javaScript:app.mail.mail_flag',
//'disableClass' => 'flagged', //'disableClass' => 'flagged',
//'enabled' => "javaScript:mail_disabledByClass", //'enabled' => "javaScript:mail_disabledByClass",
'shortcut' => egw_keymanager::shortcut(egw_keymanager::F, true, true), 'shortcut' => egw_keymanager::shortcut(egw_keymanager::F, true, true),
), ),
/*
'unflagged' => array( 'unflagged' => array(
'group' => $group, 'group' => $group,
'caption' => 'Unflagged', 'caption' => 'Unflagged',
@ -1024,14 +1035,16 @@ class mail_ui
//'enabled' => "javaScript:mail_enabledByClass", //'enabled' => "javaScript:mail_enabledByClass",
'shortcut' => egw_keymanager::shortcut(egw_keymanager::U, true, true), 'shortcut' => egw_keymanager::shortcut(egw_keymanager::U, true, true),
), ),
*/
'read' => array( 'read' => array(
'group' => $group, 'group' => $group,
'caption' => 'Read', 'caption' => 'Read / Unread',
'icon' => 'read_small', 'icon' => 'read_small',
'onExecute' => 'javaScript:app.mail.mail_flag', 'onExecute' => 'javaScript:app.mail.mail_flag',
//'enableClass' => 'unseen', //'enableClass' => 'unseen',
//'enabled' => "javaScript:mail_enabledByClass", //'enabled' => "javaScript:mail_enabledByClass",
), ),
/*
'unread' => array( 'unread' => array(
'group' => $group, 'group' => $group,
'caption' => 'Unread', 'caption' => 'Unread',
@ -1040,6 +1053,7 @@ class mail_ui
//'disableClass' => 'unseen', //'disableClass' => 'unseen',
//'enabled' => "javaScript:mail_disabledByClass", //'enabled' => "javaScript:mail_disabledByClass",
), ),
*/
'undelete' => array( 'undelete' => array(
'group' => $group, 'group' => $group,
'caption' => 'Undelete', 'caption' => 'Undelete',
@ -1275,7 +1289,7 @@ unset($query['actions']);
$dateToday = date("Y-m-d"); $dateToday = date("Y-m-d");
$rv = array(); $rv = array();
$actions = self::get_actions(); $actions = self::get_actions();
foreach(array('composeasnew','reply','reply_all','forward','flagged','unflagged','delete','print','infolog','tracker','save','header') as $a => $act) foreach(array('composeasnew','reply','reply_all','forward','flagged','delete','print','infolog','tracker','save','header') as $a => $act)
{ {
//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act])); //error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
switch ($act) switch ($act)
@ -1290,8 +1304,18 @@ unset($query['actions']);
$actionsenabled[$act]=$actions['view']['children'][$act]; $actionsenabled[$act]=$actions['view']['children'][$act];
break; break;
case 'flagged': case 'flagged':
case 'unflagged': $actionsenabled[$act]=$actions['mark']['children'][$act]=array(
$actionsenabled[$act]=$actions['mark']['children'][$act]; 'group' => $group,
'caption' => 'Flagged',
'icon' => 'unread_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag',
);
$actionsenabled['unflagged']=$actions['mark']['children']['unflagged']=array(
'group' => $group,
'caption' => 'Unflagged',
'icon' => 'read_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag',
);
break; break;
default: default:
if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
@ -1511,6 +1535,18 @@ unset($query['actions']);
$data["size"] = $header['size']; /// size $data["size"] = $header['size']; /// size
$data["class"] = implode(' ', $css_styles); $data["class"] = implode(' ', $css_styles);
if ($header['seen']) $data["flags"]['seen'] = 'seen';
foreach ($css_styles as $k => $flag) {
if ($flag!='mail')
{
if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
else $data["flags"][$flag] = $flag;
}
}
$data['attachmentsPresent'] = $imageTag; $data['attachmentsPresent'] = $imageTag;
$data['attachmentsBlock'] = $imageHTMLBlock; $data['attachmentsBlock'] = $imageHTMLBlock;
$data['toolbaractions'] = json_encode($actionsenabled); $data['toolbaractions'] = json_encode($actionsenabled);
@ -3460,7 +3496,7 @@ blockquote[type=cite] {
} }
*/ */
$response = egw_json_response::get(); $response = egw_json_response::get();
$response->call('egw_refresh',lang('flagged %1 messages as %2 in %3',count($_messageList['msg']),$_flag,$folder),'mail'); $response->call('egw_refresh',lang('flagged %1 messages as %2 in %3',count($_messageList['msg']),lang($_flag),$folder),'mail');
} }
/** /**

View File

@ -1082,19 +1082,25 @@ app.classes.mail = AppJS.extend(
{ {
msg = this.mail_getFormData(_elems); msg = this.mail_getFormData(_elems);
if (_action.id.substring(0,2)=='un') { if (_action.id.substring(0,2)=='un') {
//old style, probably only available for undelete (no toggle)
this.mail_removeRowClass(_elems,_action.id.substring(2)); this.mail_removeRowClass(_elems,_action.id.substring(2));
this.mail_setRowClass(_elems,_action.id);
this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
} }
else else
{ {
this.mail_removeRowClass(_elems,'un'+_action.id); var dataElem = egw.dataGetUIDdata(msg.msg[0]);
var flags = dataElem.data.flags;
this.mail_removeRowClass(_elems,(flags[_action.id]?'un':'')+_action.id);
this.mail_setRowClass(_elems,(flags[_action.id]?'':'un')+_action.id);
this.mail_flagMessages((flags[_action.id]?'un':'')+_action.id,msg,(do_nmactions?false:true),false);
this.mail_refreshMessageGrid((do_nmactions?false:true));
} }
this.mail_setRowClass(_elems,_action.id);
} }
else else
{ {
//mail_parentRefreshListRowStyle(msg,_action.id); this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
} }
this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
this.mail_refreshFolderStatus(); this.mail_refreshFolderStatus();
}, },
@ -1104,13 +1110,14 @@ app.classes.mail = AppJS.extend(
* @param _action _action.id is 'read', 'unread', 'flagged' or 'unflagged' * @param _action _action.id is 'read', 'unread', 'flagged' or 'unflagged'
* @param _elems * @param _elems
*/ */
mail_flagMessages: function(_flag, _elems,_isPopup) mail_flagMessages: function(_flag, _elems,_isPopup,_refreshGrid)
{ {
console.log(_flag, _elems); //console.log('mail_flagMessages',_flag, _elems);
if (typeof _refreshGrid == 'undefined') _refreshGrid=true;
app.mail.app_refresh(this.egw.lang('flag messages'), 'mail'); app.mail.app_refresh(this.egw.lang('flag messages'), 'mail');
egw.json('mail.mail_ui.ajax_flagMessages',[_flag, _elems]) egw.json('mail.mail_ui.ajax_flagMessages',[_flag, _elems])
.sendRequest(); .sendRequest();
this.mail_refreshMessageGrid(_isPopup); if (_refreshGrid) this.mail_refreshMessageGrid(_isPopup);
}, },
/** /**
@ -1633,11 +1640,11 @@ app.classes.mail = AppJS.extend(
var aO = nm.controller._objectManager.selectedChildren; var aO = nm.controller._objectManager.selectedChildren;
for (var i = 0; i < _actionObjects['msg'].length; i++) for (var i = 0; i < _actionObjects['msg'].length; i++)
{ {
for (var i = 0; i < aO.length; i++) for (var k = 0; k < aO.length; k++)
{ {
if (aO[i].id==_actionObjects['msg'][i]) if (aO[k].id==_actionObjects['msg'][i])
{ {
var dataElem = $j(aO[i].iface.getDOMNode()); var dataElem = $j(aO[k].iface.getDOMNode());
dataElem.removeClass(_class); dataElem.removeClass(_class);
} }