]> err.no Git - scalable-opengroupware.org/commitdiff
stable version
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 12 Oct 2004 22:01:11 +0000 (22:01 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 12 Oct 2004 22:01:11 +0000 (22:01 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@390 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/English.lproj/default.strings
SOGo/UI/Mailer/UIxMailToSelection.m
SOGo/UI/Mailer/UIxMailToSelection.wox
SOGo/UI/Mailer/Version

index 4034ef86e6fca0722cb472a60a5a5fe531d65acc..c0ef4db5c2fbe37066d329be2b2ff90cb3a42914 100644 (file)
@@ -1,3 +1,12 @@
+2004-10-12  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+        * v0.9.37
+
+        * UIxMailToSelection.[wox|m]: stable version with heavily improved
+          JavaScript code.
+
+        * English.lproj/default.strings: new localizable strings
+
 2004-10-12  Helge Hess  <helge.hess@opengroupware.org>
 
        * UIxMailEditor.m: enabled -takeValuesFromRequest: (v0.9.36)
index 318ac1e6d8ccdce1846b09743fcbc62aad249386..953dd592a8331c5c087205d1b5e40ed890316f5c 100644 (file)
@@ -4,6 +4,6 @@
 "Subject"       = "Subject";
 "Add address"   = "Add address";
 
-"TO"            = "To";
-"CC"            = "Cc";
-"BCC"           = "Bcc";
+"to"            = "To";
+"cc"            = "Cc";
+"bcc"           = "Bcc";
index b41ec79b455b8bc92b054877ea82afccad041d52..41df6cd83e177bff4e4f5e28bb50a266af906758 100644 (file)
@@ -63,8 +63,8 @@
 
 - (NSArray *)properlySplitAddresses:(NSArray *)_addresses;
 
-- (NSArray *)getAddressesOfType:(NSString *)_type
-                 fromFormValues:(NSArray *)_values;
+- (void)getAddressesFromFormValues:(NSDictionary *)_dict;
+- (NSString *)getIndexFromIdentifier:(NSString *)_identifier;
 
 @end
 
@@ -171,6 +171,12 @@ static NSArray *headers = nil;
     [ma addObject:self->cc];
   if(self->bcc)
     [ma addObject:self->bcc];
+  /* ensure that min 1 object is available */
+  if([ma count] == 0) {
+    NSArray *tmp = [NSArray arrayWithObject:@""];
+    ASSIGN(self->to, tmp);
+    [ma addObject:self->to];
+  }
   return ma;
 }
 
@@ -189,8 +195,6 @@ static NSArray *headers = nil;
 /* identifiers */
 
 - (NSString *)currentRowId {
-  if(currentIndex == 0)
-    return @"addr_proto";
   return [NSString stringWithFormat:@"row_%d", self->currentIndex];
 }
 
@@ -254,43 +258,62 @@ static NSArray *headers = nil;
 
 /* handling requests */
 
-- (NSArray *)getAddressesOfType:(NSString *)_type
-                 fromFormValues:(NSArray *)_values
-{
+- (void)getAddressesFromFormValues:(NSDictionary *)_dict {
+  NSMutableArray *rawTo, *rawCc, *rawBcc;
+  NSArray *keys;
   unsigned i, count;
-  NSMutableArray *result;
+
+  rawTo  = [NSMutableArray array];
+  rawCc  = [NSMutableArray array];
+  rawBcc = [NSMutableArray array];
   
-  count = [_values count];
-  result = [NSMutableArray arrayWithCapacity:count];
-  for (i = 0; i < count; i++) {
-    NSString *s;
+  keys = [_dict allKeys];
+  count = [keys count];
+  for(i = 0; i < count; i++) {
+    NSString *key;
     
-    s = [_values objectAtIndex:i];
-    if ([s length] == 0)
-      continue;
+    key = [keys objectAtIndex:i];
+    if([key hasPrefix:@"addr_"]) {
+      NSString *idx, *addr, *popupKey, *popupValue;
+      
+      addr = [[_dict objectForKey:key] lastObject];
+      idx  = [self getIndexFromIdentifier:key];
+      popupKey = [NSString stringWithFormat:@"popup_%@", idx];
+      popupValue = [[_dict objectForKey:popupKey] lastObject];
+      if([popupValue isEqualToString:@"0"])
+        [rawTo addObject:addr];
+      else if([popupValue isEqualToString:@"1"])
+        [rawCc addObject:addr];
+      else
+        [rawBcc addObject:addr];
+    }
   }
-  return result;
+
+  [self setTo:rawTo];
+  [self setCc:rawCc];
+  [self setBcc:rawBcc];
+}
+
+- (NSString *)getIndexFromIdentifier:(NSString *)_identifier {
+  NSRange r = [_identifier rangeOfString:@"_"];
+  return [_identifier substringFromIndex:NSMaxRange(r)];
 }
 
 - (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
   /* OK, we have a special form value processor */
-  NSArray *tmp;
-  
+  NSDictionary *d;
+
+  d = [_rq formValues];
+  if(!d)
+    return;
+
+#if 0
   [self debugWithFormat:@"Note: will take values ..."];
-  
   NSLog(@"%s formValues: %@",
         __PRETTY_FUNCTION__,
-        [_rq formValues]);
-  
-  tmp = [self getAddressesOfType:@"to"
-                  fromFormValues:[_rq formValuesForKey:@"to"]];
-  [self setTo:tmp];
-  tmp = [self getAddressesOfType:@"cc"
-                  fromFormValues:[_rq formValuesForKey:@"cc"]];
-  [self setCc:tmp];
-  tmp = [self getAddressesOfType:@"bcc"
-                  fromFormValues:[_rq formValuesForKey:@"bcc"]];
-  [self setBcc:tmp];
+        d);
+#endif
+  [self getAddressesFromFormValues:d];
 }
 
 /* response generation */
@@ -307,26 +330,26 @@ static NSArray *headers = nil;
   @"}\n"
   @"\n"
   @"function rememberAddress(email) {\n"
-  @"  var list, e;\n"
+  @"  var list, span, idx;\n"
   @"  \n"
-  @"  list = document.getElementById(\"addr_addresses\");\n"
-  @"  e = document.createElement(\"span\");\n"
-  @"  e.id = email;\n"
-  @"  list.appendChild(e);\n"
+  @"  list = document.getElementById('addr_addresses');\n"
+  @"  span = document.createElement('span');\n"
+  @"  span.id = email;\n"
+  @"  idx = document.createTextNode(currentIndex);\n"
+  @"  span.appendChild(idx);\n"
+  @"  list.appendChild(span);\n"
   @"}\n"
   @"\n"
   @"function addAddress(type, cn, dn, email, uid, sn) {\n"
-  @"  var shouldAddRow, s;\n"
+  @"  var shouldAddRow, s, e;\n"
   @"  \n"
   @"  shouldAddRow = true;\n"
-  @"  s = cn + \" <\" + email + \">\";\n"
+  @"  s = cn + ' <' + email + '>';\n"
   @"\n"
   @"  if(this.hasAddress(email))\n"
   @"    return;\n"
   @"\n"
-  @"  this.rememberAddress(email);\n"
-  @"\n"
-  @"  var e = document.getElementById(\"addr_0\");\n"
+  @"  e = document.getElementById('addr_0');\n"
   @"  if(e.value == '') {\n"
   @"    e.value = s;\n"
   @"    shouldAddRow = false;\n"
@@ -334,24 +357,26 @@ static NSArray *headers = nil;
   @"  if(shouldAddRow) {\n"
   @"    this.fancyAddRow(false, s);\n"
   @"  }\n"
+  @"  this.rememberAddress(email);\n"
   @"}\n"
   @"\n"
   @"function fancyAddRow(shouldEdit, text) {\n"
-  @"  var table = document.getElementById(\"addr_table\").childNodes[1];\n"
-  @"  var lastChild = document.getElementById(\"addr_lastentry\");\n"
-  @"  var proto, row, select, input;\n"
+  @"  var table, lastChild, proto, row, select, input;\n"
+  @"\n"
+  @"  table = this.getTable();\n"
+  @"  lastChild = document.getElementById('row_last');\n"
   @"\n"
   @"  currentIndex++;\n"
   @"\n"
-  @"  proto = document.getElementById(\"addr_proto\");\n"
+  @"  proto = document.getElementById('row_0');\n"
   @"  row = proto.cloneNode(true);\n"
-  @"  row.id = \"\";\n"
+  @"  row.id = 'row_' + currentIndex;\n"
   @"\n"
   @"  select = row.childNodes[1].childNodes[1];\n"
-  @"  select.name = \"popup_\" + currentIndex;\n"
+  @"  select.name = 'popup_' + currentIndex;\n"
   @"  input = row.childNodes[3].childNodes[1];\n"
-  @"  input.name = \"addr_\" + currentIndex;\n"
-  @"  input.id = \"addr_\" + currentIndex;\n"
+  @"  input.name  = 'addr_' + currentIndex;\n"
+  @"  input.id    = 'addr_' + currentIndex;\n"
   @"  input.value = text;\n"
   @"\n"
   @"  table.insertBefore(row, lastChild);\n"
@@ -360,10 +385,56 @@ static NSArray *headers = nil;
   @"    input.select();\n"
   @"  }\n"
   @"}\n"
-  @"\n";
+  @"\n"
+  @"function removeIfNecessary(sender) {\n"
+  @"  var idx, addr, table, senderRow;\n"
+  @"\n"
+  @"  if(sender.value != '')\n"
+  @"    return;\n"
+  @"  if(sender.id == 'addr_0')\n"
+  @"    return;\n"
+  @"  idx = this.getIndexFromIdentifier(sender.id);\n"
+  @"  addr = this.findAddressWithIndex(idx);\n"
+  @"  if(addr) {\n"
+  @"     var addresses = document.getElementById('addr_addresses');\n"
+  @"     addresses.removeChild(addr);\n"
+  @"  }\n"
+  @"  table = this.getTable();\n"
+  @"  senderRow = this.findRowWithIndex(idx);\n"
+  @"  table.removeChild(senderRow);\n"
+  @"}\n"
+  @"\n"
+  @"function findAddressWithIndex(idx) {\n"
+  @"  var list, i, count, addr, idx\n"
+  @"  list = document.getElementById('addr_addresses').childNodes;\n"
+  @"  count = list.length;\n"
+  @"  for(i = 0; i < count; i++) {\n"
+  @"    addr = list[i];\n"
+  @"    if(addr.innerHTML == idx)\n"
+  @"      return addr;\n"
+  @"  }\n"
+  @"  return null;\n"
+  @"}\n"
+  @"\n"
+  @"function findRowWithIndex(idx) {\n"
+  @"  var id = 'row_' + idx;\n"
+  @"  return document.getElementById(id);\n"
+  @"}\n"
+  @"\n"
+  @"function getIndexFromIdentifier(id) {\n"
+  @"  return id.split('_')[1];\n"
+  @"}\n"
+  @"\n"
+  @"function getTable() {\n"
+  @"  return document.getElementById('addr_table').childNodes[1];\n"
+  @"}\n";
+  unsigned idx;
+  
+  idx = [self->to count] + [self->cc count] + [self->bcc count];
+
   return [NSString stringWithFormat:
     script,
-    self->currentIndex];
+    idx];
 }
 
 @end
