]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@234 d1b88da0-ebda-0310-925b-ed51d...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 15 Aug 2004 19:28:26 +0000 (19:28 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 15 Aug 2004 19:28:26 +0000 (19:28 +0000)
SOGo/UI/Scheduler/ChangeLog
SOGo/UI/Scheduler/UIxAppointmentEditor.m
SOGo/UI/Scheduler/UIxAppointmentEditor.wox
SOGo/UI/Scheduler/Version

index 732da32a7d1ab3ac2c4e3ce0faa14a80b0d932e5..c26bcb015523ca82bfc4a0cbbc7d4f08d3137065 100644 (file)
@@ -1,5 +1,8 @@
 2004-08-15  Helge Hess  <helge.hess@skyrix.com>
 
+       * UIxAppointmentEditor.m: more decoupling from iCal. Added some error
+         handling UI code (errorText), date selector is broken (v0.9.47)
+
        * v0.9.46
        
        * iCalPerson+UIx.m: changed -cnForDisplay method, znek needs to check
index 8922837fde7b3bdd1010ccd30f531ffc98859570..9d04485a99382835cb65045db2c5b39b0d19eb38 100644 (file)
@@ -31,7 +31,7 @@
 @interface UIxAppointmentEditor : UIxComponent
 {
   NSString *iCalString;
-  id appointment;
+  NSString *errorText;
   id item;
   
   /* individual values */
@@ -44,7 +44,6 @@
   NSArray        *resources;
 }
 
-- (SOGoAppointment *)appointment;
 - (NSString *)iCalStringTemplate;
 - (NSString *)iCalString;
 
@@ -73,6 +72,7 @@
 @implementation UIxAppointmentEditor
 
 - (void)dealloc {
+  [self->errorText    release];
   [self->participants release];
   [self->resources    release];
   [self->startDate    release];
@@ -81,7 +81,6 @@
   [self->location     release];
   [self->comment      release];
   [self->iCalString   release];
-  [self->appointment  release];
   [self->item         release];
   [super dealloc];
 }
   return self->item;
 }
 
+- (void)setErrorText:(NSString *)_txt {
+  ASSIGNCOPY(self->errorText, _txt);
+}
+- (NSString *)errorText {
+  return self->errorText;
+}
+- (BOOL)hasErrorText {
+  return [self->errorText length] > 0 ? YES : NO;
+}
+
 - (NSFormatter *)titleDateFormatter {
   SOGoDateFormatter *fmt;
   
   return template;
 }
 
-- (SOGoAppointment *)appointment {
-  return self->appointment;
-}
-
 /* helper */
 
 - (NSString *)_completeURIForMethod:(NSString *)_method {
   self->resources    = [[_appointment resources]    retain];
 }
 
