]> err.no Git - scalable-opengroupware.org/commitdiff
added filtering ...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 27 Aug 2004 04:23:50 +0000 (04:23 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 27 Aug 2004 04:23:50 +0000 (04:23 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@282 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Contacts/ChangeLog
SOGo/UI/Contacts/UIxContactsListView.m
SOGo/UI/Contacts/UIxContactsListView.wox
SOGo/UI/Contacts/Version

index 0ac3348c6b7e503db7eaba589f7da15a81f92516..e7e7c3b794f7033f72263bc1feb12e80423a8ebb 100644 (file)
@@ -1,5 +1,7 @@
 2004-08-27  Helge Hess  <helge.hess@skyrix.com>
 
+       * UIxContactsListView: added simple filtering (v0.9.6)
+
        * UIxContactsListView: added simple sorting (v0.9.5)
 
        * first working version of contacts UI (v0.9.4)
index 44f5b49e10c77370a763e35a27a09d61e3c5aee2..73195e53c0f4ed7437735ba286544d438b38a5af 100644 (file)
@@ -25,6 +25,9 @@
 
 @interface UIxContactsListView : UIxComponent
 {
+  NSArray  *allRecords;
+  NSArray  *filteredRecords;
+  NSString *searchText;
   id contact;
 }
 
 @implementation UIxContactsListView
 
 - (void)dealloc {
-  [self->contact release];
+  [self->allRecords      release];
+  [self->filteredRecords release];
+  [self->searchText release];
+  [self->contact    release];
   [super dealloc];
 }
 
   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";
 }
   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 */
index 77a533af7fec2139d198c4ff2efd9ed36a4512ad..9026cbfb434d6229e6bff8b6213815b2d081c252 100644 (file)
@@ -17,6 +17,9 @@
     table.contacttableview th {
       text-align: left;
     }
+    input.searchfield {
+      font-size:        8pt;
+    }
   </style>
 
   <table id="skywintable"
     </tr>
     <tr>
       <td id="skywinbodycell" class="wincontent">
+       <form name="searchform" var:href="view" var:_sort="sortKey"
+             method="GET">
         <table border="0" width="100%" cellpadding="0" cellspacing="0">
           <tr>
             <td colspan="2">
-                <table border="0" cellpadding="4" width="100%" cellspacing="2">
-                  <tr>
-                    <td align="right" bgcolor="#e8e8e0">
+                <table border="0" cellpadding="4" width="100%" cellspacing="0">
+                  <tr bgcolor="#e8e8e0">
+                    <td align="left">
+                      <input type="text" name="search" class="searchfield" 
+                             var:value="searchText" />
+                    </td>
+                    <td align="right">
                       <table border="0" cellpadding="0" cellspacing="1">
                         <tr>
                           <td class="button_auto_env"
@@ -74,7 +83,8 @@
                     <th>
                       <var:if condition="sortKey" const:value="sn"
                               const:negate="YES">
-                       <a href="?sort=sn">Lastname</a>
+                       <a href="view" _sort="sn" 
+                           var:_search="searchText">Lastname</a>
                       </var:if>
                       <var:if condition="sortKey" const:value="sn">
                         <i>Lastname</i>
@@ -83,7 +93,8 @@
                     <th>
                       <var:if condition="sortKey" const:value="givenname"
                               const:negate="YES">
-                       <a href="?sort=givenname">Firstname</a>
+                       <a href="view" _sort="givenname" 
+                           var:_search="searchText">Firstname</a>
                       </var:if>
                       <var:if condition="sortKey" const:value="givenname">
                         <i>Firstname</i>
                     <th>
                       <var:if condition="sortKey" const:value="mail"
                               const:negate="YES">
-                       <a href="?sort=mail">EMail</a>
+                       <a href="view" _sort="mail" 
+                           var:_search="searchText">EMail</a>
                       </var:if>
                       <var:if condition="sortKey" const:value="mail">
                         <i>Email</i>
             </td>
           </tr>
         </table>
+       </form>
       </td>
     </tr>
   </table>
+  
+<!-- todo: need onload for this to work ...
+  <script language="JavaScript">
+    document.searchform.search.select();
+    document.searchform.search.focus();
+  </script>
+-->
 
   <var:if condition="isUIxDebugEnabled">
     <hr />
index 6b227f7e3b266ef9cc7a5dc1fd384537da8702c7..0eb47da345be1d4c8ac5a363234ca3f2c77473cb 100644 (file)
@@ -1,3 +1,3 @@
 # $Id$
 
-SUBMINOR_VERSION:=5
+SUBMINOR_VERSION:=6