Merge lp:~renatofilho/ubuntu-calendar-app/fix-1439049 into lp:ubuntu-calendar-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Arthur Mello
Approved revision: 787
Merged at revision: 795
Proposed branch: lp:~renatofilho/ubuntu-calendar-app/fix-1439049
Merge into: lp:ubuntu-calendar-app
Diff against target: 269 lines (+92/-52)
1 file modified
calendar.qml (+92/-52)
To merge this branch: bzr merge lp:~renatofilho/ubuntu-calendar-app/fix-1439049
Reviewer Review Type Date Requested Status
Arthur Mello (community) Approve
Nekhelesh Ramananthan Approve
Review via email: mp+289198@code.launchpad.net

Commit message

Accept 'calendar://*' url as argument on app startup.

This is necessary because url-dispatcher calls the app with uri as an argument if the app is not opened yet.

Description of the change

To post a comment you must log in.
783. By Renato Araujo Oliveira Filho

Trunk merged.

784. By Renato Araujo Oliveira Filho

Accept 'startdate' in the uri handler.

785. By Renato Araujo Oliveira Filho

Trunk merged.

786. By Renato Araujo Oliveira Filho

Handle 'startTime' arg on uri.

Make sure that the app opens on day view with the 'startTime' visible when app is called from uri handler.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

On testing on the device, I found that clicking the event in the indicator opens the calendar app in the Day View (nice!) rather than the month/year/week view. It also nicely positions the hours close to the event. However it does not show the event details page which is critical to fixing this bug.

review: Needs Fixing
Revision history for this message
Arthur Mello (artmello) wrote :

Added some diff comments

review: Needs Fixing
787. By Renato Araujo Oliveira Filho

Removed debug message.
Fixed function name typo.

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> On testing on the device, I found that clicking the event in the indicator
> opens the calendar app in the Day View (nice!) rather than the month/year/week
> view. It also nicely positions the hours close to the event. However it does
> not show the event details page which is critical to fixing this bug.

yes we know that, unfortunately we do not have a API necessary to do this right now. (There is no way to fetch for a specific recurrence). As short term solution we will open the day view page in the event time.

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> Added some diff comments
fixed.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> > On testing on the device, I found that clicking the event in the indicator
> > opens the calendar app in the Day View (nice!) rather than the
> month/year/week
> > view. It also nicely positions the hours close to the event. However it does
> > not show the event details page which is critical to fixing this bug.
>
> yes we know that, unfortunately we do not have a API necessary to do this
> right now. (There is no way to fetch for a specific recurrence). As short term
> solution we will open the day view page in the event time.

Based on that reasoning, the MP lgtm.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> > On testing on the device, I found that clicking the event in the indicator
> > opens the calendar app in the Day View (nice!) rather than the
> month/year/week
> > view. It also nicely positions the hours close to the event. However it does
> > not show the event details page which is critical to fixing this bug.
>
> yes we know that, unfortunately we do not have a API necessary to do this
> right now. (There is no way to fetch for a specific recurrence). As short term
> solution we will open the day view page in the event time.

Based on that reasoning, the MP lgtm.

