Finished vList implementation

Monotone-Parent: 2570bc0c998646aa6c0501c971a29d77357cb7a1
Monotone-Revision: b798ab587b14c946102732e79770636904870654

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-08-24T20:26:52
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert committed 2009-08-24 20:26:52 +00:00
1 parent 2f39baacc1
commit 7a4b84b9b6
22 files changed
+571 -48

No files matched your search

@@ -168,3 +168,12 @@
"Forbidden" = "Você não pode gravar neste catálogo.";
"Invalid Contact" = "O contato selecionado não existe.";
"Unknown Destination Folder" = "O catálogo de destino selecionado não existe.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "Nemůžete zapisovat do tohoto adresáře.";
"Invalid Contact" = "Označený kontakt již neexistuje.";
"Unknown Destination Folder" = "Zvolený cílový adresář již neexistuje.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "You cannot write to this address book.";
"Invalid Contact" = "The selected contact no longer exists.";
"Unknown Destination Folder" = "The chosen destination address book no longer exists.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "You cannot write to this address book.";
"Invalid Contact" = "The selected contact no longer exists.";
"Unknown Destination Folder" = "The chosen destination address book no longer exists.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "Vous ne pouvez pas ajouter de fiches à ce carnet.";
"Invalid Contact" = "La fiche sélectionnée n'existe plus.";
"Unknown Destination Folder" = "Le carnet d'adresses choisi n'existe plus.";
/* Lists */
"List details" = "Détails";
"List name:" = "Liste:";
"List nickname:" = "Surnom:";
"List description:" = "Description:";
"Members" = "Membres";
"Contacts" = "Contacts";
"Add" = "Ajouter";
@@ -168,3 +168,12 @@
"Forbidden" = "Sie können nicht auf dieses Adressbuch schreiben.";
"Invalid Contact" = "Der gewählte Kontakt existiert nicht mehr.";
"Unknown Destination Folder" = "Das gewählte Ziel-Adressbuch existiert nicht mehr.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "Ön nem írhat ebbe a címjegyzékbe.";
"Invalid Contact" = "A kijelölt kapcsolat már nem létezik.";
"Unknown Destination Folder" = "A kijelölt címjegyzék már nem elérhető.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "You cannot write to this address book.";
"Invalid Contact" = "The selected contact no longer exists.";
"Unknown Destination Folder" = "The chosen destination address book no longer exists.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -153,3 +153,12 @@
"Forbidden" = "You cannot write to this address book.";
"Invalid Contact" = "The selected contact no longer exists.";
"Unknown Destination Folder" = "The chosen destination address book no longer exists.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -168,3 +168,12 @@
"Forbidden" = "You cannot write to this address book.";
"Invalid Contact" = "The selected contact no longer exists.";
"Unknown Destination Folder" = "The chosen destination address book no longer exists.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
@@ -7,9 +7,9 @@
onclick = "newContact(this); return false;";
tooltip = "Create a new address book card"; },
{ link = "new_list";
enabled = "NO";
label="New List";
image="new-list.png";
onclick = "newList(this); return false;";
tooltip = "Create a new list"; }
),
(
+66
View File
@@ -19,6 +19,12 @@
02111-1307, USA.
*/
#import <Foundation/Foundation.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSString+misc.h>
@@ -103,6 +109,66 @@
return contactInfos;
}
- (id <WOActionResults>) contactSearchAction
{
id <WOActionResults> result;
id <SOGoContactFolder> folder;
NSString *searchText, *mail;
NSDictionary *contact, *data;
NSArray *contacts, *descriptors, *sortedContacts;
NSMutableDictionary *uniqueContacts;
unsigned int i;
NSSortDescriptor *commonNameDescriptor;
searchText = [self queryParameterForKey: @"search"];
if ([searchText length] > 0)
{
NS_DURING
folder = [self clientObject];
NS_HANDLER
if ([[localException name] isEqualToString: @"SOGoDBException"])
folder = nil;
else
[localException raise];
NS_ENDHANDLER
uniqueContacts = [NSMutableDictionary dictionary];
contacts = [folder lookupContactsWithFilter: searchText
sortBy: @"c_cn"
ordering: NSOrderedAscending];
for (i = 0; i < [contacts count]; i++)
{
contact = [contacts objectAtIndex: i];
mail = [contact objectForKey: @"c_mail"];
if ([mail isNotNull] && [uniqueContacts objectForKey: mail] == nil)
[uniqueContacts setObject: contact forKey: mail];
}
if ([uniqueContacts count] > 0)
{
// Sort the contacts by display name
commonNameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"c_cn"
ascending:YES] autorelease];
descriptors = [NSArray arrayWithObjects: commonNameDescriptor, nil];
sortedContacts = [[uniqueContacts allValues] sortedArrayUsingDescriptors: descriptors];
}
else
sortedContacts = [NSArray array];
data = [NSDictionary dictionaryWithObjectsAndKeys: searchText, @"searchText",
sortedContacts, @"contacts", nil];
result = [self responseWithStatus: 200];
[(WOResponse*)result appendContentString: [data jsonRepresentation]];
}
else
result = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'search' parameter"];
return result;
}
/* actions */
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) _rq
+6
View File
@@ -24,8 +24,14 @@
#define UIXLISTEDITOR_H
#import <SOGoUI/UIxComponent.h>
#import <SoObjects/Contacts/SOGoContactGCSList.h>
@interface UIxListEditor : UIxComponent
{
NGVList *list;
SOGoContactGCSList *co;
id reference;
}
@end
+198 -2
View File
@@ -20,33 +20,204 @@
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSDictionary.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOResponse.h>
#import <Foundation/NSPropertyList.h>
#import <Contacts/SOGoContactGCSFolder.h>
#import <NGCards/NGVCardReference.h>
#import <NGCards/NGVList.h>
#import "UIxListEditor.h"
@implementation UIxListEditor
- (NSString *) name
{
return [list fn];
}
- (void) setName: (NSString *) newName
{
[list setFn: newName];
}
- (NSString *) nickname
{
return [list nickname];
}
- (void) setNickname: (NSString *) newName
{
[list setNickname: newName];
}
- (NSString *) description
{
return [list description];
}
- (void) setDescription: (NSString *) newDescription
{
[list setDescription: newDescription];
}
- (NSArray *) references
{
NSMutableArray *rc;
NSMutableDictionary *row;
id ref;
int i, count;
rc = [NSMutableArray array];
count = [[list cardReferences] count];
for (i = 0; i < count; i++)
{
ref = [[list cardReferences] objectAtIndex: i];
row = [NSMutableDictionary dictionary];
[row setObject: [NSString stringWithFormat: @"%@ <%@>", [ref fn], [ref email]]
forKey: @"name"];
[row setObject: [ref reference] forKey: @"id"];
[rc addObject: row];
}
return rc;
}
- (void) setReferencesValue: (NSString *) value
{
NSData *data;
NSDictionary *references;
NSArray *values, *initialReferences;
NSString *error, *currentReference;
NSPropertyListFormat format;
int i, count;
NGVCardReference *cardReference;
data = [value dataUsingEncoding: NSUTF8StringEncoding];
references = [NSPropertyListSerialization propertyListFromData: data
mutabilityOption: NSPropertyListImmutable
format: &format
errorDescription: &error];
if(!references)
{
NSLog(error);
[error release];
}
else
{
// Remove from list
initialReferences = [list cardReferences];
count = [initialReferences count];
for (i = 0; i < count; i++)
{
cardReference = [initialReferences objectAtIndex: i];
if (![[references allKeys] containsObject: [cardReference reference]])
[list deleteCardReference: cardReference];
}
// Add new objects
initialReferences = [list cardReferences];
count = [[references allKeys] count];
for (i = 0; i < count; i++)
{
currentReference = [[references allKeys] objectAtIndex: i];
if (![self cardReferences: initialReferences
contain: currentReference])
{
NSLog (@"Adding a new cardRef");
values = [references objectForKey: currentReference];
cardReference = [NGVCardReference elementWithTag: @"card"];
[cardReference setFn: [values objectAtIndex: 0]];
[cardReference setEmail: [values objectAtIndex: 1]];
[cardReference setReference: currentReference];
[list addCardReference: cardReference];
}
}
}
}
- (BOOL) cardReferences: (NSArray *) references
contain: (NSString *) ref
{
int i, count;
BOOL rc = NO;
count = [references count];
for (i = 0; i < count; i++)
{
if ([ref isEqualToString: [[references objectAtIndex: i] reference]])
{
rc = YES;
break;
}
}
return rc;
}
- (NSString *) saveURL
{
return [NSString stringWithFormat: @"%@/saveAsList",
[[self clientObject] baseURL]];
}
- (BOOL) canCreateOrModify
{
return ([co isKindOfClass: [SOGoContentObject class]]
&& [super canCreateOrModify]);
}
- (id <WOActionResults>) defaultAction
{
co = [self clientObject];
list = [co vList];
if (list)
NSLog (@"Found list");
else
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
reason: @"could not open list"];
return self;
}
- (void) takeValuesFromRequest: (WORequest *) _rq
inContext: (WOContext *) _ctx
{
co = [self clientObject];
list = [co vList];
[super takeValuesFromRequest: _rq inContext: _ctx];
}
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
inContext: (WOContext*) context
{
NSString *actionName;
actionName = [[request requestHandlerPath] lastPathComponent];
return ([[self clientObject] isKindOfClass: [SOGoContactGCSList class]]
&& [actionName hasPrefix: @"save"]);
}
#warning Could this be part of a common parent with UIxAppointment/UIxTaskEditor/UIxListEditor ?
- (id) newAction
{
NSString *objectId, *method, *uri;
id <WOActionResults> result;
SOGoContactGCSFolder *co;
co = [self clientObject];
objectId = [co globallyUniqueObjectId];
if ([objectId length] > 0)
{
method = [NSString stringWithFormat:@"%@/%@.vls/editAsList",
method = [NSString stringWithFormat:@"%@/%@.vlf/editAsList",
[co soURL], objectId];
uri = [self completeHrefForMethod: method];
result = [self redirectToLocation: uri];
@@ -58,4 +229,29 @@
return result;
}
- (id <WOActionResults>) saveAction
{
id result;
NSString *jsRefreshMethod;
if (co)
{
[co save];
if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
result = [self redirectToLocation: [self applicationPath]];
else
{
jsRefreshMethod
= [NSString stringWithFormat: @"refreshContacts(\"%@\")",
[co nameInContainer]];
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
}
}
else
result = [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
reason: @"method cannot be invoked on "
@"the specified object"];
return result;
}
@end
@@ -152,3 +152,12 @@
"Forbidden" = "Ni fedrwch ysgrifennu i'r llyfr cyfeiriadau hwn.";
"Invalid Contact" = "Nid yw'r cyswllt dewisol yn bodoli mwyach.";
"Unknown Destination Folder" = "Nid yw'r llyfr cyfeiriadau dewisol yn bodoli mwyach.";
/* Lists */
"List details" = "List details";
"List name:" = "List name:";
"List nickname:" = "List nickname:";
"List description:" = "List description:";
"Members" = "Members";
"Contacts" = "Contacts";
"Add" = "Add";
+5
View File
@@ -78,6 +78,11 @@
protectedBy = "View";
pageName = "UIxContactsListView";
};
contactSearch = {
protectedBy = "<public>";
pageName = "UIxContactsListView";
actionName = "contactSearch";
};
newcontact = {
protectedBy = "<public>";
pageName = "UIxContactEditor";