* Mail: Implement new preference for toggle actions. For instance, switching Cc, BCc or S/MIME Sign always on when trying to compose an email.

This commit is contained in:
Hadi Nategh 2018-07-13 10:38:47 +02:00
parent 32f50567f0
commit 68de0eba1a
2 changed files with 47 additions and 12 deletions

View File

@ -182,25 +182,25 @@ class mail_hooks
$folderList['none'] = lang('no folders'); $folderList['none'] = lang('no folders');
// Build toogled on actions sel options // Build toogled on actions sel options
$allActions = array_merge(mail_compose::getToolbarActions(array( $allActions = mail_compose::getToolbarActions(array(
'priority' => true, 'priority' => true,
'mailaccount' => $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] 'mailaccount' => $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']
))); ));
$toggledOnActions = array ( $toggledOnActions = array (
'mail_compose.cc_expander' => array ( 'cc_expander' => array (
'id' => 'mail_compose.cc_expander', 'id' => 'cc_expander',
'label' => lang('Cc'), 'label' => lang('Cc'),
), ),
'mail_compose.bcc_expander' => array ( 'bcc_expander' => array (
'id' => 'mail_compose.bcc_expander', 'id' => 'bcc_expander',
'label' => lang('Bcc') 'label' => lang('Bcc')
), ),
'mail_compose.folder_expander' => array( 'folder_expander' => array(
'id' => 'mail_compose.folder_expander', 'id' => 'folder_expander',
'label' => lang('Folder') 'label' => lang('Folder')
), ),
'mail_compose.replyto_expander' => array( 'replyto_expander' => array(
'id' => 'mail_compose.replyto_expander', 'id' => 'replyto_expander',
'label' => lang('Reply to') 'label' => lang('Reply to')
) )
); );
@ -209,8 +209,8 @@ class mail_hooks
{ {
if ($action['checkbox']) if ($action['checkbox'])
{ {
$toggledOnActions['mail_compose.'.$name] = array( $toggledOnActions[$name] = array(
'id' => 'mail_compose.'.$name, 'id' => $name,
'label' => lang($action['caption']), 'label' => lang($action['caption']),
'title' => lang($action['hint']), 'title' => lang($action['hint']),
'app' => 'mail' 'app' => 'mail'

View File

@ -350,6 +350,7 @@ app.classes.mail = AppJS.extend(
this.mail_currentlyFocussed = this.et2.mail_currentlyFocussed; this.mail_currentlyFocussed = this.et2.mail_currentlyFocussed;
} }
this.preSetToggledOnActions ();
}, },
/** /**
@ -6048,5 +6049,39 @@ app.classes.mail = AppJS.extend(
nm.header.right_div.addClass('vertical_splitter'); nm.header.right_div.addClass('vertical_splitter');
} }
return state; return state;
},
/**
* Pre set toggled actions
*/
preSetToggledOnActions: function ()
{
var actions = egw.preference('toggledOnActions', 'mail');
var toolbar = this.et2.getWidgetById('composeToolbar');
if (actions)
{
actions = actions.split(',');
for (var i=0; i < actions.length; i++)
{
if (toolbar.options.actions[actions[i]])
{
var $d = jQuery('#composeToolbar-'+actions[i]);
if ($d.length > 0
&& toolbar._actionManager.getActionById(actions[i]).checkbox
&& !toolbar._actionManager.getActionById(actions[i]).checked)
{
$d.trigger('click');
}
}
else
{
var widget = this.et2.getWidgetById(actions[i]);
if (widget)
{
jQuery(widget.getDOMNode()).trigger('click');
}
}
}
}
} }
}); });