From 4eeeec806e6c34febb65f7fe0d18fe31b1ed8a5e Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Tue, 10 May 2011 20:54:52 +0100 Subject: [PATCH] Bug 593795 - Need warning for moving cards via the message header if the cards exist in a list; Patch by mconley and Standard8. r=Standard8,bwinton ui-review=bwinton --- mail/base/content/editContactOverlay.js | 33 +++- mail/base/content/editContactOverlay.xul | 62 ++++--- .../chrome/messenger/editContactOverlay.dtd | 2 + .../message-header/test-message-header.js | 151 ++++++++++++++++++ .../test-address-book-helpers.js | 43 ++++- .../gnomestripe/mail/editContactOverlay.css | 17 +- .../pinstripe/mail/editContactOverlay.css | 14 ++ mail/themes/qute/mail/editContactOverlay.css | 12 ++ 8 files changed, 299 insertions(+), 35 deletions(-) diff --git a/mail/base/content/editContactOverlay.js b/mail/base/content/editContactOverlay.js index fafeac05a9..3ef1eac3d5 100644 --- a/mail/base/content/editContactOverlay.js +++ b/mail/base/content/editContactOverlay.js @@ -66,6 +66,8 @@ var editContactInlineUI = { elt.removeAttribute("disabled"); elt.removeAttribute("wasDisabled"); } + document.getElementById("editContactAddressBookList").disabled = false; + document.getElementById("contactMoveDisabledText").collapsed = true; }, onPopupHidden: function (aEvent) { @@ -121,7 +123,6 @@ var editContactInlineUI = { _doShowEditContactPanel: function (aAnchorElement, aPosition) { this._blockCommands(); // un-done in the popuphiding handler. - var bundle = document.getElementById("bundle_editContact"); // Is this address book writeable? @@ -163,8 +164,34 @@ var editContactInlineUI = { document.getElementById("editContactAddressBookList").value = this._cardDetails.book.URI; - document.getElementById("editContactAddressBookList").disabled = - !this._writeable; + + // Is this card contained within mailing lists? + let inMailList = false; + if (this._cardDetails.book.supportsMailingLists) { + // We only have to look in one book here, because cards currently have + // to be in the address book they belong to. + let mailingLists = this._cardDetails.book.childNodes; + while (mailingLists.hasMoreElements() && !inMailList) { + let list = mailingLists.getNext(); + if (!(list instanceof Components.interfaces.nsIAbDirectory) || + !list.isMailList) + continue; + + for (let card in fixIterator(list.addressLists.enumerate())) { + if (card instanceof Components.interfaces.nsIAbCard && + card.primaryEmail == this._cardDetails.card.primaryEmail) { + inMailList = true; + break; + } + } + } + } + + if (!this._writeable || inMailList) + document.getElementById("editContactAddressBookList").disabled = true; + + if (inMailList) + document.getElementById("contactMoveDisabledText").collapsed = false; this.panel.popupBoxObject .setConsumeRollupEvent(Components.interfaces diff --git a/mail/base/content/editContactOverlay.xul b/mail/base/content/editContactOverlay.xul index 1ea5874f0c..c31c2543bb 100644 --- a/mail/base/content/editContactOverlay.xul +++ b/mail/base/content/editContactOverlay.xul @@ -75,6 +75,7 @@ - -