+- (void)saveValuesIntoAppointment:(SOGoAppointment *)_appointment {
+  /* merge in form values */
+  NSArray        *attendees, *lResources;
+  
+#warning TODO: broken for the new date/time selector!
+#if 0
+  NSCalendarDate *sd, *ed;
+  
+  sd = [self _dateFromString:[req formValueForKey:@"startDate"]];
+  ed = [self _dateFromString:[req formValueForKey:@"endDate"]];
+  if (sd == nil || ed == nil) {
+    [self setErrorText:@"missing startdate or enddate ..."]; // localize
+    return self;
+  }
+  [_appointment setStartDate:sd];
+  [_appointment setEndDate:ed];
+#endif
+  
+  [_appointment setSummary:[self title]];
+  [_appointment setLocation:[self location]];
+  
+  attendees  = [self participants];
+  lResources = [self resources];
+  if ([lResources count] > 0) {
+    attendees = ([attendees count] > 0)
+      ? [attendees arrayByAddingObjectsFromArray:lResources]
+      : lResources;
+  }
+  [_appointment setAttendees:attendees];
+  
+  [_appointment setOrganizer:[self getOrganizer]];
+}
+
+- (void)loadValuesFromICalString:(NSString *)_ical {
+  SOGoAppointment *apt;
+
+  apt = [[SOGoAppointment alloc] initWithICalString:_ical];
+  [self loadValuesFromAppointment:apt];
+  [apt release];
+}
+
 /* actions */
 
 - (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c{
     ical = [self iCalStringTemplate];
   
   [self setICalString:ical];
-  
-  /* parse */
-  
-  self->appointment = 
-    [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
-  
-  /* load values */
-  
-  [self loadValuesFromAppointment:[self appointment]];
+  [self loadValuesFromICalString:ical];
   
   return self;
 }
 
 - (id)saveAction {
-  NSString       *uri;
-  NSCalendarDate *sd, *ed;
-  NSArray        *attendees, *lResources;
-  WORequest      *req;
+  SOGoAppointment *apt;
+  NSString        *uri;
+  NSException *ex;
+  NSString    *content;
   
   if (![self isWriteableClientObject]) {
     /* return 400 == Bad Request */
                                @"the specified object"];
   }
   
-  req = [[self context] request];
-  
-  /* get iCalString from hidden input */
-  [self setICalString:[req formValueForKey:@"ical"]];
-
-  self->appointment = 
-    [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
-  
-  if (self->appointment == nil) {
-    return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
-                        reason:@"invalid iCalendar form data in request"];
+  apt = [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
+  if (apt == nil) {
+    [self setErrorText:@"Invalid iCalendar data ..."]; // localize
+    return self;
   }
   
-  /* merge in form values */
+  [self saveValuesIntoAppointment:apt];
+  content = [apt iCalString];
+  [apt release]; apt = nil;
   
-  sd = [self _dateFromString:[req formValueForKey:@"startDate"]];
-  ed = [self _dateFromString:[req formValueForKey:@"endDate"]];
-  [self->appointment setStartDate:sd];
-  [self->appointment setEndDate:ed];
-  
-  [self->appointment setSummary:[req formValueForKey:@"summary"]];
-  [self->appointment setLocation:[req formValueForKey:@"location"]];
-  
-  attendees = [self getICalPersonsFromFormValues:
-                     [req formValuesForKey:@"participants"]
-                   treatAsResource:NO];
-  lResources = [self getICalPersonsFromFormValues:
-                     [req formValuesForKey:@"resources"]
-                   treatAsResource:YES];
-  if ([lResources count] > 0) {
-    attendees = ([attendees count] > 0)
-      ? [attendees arrayByAddingObjectsFromArray:lResources]
-      : lResources;
+  if (content == nil) {
+    [self setErrorText:@"Could not create iCalendar data ..."]; // localize
+    return self;
   }
-  [self->appointment setAttendees:attendees];
-  
-  [self->appointment setOrganizer:[self getOrganizer]];
   
-  /* receive current representation for save operation */
-  {
-    NSException *ex;
-    NSString *content;
-    
-    content = [self->appointment iCalString];
-    if (content == nil) {
-      return [NSException exceptionWithHTTPStatus:500 /* Internal Error */
-                         reason:@"failed to create iCal content for apt"];
-    }
-    
-    ex = [[self clientObject] saveContentString:content];
-    if (ex) return ex;
-    // TODO: add some error handling in form! (eg like in Zope)
+  ex = [[self clientObject] saveContentString:content];
+  if (ex != nil) {
+    [self setErrorText:[ex reason]];
+    return self;
   }
   
   uri = [self _completeURIForMethod:@".."];
index d32b0c0e17ffabb27c54ee387cf0b9b8a5e152e4..a0a9b40588d31a543aadf93c720b23ee2f660294 100644 (file)
       </tr>
       <tr>
         <td>
+          <var:if condition="hasErrorText">
+           <span style="background-color: #AA0000;">
+             <var:string value="errorText" />
+            </span>
+            <hr />
+          </var:if>
+
           <table border="0" cellpadding="2" cellspacing="0" width="100%"
                  bgcolor="#e8e8e0"
           >
index 3c9ce3a1b05de8e9f50286711fc3f9b1415fda6e..8846f04e9f9654efedc839dd9279e12e7629f5f2 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 
-SUBMINOR_VERSION:=46
+SUBMINOR_VERSION:=47
 
 # v0.9.41 requires libNGObjWeb     v4.2.431
 # v0.9.31 requires libWEExtensions v4.2.52