]> err.no Git - scalable-opengroupware.org/commitdiff
work in progress. some more refactoring and overall improvement of the editor.
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 22:34:55 +0000 (22:34 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 22:34:55 +0000 (22:34 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@84 d1b88da0-ebda-0310-925b-ed51d893ca5b

ZideStore/UI-X/Common/UIxComponent.h
ZideStore/UI-X/Common/UIxComponent.m
ZideStore/UI-X/Common/UIxPageFrame.wox
ZideStore/UI-X/Scheduler/UIxAppointmentEditor.m
ZideStore/UI-X/Scheduler/UIxAppointmentEditor.wox
ZideStore/UI-X/Scheduler/UIxAppointmentView.m
ZideStore/UI-X/Scheduler/UIxAppointmentView.wox
ZideStore/UI-X/Scheduler/UIxCalView.h
ZideStore/UI-X/Scheduler/UIxCalView.m
ZideStore/UI-X/Scheduler/product.plist

index b3b41f59d1bcca2bc6149b80be3c2d83d350e4b1..d9a0c6ffc51641f4198fc89b699c3c351b55c240 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <NGObjWeb/SoComponent.h>
 
+@class NSCalendarDate;
+
 
 @interface UIxComponent : SoComponent
 {
 
 - (NSString *)ownMethodName;
 
+/* date selection */
+- (NSCalendarDate *)selectedDate;
+- (NSString *)dateStringForDate:(NSCalendarDate *)_date;
+- (NSCalendarDate *)dateForDateString:(NSString *)_dateString;
+
 @end
 
 #endif /* __UIxComponent_H_ */
index 0a1650e6ac6e5778d1804e02e2322ccce6326912..280bcd719383d1febfcef3caad9fbc22d9c7d82e 100644 (file)
     return [uri substringFromIndex:(r.location + 1)];
 }
 
+/* date */
+
+- (NSCalendarDate *)selectedDate {
+    NSString *s;
+    
+    s = [self queryParameterForKey:@"day"];
+    if(s) {
+        return [self dateForDateString:s];
+    }
+    return [NSCalendarDate date];
+}
+
+- (NSString *)dateStringForDate:(NSCalendarDate *)_date {
+    return [_date descriptionWithCalendarFormat:@"%Y%m%d"];
+}
+
+- (NSCalendarDate *)dateForDateString:(NSString *)_dateString {
+    return [NSCalendarDate dateWithString:_dateString calendarFormat:@"%Y%m%d"];
+}
+
 @end
index 8a7f9d6d1640f8b56395c1ae32809fcdb425ccc6..efc1f4d9388131f35c2e3a4dc75ea165dd10186c 100644 (file)
                     </tr>
                     <tr>
                       <td valign="middle">
-                        <a href="/OpenGroupware/wo/5A715A710740C43D13/12440c4518c09603e3c.0.15.1.17.3.1.1.3.3.1.8.14" class="skydockfont">Logout</a>
+                        <a href="/OpenGroupware/x/dock" class="skydockfont">Logout</a>
                       </td>
                     </tr>
                   </table>
index f2e197841caa58f062884b20520d58008814da37..23860cf296c56dc90fc0f2f5f3dabe247e39ed8c 100644 (file)
 #include "common.h"
 #include <Common/UIxComponent.h>
 #include <SOGoLogic/SOGoAppointment.h>
+#include <NGiCal/NGiCal.h>
 
 
+/* TODO: CLEAN THIS MESS UP */
+
+
+@interface NSObject (AppointmentHack)
+- (BOOL)isAppointment;
+@end
+
+@implementation NSObject (AppointmentHack)
+- (BOOL)isAppointment {
+    return NO;
+}
+@end
+
+@interface SxAppointment : NSObject
+@end
+
+@implementation SxAppointment (AppointmentHack)
+- (BOOL)isAppointment {
+    return YES;
+}
+@end
+
+@interface iCalPerson (Convenience)
+- (NSString *)rfc822Email;
+@end
+
+@implementation iCalPerson (Convenience)
+- (NSString *)rfc822Email {
+    NSString *_email = [self email];
+    NSRange colon = [_email rangeOfString:@":"];
+    if(colon.location != NSNotFound) {
+        return [_email substringFromIndex:colon.location + 1];
+    }
+    return _email;
+}
+@end
+
 @interface UIxAppointmentEditor : UIxComponent
 {
     id appointment;
+    id participants;
 }
 
 - (SOGoAppointment *)appointment;
+- (NSString *)iCalStringTemplate;
+- (BOOL)isNewAppointment;
 
 @end
 
@@ -39,6 +80,7 @@
 
 - (void)dealloc {
     [self->appointment release];
+    [self->participants release];
     [super dealloc];
 }
 
@@ -54,6 +96,9 @@
     return [date descriptionWithCalendarFormat:@"%A, %Y-%m-%d %H:%M %Z"];
 }
 
+- (BOOL)isNewAppointment {
+    return ! [[self clientObject] isAppointment];
+}
 
 /* backend */
 
 - (SOGoAppointment *)appointment {
     if(self->appointment == nil) {
         NSString *iCalString;
-        
-        iCalString = [[self clientObject] valueForKey:@"iCalString"];
-        self->appointment = [[SOGoAppointment alloc] initWithICalString:iCalString];
+
+        if([[self clientObject] isAppointment]) {
+            iCalString = [[self clientObject] valueForKey:@"iCalString"];
+        }
+        else {
+            iCalString = [self iCalStringTemplate];
+        }
+        self->appointment = [[SOGoAppointment alloc]
+                                              initWithICalString:iCalString];
     }
     return self->appointment;
 }
 
+- (id)participants {
+    if(self->participants == nil) {
+        NSArray *attendees;
+        NSMutableArray *emailAddresses;
+        unsigned i, count;
+
+        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"]
+            retain];
+        [emailAddresses release];
+    }
+    return self->participants;
+}
+
+- (NSString *)iCalStringTemplate {
+    static NSString *iCalStringTemplate = \
+    @"BEGIN:VCALENDAR\nMETHOD:REQUEST\nPRODID:OpenGroupware.org ZideStore 1.2\n" \
+    @"VERSION:2.0\nBEGIN:VEVENT\nCLASS:PRIVATE\nSTATUS:CONFIRMED\n" \
+    @"DTSTART:%@\nDTEND:%@\n" \
+    @"TRANSP:OPAQUE\n" \
+    @"END:VEVENT\nEND:VCALENDAR";
+    NSCalendarDate *startDate, *endDate;
+    NSString *template;
+
+    startDate = [self selectedDate];
+    endDate = [startDate dateByAddingYears:0 months:0 days:0
+                         hours:1 minutes:0 seconds:0];
+    
+
+    template = [NSString stringWithFormat:iCalStringTemplate,
+                                          [startDate icalString],
+                                          [endDate icalString]];
+
+    return template;
+}
+
+
+/* helper */
+
+- (NSString *)uriAsFormat {
+    NSString *uri, *qp;
+    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];
+        qp = [uri substringFromIndex:r.location];
+    }
+    else {
+        qp = nil;
+    }
+    
+    /* next: strip trailing slash */
+    if([uri hasSuffix:@"/"])
+        uri = [uri substringToIndex:([uri length] - 1)];
+    r = [uri rangeOfString:@"/" options:NSBackwardsSearch];
+    
+    /* then: cut of last path component */
+    if(r.location == NSNotFound) { // 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;
+}
+
+
+/* save */
+
+
+- (id)saveAction {
+    NSString *foo, *nextMethod, *uri, *uriFormat;
+    NSMutableArray *attendees;
+    WOResponse *r;
+    WORequest *req;
+
+    req = [[self context] request];
+    foo = [req formValueForKey:@"ical"];
+
+    if([self isNewAppointment])
+        nextMethod = @"duhduh";
+    else
+        nextMethod = @"view";
+
+    uriFormat = [self uriAsFormat];
+    uri = [NSString stringWithFormat:uriFormat, nextMethod];
+    NSLog(@"%s got foo:%@, redirecting to '%@'",
+          __PRETTY_FUNCTION__,
+          foo,
+          uri);
+
+    r = [WOResponse responseWithRequest:req];
+    [r setStatus:302 /* moved */];
+    [r setHeader:uri forKey:@"location"];
+    return r;
+}
+
 @end
