From 8e04f91206ac2410d579d4c4f3122da0d97a6208 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Tue, 13 Feb 2007 22:13:55 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1023 d1b88da0-ebda-0310-925b-ed51d893ca5b --- UI/Scheduler/UIxCalMulticolumnDayView.h | 58 ++++ UI/Scheduler/UIxCalMulticolumnDayView.m | 296 ++++++++++++++++++ .../SchedulerUI/UIxCalMulticolumnDayView.wox | 119 +++++++ 3 files changed, 473 insertions(+) create mode 100644 UI/Scheduler/UIxCalMulticolumnDayView.h create mode 100644 UI/Scheduler/UIxCalMulticolumnDayView.m create mode 100644 UI/Templates/SchedulerUI/UIxCalMulticolumnDayView.wox diff --git a/UI/Scheduler/UIxCalMulticolumnDayView.h b/UI/Scheduler/UIxCalMulticolumnDayView.h new file mode 100644 index 00000000..2b915a56 --- /dev/null +++ b/UI/Scheduler/UIxCalMulticolumnDayView.h @@ -0,0 +1,58 @@ +/* UIxCalMulticolumnDayView.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 __UIxCalMulticolumnDayView_H_ +#define __UIxCalMulticolumnDayView_H_ + +#import "UIxCalDayView.h" + +@interface UIxCalMulticolumnDayView : UIxCalDayView +{ + SOGoDateFormatter *dateFormatter; + NSString *currentTableHour; + NSMutableArray *subscriptionUsers; + NSMutableArray *hoursToDisplay; + NSArray *allAppointments; + + NSString *currentTableUser; + NSDictionary *currentAppointment; + + NSString *cssClass; + NSString *cssId; +} + +- (void) setCSSClass: (NSString *) aCssClass; +- (NSString *) cssClass; + +- (void) setCSSId: (NSString *) aCssId; +- (NSString *) cssId; + +- (NSArray *) subscriptionUsers; +- (void) setCurrentTableUser: (NSString *) aTableDay; +- (NSString *) currentTableUser; + +- (void) setCurrentAppointment: (NSDictionary *) newCurrentAppointment; +- (NSDictionary *) currentAppointment; + +@end + +#endif /* __UIxCalMulticolumnDayView_H_ */ diff --git a/UI/Scheduler/UIxCalMulticolumnDayView.m b/UI/Scheduler/UIxCalMulticolumnDayView.m new file mode 100644 index 00000000..975d1c2d --- /dev/null +++ b/UI/Scheduler/UIxCalMulticolumnDayView.m @@ -0,0 +1,296 @@ +/* UIxCalMulticolumnDayView.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. + */ + +#import +#import +#import +#import + +#import + +#import +#import + +#import "UIxCalMulticolumnDayView.h" + +@implementation UIxCalMulticolumnDayView : UIxCalDayView + +- (id) init +{ + if ((self = [super init])) + { + allAppointments = nil; + subscriptionUsers = nil; + hoursToDisplay = nil; + currentTableUser = nil; + currentTableHour = nil; + dateFormatter = [[SOGoDateFormatter alloc] + initWithLocale: [self locale]]; + } + + return self; +} + +- (void) dealloc +{ + if (allAppointments) + [allAppointments release]; + if (subscriptionUsers) + [subscriptionUsers release]; + if (hoursToDisplay) + [hoursToDisplay release]; + [dateFormatter release]; + [super dealloc]; +} + +- (void) setCSSClass: (NSString *) aCssClass +{ + cssClass = aCssClass; +} + +- (NSString *) cssClass +{ + return cssClass; +} + +- (void) setCSSId: (NSString *) aCssId +{ + cssId = aCssId; +} + +- (NSString *) cssId +{ + return cssId; +} + +- (NSArray *) hoursToDisplay +{ + unsigned int currentHour, lastHour; + + if (!hoursToDisplay) + { + currentHour = [self dayStartHour]; + lastHour = [self dayEndHour]; + hoursToDisplay = [NSMutableArray new]; + + while (currentHour < lastHour) + { + [hoursToDisplay + addObject: [NSString stringWithFormat: @"%d", currentHour]]; + currentHour++; + } + [hoursToDisplay + addObject: [NSString stringWithFormat: @"%d", currentHour]]; + } + + return hoursToDisplay; +} + +- (NSArray *) subscriptionUsers +{ + SOGoUser *activeUser; + NSString *userList, *currentUserLogin; + NSEnumerator *users; + + if (!subscriptionUsers) + { + subscriptionUsers = [NSMutableArray new]; + activeUser = [context activeUser]; + userList = [[activeUser userDefaults] objectForKey: @"calendaruids"]; + users = [[userList componentsSeparatedByString: @","] objectEnumerator]; + currentUserLogin = [users nextObject]; + while (currentUserLogin) + { + if (![currentUserLogin hasPrefix: @"-"]) + [subscriptionUsers addObject: currentUserLogin]; + currentUserLogin = [users nextObject]; + } + } + + return subscriptionUsers; +} + +- (void) setCurrentTableUser: (NSString *) aTableUser; +{ + currentTableUser = aTableUser; +} + +- (NSString *) currentTableUser; +{ + return currentTableUser; +} + +- (void) setCurrentTableHour: (NSString *) aTableHour +{ + currentTableHour = aTableHour; +} + +- (NSString *) currentTableHour +{ + return currentTableHour; +} + +- (NSString *) currentAppointmentHour +{ + return [NSString stringWithFormat: @"%.2d00", [currentTableHour intValue]]; +} + +- (NSDictionary *) _adjustedAppointment: (NSDictionary *) anAppointment + forStart: (NSCalendarDate *) start + andEnd: (NSCalendarDate *) end +{ + NSMutableDictionary *newMutableAppointment; + NSDictionary *newAppointment; + BOOL startIsEarlier, endIsLater; + + startIsEarlier + = ([[anAppointment objectForKey: @"startDate"] laterDate: start] == start); + endIsLater + = ([[anAppointment objectForKey: @"endDate"] earlierDate: end] == end); + + if (startIsEarlier || endIsLater) + { + newMutableAppointment + = [NSMutableDictionary dictionaryWithDictionary: anAppointment]; + + if (startIsEarlier) + [newMutableAppointment setObject: start + forKey: @"startDate"]; + if (endIsLater) + [newMutableAppointment setObject: end + forKey: @"endDate"]; + + newAppointment = newMutableAppointment; + } + else + newAppointment = anAppointment; + + return newAppointment; +} + +/* fetching */ + +- (NSCalendarDate *) startDate +{ + return [[self selectedDate] beginOfDay]; +} + +- (NSCalendarDate *) endDate +{ + return [[self selectedDate] endOfDay]; +} + +- (NSArray *) appointmentsForCurrentUser +{ + NSMutableArray *filteredAppointments; + NSEnumerator *aptsEnumerator; + NSDictionary *userAppointment; + NSCalendarDate *start, *end; + int endHour; + + if (!allAppointments) + { + allAppointments = [self fetchCoreAppointmentsInfos]; + [allAppointments retain]; + } + + start = [[self selectedDate] hour: [self dayStartHour] minute: 0]; + endHour = [self dayEndHour]; + if (endHour < 24) + end = [[self selectedDate] hour: [self dayEndHour] minute: 59]; + else + end = [[[self selectedDate] tomorrow] hour: 0 minute: 0]; + + filteredAppointments = [NSMutableArray new]; + [filteredAppointments autorelease]; + + aptsEnumerator = [allAppointments objectEnumerator]; + userAppointment = [aptsEnumerator nextObject]; + while (userAppointment) + { + if ([[userAppointment objectForKey: @"owner"] + isEqualToString: currentTableUser]) + [filteredAppointments + addObject: [self _adjustedAppointment: userAppointment + forStart: start andEnd: end]]; + userAppointment = [aptsEnumerator nextObject]; + } + + return filteredAppointments; +} + +- (void) setCurrentAppointment: (NSDictionary *) newCurrentAppointment +{ + currentAppointment = newCurrentAppointment; +} + +- (NSDictionary *) currentAppointment +{ + return currentAppointment; +} + +- (NSString *) appointmentsClasses +{ + return @"appointments appointmentsFor1Days"; +} + +- (NSString *) currentUserClasses +{ + NSArray *users; + NSString *lastDayUser; + + users = [self subscriptionUsers]; + + if (currentTableUser == [users lastObject]) + lastDayUser = @" lastDayUser"; + else + lastDayUser = @""; + + return [NSString stringWithFormat: @"day appointmentsOf%@%@", + currentTableUser, lastDayUser]; +} + +- (NSString *) clickableHourCellClass +{ + return [NSString stringWithFormat: @"clickableHourCell clickableHourCell%@", currentTableHour]; +} + +- (NSNumber *) dayWidthPercentage +{ + NSArray *users; + + users = [self subscriptionUsers]; + + return [NSNumber numberWithFloat: (100.0 / [users count])]; +} + +- (NSNumber *) currentTableUserDayLeftPercentage +{ + NSArray *users; + + users = [self subscriptionUsers]; + + return [NSNumber numberWithFloat: ([users indexOfObject: currentTableUser] + * (100.0 / [users count]))]; +} + +@end diff --git a/UI/Templates/SchedulerUI/UIxCalMulticolumnDayView.wox b/UI/Templates/SchedulerUI/UIxCalMulticolumnDayView.wox new file mode 100644 index 00000000..38f8de03 --- /dev/null +++ b/UI/Templates/SchedulerUI/UIxCalMulticolumnDayView.wox @@ -0,0 +1,119 @@ + + + + + + + + + +
+
+
+
:00
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
-- 2.39.5