Fix priority toolbar action loses its selected label after submit in compose dialog

This commit is contained in:
Hadi Nategh 2015-01-13 12:14:41 +00:00
parent a0a2898679
commit 5129750d2e
2 changed files with 30 additions and 11 deletions

View File

@ -104,10 +104,11 @@ class mail_compose
/**
* Provide toolbar actions used for compose toolbar
* @param array $content content of compose temp
*
* @return array an array of actions
*/
function getToolbarActions()
function getToolbarActions($content)
{
$actions = array(
'send' => array(
@ -178,7 +179,8 @@ class mail_compose
'icon' => 'priority',
'children' => array(),
'toolbarDefault' => true,
'hint' => 'Select the message priority tag'
'hint' => 'Select the message priority tag',
),
'save2vfs' => array (
'caption' => 'Save to VFS',
@ -192,7 +194,9 @@ class mail_compose
{
$actions['prty']['children'][$key] = array(
'caption' => $priority,
'icon' => 'prio_high'
'icon' => 'prio_high',
'default' => false,
'onExecute' => 'javaScript:app.mail.compose_priorityChange'
);
switch ($priority)
{
@ -206,6 +210,12 @@ class mail_compose
$actions['prty']['children'][$key]['icon'] = 'prio_low';
}
}
// Set the priority action its current state
if ($content['priority'])
{
$actions['prty']['children'][$content['priority']]['default'] = true;
}
return $actions;
}
@ -1228,7 +1238,7 @@ class mail_compose
//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
$etpl = new etemplate_new('mail.compose');
$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions());
$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
if ($content['mimeType']=='html')
{
//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"

View File

@ -4227,28 +4227,37 @@ app.classes.mail = AppJS.extend(
*/
compose_submitAction: function (_action)
{
var action_widget = ['to_infolog','to_tracker','disposition','priority'];
var action_widget = ['to_infolog','to_tracker','disposition'];
var toolbar = this.et2.getWidgetById('composeToolbar');
for(var i=0;action_widget.length>i;i++)
{
var widget = this.et2.getWidgetById(action_widget[i]);
if (toolbar._actionManager)
{
var action_event = toolbar._actionManager.getActionById(action_widget[i]== 'priority'?'prty':action_widget[i]);
var action_event = toolbar._actionManager.getActionById(action_widget[i]);
if (typeof action_event.checkbox != 'undefined' && action_event.checkbox)
{
widget.set_value(action_event.checked?"on":"off");
}
else if (action_event && toolbar.options)
{
widget.set_value(toolbar.options.actions[action_event.id]['value']||'3');
}
}
}
this.et2._inst.submit(null,null,true);
},
/**
* Set the selected priority value
* @param {type} _action selected action
* @returns {undefined}
*/
compose_priorityChange: function (_action)
{
var widget = this.et2.getWidgetById ('priority');
if (widget)
{
widget.set_value(_action.id);
}
},
/**
* Triger relative widget via its toolbar identical action
* @param {type} _action toolbar action