← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~artmello/ubuntu-calendar-app/ubuntu-calendar-app-fix_1539982 into lp:ubuntu-calendar-app

 

Arthur Mello has proposed merging lp:~artmello/ubuntu-calendar-app/ubuntu-calendar-app-fix_1539982 into lp:ubuntu-calendar-app.

Commit message:
Make sure that dates from previous/next months can be selected from month view

Requested reviews:
  Ubuntu Calendar Developers (ubuntu-calendar-dev)
Related bugs:
  Bug #1539982 in Ubuntu Calendar App: "Chooses wrong month when creating event from the month view"
  https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1539982

For more details, see:
https://code.launchpad.net/~artmello/ubuntu-calendar-app/ubuntu-calendar-app-fix_1539982/+merge/290035

Make sure that dates from previous/next months can be selected from month view

Tests
-----
In Month view, make sure that any date is highlighted after clicked. Test with dates from previous, current and next month.
It should still work when previous month is December from last year and next month is January from next
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~artmello/ubuntu-calendar-app/ubuntu-calendar-app-fix_1539982 into lp:ubuntu-calendar-app.
=== modified file 'MonthComponent.qml'
--- MonthComponent.qml	2016-03-09 01:35:28 +0000
+++ MonthComponent.qml	2016-03-24 13:03:37 +0000
@@ -95,14 +95,19 @@
                 return -1;
             }
 
-            if ((root.currentMonth === date.getMonth()) &&
-                (root.currentYear === date.getFullYear())) {
-
-                return date.getDate() +
-                       (Date.daysInMonth(monthStartYear, monthStartMonth) - monthStartDate);
-            } else {
-                return -1;
+            if (date.getFullYear() < root.currentYear ||
+                (date.getFullYear() === root.currentYear && date.getMonth() < root.currentMonth)) {
+                return offset - (Date.daysInMonth(date.getFullYear(), date.getMonth()) - date.getDate());
+
+            } else if (date.getFullYear() === root.currentYear && date.getMonth() === root.currentMonth) {
+               return offset + date.getDate();
+
+            } else if (date.getFullYear() > root.currentYear ||
+                       (date.getFullYear() === root.currentYear && date.getMonth() > root.currentMonth)) {
+                return offset + Date.daysInMonth(root.currentYear, root.currentMonth) + date.getDate();
             }
+
+            return -1;
         }
     }
 
@@ -245,19 +250,14 @@
             var dayItem = getItemAt(mouse.x, mouse.y)
 
             if( dayItem.isSelected ) {
-                var selectedDate = new Date();
-                selectedDate.setFullYear(intern.monthStartYear)
-                selectedDate.setMonth(intern.monthStartMonth + 1)
-                selectedDate.setDate(dayItem.date)
+                var selectedDate = new Date(dayItem.delegateDate.getTime());
                 selectedDate.setMinutes(60, 0, 0)
                 pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
             }
         }
         onClicked: {
             var dayItem = getItemAt(mouse.x, mouse.y)
-            var selectedDate = new Date(intern.monthStartYear,
-                                        intern.monthStartMonth + 1,
-                                        dayItem.date, 0, 0, 0, 0)
+            var selectedDate = new Date(dayItem.delegateDate.getTime());
             if (root.isYearView) {
                 //If yearView is clicked then open selected MonthView
                 root.monthSelected(selectedDate);


Follow ups