diff --git a/ChangeLog b/ChangeLog index 3a22ea2db..e8437d9d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-07-07 Francis Lachapelle + * UI/WebServerResources/UIxListEditor.js (endEditable): when a + string doesn't match an existing card, keep the entry but + highlight it in red. + (serializeReferences): when an entry is not associated to a card, + extract the email and fullname from the string to create a new card. + + * UI/Contacts/UIxListEditor.m (-setReferencesValue:): if a card + reference doesn't match a known vCard UID, create a new vCard + like Thunderbird does. + * UI/MainUI/SOGoUserHomePage.m (-_usersForResults:inDomain:): fixed bug when the domain was empty. (-usersSearchAction): idem. diff --git a/UI/Contacts/UIxListEditor.m b/UI/Contacts/UIxListEditor.m index 963e9e442..0ab577aa7 100644 --- a/UI/Contacts/UIxListEditor.m +++ b/UI/Contacts/UIxListEditor.m @@ -1,8 +1,9 @@ /* UIxListEditor.m - this file is part of SOGo * - * Copyright (C) 2008-2009 Inverse inc. + * Copyright (C) 2008-2011 Inverse inc. * * Author: Wolfgang Sourdeau + * Francis Lachapelle * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +32,7 @@ #import #import +#import #import #import @@ -159,6 +161,46 @@ [list addCardReference: cardReference]; } + else + { + // Not a valid UID; expect a string formatted as : "email|fullname" + NSString *workMail, *fn, *newUID; + NSArray *contactInfo; + NGVCard *newCard; + CardElement *newWorkMail; + SOGoContactGCSEntry *newContact; + + contactInfo = [currentReference componentsSeparatedByString: @"|"]; + if ([contactInfo count] > 1) + { + workMail = [contactInfo objectAtIndex: 0]; + fn = [contactInfo objectAtIndex: 1]; + + // Create a new vCard + newUID = [NSString stringWithFormat: @"%@.vcf", [co globallyUniqueObjectId]]; + newCard = [NGVCard cardWithUid: newUID]; + newWorkMail = [CardElement new]; + [newWorkMail autorelease]; + [newWorkMail setTag: @"email"]; + [newWorkMail addType: @"work"]; + [newCard addChild: newWorkMail]; + [newWorkMail setValue: 0 to: workMail]; + [newCard setFn: fn]; + + // Add vCard to current folder + newContact = [SOGoContactGCSEntry objectWithName: newUID + inContainer: folder]; + [newContact saveContentString: [newCard versitString]]; + + // Create card reference for the list + cardReference = [NGVCardReference elementWithTag: @"card"]; + [cardReference setFn: fn]; + [cardReference setEmail: workMail]; + [cardReference setReference: newUID]; + + [list addCardReference: cardReference]; + } + } } } } diff --git a/UI/WebServerResources/UIxListEditor.css b/UI/WebServerResources/UIxListEditor.css index d4cfc4269..ed1cccb7c 100644 --- a/UI/WebServerResources/UIxListEditor.css +++ b/UI/WebServerResources/UIxListEditor.css @@ -21,9 +21,6 @@ TD.referenceListCell background: #CCDDEC; text-align: left;} -TABLE#referenceList TD INPUT -{ width: 97%; } - DIV#referenceListWrapper { background: #CCDDEC; overflow: auto; @@ -40,12 +37,24 @@ TR.referenceListRow { background: #CCDDEC; line-height: 2em; } -TD.referenceListCell -{ -moz-user-select: none; } +TD.referenceListCell, +TD.editing +{ background-repeat: no-repeat; + background-position: 4px 50%; + background-image: url('abcard.png'); + text-align: left; + -moz-user-select: none; } TD.referenceListCell SPAN, -TD.referenceListCell INPUT -{ margin-left: 3px; } +TD.editing INPUT +{ margin-left: 24px; } + +TD.editing INPUT, +TABLE#referenceList TD INPUT +{ width: 90%; } + +TR.notfound TD.referenceListCell +{ color: #f00 !important; } DIV#windowButtons { position: fixed; @@ -71,10 +80,9 @@ DIV#buttons vertical-align: middle; text-align: right; } -td {color: #535D6D;} +TD +{ color: #535D6D; } DIV#listEditor { padding: 5px; } -TD.editing -{ text-align: left; } diff --git a/UI/WebServerResources/UIxListEditor.js b/UI/WebServerResources/UIxListEditor.js index 3b45bc476..e9b22eab3 100644 --- a/UI/WebServerResources/UIxListEditor.js +++ b/UI/WebServerResources/UIxListEditor.js @@ -30,16 +30,16 @@ function endEditable(event, textField) { cell.addClassName("referenceListCell"); textField.hide(); - if (uid) { - var tmp = textField.value; - tmp = tmp.replace (//, ">"); + var tmp = textField.value; + tmp = tmp.replace (//, ">"); + if (!uid) + cell.up("TR").addClassName("notfound"); + if (tmp) textSpan.update(tmp); - } - else { + else cell.up("TR").remove(); - } - + if (event) Event.stop(event); @@ -108,8 +108,20 @@ function serializeReferences(e) { var uid = $(r[i]).readAttribute("uid"); if (uid) cards.push(uid); + else { + var addresses = r[i].value.split(/[,;]/); + for (var j = 0; j < addresses.length; j++) { + var mailto = addresses[j].strip(); + var email = extractEmailAddress(mailto); + var c_name = extractEmailName(mailto); + if (!email && !c_name) + c_name = mailto; + cards.push(email + '|' + c_name); + } + } } $("referencesValue").value = cards.join(","); + return true; }