From cc27108ee7d0ed480190cdfd5d35bce9568e939d Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 20 Mar 2017 10:12:15 -0600 Subject: [PATCH] Calendar - fix no events shown in planner if you had empty rows hidden --- calendar/js/app.js | 4 +++ calendar/js/et2_widget_event.js | 2 +- calendar/js/et2_widget_planner.js | 53 +++++++++++++++++++++---------- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 427041aef7..b52dbdf3ea 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -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) diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index e2d5e802bf..2016130b72 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -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 = []; diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 662f2c2f91..b4a637ac22 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -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 *