]> err.no Git - scalable-opengroupware.org/commitdiff
refactoring
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 29 Jul 2004 16:23:51 +0000 (16:23 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 29 Jul 2004 16:23:51 +0000 (16:23 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@161 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/README
SOGo/UI/Scheduler/ChangeLog
SOGo/UI/Scheduler/UIxCalDayOverview.m
SOGo/UI/Scheduler/UIxCalDayOverview.wox
SOGo/UI/Scheduler/UIxCalDayView.h
SOGo/UI/Scheduler/UIxCalDayView.m
SOGo/UI/Scheduler/UIxCalMonthView.m
SOGo/UI/Scheduler/UIxCalView.h
SOGo/UI/Scheduler/UIxCalView.m
SOGo/UI/Scheduler/UIxCalWeekView.m

index ee66be99c946b9f7a37d6050c693932e477387bb..83fb015c82f8502ee8eb0fbda4fa7fa5c4fe64f9 100644 (file)
@@ -14,3 +14,11 @@ Main contains the main server binary (.woa) and application wide objects
 like authenticators.
 
 UI contains the actual UI which is bound to the SoObjects as SOPE methods
+
+
+NOTES
+=====
+
+mapping email <-> logins
+usermanager -> part of SOGoLogic
+
index 7a5247c270d2f332dae1ce5a20cbad0eea6a380e..fb18d88f4aa1d729852e59c06e2476fca38f7d8b 100644 (file)
@@ -1,3 +1,21 @@
+2004-07-29  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * v0.9.10
+
+       * UIxCalDayView.m, UIxCalWeekView.m, UIxCalMonthView.m: reversed
+         previous changes to -startDate/-endDate as these were wrong.
+         Views have to deal on their own if appointments break the
+         "usual" time range. Nevertheless we should never drop any
+         appointments!
+
+       * UIxCalDayOverview.[wox|m]: refactored dateRanges (moved to
+         UIxCalDayView) and completed display of all appropriate attributes
+         (all day appointments, holiday info).
+
+       * UIxCalDayView.[hm]: fixed dateRanges.
+
+       * UIxCalView.[hm]: implemented -allDayApts and refactored some code.
+
 2004-07-28  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * v0.9.9
index fae83bef3aa06896fcd6cd9ce76b91d82dce06f6..df44ec5229ce603545eaeadc8167fd277447abaa 100644 (file)
     return self->currentApts;
 }
 
-- (NSArray *)dateRange {
-    NSMutableArray *dateRange;
-    unsigned i, count, offset;
-    
-    offset = [self dayStartHour];
-    count = [self dayEndHour] - offset;
-    dateRange = [[NSMutableArray alloc] initWithCapacity:count];
-    for(i = 0; i < count; i++) {
-        NSCalendarDate *date;
-        
-        date = [[self startDate] hour:offset + i minute:0];
-        [dateRange addObject:date];
-    }
-    return [dateRange autorelease];
-}
-
-
 - (NSArray *)aptsForCurrentDate {
     NSArray *apts;
     NSMutableArray *filtered;
     return [filtered autorelease];
 }
 
-- (NSString *)shortTextForApt {
-    NSCalendarDate *startDate, *endDate;
-    NSString *ms;
-    
-    startDate = [[self appointment] valueForKey:@"startDate"];
-    [startDate setTimeZone:[self viewTimeZone]];
-    endDate = [[self appointment] valueForKey:@"endDate"];
-    [endDate setTimeZone:[self viewTimeZone]];
-
-    ms = [NSString stringWithFormat:@"%02i:%02i %@",
-        [startDate hourOfDay],
-        [startDate minuteOfHour],
-        [[self appointment] valueForKey:@"title"]];
-    return ms;
-}
-
-
-/* URLs */
-
 - (NSDictionary *)currentDateQueryParameters {
     NSMutableDictionary *qp;
     NSString *hmString;
     NSCalendarDate *date;
-
+    
     date = [self currentDate];
     hmString = [NSString stringWithFormat:@"%02d%02d",
         [date hourOfDay], [date minuteOfHour]];
     return [qp autorelease];
 }
 
-
-/* appointments */
-
-- (NSArray *)appointments {
-    return [self fetchCoreInfos];
-}
-
 @end
index 1724763f9b1af1d38c00c434930d612c16ea16e0..cc244e84e3164326c417b3663f0c3e63e5c6e8d2 100644 (file)
                     </td>
                     <td width="100%">
                       <table class="dayoverview_content" width="100%">
+                        <var:if condition="hasHolidayInfo">
+                          <tr>
+                            <td class="dayoverview_content_time" colspan="2">
+                              <b><var:string value="holidayInfo.title" /></b>
+                            </td>
+                          </tr>
+                        </var:if>
+                        <var:foreach list="allDayApts" item="appointment">
+                          <tr>
+                            <td class="dayoverview_content_time">
+                              <var:entity value="nbsp" />
+                            </td>
+                            <td class="dayoverview_content_apts" width="90%">
+                              <var:foreach list="allDayApts" item="appointment">
+                                <a var:href="appointmentViewURL"
+                                   var:queryDictionary="currentDateQueryParameters"
+                                ><var:string value="shortTextForApt" /></a>
+                                <br />
+                              </var:foreach>
+                            </td>
+                          </tr>
+                        </var:foreach>
                         <var:foreach list="dateRange" item="currentDate">
                           <tr>
                             <td class="dayoverview_content_time">
index ac7d700a389f0bf37efb6741257509188f879e1f..8b428bea2081581ee212abc334fd8372576b6b94 100644 (file)
 
 @interface UIxCalDayView : UIxCalView
 {
-
 }
 
+- (NSArray *)dateRange;
+
 @end
 
 #endif /* __UIxCalDayView_H_ */
index 8bf4101d9b5edccea5466fc7018eb7f982bff0ee..b072fafee8a5ae8ba60205a0d20c33668fd730da 100644 (file)
 
 
 #import "UIxCalDayView.h"
-#include <NGExtensions/NGExtensions.h>
+#include <EOControl/EOControl.h>
+#include "common.h"
 
+@interface UIxCalDayView (PrivateAPI)
+- (NSArray *)_getDatesFrom:(NSCalendarDate *)_from to:(NSCalendarDate *)_to;
+@end
 
 @implementation UIxCalDayView
 
+
+- (NSArray *)dateRange {
+    /* default range is from dayStartHour to dayEndHour. Any values before
+       or after are also fine */
+
+    NSCalendarDate *min, *max;
+    NSArray *aptDateRanges;
+
+    min = [[self startDate] hour:[self dayStartHour] minute:0];
+    max = [[self startDate] hour:[self dayEndHour] minute:0];
+
+    aptDateRanges = [[self appointments] valueForKey:@"startDate"];
+    if([aptDateRanges count] != 0) {
+        NSCalendarDate *d;
+        
+        aptDateRanges = [aptDateRanges sortedArrayUsingSelector:@selector(compareAscending:)];
+        d = [aptDateRanges objectAtIndex:0];
+        min = (NSCalendarDate *)[d earlierDate:min];
+        d = [aptDateRanges objectAtIndex:[aptDateRanges count] - 1];
+        max = (NSCalendarDate *)[d laterDate:max];
+    }
+
+    return [self _getDatesFrom:min to:max];
+}
+
+- (NSArray *)_getDatesFrom:(NSCalendarDate *)_from to:(NSCalendarDate *)_to {
+    NSMutableArray *dates;
+    unsigned i, count, offset;
+
+    offset = [_from hourOfDay];
+    count = ([_to hourOfDay] + 1) - offset;
+    dates = [[NSMutableArray alloc] initWithCapacity:count];
+    for(i = 0; i < count; i++) {
+        NSCalendarDate *date;
+        
+        date = [_from hour:offset + i minute:0];
+        [dates addObject:date];
+    }
+    return [dates autorelease];
+}
+
+
+- (NSString *)shortTextForApt {
+    NSCalendarDate *startDate, *endDate;
+    NSMutableString *aptDescr;
+    NSString *s;
+    BOOL spansRange;
+    id apt;
+    
+    apt = [self appointment];
+    spansRange = NO;
+    startDate = [apt valueForKey:@"startDate"];
+    [startDate setTimeZone:[self viewTimeZone]];
+    endDate = [apt valueForKey:@"endDate"];
+    if(endDate != nil) {
+        [endDate setTimeZone:[self viewTimeZone]];
+        spansRange = ![endDate isEqualToDate:startDate];
+    }
+    aptDescr = [[NSMutableString alloc] init];
+    [aptDescr appendFormat:@"%02i:%02i",
+        [startDate hourOfDay],
+        [startDate minuteOfHour]];
+    if(spansRange) {
+        [aptDescr appendFormat:@"- %02i:%02i",
+            [endDate hourOfDay],
+            [endDate minuteOfHour]];
+    }
+    s = [apt valueForKey:@"title"];
+    if(s) {
+        [aptDescr appendFormat:@"; %@", s];
+    }
+    s = [apt valueForKey:@"location"];
+    if(s) {
+        [aptDescr appendFormat:@"; %@", s];
+    }
+    return [aptDescr autorelease];
+}
+
+
 /* URLs */
 
 - (NSDictionary *)prevDayQueryParameters {
 /* fetching */
 
 - (NSCalendarDate *)startDate {
-    return [[self selectedDate] hour:[self dayStartHour] minute:0];
+    return [[self selectedDate] beginOfDay];
 }
 - (NSCalendarDate *)endDate {
-    return [[self startDate] hour:[self dayEndHour] minute:0];
+    return [[self startDate] endOfDay];
+}
+
+
+/* appointments */
+
+- (NSArray *)appointments {
+    return [self fetchCoreInfos];
 }
 
 @end
index d2e1f73f16ee7acb65c5b933b303c1fc787f8250..352a8c239119bf2829701ac53faabd58d7e3866f 100644 (file)
@@ -8,15 +8,11 @@
 @implementation UIxCalMonthView
 
 - (NSCalendarDate *)startDate {
-  return [[[super startDate] firstDayOfMonth]
-                             hour:[self dayStartHour]
-                             minute:0];
+  return [[[super startDate] firstDayOfMonth] beginOfDay];
 }
 
 - (NSCalendarDate *)endDate {
-  NSCalendarDate *startDate = [[self startDate]
-                                     hour:[self dayEndHour]
-                                     minute:0];
+  NSCalendarDate *startDate = [[self startDate] endOfDay];
   return [startDate dateByAddingYears:0
                     months:0
                     days:[startDate numberOfDaysInMonth]
index e861a07402f1d49df8e5fe98aaa343f5432a7b5b..65a17f7c90a2c89e3e79b803535632297fc9eeaa 100644 (file)
@@ -10,6 +10,7 @@
 @interface UIxCalView : UIxComponent
 {
   NSArray *appointments;
+  NSArray *allDayApts;
   id      appointment;
   NSCalendarDate *currentDay;
 }
 /* accessors */
 
 - (NSArray *)appointments;
+- (NSArray *)allDayApts;
 - (id)appointment;
 
+- (BOOL)hasDayInfo;
+- (BOOL)hasHoldidayInfo;
+- (BOOL)hasAllDayApts;
+
 - (NSDictionary *)aptTypeDict;
 - (NSString *)aptTypeLabel;
 - (NSString *)aptTypeIcon;
 - (NSString *)shortTextForApt;
 - (NSString *)shortTitleForApt;
+- (NSString *)appointmentViewURL;
+
+- (id)holidayInfo;
+
 
 /* related to current day */
 - (void)setCurrentDay:(NSCalendarDate *)_day;
 - (NSCalendarDate *)currentDay;
-- (NSString *)currentDayName;
-- (NSArray *)allDayApts;
-- (BOOL)hasDayInfo;
-- (BOOL)hasHoldidayInfo;
+- (NSString *)currentDayName; /* localized */
 
-    
+/* defaults */
 - (BOOL)showFullNames;
 - (BOOL)showAMPMDates;
 - (unsigned)dayStartHour;
 - (NSCalendarDate *)thisMonth;
 - (NSCalendarDate *)nextMonth;
 
-/* URLs */
-
-- (NSString *)appointmentViewURL;
-
-/* backend */
-
 /* fetching */
 
 - (NSCalendarDate *)startDate;
index 6be1a80f8431d599e5a9aa966819a2810ace3d51..0fe828b46835b3756db73610255b404c9850e442 100644 (file)
@@ -9,8 +9,9 @@
 @implementation UIxCalView
 
 - (void)dealloc {
-  [self->appointment  release];
   [self->appointments release];
+  [self->allDayApts release];
+  [self->appointment  release];
   [self->currentDay   release];
   [super dealloc];
 }
   return [self localizedNameForDayOfWeek:[self->currentDay dayOfWeek]];
 }
 
+- (id)holidayInfo {
+    return nil;
+}
+
+- (NSArray *)allDayApts {
+    NSArray *apts;
+    NSMutableArray *filtered;
+    unsigned i, count;
+
+    if(self->allDayApts)
+        return self->allDayApts;
+
+    apts = [self appointments];
+    count = [apts count];
+    filtered = [[NSMutableArray alloc] initWithCapacity:3];
+    for(i = 0; i < count; i++) {
+        id apt;
+        NSNumber *bv;
+
+        apt = [apts objectAtIndex:i];
+#warning !! check if isAllDay is correct
+        bv = [apt valueForKey:@"isAllDay"];
+        if([bv boolValue]) {
+            [filtered addObject:apt];
+        }
+    }
+    
+    ASSIGN(self->allDayApts, filtered);
+    [filtered release];
+    return self->allDayApts;
+}
+
+
+/* special appointments */
+
 - (BOOL)hasDayInfo {
-    return [self hasHoldidayInfo] || ([[self allDayApts] count] != 0);
+    return [self hasHoldidayInfo] || [self hasAllDayApts];
 }
 
 - (BOOL)hasHoldidayInfo {
-    return NO;
+    return [self holidayInfo] != nil;
 }
 
-- (NSArray *)allDayApts {
-    return [NSArray array];
+- (BOOL)hasAllDayApts {
+    return [[self allDayApts] count] != 0;
 }
 
 
 }
 
 - (unsigned)dayEndHour {
-    return 19;
+    return 18;
 }
 
 - (BOOL)shouldDisplayWeekend {
index 8d2240748ca429c3c431ac89ddfda3bb59c02867..43303b090c4e8a04a4e5d02e563a51c17fa33f9e 100644 (file)
@@ -7,14 +7,13 @@
 @implementation UIxCalWeekView
 
 - (NSCalendarDate *)startDate {
-    return [[[super startDate] mondayOfWeek] hour:[self dayStartHour]
-                                             minute:0];
+    return [[[super startDate] mondayOfWeek] beginOfDay];
 }
 
 - (NSCalendarDate *)endDate {
   return [[[self startDate] dateByAddingYears:0 months:0 days:7
                                         hours:0 minutes:0 seconds:0]
-                            hour:[self dayEndHour] minute:0];
+                            endOfDay];
 }
 
 /* URLs */