From 272c5ccc319b2ff4396db2e29fd57e12eece3d21 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 27 Aug 2004 04:23:50 +0000 Subject: [PATCH] added filtering ... git-svn-id: http://svn.opengroupware.org/SOGo/trunk@282 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Contacts/ChangeLog | 2 + SOGo/UI/Contacts/UIxContactsListView.m | 77 +++++++++++++++++++----- SOGo/UI/Contacts/UIxContactsListView.wox | 32 ++++++++-- SOGo/UI/Contacts/Version | 2 +- 4 files changed, 90 insertions(+), 23 deletions(-) diff --git a/SOGo/UI/Contacts/ChangeLog b/SOGo/UI/Contacts/ChangeLog index 0ac3348c..e7e7c3b7 100644 --- a/SOGo/UI/Contacts/ChangeLog +++ b/SOGo/UI/Contacts/ChangeLog @@ -1,5 +1,7 @@ 2004-08-27 Helge Hess + * UIxContactsListView: added simple filtering (v0.9.6) + * UIxContactsListView: added simple sorting (v0.9.5) * first working version of contacts UI (v0.9.4) diff --git a/SOGo/UI/Contacts/UIxContactsListView.m b/SOGo/UI/Contacts/UIxContactsListView.m index 44f5b49e..73195e53 100644 --- a/SOGo/UI/Contacts/UIxContactsListView.m +++ b/SOGo/UI/Contacts/UIxContactsListView.m @@ -25,6 +25,9 @@ @interface UIxContactsListView : UIxComponent { + NSArray *allRecords; + NSArray *filteredRecords; + NSString *searchText; id contact; } @@ -36,7 +39,10 @@ @implementation UIxContactsListView - (void)dealloc { - [self->contact release]; + [self->allRecords release]; + [self->filteredRecords release]; + [self->searchText release]; + [self->contact release]; [super dealloc]; } @@ -49,6 +55,28 @@ return self->contact; } +- (void)setSearchText:(NSString *)_txt { + ASSIGNCOPY(self->searchText, _txt); +} +- (id)searchText { + return self->searchText; +} +- (EOQualifier *)qualifier { + NSString *qs, *s; + + s = [self searchText]; + if ([s length] == 0) + return nil; + + qs = [NSString stringWithFormat: + @"(sn isCaseInsensitiveLike: '%@*') OR " + @"(givenname isCaseInsensitiveLike: '%@*') OR " + @"(mail isCaseInsensitiveLike: '*%@*') OR " + @"(telephonenumber isCaseInsensitiveLike: '*%@*')", + s, s, s, s]; + return [EOQualifier qualifierWithQualifierFormat:qs]; +} + - (NSString *)defaultSortKey { return @"sn"; } @@ -58,33 +86,50 @@ s = [[[self context] request] formValueForKey:@"sort"]; return [s length] > 0 ? s : [self defaultSortKey]; } - -static int sortDicts(id left, id right, void *ctx) { - id v1, v2; - - v1 = [left valueForKey:ctx]; - v2 = [right valueForKey:ctx]; - return [v1 caseInsensitiveCompare:v2]; +- (EOSortOrdering *)sortOrdering { + return [EOSortOrdering sortOrderingWithKey:[self sortKey] + selector:EOCompareCaseInsensitiveAscending]; +} +- (NSArray *)sortOrderings { + return [NSArray arrayWithObjects:[self sortOrdering], nil]; } - (NSArray *)contactInfos { - NSString *sort; - NSArray *records; - // TODO: should be done in the backend, but for Agenor AB its OK here - sort = [self sortKey]; + NSArray *records; + EOQualifier *q; + + if (self->filteredRecords) + return self->filteredRecords; records = [[self clientObject] fetchCoreInfos]; - if ([sort length] > 0) - records = [records sortedArrayUsingFunction:sortDicts context:sort]; - return records; + self->allRecords = + [[records sortedArrayUsingKeyOrderArray:[self sortOrderings]] retain]; + + if ((q = [self qualifier]) != nil) { + [self logWithFormat:@"qs: %@", q]; + self->filteredRecords = + [[self->allRecords filteredArrayUsingQualifier:q] retain]; + } + else + self->filteredRecords = [self->allRecords retain]; + + return self->filteredRecords; } /* notifications */ - (void)sleep { - [self->contact release]; self->contact = nil; + [self->contact release]; self->contact = nil; + [self->allRecords release]; self->allRecords = nil; + [self->filteredRecords release]; self->filteredRecords = nil; [super sleep]; } +/* actions */ + +- (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c{ + return YES; +} + @end /* UIxContactsListView */ diff --git a/SOGo/UI/Contacts/UIxContactsListView.wox b/SOGo/UI/Contacts/UIxContactsListView.wox index 77a533af..9026cbfb 100644 --- a/SOGo/UI/Contacts/UIxContactsListView.wox +++ b/SOGo/UI/Contacts/UIxContactsListView.wox @@ -17,6 +17,9 @@ table.contacttableview th { text-align: left; } + input.searchfield { + font-size: 8pt; + }
+
- - -
+ + + +
+ +
- Lastname + Lastname Lastname @@ -83,7 +93,8 @@ - Firstname + Firstname Firstname @@ -92,7 +103,8 @@ - EMail + EMail Email @@ -140,9 +152,17 @@
+
+ +
diff --git a/SOGo/UI/Contacts/Version b/SOGo/UI/Contacts/Version index 6b227f7e..0eb47da3 100644 --- a/SOGo/UI/Contacts/Version +++ b/SOGo/UI/Contacts/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=5 +SUBMINOR_VERSION:=6 -- 2.39.5