Keep hooked sidebox templates from other applications (resources) up to date as state changes

This commit is contained in:
Nathan Gray 2015-12-14 22:08:12 +00:00
parent 9252607705
commit d07ab5285f

View File

@ -70,6 +70,10 @@ app.classes.calendar = AppJS.extend(
// date in the current view. // date in the current view.
sidebox_changes_views: ['day','week','month'], sidebox_changes_views: ['day','week','month'],
// Calendar allows other apps to hook into the sidebox. We keep these etemplates
// up to date as state is changed.
sidebox_hooked_templates: [],
/** /**
* Constructor * Constructor
* *
@ -112,6 +116,7 @@ app.classes.calendar = AppJS.extend(
var date = this.sidebox_et2.getWidgetById('date'); var date = this.sidebox_et2.getWidgetById('date');
$j(window).off('resize.calendar'+date.dom_id); $j(window).off('resize.calendar'+date.dom_id);
} }
this.sidebox_hooked_templates = null;
egw_unregisterGlobalShortcut(jQuery.ui.keyCode.PAGE_UP, false, false, false); egw_unregisterGlobalShortcut(jQuery.ui.keyCode.PAGE_UP, false, false, false);
egw_unregisterGlobalShortcut(jQuery.ui.keyCode.PAGE_DOWN, false, false, false); egw_unregisterGlobalShortcut(jQuery.ui.keyCode.PAGE_DOWN, false, false, false);
@ -147,6 +152,7 @@ app.classes.calendar = AppJS.extend(
{ {
case 'calendar.sidebox': case 'calendar.sidebox':
this.sidebox_et2 = _et2.widgetContainer; this.sidebox_et2 = _et2.widgetContainer;
this.sidebox_hooked_templates.push(this.sidebox_et2);
$j(_et2.DOMContainer).hide(); $j(_et2.DOMContainer).hide();
this._setup_sidebox_filters(); this._setup_sidebox_filters();
break; break;
@ -1976,9 +1982,18 @@ app.classes.calendar = AppJS.extend(
this._sortable(); this._sortable();
/* Update sidebox widgets to show current value*/ /* Update sidebox widgets to show current value*/
if(this.sidebox_et2) if(this.sidebox_hooked_templates.length)
{ {
this.sidebox_et2.iterateOver(function(widget) { for(var j = 0; j < this.sidebox_hooked_templates.length; j++)
{
var sidebox = this.sidebox_hooked_templates[j];
// Remove any destroyed or not valid templates
if(!sidebox.getInstanceManager || !sidebox.getInstanceManager())
{
this.sidebox_hooked_templates.splice(j,1,0);
continue;
}
sidebox.iterateOver(function(widget) {
if(widget.id == 'view') if(widget.id == 'view')
{ {
// View widget has a list of state settings, which require special handling // View widget has a list of state settings, which require special handling
@ -2022,6 +2037,7 @@ app.classes.calendar = AppJS.extend(
} }
},this,et2_valueWidget); },this,et2_valueWidget);
} }
}
// If current state matches a favorite, hightlight it // If current state matches a favorite, hightlight it
this.highlight_favorite(); this.highlight_favorite();
@ -2904,6 +2920,22 @@ app.classes.calendar = AppJS.extend(
this.setState({state:this.state}); this.setState({state:this.state});
} }
} }
else
{
var app_name = _name.split('.')[0];
if(app_name && app_name != 'calendar' && egw.app(app_name))
{
// A template from another application? Keep it up to date as state changes
this.sidebox_hooked_templates.push(_et2.widgetContainer);
// If it leaves (or reloads) remove it
$j(_et2.DOMContainer).one('clear',jQuery.proxy(function() {
if(app.calendar)
{
app.calendar.sidebox_hooked_templates.splice(this,1,0);
}
},this.sidebox_hooked_templates.length -1));
}
}
}, },
/** /**