]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1023 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 13 Feb 2007 22:13:55 +0000 (22:13 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 13 Feb 2007 22:13:55 +0000 (22:13 +0000)
UI/Scheduler/UIxCalMulticolumnDayView.h [new file with mode: 0644]
UI/Scheduler/UIxCalMulticolumnDayView.m [new file with mode: 0644]
UI/Templates/SchedulerUI/UIxCalMulticolumnDayView.wox [new file with mode: 0644]

diff --git a/UI/Scheduler/UIxCalMulticolumnDayView.h b/UI/Scheduler/UIxCalMulticolumnDayView.h
new file mode 100644 (file)
index 0000000..2b915a5
--- /dev/null
@@ -0,0 +1,58 @@
+/* UIxCalMulticolumnDayView.h - this file is part of SOGo
+ *
+ * Copyright (C) 2006 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * 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 (file)
index 0000000..975d1c2
--- /dev/null
@@ -0,0 +1,296 @@
+/* UIxCalMulticolumnDayView.h - this file is part of SOGo
+ *
+ * Copyright (C) 2006 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * 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 <Foundation/NSArray.h>
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSString.h>
+#import <Foundation/NSValue.h>
+
+#import <NGExtensions/NSCalendarDate+misc.h>
+
+#import <SOGo/SOGoUser.h>
+#import <SOGoUI/SOGoDateFormatter.h>
+
+#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 (file)
index 0000000..38f8de0
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" standalone="yes"?>
+  <container
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:var="http://www.skyrix.com/od/binding"
+    xmlns:const="http://www.skyrix.com/od/constant"
+    xmlns:rsrc="OGo:url"
+    xmlns:label="OGo:label">
+    <a href="#"
+      class="leftNavigationArrow"
+      var:date="prevDayQueryParameters.day"
+      onclick="return onCalendarGotoDay(this);"
+      ><img rsrc:src="arrow-lft-sharp.gif"/></a>
+    <span class="daysHeader">
+      <span class="day2"><a href="#"
+          var:date="dayBeforePrevDayQueryParameters.day"
+          onclick="return onCalendarGotoDay(this);"
+          ><var:string value="dayBeforeYesterdayName"
+            /></a></span
+        ><span class="day1"><a href="#"
+          var:date="prevDayQueryParameters.day"
+          onclick="return onCalendarGotoDay(this);"
+          ><var:string value="yesterdayName"
+            /></a></span
+        ><span class="day0"><var:string value="currentDayName" /></span
+        ><span class="day1"><a href="#"
+          var:date="nextDayQueryParameters.day"
+          onclick="return onCalendarGotoDay(this);"
+          ><var:string value="tomorrowName"
+            /></a></span
+        ><span class="day2"><a href="#"
+          var:date="dayAfterNextDayQueryParameters.day"
+          onclick="return onCalendarGotoDay(this);"
+          ><var:string value="dayAfterTomorrowName"
+            /></a></span
+        ></span>
+    <a href="#"
+      class="rightNavigationArrow"
+      var:date="nextDayQueryParameters.day"
+      onclick="return onCalendarGotoDay(this);"
+      ><img rsrc:src="arrow-rit-sharp.gif"/></a>
+
+    <style type="text/css">
+      DIV.day
+      {
+        width: <var:string value="dayWidthPercentage" />% !important;
+      }
+      <var:foreach list="subscriptionUsers" item="currentTableUser">
+      DIV[class~='day'].appointmentsOf<var:string value="currentTableUser" />
+      {
+        left: <var:string value="currentTableUserDayLeftPercentage" />% !important;
+      }
+      </var:foreach>
+    </style>
+
+    <div id="calendarContent">
+      <div id="daysView" class="daysView multicolumnDayView">
+        <div class="hours">
+          <var:foreach list="hoursToDisplay" item="currentTableHour"
+            ><div class="hour"><var:string value="currentTableHour" />:00</div
+              ></var:foreach>
+        </div>
+        <div class="hourLines">
+          <div class="hourLine hourLine0"><!-- space --></div
+            ><div class="hourLine hourLine1"><!-- space --></div
+            ><div class="hourLine hourLine2"><!-- space --></div
+            ><div class="hourLine hourLine3"><!-- space --></div
+            ><div class="hourLine hourLine4"><!-- space --></div
+            ><div class="hourLine hourLine5"><!-- space --></div
+            ><div class="hourLine hourLine6"><!-- space --></div
+            ><div class="hourLine hourLine7"><!-- space --></div
+            ><div class="hourLine hourLine8"><!-- space --></div
+            ><div class="hourLine hourLine9"><!-- space --></div
+            ><div class="hourLine hourLine10"><!-- space --></div
+            ><div class="hourLine hourLine11"><!-- space --></div
+            ><div class="hourLine hourLine12"><!-- space --></div
+            ><div class="hourLine hourLine13"><!-- space --></div
+            ><div class="hourLine hourLine14"><!-- space --></div
+            ><div class="hourLine hourLine15"><!-- space --></div
+            ><div class="hourLine hourLine16"><!-- space --></div
+            ><div class="hourLine hourLine17"><!-- space --></div
+            ><div class="hourLine hourLine18"><!-- space --></div
+            ><div class="hourLine hourLine19"><!-- space --></div
+            ><div class="hourLine hourLine20"><!-- space --></div
+            ><div class="hourLine hourLine21"><!-- space --></div
+            ><div class="hourLine hourLine22"><!-- space --></div
+            ><div class="hourLine hourLine23"><!-- space --></div>
+        </div>
+
+        <div class="days" var:day="selectedDate.shortDateString">
+          <var:foreach list="subscriptionUsers" item="currentTableUser"
+            ><div var:class="currentUserClasses"
+              var:user="currentTableUser"
+              ><div class="header"><var:string value="currentTableUser" /></div>
+              <div class="appointments">
+                <var:foreach list="hoursToDisplay" item="currentTableHour"
+                  ><div var:class="clickableHourCellClass"
+                    var:hour="currentAppointmentHour">
+                  </div></var:foreach>
+                <var:foreach list="appointmentsForCurrentUser" item="currentAppointment"
+                  ><var:component className="UIxCalInlineAptView"
+                    dayStartHour="dayStartHour"
+                    dayEndHour="dayEndHour"
+                    appointment="currentAppointment"
+                    formatter="aptFormatter"
+                    tooltipFormatter="aptTooltipFormatter"
+                    url="appointmentViewURL"
+                    const:style="dayoverview"
+                    queryDictionary="currentDateQueryParameters"
+                    referenceDate="selectedDate"
+                    canAccess="canAccessApt"
+                    /></var:foreach
+                  >
+              </div>
+            </div>
+          </var:foreach>
+        </div>
+      </div>
+    </div>
+  </container>