From 43ac57b671ecf4f0d81daf3e40fab856a5d3b52a Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Tue, 10 Jun 2014 16:18:12 -0400 Subject: [PATCH 1/4] display the number of active tasks in calendar view --- .../Appointments/SOGoAppointmentFolder.h | 2 + .../Appointments/SOGoAppointmentFolder.m | 22 ++++++- UI/Scheduler/UIxCalendarSelector.m | 60 ++++++++++--------- .../SchedulerUI/UIxCalendarSelector.wox | 9 ++- 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index ee703b1d5..b09241cfd 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -80,6 +80,8 @@ typedef enum { - (NSArray *) calendarUIDs; +- (NSString *) activeTasks; + /* vevent UID handling */ - (NSString *) resourceNameForEventUID: (NSString *) _uid; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 61cef70dc..a70a0eb16 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -522,7 +522,6 @@ static iCalEvent *iCalEventK = nil; { /* this is used for group calendars (this folder just returns itself) */ NSString *s; - s = [[self container] nameInContainer]; // [self logWithFormat:@"CAL UID: %@", s]; return [s isNotNull] ? [NSArray arrayWithObjects:&s count:1] : nil; @@ -3270,4 +3269,25 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return users; } +- (NSString *) activeTasks +{ + NSArray *tasksList; + NSString *activeTasks; + NSMutableArray *fields; + + fields = [NSMutableArray arrayWithObjects: @"c_component", @"c_status", nil]; + + tasksList = [self bareFetchFields: fields + from: nil + to: nil + title: nil + component: @"vtodo" + additionalFilters: @"c_status != 2 AND c_status != 3"]; + + activeTasks = [NSString stringWithFormat:@"(%d)", [tasksList count]]; + + return activeTasks; +} + + @end /* SOGoAppointmentFolder */ diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index 7da4392b3..196299fad 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -92,38 +92,42 @@ _intValueFromHex (NSString *hexString) SOGoAppointmentFolder *folder; NSMutableDictionary *calendar; unsigned int count, max; - NSString *folderName, *fDisplayName; + NSString *folderName, *fDisplayName, *fActiveTasks; NSNumber *isActive; - + if (!calendars) + { + co = [self clientObject]; + folders = [co subFolders]; + max = [folders count]; + calendars = [[NSMutableArray alloc] initWithCapacity: max]; + for (count = 0; count < max; count++) { - co = [self clientObject]; - folders = [co subFolders]; - max = [folders count]; - calendars = [[NSMutableArray alloc] initWithCapacity: max]; - for (count = 0; count < max; count++) - { - folder = [folders objectAtIndex: count]; - calendar = [NSMutableDictionary dictionary]; - folderName = [folder nameInContainer]; - fDisplayName = [folder displayName]; - if (fDisplayName == nil) - fDisplayName = @""; - if ([fDisplayName isEqualToString: [co defaultFolderName]]) - fDisplayName = [self labelForKey: fDisplayName]; - [calendar setObject: [NSString stringWithFormat: @"/%@", folderName] - forKey: @"id"]; - [calendar setObject: fDisplayName forKey: @"displayName"]; - [calendar setObject: folderName forKey: @"folder"]; - [calendar setObject: [folder calendarColor] forKey: @"color"]; - isActive = [NSNumber numberWithBool: [folder isActive]]; - [calendar setObject: isActive forKey: @"active"]; - [calendar setObject: [folder ownerInContext: context] - forKey: @"owner"]; - [calendars addObject: calendar]; - } + folder = [folders objectAtIndex: count]; + calendar = [NSMutableDictionary dictionary]; + folderName = [folder nameInContainer]; + fDisplayName = [folder displayName]; + if (fDisplayName == nil) + fDisplayName = @""; + if ([fDisplayName isEqualToString: [co defaultFolderName]]) + fDisplayName = [self labelForKey: fDisplayName]; + [calendar setObject: [NSString stringWithFormat: @"/%@", folderName] + forKey: @"id"]; + [calendar setObject: fDisplayName forKey: @"displayName"]; + [calendar setObject: folderName forKey: @"folder"]; + [calendar setObject: [folder calendarColor] forKey: @"color"]; + isActive = [NSNumber numberWithBool: [folder isActive]]; + [calendar setObject: isActive forKey: @"active"]; + [calendar setObject: [folder ownerInContext: context] + forKey: @"owner"]; + fActiveTasks = [folder activeTasks]; + if (fActiveTasks == nil) + fActiveTasks = @""; + [calendar setObject:fActiveTasks forKey:@"activeTasks" ]; + [calendars addObject: calendar]; } - + } + return calendars; } diff --git a/UI/Templates/SchedulerUI/UIxCalendarSelector.wox b/UI/Templates/SchedulerUI/UIxCalendarSelector.wox index 477a64513..e5f0b03e6 100644 --- a/UI/Templates/SchedulerUI/UIxCalendarSelector.wox +++ b/UI/Templates/SchedulerUI/UIxCalendarSelector.wox @@ -38,9 +38,12 @@ div.colorBox.calendarFolder
  • -
  • +
    + + + + +
    From de2ee2322af740251ac82ca06deb1f7585637024 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Wed, 11 Jun 2014 10:24:04 -0400 Subject: [PATCH 2/4] Change the NSString with NSNumber and add some JavaScript --- .../Appointments/SOGoAppointmentFolder.h | 2 +- .../Appointments/SOGoAppointmentFolder.m | 8 ++-- UI/Scheduler/UIxCalendarSelector.m | 6 +-- .../SchedulerUI/UIxCalendarSelector.wox | 6 +-- UI/WebServerResources/SchedulerUI.js | 44 ++++++++++--------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index b09241cfd..05e760909 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -80,7 +80,7 @@ typedef enum { - (NSArray *) calendarUIDs; -- (NSString *) activeTasks; +- (NSNumber *) activeTasks; /* vevent UID handling */ diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index a70a0eb16..0a8746083 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3269,11 +3269,11 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return users; } -- (NSString *) activeTasks +- (NSNumber *) activeTasks { NSArray *tasksList; - NSString *activeTasks; NSMutableArray *fields; + NSNumber *activeTasks; fields = [NSMutableArray arrayWithObjects: @"c_component", @"c_status", nil]; @@ -3284,8 +3284,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir component: @"vtodo" additionalFilters: @"c_status != 2 AND c_status != 3"]; - activeTasks = [NSString stringWithFormat:@"(%d)", [tasksList count]]; - + activeTasks = [NSNumber numberWithInt:[tasksList count]]; + return activeTasks; } diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index 196299fad..fd9e99c76 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -92,8 +92,8 @@ _intValueFromHex (NSString *hexString) SOGoAppointmentFolder *folder; NSMutableDictionary *calendar; unsigned int count, max; - NSString *folderName, *fDisplayName, *fActiveTasks; - NSNumber *isActive; + NSString *folderName, *fDisplayName; + NSNumber *isActive, *fActiveTasks; if (!calendars) { @@ -122,7 +122,7 @@ _intValueFromHex (NSString *hexString) forKey: @"owner"]; fActiveTasks = [folder activeTasks]; if (fActiveTasks == nil) - fActiveTasks = @""; + fActiveTasks = 0; [calendar setObject:fActiveTasks forKey:@"activeTasks" ]; [calendars addObject: calendar]; } diff --git a/UI/Templates/SchedulerUI/UIxCalendarSelector.wox b/UI/Templates/SchedulerUI/UIxCalendarSelector.wox index e5f0b03e6..5b3bd488e 100644 --- a/UI/Templates/SchedulerUI/UIxCalendarSelector.wox +++ b/UI/Templates/SchedulerUI/UIxCalendarSelector.wox @@ -39,10 +39,8 @@ div.colorBox.calendarFolder >
  • - - - - + +
  • diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 8a3a44215..ec3d7ce81 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -2900,27 +2900,29 @@ function configureDragHandles() { } function initCalendarSelector() { - var selector = $("calendarSelector"); - updateCalendarStatus(); // triggers the initial events refresh - selector.changeNotification = updateCalendarsList; - - var list = $("calendarList"); - list.on("mousedown", onCalendarSelectionChange); - list.on("dblclick", onCalendarModify); - list.on("selectstart", listRowMouseDownHandler); - list.attachMenu("calendarsMenu"); - - var items = list.childNodesWithTag("li"); - for (var i = 0; i < items.length; i++) { - var input = items[i].childNodesWithTag("input")[0]; - $(input).observe("click", clickEventWrapper(updateCalendarStatus)); - } - - var links = $("calendarSelectorButtons").childNodesWithTag("a"); - $(links[0]).observe("click", clickEventWrapper(onCalendarNew)); - $(links[1]).observe("click", clickEventWrapper(onCalendarWebAdd)); - $(links[2]).observe("click", clickEventWrapper(onCalendarAdd)); - $(links[3]).observe("click", clickEventWrapper(onCalendarRemove)); + var selector = $("calendarSelector"); + updateCalendarStatus(); // triggers the initial events refresh + selector.changeNotification = updateCalendarsList; + + var list = $("calendarList"); + list.on("mousedown", onCalendarSelectionChange); + list.on("dblclick", onCalendarModify); + list.on("selectstart", listRowMouseDownHandler); + list.attachMenu("calendarsMenu"); + + var items = list.childNodesWithTag("li"); + for (var i = 0; i < items.length; i++) { + var input = items[i].childNodesWithTag("input")[0]; + var activeTasks = items[i].childNodesWithTag("span")[0]; + $(input).observe("click", clickEventWrapper(updateCalendarStatus)); + $(activeTasks).innerHTML = "(" + activeTasks.innerText + ")"; + } + + var links = $("calendarSelectorButtons").childNodesWithTag("a"); + $(links[0]).observe("click", clickEventWrapper(onCalendarNew)); + $(links[1]).observe("click", clickEventWrapper(onCalendarWebAdd)); + $(links[2]).observe("click", clickEventWrapper(onCalendarAdd)); + $(links[3]).observe("click", clickEventWrapper(onCalendarRemove)); } function onCalendarSelectionChange(event) { From 0e182f84360aa35c87d39320cab08d7eaeb55d90 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Wed, 11 Jun 2014 11:25:17 -0400 Subject: [PATCH 3/4] Update SOGoAppointmentFolder.m Fix the status filtering from 2 to 1 --- SoObjects/Appointments/SOGoAppointmentFolder.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 0a8746083..6f759a137 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3282,7 +3282,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir to: nil title: nil component: @"vtodo" - additionalFilters: @"c_status != 2 AND c_status != 3"]; + additionalFilters: @"c_status != 1 AND c_status != 3"]; activeTasks = [NSNumber numberWithInt:[tasksList count]]; From 7a69bc46eb5c2300e93d4b85c6954638a4271132 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Thu, 26 Jun 2014 16:42:05 -0400 Subject: [PATCH 4/4] applied comments --- SoObjects/Appointments/SOGoAppointmentFolder.m | 2 +- UI/Scheduler/UIxCalendarSelector.m | 2 -- UI/WebServerResources/SchedulerUI.js | 8 +++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 0a8746083..6f759a137 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3282,7 +3282,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir to: nil title: nil component: @"vtodo" - additionalFilters: @"c_status != 2 AND c_status != 3"]; + additionalFilters: @"c_status != 1 AND c_status != 3"]; activeTasks = [NSNumber numberWithInt:[tasksList count]]; diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index fd9e99c76..2c8a6910d 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -121,8 +121,6 @@ _intValueFromHex (NSString *hexString) [calendar setObject: [folder ownerInContext: context] forKey: @"owner"]; fActiveTasks = [folder activeTasks]; - if (fActiveTasks == nil) - fActiveTasks = 0; [calendar setObject:fActiveTasks forKey:@"activeTasks" ]; [calendars addObject: calendar]; } diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index ec3d7ce81..d69d69830 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -2915,7 +2915,13 @@ function initCalendarSelector() { var input = items[i].childNodesWithTag("input")[0]; var activeTasks = items[i].childNodesWithTag("span")[0]; $(input).observe("click", clickEventWrapper(updateCalendarStatus)); - $(activeTasks).innerHTML = "(" + activeTasks.innerText + ")"; + if (activeTasks.textContent == "0") { + activeTasks.innerHTML = ""; + } + else { + activeTasks.innerHTML = "(" + activeTasks.innerText + ")"; + } + } var links = $("calendarSelectorButtons").childNodesWithTag("a");