]> err.no Git - scalable-opengroupware.org/commitdiff
enhancements
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 13 Aug 2004 14:06:17 +0000 (14:06 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 13 Aug 2004 14:06:17 +0000 (14:06 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@199 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Scheduler/ChangeLog
SOGo/UI/Scheduler/UIxAppointmentEditor.m
SOGo/UI/Scheduler/UIxAppointmentEditor.wox
SOGo/UI/Scheduler/UIxAppointmentView.m
SOGo/UI/Scheduler/UIxAppointmentView.wox
SOGo/UI/Scheduler/Version
SOGo/UI/Scheduler/iCalPerson+UIx.h
SOGo/UI/Scheduler/iCalPerson+UIx.m

index 8706d704e97f6fc467d6b26486760b55df51b69f..d0dd351ed1e2e6a82a6a4aa5a35819fd630498e7 100644 (file)
@@ -1,3 +1,14 @@
+2004-08-13  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * v0.9.28
+
+       * iCalPerson+UIx.[hm]: more convenience
+
+       * UIxAppointmentView.[hm]: display CN's as Names
+
+       * UIxAppointmentEditor.[wox|m]: more functionality, but still
+         unfinished. You can use it to test appointments, though.
+
 2004-08-13  Helge Hess  <helge.hess@skyrix.com>
 
        * UIxAppointmentEditor.wox: fixed base URL of form not to include
index 07ecdbb9e6101085bbd7f1c8c702cae611fdc6d9..169a123dfea0b65a15f8d960d54a0a525b97e93f 100644 (file)
 {
   id appointment;
   id participants;
+  id item;
 }
 
 - (SOGoAppointment *)appointment;
 - (NSString *)iCalStringTemplate;
 - (NSString *)iCalString;
 
+- (NSString *)_completeURIForMethod:(NSString *)_method;
+
 @end
 
 #include <SOGoUI/SOGoDateFormatter.h>
 - (void)dealloc {
   [self->appointment  release];
   [self->participants release];
+  [self->item release];
   [super dealloc];
 }
 
 /* accessors */
 
+- (void)setItem:(id)_item {
+    ASSIGN(self->item, _item);
+}
+- (id)item {
+    return self->item;
+}
+
 - (NSString *)formattedAptStartTime {
   NSCalendarDate    *date;
   SOGoDateFormatter *fmt;
   return self->appointment;
 }
 
-- (id)participants {
-  NSArray *attendees;
-  NSMutableArray *emailAddresses;
-  unsigned i, count;
-  
-  if (self->participants)
-    return self->participants;
+- (BOOL)hasParticipants {
+    return [[self participants] count] != 0;
+}
 
-  attendees      = [self->appointment attendees];
-  count          = [attendees count];
-  emailAddresses = [[NSMutableArray alloc] initWithCapacity:count];
-  for (i = 0; i < count; i++) {
-    NSString *email;
-            
-    email = [[attendees objectAtIndex:i] rfc822Email];
-    if (email)
-      [emailAddresses addObject:email];
-  }
-  
-  self->participants = 
-    [[emailAddresses componentsJoinedByString:@"\n"] copy];
-  [emailAddresses release];
-  return self->participants;
+- (NSArray *)participants {
+#warning TODO: FILTER ROLE!
+    return [self->appointment attendees];
+}
+
+- (NSArray *)resources {
+#warning TODO: FILTER ROLE!
+    return [self->appointment attendees];
 }
 
 
     @"  checkbox = document.createElement('input');"
     @"  checkbox.setAttribute('type', 'checkbox');"
     @"  checkbox.setAttribute('checked', 'checked');"
-    @"  checkbox.setAttribute('value', email);"
+    @"  checkbox.setAttribute('value', email + ';' + cn);"
     @"  checkbox.setAttribute('id', email);"
     @"  checkbox.setAttribute('name', tableId);"
     @"  td.appendChild(checkbox);"
 
 /* helper */
 
-- (NSString *)uriAsFormat {
-  // TODO: replace that with "-uriToCallMethodNamed:" or sth like this
-  NSString *uri, *qp;
-  NSRange  r;
-  
-  uri = [[[self context] request] uri];
-
-  /* first: identify query parameters */
-  r = [uri rangeOfString:@"?" options:NSBackwardsSearch];
-  if (r.length > 0) {
-    qp = [uri substringFromIndex:r.location];
-    uri = [uri substringToIndex:r.location];
-  }
-  else
-    qp = nil;
+- (NSString *)_completeURIForMethod:(NSString *)_method {
+    NSString *uri;
+    NSRange r;
+    
+    uri = [[[self context] request] uri];
+    
+    /* first: identify query parameters */
+    r = [uri rangeOfString:@"?" options:NSBackwardsSearch];
+    if(r.length > 0)
+        uri = [uri substringToIndex:r.location];
+    
+    /* next: append trailing slash */
+    if(![uri hasSuffix:@"/"])
+        uri = [uri stringByAppendingString:@"/"];
     
-  /* next: strip trailing slash */
-  if ([uri hasSuffix:@"/"])
-    uri = [uri substringToIndex:([uri length] - 1)];
-  r = [uri rangeOfString:@"/" options:NSBackwardsSearch];
+    /* next: append method */
+    uri = [uri stringByAppendingString:_method];
     
-  /* then: cut of last path component */
-  if (r.length == 0) // no slash? are we at root?
-    uri = @"/";
-  else
-    uri = [uri substringToIndex:(r.location + 1)];
-
-  /* next: append format token */
-  uri = [uri stringByAppendingString:@"%@"];
-  if (qp != nil)
-    uri = [uri stringByAppendingString:qp];
-  return uri;
+    /* next: append query parameters */
+    return [self completeHrefForMethod:uri];
+}
+
+/* HACK: this is for agenor only */
+- (NSString *)emailForUser {
+    NSString *uid;
+    NSRange r;
+
+    uid = [[self user] login];
+    r = [uid rangeOfString:@"@"];
+    if(r.length > 0)
+        return uid;
+    return [NSString stringWithFormat:@"%@@equipement.gouv.fr", uid];
 }
 
 
     
     Note: 'clientObject' is the SOGoAppointmentFolder!
   */
-  NSString *uri, *uriFormat, *objectId, *nextMethod;
+  NSString *uri, *objectId, *nextMethod;
   
   objectId = [NSClassFromString(@"SOGoAppointmentFolder")
                               globallyUniqueObjectId];
   
-  nextMethod = [NSString stringWithFormat:@"%@/edit", objectId];
-  uriFormat  = [self uriAsFormat];
-  uri = [NSString stringWithFormat:uriFormat, nextMethod];
-  
+  nextMethod = [NSString stringWithFormat:@"../%@/edit", objectId];
+  uri = [self _completeURIForMethod:nextMethod];
   return [self redirectToLocation:uri];
 }
 
   return date;
 }
 
+/* for testing only */
 - (id)testAction {
     WORequest      *req;
     
 - (id)saveAction {
   SOGoAppointment *apt;
   NSString       *iCalString;
-  NSString       *summary, *location, *uri, *uriFormat;
+  NSString       *summary, *location, *uri;
   NSCalendarDate *sd, *ed;
   NSArray        *ps;
   unsigned       i, count;
   WORequest      *req;
 
+  
   if (![[self clientObject] respondsToSelector:@selector(saveContentString:)]){
-    return [NSException exceptionWithHTTPStatus:400 /* invalid request */
-                       reason:
-                         @"method cannot be invoked on the specified object"];
+    /* return 400 == Bad Request */
+    return [NSException exceptionWithHTTPStatus:400
+                        reason:@"method cannot be invoked on "
+                               @"the specified object"];
   }
   
   req = [[self context] request];
   ps = [req formValuesForKey:@"participants"];
   count = [ps count];
   for (i = 0; i < count; i++) {
-    NSString   *email;
+    NSString   *pString, *email, *cn;
+    NSRange r;
     iCalPerson *p;
-    NSRange    cnr;
     
-    email = [ps objectAtIndex:i];
-    if ([email length] == 0)
+    pString = [ps objectAtIndex:i];
+    if([pString length] == 0)
       continue;
-    
+
+    /* delimiter between email and cn */
+    r = [pString rangeOfString:@";"];
+    if(r.length > 0) {
+        email = [pString substringToIndex:r.location];
+        if(r.location + 1 < [pString length]) {
+            cn = [pString substringFromIndex:r.location + 1];
+        }
+        else {
+            cn = nil;
+        }
+    }
+    else {
+        email = pString;
+        cn = nil;
+    }
+    if(cn == nil) {
+        /* construct a fake CN if possible */
+        r = [email rangeOfString:@"@"];
+        if (r.length > 0)
+            cn = [email substringToIndex:r.location];
+    }
     p = [[iCalPerson alloc] init];
-    [p setEmail:[@"mailto:" stringByAppendingString:[email stringValue]]];
-    /* construct a fake CN */
-    cnr = [email rangeOfString:@"@"];
-    if (cnr.length > 0)
-      [p setCn:[email substringToIndex:cnr.location]];
+    [p setEmail:[@"mailto:" stringByAppendingString:email]];
+    if(cn)
+      [p setCn:cn];
     [apt addToAttendees:p];
     [p release];
   }
     // TODO: add some error handling in form! (eg like in Zope)
   }
   
-  uriFormat = [self uriAsFormat];
-  uri = [NSString stringWithFormat:uriFormat, @"view"];
+  uri = [self _completeURIForMethod:@"view"];
   return [self redirectToLocation:uri];
 }
 
index 8cfc68fd760db5dd714292292f5b117dc884b4f2..1920835f11bf6882d8d31c0e81a71b80019456ed 100644 (file)
                   />
                   <hr />
                   <table id="participants">
-                    <tr>
-                      <td><input type="checkbox"
-                                 checked="checked"
-                                 var:value="user.login"
-                                 var:id="user.login"
-                                 name="participants"
-                          /></td>
-                      <td>TODO: EMAIL(!) <var:string value="user.login" /></td>
-                    </tr>
+                    <var:if condition="hasParticipants" const:negate="YES">
+                      <tr>
+                        <td><input type="checkbox"
+                                   checked="YES"
+                                   var:value="cnAndEmailForUser"
+                                   var:id="emailForUser"
+                                   name="participants"
+                            /></td>
+                        <td><var:string value="shortUserNameForDisplay" /></td>
+                      </tr>
+                    </var:if>
+                    <var:if condition="hasParticipants">
+                      <var:foreach list="participants" item="item">
+                        <tr>
+                          <td><input type="checkbox"
+                                     checked="YES"
+                                     var:value="combinedCNAndEmail"
+                                     var:id="item.rfc822Email"
+                                     name="participants"
+                              /></td>
+                          <td><var:string value="item.cnForDisplay" /></td>
+                        </tr>
+                      </var:foreach>
+                    </var:if>
                   </table>
                 </span>
               </td>
                   />
                   <hr />
                   <table id="resources">
+                    <var:foreach list="resources" item="item">
+                      <tr>
+                        <td><input type="checkbox"
+                                   checked="YES"
+                                   var:value="item.rfc822Email"
+                                   var:id="item.rfc822Email"
+                                   name="resources"
+                            /></td>
+                        <td><var:string value="item.cnForDisplay" /></td>
+                      </tr>
+                    </var:foreach>
                   </table>
                 </span>
               </td>
           </table>
         </td>
       </tr>
+      <tr>
+        <td>
+          <table border="0"
+                 cellpadding="2"
+                 width="100%"
+                 cellspacing="0"
+                 bgcolor="#e8e8e0"
+          >
+            <tr>
+              <td align="left" colspan="2">
+                <span class="aptview_title">
+                  <var:string label:value="Comment" />
+                </span>
+              </td>
+            </tr>
+            <tr valign="top">
+              <td align="right" width="15%">
+                <span class="aptview_text">
+                  <var:string label:value="Comment" />:
+                </span>
+              </td>
+              <td align="left" bgcolor="#FFFFF0">
+                <span class="aptview_text">
+                  <textarea name="comment"
+                            rows="8"
+                            cols="80"
+                            wrap="physical"
+                  ><var:string value="appointment.comment" /></textarea>
+                </span>
+              </td>
+            </tr>
+          </table>
+        </td>
+      </tr>
       <tr>
         <td>
             <input type="submit" label:value="Save" name="save:method" />
             <input type="hidden" name="ical" var:value="iCalString" />
-            <input type="submit" value="test" name="test:method" />
+            <!-- <input type="submit" value="test" name="test:method" /> -->
         </td>
       </tr>
     </table>
index 46d653d750c17db33bf2618dd383a1d6fe265b0e..68f41da4b9c49215356b5a5a0d45e03853eef358 100644 (file)
   return self->attendee;
 }
 
-- (NSString *)attendeeEmail {
-  NSString *s;
-  
-  s = [[self attendee] email];
-  if (![s hasPrefix:@"mailto:"]) return s;
-  return [s substringFromIndex:7];
-}
-
 /* backend */
 
 - (SOGoAppointment *)appointment {
index 775a5c5f5eba8b0edf4d2a324a3f15f5e17c5d91..b7a226db9457b0fe58b3de58a2402967317c4eaf 100644 (file)
                    var:href="participantsTabLink">
               <table width="100%" border="0" cellpadding="4" cellspacing="0">
               <tr valign="top">
+                <td align="left" bgcolor="#E8E8E0">
+                    <span class="aptview_title">Name</span>
+                </td>
                 <td align="left" bgcolor="#E8E8E0">
                     <span class="aptview_title">Email</span>
                 </td>
               </tr>
               <var:foreach list="appointment.attendees" item="attendee">
               <tr valign="top">
+                <td align="left" bgcolor="#FFFFF0">
+                  <span class="aptview_text">
+                    <var:string value="attendee.cnForDisplay" />
+                  </span>
+                </td>
                 <td align="left" bgcolor="#FFFFF0">
                   <span class="aptview_text">
                     <a var:href="attendee.email"
-                       ><var:string value="attendeeEmail" /></a>
+                       ><var:string value="attendee.rfc822Email" /></a>
                   </span>
                 </td>
               </tr>
index 9461bed0f2fb385c7656d9d8638cc42bd78b158c..42d0a3b80cd7c5cbc793862161337200792359c1 100644 (file)
@@ -1,3 +1,3 @@
 # $Id$
 
-SUBMINOR_VERSION:=27
+SUBMINOR_VERSION:=28
index eaa1989cfe6713cb9f9ad32d66af08f04f4f56a6..7417aa6278284715eb3595730fde23558f2470d6 100644 (file)
@@ -29,6 +29,7 @@
 
 @interface iCalPerson(Convenience)
 - (NSString *)rfc822Email;
+- (NSString *)cnForDisplay;
 @end
 
 #endif /* __iCalPerson_UIx_H__ */
index 94473e33cb7c9ecd08ce25c233881536c82136b3..14ab19eb06a1e922a3ad525f121225cca0f3e990 100644 (file)
   return _email;
 }
 
+- (NSString *)cnForDisplay {
+    NSString *_cn;
+    _cn = [self cn];
+    if([_cn length] > 2)
+        return [_cn substringWithRange:NSMakeRange(1, [_cn length] - 2)];
+    return _cn;
+}
+
 @end /* iCalPerson(Convenience) */