Fix closing & reopening Calendar crashed egw

If only 1 user selected in sidebox, add user name to app header
This commit is contained in:
Nathan Gray 2015-10-15 20:06:19 +00:00
parent 8b42f6aeb8
commit 4184d88027

View File

@ -297,6 +297,10 @@ app.classes.calendar = AppJS.extend(
*/ */
linkHandler: function(_url) linkHandler: function(_url)
{ {
if (_url == 'about:blank')
{
return false;
}
if (_url.match('menuaction=calendar\.calendar_uiviews\.')) if (_url.match('menuaction=calendar\.calendar_uiviews\.'))
{ {
var view = _url.match(/calendar_uiviews\.([^&?]+)/); var view = _url.match(/calendar_uiviews\.([^&?]+)/);
@ -305,18 +309,13 @@ app.classes.calendar = AppJS.extend(
// Get query // Get query
var q = {}; var q = {};
_url.split('?')[1].split('&').forEach(function(i){ _url.split('?')[1].split('&').forEach(function(i){
q[i.split('=')[0]]=i.split('=')[1]; q[i.split('=')[0]]=unescape(i.split('=')[1]);
}); });
delete q.ajax; delete q.ajax;
delete q.menuaction; delete q.menuaction;
if((!view || view == 'index') && q.view) view = q.view; if(!view && q.view) view = q.view;
if (this.sidebox_et2 && typeof app.classes.calendar.views[view] == 'undefined' && view != 'index')
if (this.sidebox_et2 && typeof app.classes.calendar.views[view] == 'undefined')
{ {
for(var key in q)
{
q[key] = unescape(q[key]);
}
if(q.owner) if(q.owner)
{ {
q.owner = q.owner.split(','); q.owner = q.owner.split(',');
@ -331,6 +330,13 @@ app.classes.calendar = AppJS.extend(
// Known AJAX view // Known AJAX view
else if(app.classes.calendar.views[view]) else if(app.classes.calendar.views[view])
{ {
// Reload of known view?
if(view == 'index')
{
var pref = this.egw.preference('saved_states','calendar');
view = pref.view || 'day';
}
// View etemplate not loaded
if(typeof app.classes.calendar.views[view].etemplates[0] == 'string') if(typeof app.classes.calendar.views[view].etemplates[0] == 'string')
{ {
return _url + '&ajax=true'; return _url + '&ajax=true';
@ -341,9 +347,10 @@ app.classes.calendar = AppJS.extend(
return true; return true;
} }
} }
else if (_url.indexOf('menuaction=calendar.calendar_') >= 0) else if (this.sidebox_et2)
{ {
var iframe = this.sidebox_et2.getWidgetById('iframe'); var iframe = this.sidebox_et2.getWidgetById('iframe');
if(!iframe) return false;
iframe.set_src(_url); iframe.set_src(_url);
$j(this.sidebox_et2.parentNode).show(); $j(this.sidebox_et2.parentNode).show();
// Hide other views // Hide other views
@ -1808,7 +1815,7 @@ app.classes.calendar = AppJS.extend(
// prepend an owner 0, to reset all owners and not just set given resource type // prepend an owner 0, to reset all owners and not just set given resource type
if(typeof query.owner != 'undefined') if(typeof query.owner != 'undefined')
{ {
query.owner = '0,'+ query.owner; query.owner = '0,'+ query.owner.replace('0,','');
} }
this.egw.open_link(this.egw.link('/index.php',query), 'calendar'); this.egw.open_link(this.egw.link('/index.php',query), 'calendar');
@ -2502,7 +2509,7 @@ app.classes.calendar = AppJS.extend(
app.classes.calendar.views[view].etemplates[index] = _et2; app.classes.calendar.views[view].etemplates[index] = _et2;
// If a template disappears, we want to release it // If a template disappears, we want to release it
$j(_et2.DOMContainer).one('clear',jQuery.proxy(function() { $j(_et2.DOMContainer).one('clear',jQuery.proxy(function() {
this.view[index] = _name; this.view.etemplates[this.index] = _name;
},jQuery.extend({},{view: app.classes.calendar.views[view], index: ""+index, name: _name}))); },jQuery.extend({},{view: app.classes.calendar.views[view], index: ""+index, name: _name})));
if(this.state.view === view) if(this.state.view === view)
@ -2544,7 +2551,23 @@ app.classes.calendar = AppJS.extend(
header: function(state) { header: function(state) {
var formatDate = new Date(state.date); var formatDate = new Date(state.date);
formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000); formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000);
return date(egw.preference('dateformat'),formatDate); return app.calendar.View._owner(state) + date(egw.preference('dateformat'),formatDate);
},
/**
* If one owner, get the owner text
*/
_owner: function(state) {
var owner = '';
if(state.owner.length && state.owner.length == 1)
{
var own = app.calendar.sidebox_et2.getWidgetById('owner').getDOMNode();
if(own.selectedIndex >= 0)
{
owner = own.options[own.selectedIndex].innerHTML + ": ";
}
}
return owner;
}, },
/** /**
@ -2714,8 +2737,8 @@ jQuery.extend(app.classes.calendar,{
}), }),
week: app.classes.calendar.prototype.View.extend({ week: app.classes.calendar.prototype.View.extend({
header: function(state) { header: function(state) {
var formatDate = new Date(state.first);
return app.calendar.egw.lang('Weekview') + ': ' + app.calendar.egw.lang('Week') + ' ' + return app.calendar.egw.lang('Weekview') + ': ' + app.calendar.View._owner(state) + app.calendar.egw.lang('Week') + ' ' +
app.calendar.date.week_number(state.first) + ': ' + app.calendar.date.week_number(state.first) + ': ' +
app.calendar.date.long_date(state.first, state.last) app.calendar.date.long_date(state.first, state.last)
}, },
@ -2739,7 +2762,7 @@ jQuery.extend(app.classes.calendar,{
}), }),
weekN: app.classes.calendar.prototype.View.extend({ weekN: app.classes.calendar.prototype.View.extend({
header: function(state) { header: function(state) {
return app.calendar.egw.lang('Week') + ' ' + return app.calendar.View._owner(state) + app.calendar.egw.lang('Week') + ' ' +
app.calendar.date.week_number(state.first) + ' - ' + app.calendar.date.week_number(state.first) + ' - ' +
app.calendar.date.week_number(state.last) + ': ' + app.calendar.date.week_number(state.last) + ': ' +
app.calendar.date.long_date(state.first, state.last) app.calendar.date.long_date(state.first, state.last)
@ -2764,7 +2787,7 @@ jQuery.extend(app.classes.calendar,{
{ {
var formatDate = new Date(state.date); var formatDate = new Date(state.date);
formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000); formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000);
return app.calendar.egw.lang('Monthview') + ':' + app.calendar.egw.lang(date('F',formatDate)) + ' ' + date('Y',formatDate); return app.calendar.View._owner(state) + app.calendar.egw.lang('Monthview') + ': ' + app.calendar.egw.lang(date('F',formatDate)) + ' ' + date('Y',formatDate);
}, },
start_date: function(state) { start_date: function(state) {
var d = app.calendar.View.start_date.call(this,state); var d = app.calendar.View.start_date.call(this,state);
@ -2803,7 +2826,7 @@ jQuery.extend(app.classes.calendar,{
var endDate = new Date(state.last); var endDate = new Date(state.last);
endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000); endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000);
var title = state.sortby == 'user' ? 'planner by user' : state.sortby=='month' ? 'yearly planner' : 'planner by category'; var title = state.sortby == 'user' ? 'planner by user' : state.sortby=='month' ? 'yearly planner' : 'planner by category';
return app.calendar.egw.lang(title) + ': ' + date(egw.preference('dateformat'),startDate) + return app.calendar.egw.lang(title) + ': ' + app.calendar.View._owner(state) + date(egw.preference('dateformat'),startDate) +
(startDate == endDate ? '' : ' - ' + date(egw.preference('dateformat'),endDate)); (startDate == endDate ? '' : ' - ' + date(egw.preference('dateformat'),endDate));
}, },
etemplates: ['calendar.planner'], etemplates: ['calendar.planner'],
@ -2891,7 +2914,7 @@ jQuery.extend(app.classes.calendar,{
}), }),
listview: app.classes.calendar.prototype.View.extend({ listview: app.classes.calendar.prototype.View.extend({
header: function() {return app.calendar.egw.lang('Listview');}, header: function() {return app.calendar.egw.lang('Listview')},
etemplates: ['calendar.list'] etemplates: ['calendar.list']
}) })
}} }}