From dcad41f542d74413561cec363a5163dc87ec1b7c Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 26 Jun 2014 12:39:20 +0000 Subject: [PATCH] Try to not always refresh calendar via observer for every infolog entry, but only the ones that are integrated in calendar --- calendar/js/app.js | 42 ++++++++++++++++++++++++++++-------------- infolog/js/app.js | 18 +++++++++++++++++- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 77cdfa464a..aa77fa5129 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -141,26 +141,40 @@ app.classes.calendar = AppJS.extend( */ 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'); - } - else - { - window.location.reload(); - } + this.egw.refresh(_msg, 'calendar'); } - break; - } + else + { + window.location.reload(); + } + } } + break; } }, diff --git a/infolog/js/app.js b/infolog/js/app.js index 2ea6c26d0b..af8ce4e6a8 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -96,7 +96,23 @@ app.classes.infolog = AppJS.extend( 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(); + } + } + } }, /**