From 1445ac4d5bf9c54db9151605881df623940ac538 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 2 Apr 2007 19:27:46 +0000 Subject: [PATCH] Monotone-Parent: 487cdad3dbd4c7d9c8e79989636b26cefcde1b80 Monotone-Revision: 7d00dc40e4703750dc10ef05910f0c4d9a7162fb Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-04-02T19:27:46 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 + UI/Scheduler/UIxComponentEditor.h | 4 +- UI/Scheduler/UIxComponentEditor.m | 83 +++++++++++-------- .../SchedulerUI/UIxComponentEditor.wox | 33 ++------ UI/WebServerResources/UIxComponentEditor.js | 17 ++++ 5 files changed, 77 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index c017451cd..70b350e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-04-02 Wolfgang Sourdeau + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor + -calendarList]): new method replacing "availableCalendars". + * UI/Scheduler/UIxCalendarSelector.m ([UIxCalendarSelector -calendarFolders]): we now take the list of subscribed calendar from the container. diff --git a/UI/Scheduler/UIxComponentEditor.h b/UI/Scheduler/UIxComponentEditor.h index f67981871..e7c53351d 100644 --- a/UI/Scheduler/UIxComponentEditor.h +++ b/UI/Scheduler/UIxComponentEditor.h @@ -41,6 +41,7 @@ id item; NSString *saveURL; + NSMutableArray *calendarList; /* individual values */ NSCalendarDate *cycleUntilDate; @@ -125,9 +126,6 @@ - (void) setIsCycleEndUntil; - (void) setIsCycleEndNever; -- (NSString *) componentOwner; -- (NSArray *) availableCalendars; - /* access */ - (BOOL) isMyComponent; - (BOOL) canEditComponent; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 1b8c8d7d6..11258889a 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -42,6 +42,7 @@ #import #import #import +#import #import #import @@ -62,6 +63,7 @@ organizer = nil; attendeesNames = nil; attendeesEmails = nil; + calendarList = nil; } return self; @@ -82,6 +84,7 @@ [url release]; [attendeesNames release]; [attendeesEmails release]; + [calendarList release]; [super dealloc]; } @@ -293,7 +296,51 @@ - (NSString *) itemCategoryText { - return [self labelForKey: [NSString stringWithFormat: @"category_%@", item]]; + return [self labelForKey: + [NSString stringWithFormat: @"category_%@", item]]; +} + +- (NSArray *) calendarList +{ + SOGoAppointmentFolder *folder; + NSEnumerator *allCalendars; + NSDictionary *currentCalendar; + + if (!calendarList) + { + calendarList = [NSMutableArray new]; + folder = [[self clientObject] container]; + allCalendars + = [[folder calendarFoldersInContext: context] objectEnumerator]; + currentCalendar = [allCalendars nextObject]; + while (currentCalendar) + { + if ([[currentCalendar objectForKey: @"active"] boolValue]) + [calendarList addObject: currentCalendar]; + currentCalendar = [allCalendars nextObject]; + } + } + + return calendarList; +} + +- (NSString *) itemCalendarText +{ + return item; +} + +- (NSString *) calendarsFoldersList +{ + NSArray *calendars; + + calendars = [[self calendarList] valueForKey: @"folder"]; + + return [calendars componentsJoinedByString: @","]; +} + +- (NSString *) componentCalendar +{ + return @"/"; } /* priorities */ @@ -706,40 +753,6 @@ /* contact editor compatibility */ -- (NSArray *) availableCalendars -{ - NSEnumerator *rawContacts; - NSString *list, *currentId; - NSMutableArray *calendars; - SOGoUser *user; - - calendars = [NSMutableArray array]; - - user = [context activeUser]; - list = [[user userDefaults] stringForKey: @"calendaruids"]; - if ([list length] == 0) - list = [self shortUserNameForDisplay]; - - rawContacts - = [[list componentsSeparatedByString: @","] objectEnumerator]; - currentId = [rawContacts nextObject]; - while (currentId) - { - if ([currentId hasPrefix: @"-"]) - [calendars addObject: [currentId substringFromIndex: 1]]; - else - [calendars addObject: currentId]; - currentId = [rawContacts nextObject]; - } - - return calendars; -} - -- (NSString *) componentOwner -{ - return componentOwner; -} - - (NSString *) urlButtonClasses { NSString *classes; diff --git a/UI/Templates/SchedulerUI/UIxComponentEditor.wox b/UI/Templates/SchedulerUI/UIxComponentEditor.wox index 8b44ca880..48cb8e082 100644 --- a/UI/Templates/SchedulerUI/UIxComponentEditor.wox +++ b/UI/Templates/SchedulerUI/UIxComponentEditor.wox @@ -42,9 +42,11 @@ label:noSelectionString="category_NONE" string="itemCategoryText" selection="category" /> - + @@ -68,28 +70,9 @@ var:value="attendeesNames"/> - - - + diff --git a/UI/WebServerResources/UIxComponentEditor.js b/UI/WebServerResources/UIxComponentEditor.js index eb1f6d6df..525a9b1c6 100644 --- a/UI/WebServerResources/UIxComponentEditor.js +++ b/UI/WebServerResources/UIxComponentEditor.js @@ -67,6 +67,22 @@ function onMenuSetClassification(event, classification) { privacyInput.value = classification; } +function onChangeCalendar(event) { + var calendars = $("calendarFoldersList").value.split(","); + var form = document.forms["editform"]; + var urlElems = form.getAttribute("action").split("/"); + var choice = calendars[this.value]; + var ownerLogin; + if (choice.indexOf(":") > -1) + ownerLogin = choice.split(":")[0]; + else + ownerLogin = UserLogin; + urlElems[urlElems.length-4] = ownerLogin; + + form.setAttribute("action", urlElems.join("/")); + log ("after: " + form.getAttribute("action")); +} + function refreshAttendees() { var attendeesLabel = $("attendeesLabel"); var attendeesNames = $("attendeesNames"); @@ -137,4 +153,5 @@ function onComponentEditorLoad(event) { initializeAttendeesHref(); initializeDocumentHref(); initializePrivacyMenu(); + $("calendarList").addEventListener("change", onChangeCalendar, false); }