From d8b052519baf86dfe50851a0392fc428d75b02cb Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 17 Apr 2018 10:38:49 -0600 Subject: [PATCH] * Calendar - yearly planner view events would sometimes load in the next month as well --- calendar/js/et2_widget_planner.js | 37 ++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index d8903c350c..44c0bac068 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -585,28 +585,35 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e var end_key = end.getFullYear() +'-'+end.getMonth(); var year = start.getFullYear(); var month = start.getMonth(); - while(key <= end_key) + key = sprintf('%04d-%d',year,month); + + do { + var end_label_index = label_index; + + for(var i = end_label_index; i < labels.length; i++) + { + if(labels[i].id == key) + { + end_label_index = i; + if(typeof rows[end_label_index] === 'undefined') + { + rows[end_label_index] = []; + } + break; + } + } + if(end_label_index != label_index) + { + rows[label_index].push(event); + } if (++month > 11) { ++year; month = 0; } key = sprintf('%04d-%d',year,month); - for(var i = 0; i < labels.length; i++) - { - if(labels[i].id == key) - { - label_index = i; - if(typeof rows[label_index] === 'undefined') - { - rows[label_index] = []; - } - break; - } - } - rows[label_index].push(event); - } + } while(key <= end_key) }, // Draw a single row, but split up the dates draw_row: function(sort_key, label, events)