index 64da2f1c884c66a419b1cb1387c1e4542958da02..12b699eae28bf65e611fc77ee1ca0044afc1f743 100644 (file)
@@ -7,6 +7,7 @@
                title="name"
 >
 
+  <form href="save">
   <table cellspacing="0" cellpadding="5" width="100%">
   <tr>
   <td>
             </td>
             <td align="left" bgcolor="#FFFFF0">
                 <span class="aptview_text">
-                  start time
+                  <input type="text" name="startDate" var:value="appointment.startDate" const:dateformat="%Y-%m-%d %H:%M" const:size="40" />
+                </span>
+            </td>
+          </tr>
+          <tr valign="top">
+            <td align="right" width="15%">
+                <span class="aptview_text">End time:</span>
+            </td>
+            <td align="left" bgcolor="#FFFFF0">
+                <span class="aptview_text">
+                  <input type="text" name="endDate" var:value="appointment.endDate" const:dateformat="%Y-%m-%d %H:%M" const:size="40" />
+                </span>
+            </td>
+          </tr>
+          <tr valign="top">
+            <td align="right" width="15%">
+                <span class="aptview_text">Title:</span>
+            </td>
+            <td align="left" bgcolor="#FFFFF0">
+                <span class="aptview_text">
+                  <input type="text" name="summary" var:value="appointment.summary" const:size="40" />
+                </span>
+            </td>
+          </tr>
+          <tr valign="top">
+            <td align="right" width="15%">
+                <span class="aptview_text">Location:</span>
+            </td>
+            <td align="left" bgcolor="#FFFFF0">
+                <span class="aptview_text">
+                  <input type="text" name="location" var:value="appointment.location" const:size="40"/>
                 </span>
             </td>
           </tr>
           </tr>
           <tr valign="top">
             <td align="right" width="15%">
