2015-01-13 18:36:18 +01:00
|
|
|
/*
|
|
|
|
* Egroupware - Calendar javascript for home favorite portlet(s)
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package calendar
|
|
|
|
* @subpackage home
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2015-08-05 23:24:07 +02:00
|
|
|
/*egw:uses
|
|
|
|
/calendar/js/app.js;
|
|
|
|
*/
|
2015-01-13 18:36:18 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom code for calendar favorite home page portlets.
|
|
|
|
* Since calendar doesn't use etemplate2, as well as having multiple different
|
|
|
|
* views, we need some custom handling to detect and handle refreshes.
|
|
|
|
*
|
|
|
|
* Note we put the class in home.
|
|
|
|
*/
|
|
|
|
app.classes.home.calendar_favorite_portlet = app.classes.home.home_favorite_portlet.extend({
|
|
|
|
|
|
|
|
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
|
|
|
|
{
|
|
|
|
if(this.portlet.getWidgetById('nm'))
|
|
|
|
{
|
|
|
|
// List view, we can just update it
|
|
|
|
this.portlet.getWidgetById('nm').refresh(_id,_type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-05 23:24:07 +02:00
|
|
|
var event = egw.dataGetUIDdata('calendar::'+_id);
|
|
|
|
if(event && event.data && event.data.date)
|
2015-01-13 18:36:18 +01:00
|
|
|
{
|
2015-08-05 23:24:07 +02:00
|
|
|
var new_cache_id = app.classes.calendar._daywise_cache_id(event.data.date);
|
|
|
|
var daywise = egw.dataGetUIDdata(new_cache_id);
|
|
|
|
daywise = daywise ? daywise.data : [];
|
|
|
|
if(_type === 'delete')
|
|
|
|
{
|
|
|
|
daywise.splice(daywise.indexOf(_id),1);
|
|
|
|
}
|
|
|
|
else if (daywise.indexOf(_id) < 0)
|
|
|
|
{
|
|
|
|
daywise.push(_id);
|
|
|
|
}
|
|
|
|
egw.dataStoreUID(new_cache_id,daywise);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No intelligence since we don't have access to the state
|
|
|
|
// (app.calendar.getState() is for the calendar tab, not home)
|
|
|
|
// just refresh on every calendar or infolog change
|
|
|
|
if(_app == 'calendar' || _app == 'infolog')
|
|
|
|
{
|
|
|
|
app.home.refresh(this.portlet.id);
|
|
|
|
}
|
2015-01-13 18:36:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|