Calendar - fix no events shown in planner if you had empty rows hidden

This commit is contained in:
nathangray 2017-03-20 10:12:15 -06:00
parent a71f8e22ad
commit cc27108ee7
3 changed files with 41 additions and 18 deletions

View File

@ -4052,6 +4052,10 @@ jQuery.extend(app.classes.calendar,{
}
return d;
},
hide_empty: function(state) {
var check = state.sortby == 'user' ? ['user','both'] : ['cat','both'];
return (check.indexOf(egw.preference('planner_show_empty_rows','calendar')) === -1);
},
scroll: function(delta)
{
if(app.calendar.state.planner_view)

View File

@ -543,7 +543,7 @@ var et2_calendar_event = (function(){ "use strict"; return et2_valueWidget.exten
}
var participant_status = {A: 0, R: 0, T: 0, U: 0, D: 0};
var status_label = {A: 'accepted', R: 'rejected', T: 'tentative', U: 'unknown'};
var status_label = {A: 'accepted', R: 'rejected', T: 'tentative', U: 'unknown', D: 'declined'};
var participant_summary = Object.keys(this.options.value.participants).length + ' ' + this.egw().lang('Participants')+': ';
var status_totals = [];

View File

@ -46,6 +46,12 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
default: egw.preference('days_in_weekview','calendar') != 5,
description: "Display weekends. The date range should still include them for proper scrolling, but they just won't be shown."
},
hide_empty: {
name: "Hide empty rows",
type: "boolean",
default: false,
description: "Hide rows with no events."
},
value: {
type: "any",
description: "A list of events, optionally you can set start_date, end_date and group_by as keys and events will be fetched"
@ -507,23 +513,23 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
},
// Draw a single row
draw_row: function(sort_key, label, events) {
if(['user','both'].indexOf(egw.preference('planner_show_empty_rows','calendar')) !== -1 || events.length)
var row = this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
if(this.options.hide_empty && !events.length)
{
var row = this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
// Since the daywise cache is by user, we can tap in here
var t = new Date(this.options.start_date);
var end = new Date(this.options.end_date);
do
{
var cache_id = app.classes.calendar._daywise_cache_id(t, sort_key);
egw.dataRegisterUID(cache_id, row._data_callback, row);
t.setUTCDate(t.getUTCDate() + 1);
}
while(t < end);
return row;
row.set_disabled(true);
}
// Since the daywise cache is by user, we can tap in here
var t = new Date(this.options.start_date);
var end = new Date(this.options.end_date);
do
{
var cache_id = app.classes.calendar._daywise_cache_id(t, sort_key);
egw.dataRegisterUID(cache_id, row._data_callback, row);
t.setUTCDate(t.getUTCDate() + 1);
}
while(t < end);
return row;
}
},
@ -752,10 +758,12 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
}
},
draw_row: function(sort_key, label, events) {
if(['cat','both'].indexOf(egw.preference('planner_show_empty_rows','calendar')) !== -1 || events.length)
var row = this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
if(this.options.hide_empty && !events.length)
{
return this._drawRow(sort_key, label,events,this.options.start_date, this.options.end_date);
row.set_disabled(true);
}
return row;
}
}
},
@ -1904,6 +1912,7 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
if(row)
{
row._data_callback(this.cache[cache_id]);
row.set_disabled(this.options.hide_empty && this.cache[cache_id].length === 0);
}
else
{
@ -2011,6 +2020,16 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
}
},
/**
* Turn on or off the visibility of hidden (empty) rows
*
* @param {boolean} hidden
*/
set_hide_empty: function set_hide_empty(hidden)
{
this.options.hide_empty = hidden;
},
/**
* Call change handler, if set
*