-                <span class="aptview_text">Start time:</span>
+                <span class="aptview_text">Participants:</span>
             </td>
             <td align="left" bgcolor="#FFFFF0">
                 <span class="aptview_text">
-                  textarea
+                  <textarea name="participants" var:value="participants" cols="40" rows="5" />
                 </span>
             </td>
           </tr>
   </tr>
 
   <tr>
-    <td valign="top" width="100%">
-      <table width="100%" border="0" cellpadding="4" cellspacing="0">
-      <tr valign="top">
-        <td align="right" width="15%" bgcolor="#E8E8E0">
-            <span class="aptview_text">Title:</span>
-        </td>
-        <td align="left" bgcolor="#FFFFF0">
-            <span class="aptview_text">
-              <var:string value="appointment.summary" />
-            </span>
-        </td>
-      </tr>
-      <tr valign="top">
-        <td align="right" width="15%" bgcolor="#E8E8E0">
-          <span class="aptview_text">Location:</span>
-        </td>
-        <td align="left" bgcolor="#FFFFF0">
-          <span class="aptview_text">
-            <var:string value="appointment.location" />
-          </span>
-        </td>
-      </tr>
-      </table>
-   </td>
-  </tr>
-  <tr>
-    <td valign="top" width="100%">
+    <td>
+        <input type="submit" value="Save" />
+        <input type="hidden" name="ical" var:value="appointment.iCalString" />
     </td>
   </tr>
   </table>
+  </form>
   <!-- -->
   <hr />
   clientObject: <var:string value="clientObject" />
index f69ee7471b542b5244487b75b4d19fbc326b986a..b05f9084135673975d46a55d87863d5b9bea0936 100644 (file)
                  forKey:@"tab"];
 }
 
+- (NSString *)debugTabLink {
+    return [self completeHrefForMethod:[self ownMethodName]
+                 withParameter:@"debug"
+                 forKey:@"tab"];
+}
+
 - (NSString *)completeHrefForMethod:(NSString *)_method
               withParameter:(NSString *)_param
               forKey:(NSString *)_key
index e82a0d5125c044d8dd1d46a857ecb1ec6e46b498..90dfd7bcf29d0f5f314eab86a98e41d61eb6de92 100644 (file)
               </var:foreach>
               </table>
           </uix:tab>