index 678d5226f3bf218cc28a23aa75de834c08a74f96..357ca6d2d530a69d2b2e77dac89a534da167c106 100644 (file)
   <script language="JavaScript">
     <var:string value="jsCode" const:escapeHTML="NO" />
   </script>
-  <table id="addr_table">
+  <table id="addr_table" style="width: 100%;">
     <var:foreach list="addressLists" item="addressList">
       <var:foreach list="addressList" item="address">
         <tr var:id="currentRowId">
           <td width="20%">
-            <var:popup id="currentPopUpId"
-                       name="currentPopUpId"
+            <var:popup name="currentPopUpId"
                        list="headers"
                        item="item"
                        label:string="$item"
@@ -29,6 +28,7 @@
                    var:name="currentAddressId"
                    type="text"
                    var:value="address"
+                   onblur="removeIfNecessary(this);"
                    style="width: 100%;"
             />
           </td>
         <var:string value="nextId" />
       </var:foreach>
     </var:foreach>
-    <tr id="addr_lastentry">
+    <tr id="row_last">
       <td width="20%">
         <select style="width: 100%;" disabled="1">
           <option value="to" ><var:string label:value="to" />:</option>
         </select>
       </td>
       <td width="80%">
-        <input onclick="fancyAddRow(true,'');" type="text" style="width: 100%;" />
+        <input onfocus="fancyAddRow(true,'');" type="text" style="width: 100%;" />
       </td>
     </tr>
   </table>
   <span id="addr_addresses" style="visibility: hidden;">
   </span>
-  <input type="submit" label:value="Test" name="test:method" />
 </span>
\ No newline at end of file
index 38c93ee9d2f6454bf9df531ec4977b1c047f0313..62c8c2f88caff08f73de59d413798b4448cf7c8f 100644 (file)
@@ -1,3 +1,3 @@
 # $Id$
 
-SUBMINOR_VERSION:=36
+SUBMINOR_VERSION:=37