From 81edcac1c5e8e43596445635b68a34e57368414d Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 11 Aug 2004 20:52:08 +0000 Subject: [PATCH] Working AnaisUidSelector, working redirects, some refactoring. git-svn-id: http://svn.opengroupware.org/SOGo/trunk@185 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Anais/AnaisUidSelector.m | 51 ++++++++++++++++++++++++----- SOGo/UI/Anais/AnaisUidSelector.wox | 28 ++++++++++------ SOGo/UI/Anais/ChangeLog | 5 +++ SOGo/UI/Anais/Version | 2 +- SOGo/UI/Common/ChangeLog | 5 +++ SOGo/UI/Common/UIxPageFrame.m | 35 ++------------------ SOGo/UI/SOGoUI/ChangeLog | 4 +++ SOGo/UI/SOGoUI/UIxComponent.h | 6 +++- SOGo/UI/SOGoUI/UIxComponent.m | 28 ++++++++++++++++ SOGo/UI/SOGoUI/Version | 2 +- SOGo/UI/Scheduler/ChangeLog | 10 ++++++ SOGo/UI/Scheduler/UIxCalView.m | 52 ++++++++++++++++++++++++++++++ SOGo/UI/Scheduler/Version | 2 +- SOGo/UI/Scheduler/product.plist | 5 +++ 14 files changed, 182 insertions(+), 53 deletions(-) diff --git a/SOGo/UI/Anais/AnaisUidSelector.m b/SOGo/UI/Anais/AnaisUidSelector.m index 00cc3e8c..b8d88315 100644 --- a/SOGo/UI/Anais/AnaisUidSelector.m +++ b/SOGo/UI/Anais/AnaisUidSelector.m @@ -28,15 +28,20 @@ NSArray *calendarUIDs; NSString *uid; BOOL meTooChecked; + NSString *userUid; } - (NSString *)prettyUid; +- (NSString *)userUid; + +- (NSString *)showHref; - (NSString *)jsCode; @end #include "common.h" +#include @implementation AnaisUidSelector @@ -50,6 +55,7 @@ - (void)dealloc { [self->calendarUIDs release]; [self->uid release]; + [self->userUid release]; [super dealloc]; } @@ -79,30 +85,59 @@ } +/* Href */ + +- (NSString *)showHref { + return [self completeHrefForMethod:@"show"]; +} + + +/* Helper */ + +- (NSString *)userUid { + if(self->userUid) + return self->userUid; + + ASSIGN(self->userUid, [[self user] login]); + return self->userUid; +} + +- (NSString *)calendarUIDString { + return [[self calendarUIDs] componentsJoinedByString:@","]; +} + + /* JavaScript */ - (NSString *)jsCode { static NSString *script = \ - @"function submitUidList() {\n" - @"}\n" - @"function clearUidList() {\n" - @" var o = document.getElementById('anaisUidList');\n" + @"function clearElementWithId(elemId) {\n" + @" var o = document.getElementById(elemId);\n" @" var dst = o.parentNode;\n" @" var n = document.createElement('td');\n" - @" n.setAttribute('id', 'anaisUidList');\n" + @" n.setAttribute('id', elemId);\n" @" dst.replaceChild(n, o);\n" @"}\n" + @"function clearUidList() {\n" + @" clearElementWithId('anaisUIDList');\n" + @" var e = document.getElementById('anaisUIDString');\n" + @" e.setAttribute('value', '%@');\n" + @"}\n" @"function addUid(division, cn, dn, email, uid, sn) {\n" @" if(!uid)\n" - @" uid='helge';\n" - @" var td = document.getElementById('anaisUidList');\n" + @" uid='unknown';\n" + @" var td = document.getElementById('anaisUIDList');\n" @" if(td.hasChildNodes())\n" @" uid=', '+uid;\n" @" var text = document.createTextNode(uid);\n" @" td.appendChild(text);\n" + @" var e = document.getElementById('anaisUIDString');\n" + @" e.setAttribute('value', uid);\n" @"}\n" @""; - return script; + + return [NSString stringWithFormat:script, + [self userUid]]; } @end diff --git a/SOGo/UI/Anais/AnaisUidSelector.wox b/SOGo/UI/Anais/AnaisUidSelector.wox index ac691ebc..6446bd91 100644 --- a/SOGo/UI/Anais/AnaisUidSelector.wox +++ b/SOGo/UI/Anais/AnaisUidSelector.wox @@ -20,7 +20,7 @@ label:title="Search in Anais" const:windowId="UidSelector" const:callback="addUid" - const:division="CC" + const:division="TEST" /> @@ -28,9 +28,18 @@ - +
+ + + +
- - - - - + diff --git a/SOGo/UI/Anais/ChangeLog b/SOGo/UI/Anais/ChangeLog index 677db86e..4e9952d6 100644 --- a/SOGo/UI/Anais/ChangeLog +++ b/SOGo/UI/Anais/ChangeLog @@ -1,3 +1,8 @@ +2004-08-11 Marcus Mueller + + * AnaisUidSelector.[m|wox]: much enhanced, but still not perfect + (v0.9.2) + 2004-08-11 Marcus Mueller * AnaisUidSelector.[m|wox]: added (v0.9.1) diff --git a/SOGo/UI/Anais/Version b/SOGo/UI/Anais/Version index a5a61468..f285cb83 100644 --- a/SOGo/UI/Anais/Version +++ b/SOGo/UI/Anais/Version @@ -1,3 +1,3 @@ # $Id: Version 165 2004-08-05 17:55:50Z znek $ -SUBMINOR_VERSION:=1 +SUBMINOR_VERSION:=2 diff --git a/SOGo/UI/Common/ChangeLog b/SOGo/UI/Common/ChangeLog index 64c4a54c..6a10f38d 100644 --- a/SOGo/UI/Common/ChangeLog +++ b/SOGo/UI/Common/ChangeLog @@ -1,3 +1,8 @@ +2004-08-11 Marcus Mueller + + * UIxPageFrame subclasses from UIxComponent now, removed -SoUser + because it's now in UIxComponent. (v0.9.10) + 2004-08-11 Marcus Mueller * UIxPageFrame.wox, UIxAppNavView.m: added labels (v0.9.9) diff --git a/SOGo/UI/Common/UIxPageFrame.m b/SOGo/UI/Common/UIxPageFrame.m index a4a4d47a..6f538e02 100644 --- a/SOGo/UI/Common/UIxPageFrame.m +++ b/SOGo/UI/Common/UIxPageFrame.m @@ -1,18 +1,14 @@ // $Id$ -#include -#include -#include - +#include -@interface UIxPageFrame : SoComponent +@interface UIxPageFrame : UIxComponent { NSString *title; NSString *rootURL; NSString *userRootURL; } -- (SoUser *)user; - (NSString *)rootURL; - (NSString *)userRootURL; - (NSString *)calendarRootURL; @@ -20,6 +16,7 @@ @end #include "common.h" +#include @implementation UIxPageFrame @@ -39,32 +36,6 @@ return self->title; } -- (SoUser *)user { - WOContext *ctx; - - ctx = [self context]; - return [[[self clientObject] authenticatorInContext:ctx] - userInContext:ctx]; -} - -- (NSString *)shortUserNameForDisplay { - // TODO: better use a SoUser formatter? - NSString *s; - NSRange r; - - s = [[self user] login]; - if ([s length] < 10) - return s; - - // TODO: algorithm might be inappropriate, depends on the actual UID - - r = [s rangeOfString:@"."]; - if (r.length == 0) - return s; - - return [s substringToIndex:r.location]; -} - /* URL generation */ - (NSString *)rootURL { diff --git a/SOGo/UI/SOGoUI/ChangeLog b/SOGo/UI/SOGoUI/ChangeLog index dd0e9c11..f545d9d8 100644 --- a/SOGo/UI/SOGoUI/ChangeLog +++ b/SOGo/UI/SOGoUI/ChangeLog @@ -1,3 +1,7 @@ +2004-08-11 Marcus Mueller + + * UIxComponent.[hm]: added -SoUser (v0.9.7) + 2004-08-10 Marcus Mueller * v0.9.6 diff --git a/SOGo/UI/SOGoUI/UIxComponent.h b/SOGo/UI/SOGoUI/UIxComponent.h index 937a1837..359c7c85 100644 --- a/SOGo/UI/SOGoUI/UIxComponent.h +++ b/SOGo/UI/SOGoUI/UIxComponent.h @@ -26,7 +26,7 @@ #include -@class NSCalendarDate, NSTimeZone, NSMutableDictionary; +@class NSCalendarDate, NSTimeZone, NSMutableDictionary, SoUser; @interface UIxComponent : SoComponent @@ -52,6 +52,10 @@ - (NSString *)dateStringForDate:(NSCalendarDate *)_date; - (NSCalendarDate *)dateForDateString:(NSString *)_dateString; +/* SoUser */ +- (SoUser *)user; +- (NSString *)shortUserNameForDisplay; + /* labels */ - (NSString *)labelForKey:(NSString *)_key; diff --git a/SOGo/UI/SOGoUI/UIxComponent.m b/SOGo/UI/SOGoUI/UIxComponent.m index 8786220b..bb927020 100644 --- a/SOGo/UI/SOGoUI/UIxComponent.m +++ b/SOGo/UI/SOGoUI/UIxComponent.m @@ -252,6 +252,34 @@ static NSMutableArray *abbrMonthLabelKeys = nil; } +/* SoUser */ + +- (SoUser *)user { + WOContext *ctx; + + ctx = [self context]; + return [[[self clientObject] authenticatorInContext:ctx] + userInContext:ctx]; +} + +- (NSString *)shortUserNameForDisplay { + // TODO: better use a SoUser formatter? + NSString *s; + NSRange r; + + s = [[self user] login]; + if ([s length] < 10) + return s; + + // TODO: algorithm might be inappropriate, depends on the actual UID + + r = [s rangeOfString:@"."]; + if (r.length == 0) + return s; + + return [s substringToIndex:r.location]; +} + /* labels */ - (NSString *)labelForKey:(NSString *)_str { diff --git a/SOGo/UI/SOGoUI/Version b/SOGo/UI/SOGoUI/Version index 0eb47da3..cab297dc 100644 --- a/SOGo/UI/SOGoUI/Version +++ b/SOGo/UI/SOGoUI/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=6 +SUBMINOR_VERSION:=7 diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 0ef40a91..7868b60d 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,13 @@ +2004-08-11 Marcus Mueller + + * v0.9.19 + + * UIxCalView.m: implements -redirectForUIDsAction to construct a + redirect to a special appointment folder. + + * product.plist: "show" method is mapped to UIxCalView's + -redirectForUIDsAction. + 2004-08-11 Marcus Mueller * v0.9.18 diff --git a/SOGo/UI/Scheduler/UIxCalView.m b/SOGo/UI/Scheduler/UIxCalView.m index 3edb7567..f153fc36 100644 --- a/SOGo/UI/Scheduler/UIxCalView.m +++ b/SOGo/UI/Scheduler/UIxCalView.m @@ -5,6 +5,11 @@ #include "UIxAppointmentFormatter.h" #include #include "SoObjects/Appointments/SOGoAppointmentFolder.h" +#include + +@interface UIxCalView (PrivateAPI) +- (NSString *)_userFolderURI; +@end @implementation UIxCalView @@ -380,4 +385,51 @@ [_qp removeObjectForKey:@"day"]; } + +/* Actions */ + +- (NSString *)_userFolderURI { + WOContext *ctx; + id obj; + NSURL *url; + + ctx = [self context]; + obj = [[ctx objectTraversalStack] objectAtIndex:1]; + url = [NSURL URLWithString:[obj baseURLInContext:ctx]]; + return [url path]; +} + +- (id)redirectForUIDsAction { + NSMutableString *uri; + NSString *uidsString, *loc, *prevMethod; + WOResponse *r; + WORequest *req; + + req = [[self context] request]; + + uidsString = [req formValueForKey:@"anaisUIDString"]; + uidsString = [uidsString stringByTrimmingWhiteSpaces]; + if([uidsString length] == 0) { + // TODO: improve user experience ... (eg error panel like Zope) + return [NSException exceptionWithHTTPStatus:400 /* bad request */ + reason:@"missing uids from request"]; + } + prevMethod = [req formValueForKey:@"previousMethod"]; + if(prevMethod == nil) + prevMethod = @""; + + uri = [[NSMutableString alloc] initWithString:[self _userFolderURI]]; + [uri appendString:@"/Groups/_custom_"]; + [uri appendString:uidsString]; + [uri appendString:@"/Calendar/"]; + [uri appendString:prevMethod]; + + loc = [self completeHrefForMethod:uri]; /* this might return uri! */ + r = [WOResponse responseWithRequest:req]; + [r setStatus:302 /* moved */]; + [r setHeader:loc forKey:@"location"]; + [uri release]; + return r; +} + @end /* UIxCalView */ diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index 27f42dca..93c8cd1d 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=16 +SUBMINOR_VERSION:=19 diff --git a/SOGo/UI/Scheduler/product.plist b/SOGo/UI/Scheduler/product.plist index 6af39800..d282d996 100644 --- a/SOGo/UI/Scheduler/product.plist +++ b/SOGo/UI/Scheduler/product.plist @@ -73,6 +73,11 @@ pageName = "UIxAppointmentEditor"; actionName = "new"; }; + "show" = { + protectedBy = "View"; + pageName = "UIxCalView"; + actionName = "redirectForUIDs"; + }; }; }; -- 2.39.5