From: znek Date: Tue, 12 Oct 2004 22:01:11 +0000 (+0000) Subject: stable version X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f45f8073d295cb7a1324211cba597f566aa4c321;p=scalable-opengroupware.org stable version git-svn-id: http://svn.opengroupware.org/SOGo/trunk@390 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 4034ef86..c0ef4db5 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,12 @@ +2004-10-12 Marcus Mueller + + * 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 * UIxMailEditor.m: enabled -takeValuesFromRequest: (v0.9.36) diff --git a/SOGo/UI/Mailer/English.lproj/default.strings b/SOGo/UI/Mailer/English.lproj/default.strings index 318ac1e6..953dd592 100644 --- a/SOGo/UI/Mailer/English.lproj/default.strings +++ b/SOGo/UI/Mailer/English.lproj/default.strings @@ -4,6 +4,6 @@ "Subject" = "Subject"; "Add address" = "Add address"; -"TO" = "To"; -"CC" = "Cc"; -"BCC" = "Bcc"; +"to" = "To"; +"cc" = "Cc"; +"bcc" = "Bcc"; diff --git a/SOGo/UI/Mailer/UIxMailToSelection.m b/SOGo/UI/Mailer/UIxMailToSelection.m index b41ec79b..41df6cd8 100644 --- a/SOGo/UI/Mailer/UIxMailToSelection.m +++ b/SOGo/UI/Mailer/UIxMailToSelection.m @@ -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 diff --git a/SOGo/UI/Mailer/UIxMailToSelection.wox b/SOGo/UI/Mailer/UIxMailToSelection.wox index 678d5226..357ca6d2 100644 --- a/SOGo/UI/Mailer/UIxMailToSelection.wox +++ b/SOGo/UI/Mailer/UIxMailToSelection.wox @@ -10,13 +10,12 @@ - +
@@ -36,18 +36,17 @@ - +
-
- +
- \ No newline at end of file diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 38c93ee9..62c8c2f8 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=36 +SUBMINOR_VERSION:=37