use observer in mail to overwrite refresh for Sieve rules in iframe (like app_refresh)

This commit is contained in:
Ralf Becker 2014-05-23 09:21:59 +00:00
parent ddc1b2d673
commit f5c186c384
2 changed files with 59 additions and 16 deletions

View File

@ -320,7 +320,7 @@ class mail_sieve
$msg .= "\n".lang("Error: Could not save rule").' '.lang("No action defined!"); $msg .= "\n".lang("Error: Could not save rule").' '.lang("No action defined!");
$error++; $error++;
} }
egw_framework::refresh_opener($msg, 'mail'); egw_framework::refresh_opener($msg, 'mail', 'sieve');
if ($button == "apply") if ($button == "apply")
{ {
break; break;
@ -343,7 +343,7 @@ class mail_sieve
$this->rules = array_values($this->rules); $this->rules = array_values($this->rules);
$this->updateScript(); $this->updateScript();
} }
egw_framework::refresh_opener($msg, 'mail'); egw_framework::refresh_opener($msg, 'mail', 'sieve');
case 'cancel': case 'cancel':
egw_framework::window_close(); egw_framework::window_close();
@ -619,7 +619,7 @@ class mail_sieve
// refresh vacationNotice on index // refresh vacationNotice on index
$response = egw_json_response::get(); $response = egw_json_response::get();
$response->call('app.mail.mail_callRefreshVacationNotice',$this->mailbo->profileID); $response->call('app.mail.mail_callRefreshVacationNotice',$this->mailbo->profileID);
egw_framework::refresh_opener($msg, 'mail','edit'); egw_framework::refresh_opener($msg, 'mail');
if ($button === 'apply' || $icServer->error !=="") if ($button === 'apply' || $icServer->error !=="")
{ {
break; break;

View File

@ -158,6 +158,49 @@ app.classes.mail = AppJS.extend(
} }
}, },
/**
* Observer method receives update notifications from all applications
*
* App is responsible for only reacting to "messages" it is interested in!
*
* @param {string} _msg message (already translated) to show, eg. 'Entry deleted'
* @param {string} _app application name
* @param {(string|number)} _id id of entry to refresh or null
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
* - update: request just modified data from given rows. Sorting is not considered,
* so if the sort field is changed, the row will not be moved.
* - edit: rows changed, but sorting may be affected. Requires full reload.
* - delete: just delete the given rows clientside (no server interaction neccessary)
* - add: requires full reload for proper sorting
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
* @param {string} _targetapp which app's window should be refreshed, default current
* @return {false|*} false to stop regular refresh, thought all observers are run
*/
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
{
switch(_app)
{
case 'mail':
if (_id === 'sieve')
{
var iframe = this.et2.getWidgetById('extra_iframe');
if (iframe && iframe.getDOMNode())
{
var contentWindow = iframe.getDOMNode().contentWindow;
if (contentWindow && contentWindow.app && contentWindow.app.mail)
{
contentWindow.app.mail.sieve_refresh();
}
}
return false; // mail nextmatch needs NOT to be refreshed
}
break;
case 'emailadmin':
// ToDo: update tree with given account _id and _type
}
},
/** /**
* mail rebuild Action menu On nm-list * mail rebuild Action menu On nm-list
* *