+          <uix:tab const:key="debug"
+                   const:label="DEBUG"
+                   var:href="debugTabLink">
+            OGo ZideStore Server - <var:string value="name"/>
+            <br />
+            Client: <var:string value="clientObject"/>
+            <br />
+            Group:      <var:string value="clientObject.group"/><br />
+            Deletable:  <var:string value="clientObject.isDeletionAllowed"/><br />
+            Generation: <var:string value="clientObject.zlGenerationCount"/><br />
+            MsgClass:   <var:string value="clientObject.outlookMessageClass"/><br />
+
+            <hr />
+            As iCal:<br />
+            <pre><var:string value="clientObject.iCalString"/></pre>
+
+            <hr />
+            As Mail:<br />
+            <pre><var:string value="clientObject.iCalMailString"/></pre>
+
+          </uix:tab>
         </uix:tabview>
     </td>
   </tr>
   </table>
-
-<!-- DEBUGGING
-  <a href="../weekoverview" >week</a>
-  <a href="../monthoverview">month</a>
-  <br />
-    <h4>Appointment Viewer</h4>
-    OGo ZideStore Server - <var:string value="name"/>
-    <br />
-    Client: <var:string value="clientObject"/>
-    <br />
-    Group:      <var:string value="clientObject.group"/><br />
-    Deletable:  <var:string value="clientObject.isDeletionAllowed"/><br />
-    Generation: <var:string value="clientObject.zlGenerationCount"/><br />
-    MsgClass:   <var:string value="clientObject.outlookMessageClass"/><br />
-    
-    <hr />
-    
-    As iCal:<br />
-    <pre><var:string value="clientObject.iCalString"/></pre>
-
-    <hr />
-
-    As Mail:<br />
-    <pre><var:string value="clientObject.iCalMailString"/></pre>
-
-    <hr />
-
-    As SOGoApt:<br />
-    <pre><var:string value="sogoApt"/></pre>
-    <pre><var:string value="sogoApt.event"/></pre>
--->
 </var:component>
index 231d6228aab9b9a53c7552460eb608d2de68b544..c9c10e6090b6b1f7bef7de176d179cea6bef6628 100644 (file)
@@ -50,7 +50,6 @@
 
 /* fetching */
 
-- (NSCalendarDate *)selectedDate;
 - (NSCalendarDate *)startDate;
 - (NSCalendarDate *)endDate;
 - (NSArray *)fetchGIDs;
@@ -63,9 +62,6 @@
 - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
         inDictionary:(NSMutableDictionary *)_qp;
 
-- (NSString *)dateStringForDate:(NSCalendarDate *)_date;
-- (NSCalendarDate *)dateForDateString:(NSString *)_dateString;
-
 @end
 
 #endif /* __ZideStoreUI_UIxCalView_H__ */
index e68043df8d80065d0e4222b598be9242ca2e7d73..ebd925f3870351f87cbc87440bf6fa049c58f069 100644 (file)
                         queryString:nil];
 }
 
-/* date */
-
-- (NSCalendarDate *)selectedDate {
-    NSString *s;
-    
-    s = [self queryParameterForKey:@"day"];
-    if(s) {
-        return [self dateForDateString:s];
-    }
-    return [NSCalendarDate date];
-}
-
 /* fetching */
 
 - (NSCalendarDate *)startDate {
         [_qp removeObjectForKey:@"day"];
 }
 
-- (NSString *)dateStringForDate:(NSCalendarDate *)_date {
-  return [_date descriptionWithCalendarFormat:@"%Y%m%d"];
-}
-
-- (NSCalendarDate *)dateForDateString:(NSString *)_dateString {
-  return [NSCalendarDate dateWithString:_dateString calendarFormat:@"%Y%m%d"];
-}
-
 @end /* UIxCalView */
index 44393f51a5ba5b2313d512decee72f8a901450c8..680bd695cbfbdfb074b9b5c488ce0a151d1c5466 100644 (file)
           protectedBy = "View";
           pageName    = "UIxAppointmentEditor"; 
         };
+        "save" = { 
+          protectedBy = "View";
+          pageName    = "UIxAppointmentEditor"; 
+          actionName  = "save";
+        };
       };
     };
   };