Revision history for this message
Nekhelesh Ramananthan (nik90) :
review: Approve
Revision history for this message
Arthur Mello (artmello) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'calendar.qml'
2--- calendar.qml 2016-03-17 17:45:21 +0000
3+++ calendar.qml 2016-03-22 19:00:24 +0000
4@@ -31,6 +31,29 @@
5 property int reminderDefaultValue: 900;
6 readonly property bool syncInProgress: commonHeaderActions.syncInProgress
7
8+ function handleUri(uri)
9+ {
10+ if(uri !== undefined && uri !== "") {
11+ var commands = uri.split("://")[1].split("=");
12+ if(commands[0].toLowerCase() === "eventid") {
13+ // calendar://eventid=??
14+ if( eventModel ) {
15+ // qtorganizer:eds::<event-id>
16+ var eventId = commands[1];
17+ var prefix = "qtorganizer:eds::";
18+ if (eventId.indexOf(prefix) < 0)
19+ eventId = prefix + eventId;
20+
21+ eventModel.showEventFromId(eventId);
22+ }
23+ } else if (commands[0].toLowerCase() === "startdate") {
24+ var date = new Date(commands[1])
25+ // this will be handled by Tabs.component.completed
26+ tabs.starttime = date.getTime()
27+ }
28+ }
29+ }
30+
31 // Work-around until this branch lands:
32 // https://code.launchpad.net/~tpeeters/ubuntu-ui-toolkit/optIn-tabsDrawer/+merge/212496
33 //property bool windowActive: typeof window != 'undefined'
34@@ -100,21 +123,11 @@
35 Connections {
36 target: UriHandler
37 onOpened: {
38- var uri = uris[0]
39- if(uri !== undefined && uri !== "") {
40- var commands = uri.split("://")[1].split("=");
41- if(commands[0].toLowerCase() === "eventid") {
42- // calendar://eventid=??
43- if( eventModel ) {
44- // qtorganizer:eds::<event-id>
45- var eventId = commands[1];
46- var prefix = "qtorganizer:eds::";
47- if (eventId.indexOf(prefix) < 0)
48- eventId = prefix + eventId;
49-
50- eventModel.showEventFromId(eventId);
51- }
52- }
53+ handleUri(uris[0])
54+ if (tabs.starttime !== -1) {
55+ tabs.currentDay = new Date(tabs.starttime);
56+ tabs.selectedTabIndex = dayTab.index
57+ tabs.starttime = -1
58 }
59 }
60 }
61@@ -240,11 +253,16 @@
62 var requestId = "";
63 var callbackFunc = function(id,fetchedItems) {
64 if( requestId === id && fetchedItems.length > 0 ) {
65- pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":fetchedItems[0],"model": eventModel});
66+ var event = fetchedItems[0]
67+ var currentPage = tabs.selectedTab.page.item
68+ if (currentPage.showDate) {
69+ currentPage.showDate(event.startDateTime)
70+ }
71+
72+ pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":event,"model": eventModel});
73 }
74 eventModel.onItemsFetched.disconnect( callbackFunc );
75 }
76-
77 eventModel.onItemsFetched.connect( callbackFunc );
78 requestId = eventModel.fetchItems(eventId);
79 }
80@@ -282,8 +300,8 @@
81
82 // Arguments on startup
83 property bool newevent: false;
84- property int starttime: -1;
85- property int endtime: -1;
86+ property real starttime: -1;
87+ property real endtime: -1;
88 property string eventId;
89
90 //WORKAROUND: The new header api does not work with tabs check bug: #1539759
91@@ -380,14 +398,20 @@
92 var starttimepattern = new RegExp ("starttime=\\d+");
93 var endtimepattern = new RegExp ("endtime=\\d+");
94 var eventIdpattern = new RegExp ("eventId=.*")
95+ var urlpattern = new RegExp("calendar://.*")
96+
97+ if (urlpattern.test(url)) {
98+ handleUri(url)
99+ return
100+ }
101
102 newevent = newevenpattern.test(url);
103
104 if (starttimepattern.test(url))
105- starttime = url.match(/starttime=(\d+)/)[1];
106+ starttime = parseInt(url.match(/starttime=(\d+)/)[1]);
107
108 if (endtimepattern.test(url))
109- endtime = url.match(/endtime=(\d+)/)[1];
110+ endtime = parseInt(url.match(/endtime=(\d+)/)[1]);
111
112 if (eventIdpattern.test(url))
113 eventId = url.match(/eventId=(.*)/)[1];
114@@ -396,20 +420,17 @@
115 Component.onCompleted: {
116 // If an url has been set
117 if (args.defaultArgument.at(0)) {
118+ tabs.currentDay = new Date()
119 parseArguments(args.defaultArgument.at(0))
120- tabs.currentDay = new Date()
121 // If newevent has been called on startup
122 if (newevent) {
123 timer.running = true;
124 }
125 else if (starttime !== -1) { // If no newevent has been setted, but starttime
126- var startTime = parseInt(starttime);
127- tabs.currentDay = new Date(startTime);
128-
129+ tabs.currentDay = new Date(tabs.starttime);
130 // If also endtime has been settend
131 if (endtime !== -1) {
132- var endTime = parseInt(endtime);
133- tabs.selectedTabIndex = calculateDifferenceStarttimeEndtime(startTime, endTime);
134+ tabs.selectedTabIndex = calculateDifferenceStarttimeEndtime(tabs.startTime, tabs.endTime);
135 }
136 else {
137 // If no endtime has been setted, open the starttime date in day view
138@@ -432,6 +453,9 @@
139 else {
140 tabs.selectedTabIndex = settings.defaultViewIndex;
141 }
142+ tabs.starttime = -1
143+ tabs.endtime = -1
144+ tabs.eventId = ""
145 tabs.isReady = true
146 // WORKAROUND: Due the missing feature on SDK, they can not detect if
147 // there is a mouse attached to device or not. And this will cause the
148@@ -575,6 +599,11 @@
149 YearView {
150 readonly property bool tabSelected: tabs.selectedTabIndex === yearTab.index
151
152+ function showDate(date)
153+ {
154+ refreshCurrentYear(date.getFullYear())
155+ }
156+
157 reminderValue: mainView.reminderDefaultValue
158 model: eventModel.isReady ? eventModel : null
159 bootomEdgeEnabled: tabSelected
160@@ -597,7 +626,7 @@
161
162 onTabSelectedChanged: {
163 if (tabSelected) {
164- refreshCurrentYear(tabs.currentDay.getFullYear())
165+ showDate(tabs.currentDay)
166 }
167 }
168 }
169@@ -609,6 +638,14 @@
170 MonthView {
171 readonly property bool tabSelected: tabs.selectedTabIndex === monthTab.index
172
173+ function showDate(date)
174+ {
175+ anchorDate = new Date(date.getFullYear(),
176+ date.getMonth(),
177+ 1,
178+ 0, 0, 0)
179+ }
180+
181 reminderValue: mainView.reminderDefaultValue
182 model: eventModel.isReady ? eventModel : null
183 bootomEdgeEnabled: tabSelected
184@@ -632,10 +669,7 @@
185
186 onTabSelectedChanged: {
187 if (tabSelected) {
188- anchorDate = new Date(tabs.currentDay.getFullYear(),
189- tabs.currentDay.getMonth(),
190- 1,
191- 0, 0, 0)
192+ showDate(tabs.currentDay)
193 }
194 }
195 }
196@@ -647,6 +681,18 @@
197 WeekView {
198 readonly property bool tabSelected: tabs.selectedTab === weekTab
199
200+ function showDate(date)
201+ {
202+ var dateGoTo = new Date(date)
203+ if (!anchorDate ||
204+ (dateGoTo.getFullYear() != anchorDate.getFullYear()) ||
205+ (dateGoTo.getMonth() != anchorDate.getMonth()) ||
206+ (dateGoTo.getDate() != anchorDate.getDate())) {
207+ anchorDate = new Date(dateGoTo)
208+ }
209+ delayScrollToDate(dateGoTo)
210+ }
211+
212 reminderValue: mainView.reminderDefaultValue
213 model: eventModel.isReady ? eventModel : null
214 bootomEdgeEnabled: tabSelected
215@@ -674,16 +720,7 @@
216
217 onTabSelectedChanged: {
218 if (tabSelected) {
219- // 'tabs.currntDay' can change after set 'anchorDate' to avoid that
220- // create a copy of the current value
221- var tabDate = new Date(tabs.currentDay)
222- if (!anchorDate ||
223- (tabs.currentDay.getFullYear() != anchorDate.getFullYear()) ||
224- (tabs.currentDay.getMonth() != anchorDate.getMonth()) ||
225- (tabs.currentDay.getDate() != anchorDate.getDate())) {
226- anchorDate = new Date(tabDate)
227- }
228- delayScrollToDate(tabDate)
229+ showDate(tabs.currentDay)
230 }
231 }
232 }
233@@ -695,6 +732,18 @@
234 DayView {
235 readonly property bool tabSelected: tabs.selectedTabIndex === dayTab.index
236
237+ function showDate(date)
238+ {
239+ var dateGoTo = new Date(date)
240+ if (!anchorDate ||
241+ (dateGoTo.getFullYear() != anchorDate.getFullYear()) ||
242+ (dateGoTo.getMonth() != anchorDate.getMonth()) ||
243+ (dateGoTo.getDate() != anchorDate.getDate())) {
244+ anchorDate = new Date(dateGoTo)
245+ }
246+ delayScrollToDate(dateGoTo)
247+ }
248+
249 reminderValue: mainView.reminderDefaultValue
250 model: eventModel.isReady ? eventModel : null
251 bootomEdgeEnabled: tabSelected
252@@ -714,16 +763,7 @@
253
254 onTabSelectedChanged: {
255 if (tabSelected) {
256- // 'tabs.currntDay' can change after set 'anchorDate' to avoid that
257- // create a copy of the current value
258- var tabDate = new Date(tabs.currentDay)
259- if (!anchorDate ||
260- (tabs.currentDay.getFullYear() != anchorDate.getFullYear()) ||
261- (tabs.currentDay.getMonth() != anchorDate.getMonth()) ||
262- (tabs.currentDay.getDate() != anchorDate.getDate())) {
263- anchorDate = new Date(tabDate)
264- }
265- delayScrollToDate(tabDate)
266+ showDate(tabs.currentDay)
267 }
268 }
269 }

Subscribers

People subscribed via source and target branches

to status/vote changes: