Try to not always refresh calendar via observer for every infolog entry, but only the ones that are integrated in calendar

This commit is contained in:
Hadi Nategh 2014-06-26 12:39:20 +00:00
parent 2244d6fc63
commit dcad41f542
2 changed files with 45 additions and 15 deletions

View File

@ -141,26 +141,40 @@ app.classes.calendar = AppJS.extend(
*/ */
observer: function(_msg, _app, _id, _type, _msg_type, _links) observer: function(_msg, _app, _id, _type, _msg_type, _links)
{ {
if (typeof _links != 'undefined') var do_refresh = false;
switch(_app)
{ {
if (typeof _links.calendar != 'undefined') case 'infolog':
{ {
switch(_app) jQuery('.calendar_calDayTodos')
.find('a')
.each(function(i,a){
var match = a.href.split(/&info_id=/);
if (match && typeof match[1] !="undefined")
{
if (match[1]== _id) do_refresh = true;
}
});
if (jQuery('div [id^="infolog'+_id+'"]').length > 0) do_refresh = true;
switch (_type)
{ {
case 'infolog': case 'add':
do_refresh = true;
break;
}
if (do_refresh)
{
if (typeof this.et2 != 'undefined' && this.et2 !=null)
{ {
if (typeof this.et2 != 'undefined' && this.et2 !=null) this.egw.refresh(_msg, 'calendar');
{
this.egw.refresh(_msg, 'calendar');
}
else
{
window.location.reload();
}
} }
break; else
} {
window.location.reload();
}
}
} }
break;
} }
}, },

View File

@ -96,7 +96,23 @@ app.classes.infolog = AppJS.extend(
break; break;
} }
} }
} }
//Refresh handler for infologs integrated in calendar
if (_app == 'infolog' && _id && _type !='delete')
{
var info_type = egw.dataGetUIDdata(_app+"::"+_id)?egw.dataGetUIDdata(_app+"::"+_id).data.info_type:false;
var cal_show = egw.preference('cal_show','infolog')||false;
if (info_type && cal_show)
{
var rex = RegExp(info_type,'gi');
if (cal_show.match(rex))
{
//Trigger refresh the whole calendar if the changed infolog entry is integrated one
if (typeof app['calendar'] != 'undefined') app.calendar.egw.window.location.reload();
}
}
}
}, },
/** /**