From 30bc88e8d4d1ab84837804cfc3ba4c272e1e2703 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 30 Oct 2006 22:37:57 +0000 Subject: [PATCH] Monotone-Parent: 6ccdcaac87d66173b1c675ce714a85b4fa7f82b5 Monotone-Revision: a8eaad13df3d9d67b260d73ffe79b6576abb4338 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-30T22:37:57 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 9 + UI/Scheduler/GNUmakefile | 1 + UI/Scheduler/UIxFreeBusyUserSelector.h | 16 +- UI/Scheduler/UIxFreeBusyUserSelector.m | 148 +--------- UI/Scheduler/UIxFreeBusyUserSelectorTable.h | 82 ++++++ UI/Scheduler/UIxFreeBusyUserSelectorTable.m | 278 ++++++++++++++++++ UI/Scheduler/product.plist | 9 +- .../SchedulerUI/UIxFreeBusyUserSelector.wox | 79 +---- .../UIxFreeBusyUserSelectorTable.wox | 68 +++++ 9 files changed, 472 insertions(+), 218 deletions(-) create mode 100644 UI/Scheduler/UIxFreeBusyUserSelectorTable.h create mode 100644 UI/Scheduler/UIxFreeBusyUserSelectorTable.m create mode 100644 UI/Templates/SchedulerUI/UIxFreeBusyUserSelectorTable.wox diff --git a/ChangeLog b/ChangeLog index bb3925643..e7201c9e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-10-30 Wolfgang Sourdeau + + * UI/Scheduler/UIxFreeBusyUserSelectorTable.[hm]: new subcomponent + derived and taken as a subset of UIxFreeBusyUserSelector that + implements the table part of the FreeBusy view. Most of the + methods of UIxFreeBusyUserSelector relative to that table were + moved into UIxFreeBusyUserSelectorTable, which can also be used as + a standalone view for AJAX operations. + 2006-10-27 Wolfgang Sourdeau * SoObjects/Contacts/SOGoContactLDAPEntry.m ([SOGoContactLDAPEntry diff --git a/UI/Scheduler/GNUmakefile b/UI/Scheduler/GNUmakefile index 494f0832e..0da5100af 100644 --- a/UI/Scheduler/GNUmakefile +++ b/UI/Scheduler/GNUmakefile @@ -40,6 +40,7 @@ SchedulerUI_OBJC_FILES = \ UIxCalInlineMonthOverview.m \ UIxComponentEditor.m \ UIxFreeBusyUserSelector.m \ + UIxFreeBusyUserSelectorTable.m \ UIxAppointmentView.m \ UIxAppointmentEditor.m \ UIxAppointmentProposal.m \ diff --git a/UI/Scheduler/UIxFreeBusyUserSelector.h b/UI/Scheduler/UIxFreeBusyUserSelector.h index 2b12bd4d6..44ff82ec2 100644 --- a/UI/Scheduler/UIxFreeBusyUserSelector.h +++ b/UI/Scheduler/UIxFreeBusyUserSelector.h @@ -29,23 +29,16 @@ @class NSMutableArray; @class NSCalendarDate; @class NSNumber; -@class SOGoDateFormatter; @class iCalPerson; @interface UIxFreeBusyUserSelector : UIxComponent { - SOGoDateFormatter *dateFormatter; NSCalendarDate *startDate; NSCalendarDate *endDate; NSNumber *dayStartHour; NSNumber *dayEndHour; - NSMutableArray *daysToDisplay; - NSMutableArray *hoursToDisplay; - NSCalendarDate *currentDayToDisplay; - NSNumber *currentHourToDisplay; NSArray *contacts; - iCalPerson *currentContact; NSString *selectorId; } @@ -54,7 +47,9 @@ - (void) setEndDate: (NSCalendarDate *) newEndDate; - (void) setDayStartHour: (NSNumber *) newDayStartHour; +- (NSNumber *) dayStartHour; - (void) setDayEndHour: (NSNumber *) newDayEndHour; +- (NSNumber *) dayEndHour; - (void) setContacts: (NSArray *) contacts; - (NSArray *) contacts; @@ -62,13 +57,6 @@ - (void) setSelectorId: (NSString *) newSelectorId; - (NSString *) selectorId; -- (NSArray *) daysToDisplay; -- (NSArray *) hoursToDisplay; -- (void) setCurrentDayToDisplay: (NSCalendarDate *) newCurrentDayToDisplay; -- (void) setCurrentHourToDisplay: (NSNumber *) newCurrentHourToDisplay; -- (NSCalendarDate *) currentDayToDisplay; -- (NSNumber *) currentHourToDisplay; - @end #endif /* UIXFREEBUSYUSERSELECTOR_H */ diff --git a/UI/Scheduler/UIxFreeBusyUserSelector.m b/UI/Scheduler/UIxFreeBusyUserSelector.m index 467824bde..13f4c3aad 100644 --- a/UI/Scheduler/UIxFreeBusyUserSelector.m +++ b/UI/Scheduler/UIxFreeBusyUserSelector.m @@ -23,13 +23,12 @@ #import #import -#import #import #import -#import #import +#import "UIxComponent+Agenor.h" #import "UIxFreeBusyUserSelector.h" @implementation UIxFreeBusyUserSelector @@ -46,10 +45,6 @@ [dayEndHour retain]; contacts = nil; selectorId = nil; - daysToDisplay = nil; - hoursToDisplay = nil; - dateFormatter = [[SOGoDateFormatter alloc] - initWithLocale: [self locale]]; } return self; @@ -59,26 +54,16 @@ { [dayStartHour release]; [dayEndHour release]; - if (daysToDisplay) - [daysToDisplay release]; - if (hoursToDisplay) - [hoursToDisplay release]; if (contacts) [contacts release]; if (selectorId) [selectorId release]; - [dateFormatter release]; [super dealloc]; } - (void) setStartDate: (NSCalendarDate *) newStartDate { startDate = newStartDate; - if (daysToDisplay) - { - [daysToDisplay release]; - daysToDisplay = nil; - } } - (NSCalendarDate *) startDate @@ -89,11 +74,6 @@ - (void) setEndDate: (NSCalendarDate *) newEndDate { endDate = newEndDate; - if (daysToDisplay) - { - [daysToDisplay release]; - daysToDisplay = nil; - } } - (NSCalendarDate *) endDate @@ -106,11 +86,21 @@ ASSIGN (dayStartHour, newDayStartHour); } +- (NSNumber *) dayStartHour +{ + return dayStartHour; +} + - (void) setDayEndHour: (NSNumber *) newDayEndHour { ASSIGN (dayEndHour, newDayEndHour); } +- (NSNumber *) dayEndHour +{ + return dayEndHour; +} + - (void) setSelectorId: (NSString *) newSelectorId { ASSIGN (selectorId, newSelectorId); @@ -132,33 +122,6 @@ } /* callbacks */ -- (NSArray *) getICalPersonsFromValue: (NSString *) selectorValue -{ - NSMutableArray *persons; - NSEnumerator *uids; - NSString *uid; - AgenorUserManager *um; - - um = [AgenorUserManager sharedUserManager]; - - persons = [NSMutableArray new]; - [persons autorelease]; - - if ([selectorValue length] > 0) - { - uids = [[selectorValue componentsSeparatedByString: @","] - objectEnumerator]; - uid = [uids nextObject]; - while (uid) - { - [persons addObject: [um iCalPersonWithUid: uid]]; - uid = [uids nextObject]; - } - } - - return persons; -} - - (void) takeValuesFromRequest: (WORequest *) request inContext: (WOContext *) context { @@ -192,92 +155,9 @@ return [participants componentsJoinedByString: @","]; } -- (void) setCurrentContact: (iCalPerson *) newCurrentContact +- (NSString *) freeBusyViewId { - currentContact = newCurrentContact; + return [NSString stringWithFormat: @"parentOf%@", [selectorId capitalizedString]]; } - -- (iCalPerson *) currentContact -{ - return currentContact; -} - -- (NSString *) currentContactId -{ - return [currentContact cn]; -} - -- (NSString *) currentContactName -{ - return [currentContact cn]; -} - -- (NSArray *) daysToDisplay -{ - NSCalendarDate *currentDay, *finalDay; - - if (!daysToDisplay) - { - daysToDisplay = [NSMutableArray new]; - finalDay = [endDate dateByAddingYears: 0 months: 0 days: 2]; - currentDay = startDate; - [daysToDisplay addObject: currentDay]; - while (![currentDay isDateOnSameDay: finalDay]) - { - currentDay = [currentDay dateByAddingYears: 0 months: 0 days: 1]; - [daysToDisplay addObject: currentDay]; - } - } - - return daysToDisplay; -} - -- (NSArray *) hoursToDisplay -{ - NSNumber *currentHour; - - if (!hoursToDisplay) - { - hoursToDisplay = [NSMutableArray new]; - currentHour = dayStartHour; - [hoursToDisplay addObject: currentHour]; - while (![currentHour isEqual: dayEndHour]) - { - currentHour = [NSNumber numberWithInt: [currentHour intValue] + 1]; - [hoursToDisplay addObject: currentHour]; - } - } - - return hoursToDisplay; -} - -- (void) setCurrentDayToDisplay: (NSCalendarDate *) newCurrentDayToDisplay -{ - currentDayToDisplay = newCurrentDayToDisplay; -} - -- (void) setCurrentHourToDisplay: (NSNumber *) newCurrentHourToDisplay -{ - currentHourToDisplay = newCurrentHourToDisplay; -} - -- (NSCalendarDate *) currentDayToDisplay -{ - return currentDayToDisplay; -} - -- (NSNumber *) currentHourToDisplay -{ - return currentHourToDisplay; -} - -- (NSString *) currentFormattedDay -{ - return [NSString stringWithFormat: @"%@, %.4d-%.2d-%.2d", - [dateFormatter shortDayOfWeek: [currentDayToDisplay dayOfWeek]], - [currentDayToDisplay yearOfCommonEra], - [currentDayToDisplay monthOfYear], - [currentDayToDisplay dayOfMonth]]; -} - + @end diff --git a/UI/Scheduler/UIxFreeBusyUserSelectorTable.h b/UI/Scheduler/UIxFreeBusyUserSelectorTable.h new file mode 100644 index 000000000..969695f76 --- /dev/null +++ b/UI/Scheduler/UIxFreeBusyUserSelectorTable.h @@ -0,0 +1,82 @@ +/* UIxFreeBusyUserSelectorTable.h - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef UIXFREEBUSYUSERSELECTORTABLE_H +#define UIXFREEBUSYUSERSELECTORTABLE_H + +#import + +@class NSArray; +@class NSCalendarDate; +@class NSNumber; + +@class iCalPerson; +@class SOGoDateFormatter; + +@interface UIxFreeBusyUserSelectorTable : UIxComponent +{ + BOOL standAlone; + NSMutableArray *daysToDisplay; + NSMutableArray *hoursToDisplay; + SOGoDateFormatter *dateFormatter; + + NSArray *contacts; + NSNumber *dayStartHour; + NSNumber *dayEndHour; + NSCalendarDate *startDate; + NSCalendarDate *endDate; + + iCalPerson *currentContact; + NSNumber *currentHourToDisplay; + NSCalendarDate *currentDayToDisplay; +} + +- (void) setContacts: (NSArray *) newContacts; +- (NSArray *) contacts; + +- (void) setStartDate: (NSCalendarDate *) newStartDate; +- (void) setEndDate: (NSCalendarDate *) newEndDate; + +- (void) setDayStartHour: (NSNumber *) newDayStartHour; +- (NSNumber *) dayStartHour; +- (void) setDayEndHour: (NSNumber *) newDayEndHour; +- (NSNumber *) dayEndHour; + +- (void) setCurrentContact: (iCalPerson *) newCurrentContact; +- (iCalPerson *) currentContact; +- (NSString *) currentContactId; +- (NSString *) currentContactName; + +- (void) setCurrentDayToDisplay: (NSCalendarDate *) newCurrentDayToDisplay; +- (NSCalendarDate *) currentDayToDisplay; + +- (void) setCurrentHourToDisplay: (NSNumber *) newCurrentHourToDisplay; +- (NSNumber *) currentHourToDisplay; + +- (NSString *) currentFormattedDay; + +- (NSArray *) daysToDisplay; +- (NSArray *) hoursToDisplay; + +@end + +#endif /* UIXFREEBUSYUSERSELECTORTABLE_H */ diff --git a/UI/Scheduler/UIxFreeBusyUserSelectorTable.m b/UI/Scheduler/UIxFreeBusyUserSelectorTable.m new file mode 100644 index 000000000..0e409b555 --- /dev/null +++ b/UI/Scheduler/UIxFreeBusyUserSelectorTable.m @@ -0,0 +1,278 @@ +/* UIxFreeBusyUserSelectorTable.m - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import +#import + +#import +#import +#import + +#import "UIxComponent+Agenor.h" +#import "UIxFreeBusyUserSelectorTable.h" + +@implementation UIxFreeBusyUserSelectorTable + +- (id) init +{ + if ((self = [super init])) + { + standAlone = NO; + startDate = nil; + endDate = nil; + contacts = nil; + hoursToDisplay = nil; + daysToDisplay = nil; + dateFormatter + = [[SOGoDateFormatter alloc] initWithLocale: [self locale]]; + } + + return self; +} + +- (void) dealloc +{ + [dateFormatter release]; + if (hoursToDisplay) + [hoursToDisplay release]; + if (daysToDisplay) + [daysToDisplay release]; + if (standAlone) + { + if (startDate) + [startDate release]; + if (endDate) + [endDate release]; + if (contacts) + [contacts release]; + } + [super dealloc]; +} + +- (void) setContacts: (NSArray *) newContacts +{ + contacts = newContacts; +} + +- (NSArray *) contacts +{ + return contacts; +} + +- (void) setStartDate: (NSCalendarDate *) newStartDate +{ + startDate = newStartDate; + if (daysToDisplay) + { + [daysToDisplay release]; + daysToDisplay = nil; + } +} + +- (NSCalendarDate *) startDate +{ + return startDate; +} + +- (void) setEndDate: (NSCalendarDate *) newEndDate +{ + endDate = newEndDate; + if (daysToDisplay) + { + [daysToDisplay release]; + daysToDisplay = nil; + } +} + +- (NSCalendarDate *) endDate +{ + return endDate; +} + +- (void) setDayStartHour: (NSNumber *) newDayStartHour +{ + dayStartHour = newDayStartHour; + if (hoursToDisplay) + { + [hoursToDisplay release]; + hoursToDisplay = nil; + } +} + +- (NSNumber *) dayStartHour +{ + return dayStartHour; +} + +- (void) setDayEndHour: (NSNumber *) newDayEndHour +{ + dayEndHour = newDayEndHour; + if (hoursToDisplay) + { + [hoursToDisplay release]; + hoursToDisplay = nil; + } +} + +- (NSNumber *) dayEndHour +{ + return dayEndHour; +} + +/* template operations */ +- (NSArray *) daysToDisplay +{ + NSCalendarDate *currentDay, *finalDay; + + if (!daysToDisplay) + { + daysToDisplay = [NSMutableArray new]; + finalDay = [endDate dateByAddingYears: 0 months: 0 days: 2]; + currentDay = startDate; + [daysToDisplay addObject: currentDay]; + while (![currentDay isDateOnSameDay: finalDay]) + { + currentDay = [currentDay dateByAddingYears: 0 + months: 0 + days: 1]; + [daysToDisplay addObject: currentDay]; + } + } + + return daysToDisplay; +} + +- (NSArray *) hoursToDisplay +{ + NSNumber *currentHour; + + if (!hoursToDisplay) + { + hoursToDisplay = [NSMutableArray new]; + currentHour = dayStartHour; + [hoursToDisplay addObject: currentHour]; + while (![currentHour isEqual: dayEndHour]) + { + currentHour = [NSNumber numberWithInt: [currentHour intValue] + 1]; + [hoursToDisplay addObject: currentHour]; + } + } + + return hoursToDisplay; +} + +- (void) setCurrentContact: (iCalPerson *) newCurrentContact +{ + currentContact = newCurrentContact; +} + +- (iCalPerson *) currentContact +{ + return currentContact; +} + +- (NSString *) currentContactId +{ + return [currentContact cn]; +} + +- (NSString *) currentContactName +{ + return [currentContact cn]; +} + +- (void) setCurrentDayToDisplay: (NSCalendarDate *) newCurrentDayToDisplay +{ + currentDayToDisplay = newCurrentDayToDisplay; +} + +- (void) setCurrentHourToDisplay: (NSNumber *) newCurrentHourToDisplay +{ + currentHourToDisplay = newCurrentHourToDisplay; +} + +- (NSCalendarDate *) currentDayToDisplay +{ + return currentDayToDisplay; +} + +- (NSNumber *) currentHourToDisplay +{ + return currentHourToDisplay; +} + +- (NSString *) currentFormattedDay +{ + return [NSString stringWithFormat: @"%@, %.4d-%.2d-%.2d", + [dateFormatter shortDayOfWeek: [currentDayToDisplay dayOfWeek]], + [currentDayToDisplay yearOfCommonEra], + [currentDayToDisplay monthOfYear], + [currentDayToDisplay dayOfMonth]]; +} + +/* as stand-alone component... */ + +- (id ) defaultAction +{ + SOGoFreeBusyObject *co; + NSString *queryParam; + NSTimeZone *uTZ; + + co = [self clientObject]; + uTZ = [co userTimeZone]; + + queryParam = [self queryParameterForKey: @"sday"]; + if ([queryParam length] > 0) + { + [self setStartDate: [NSCalendarDate dateFromShortDateString: queryParam + andShortTimeString: @"0000" + inTimeZone: uTZ]]; + [startDate retain]; + } + queryParam = [self queryParameterForKey: @"eday"]; + if ([queryParam length] > 0) + { + [self setEndDate: [NSCalendarDate dateFromShortDateString: queryParam + andShortTimeString: @"0000" + inTimeZone: uTZ]]; + [endDate retain]; + } + queryParam = [self queryParameterForKey: @"attendees"]; + if ([queryParam length] > 0) + { + [self setContacts: [self getICalPersonsFromValue: queryParam]]; + [contacts retain]; + } + dayStartHour = [NSNumber numberWithInt: 8]; + dayEndHour = [NSNumber numberWithInt: 18]; + + standAlone = YES; + + return self; +} + +@end diff --git a/UI/Scheduler/product.plist b/UI/Scheduler/product.plist index 8a83383f3..272b3b1a8 100644 --- a/UI/Scheduler/product.plist +++ b/UI/Scheduler/product.plist @@ -1,5 +1,5 @@ { - requires = ( MAIN, CommonUI, Appointments, Contacts ); + requires = ( MAIN, CommonUI, Appointments, Contacts, ContactsUI ); publicResources = ( previous_week.gif, @@ -64,7 +64,6 @@ protectedBy = "View"; pageName = "UIxCalMonthView"; }; - dayoverview = { protectedBy = "View"; pageName = "UIxCalDayOverview"; @@ -134,7 +133,11 @@ protectedBy = "View"; pageName = "UIxCalMainView"; actionName = "updateCalendars"; - } + }; + freeBusyTable = { + protectedBy = "View"; + pageName = "UIxFreeBusyUserSelectorTable"; + }; }; }; diff --git a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox index 3832bbe39..24a0ee4f7 100644 --- a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox +++ b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox @@ -7,74 +7,19 @@ xmlns:rsrc="OGo:url" xmlns:label="OGo:label"> -
- - - - - - - - - - - - - -
00
+ +
+
-
+

  • + + + + + + + + + + + + +
    00