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
This commit is contained in:
Родитель
9a088c9be2
Коммит
4eeeec806e
|
@ -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
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<rows>
|
||||
<row align="center" id="editContactNameRow">
|
||||
<label value="&editContactName.label;"
|
||||
class="editContactPanel_rowLabel"
|
||||
accesskey="&editContactName.accesskey;"
|
||||
control="editContactName"/>
|
||||
<textbox id="editContactName" class="editContactTextbox"
|
||||
|
@ -82,6 +83,7 @@
|
|||
</row>
|
||||
<row align="center" id="editContactEmailRow">
|
||||
<label value="&editContactEmail.label;"
|
||||
class="editContactPanel_rowLabel"
|
||||
accesskey="&editContactEmail.accesskey;"
|
||||
control="editContactEmail"/>
|
||||
<textbox id="editContactEmail" readonly="true"
|
||||
|
@ -90,6 +92,7 @@
|
|||
</row>
|
||||
<row align="center" id="editContactABRow">
|
||||
<label id="editContactAddressBook"
|
||||
class="editContactPanel_rowLabel"
|
||||
value="&editContactAddressBook.label;"
|
||||
accesskey="&editContactAddressBook.accesskey;"
|
||||
control="editContactAddressBookList"/>
|
||||
|
@ -98,38 +101,45 @@
|
|||
class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
</row>
|
||||
<row>
|
||||
<hbox/>
|
||||
<description id="contactMoveDisabledText"
|
||||
collapsed="true">&contactMoveDisabledWarning.description;</description>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
|
||||
<hbox flex="1" id="editContactPanelBottomButtons">
|
||||
<button id="editContactPanelEditDetailsButton"
|
||||
oncommand="editContactInlineUI.editDetails();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<spacer flex="1"/>
|
||||
<vbox>
|
||||
<hbox flex="1" id="editContactPanelBottomButtons">
|
||||
<button id="editContactPanelEditDetailsButton"
|
||||
oncommand="editContactInlineUI.editDetails();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<spacer flex="1"/>
|
||||
#ifndef XP_UNIX
|
||||
<button id="editContactPanelDoneButton"
|
||||
label="&editContactPanelDone.label;"
|
||||
accesskey="&editContactPanelDone.accesskey;" default="true"
|
||||
oncommand="editContactInlineUI.saveChanges();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelCancelButton"
|
||||
label="&editContactPanelCancel.label;"
|
||||
accesskey="&editContactPanelCancel.accesskey;"
|
||||
oncommand="editContactInlineUI.panel.hidePopup();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelDoneButton"
|
||||
label="&editContactPanelDone.label;"
|
||||
accesskey="&editContactPanelDone.accesskey;" default="true"
|
||||
oncommand="editContactInlineUI.saveChanges();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelCancelButton"
|
||||
label="&editContactPanelCancel.label;"
|
||||
accesskey="&editContactPanelCancel.accesskey;"
|
||||
oncommand="editContactInlineUI.panel.hidePopup();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
#else
|
||||
<button id="editContactPanelCancelButton"
|
||||
label="&editContactPanelCancel.label;"
|
||||
accesskey="&editContactPanelCancel.accesskey;"
|
||||
oncommand="editContactInlineUI.panel.hidePopup();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelDoneButton"
|
||||
label="&editContactPanelDone.label;"
|
||||
accesskey="&editContactPanelDone.accesskey;" default="true"
|
||||
oncommand="editContactInlineUI.saveChanges();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelCancelButton"
|
||||
label="&editContactPanelCancel.label;"
|
||||
accesskey="&editContactPanelCancel.accesskey;"
|
||||
oncommand="editContactInlineUI.panel.hidePopup();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
<button id="editContactPanelDoneButton"
|
||||
label="&editContactPanelDone.label;"
|
||||
accesskey="&editContactPanelDone.accesskey;" default="true"
|
||||
oncommand="editContactInlineUI.saveChanges();"
|
||||
onkeypress="editContactInlineUI.onKeyPress(event, false);"/>
|
||||
#endif
|
||||
</hbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</panel>
|
||||
</overlay>
|
||||
|
|
|
@ -15,3 +15,5 @@
|
|||
|
||||
<!ENTITY editContactPanelDone.label "Done">
|
||||
<!ENTITY editContactPanelDone.accesskey "D">
|
||||
|
||||
<!ENTITY contactMoveDisabledWarning.description "You can't change the address book because the contact is in a mailing list.">
|
||||
|
|
|
@ -317,6 +317,156 @@ function test_more_button_with_many_recipients()
|
|||
" and didn't change back.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we can open up the inline contact editor when we
|
||||
* click on the star.
|
||||
*/
|
||||
function test_clicking_star_opens_inline_contact_editor()
|
||||
{
|
||||
// Make sure we're in the right folder
|
||||
be_in_folder(folder);
|
||||
|
||||
// Add a new message
|
||||
let msg = create_message();
|
||||
add_message_to_folder(folder, msg);
|
||||
|
||||
// Open the latest message
|
||||
let curMessage = select_click_row(-1);
|
||||
// Make sure the star is clicked, and we add the
|
||||
// new contact to our address book
|
||||
let toDescription = mc.a('expandedtoBox', {class: "headerValue"});
|
||||
|
||||
// Ensure that the inline contact editing panel is not open
|
||||
let contactPanel = mc.eid('editContactPanel').getNode();
|
||||
assert_not_equals(contactPanel.state, "open");
|
||||
subtest_more_widget_star_click(toDescription);
|
||||
|
||||
// Ok, if we're here, then the star has been clicked, and
|
||||
// the contact has been added to our AB.
|
||||
let addrs = toDescription.getElementsByTagName('mail-emailaddress');
|
||||
let lastAddr = addrs[addrs.length-1];
|
||||
|
||||
// Click on the star, and ensure that the inline contact
|
||||
// editing panel opens
|
||||
mc.click(mc.aid(lastAddr, {class: 'emailStar'}));
|
||||
assert_equals(contactPanel.state, "open");
|
||||
contactPanel.hidePopup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that if a contact belongs to a mailing list within their
|
||||
* address book, then the inline contact editor will not allow
|
||||
* the user to change what address book the contact belongs to.
|
||||
* The editor should also show a message to explain why the
|
||||
* contact cannot be moved.
|
||||
*/
|
||||
function test_address_book_switch_disabled_on_contact_in_mailing_list()
|
||||
{
|
||||
const MAILING_LIST_DIRNAME = "Some Mailing List";
|
||||
const ADDRESS_BOOK_NAME = "Some Address Book";
|
||||
// Add a new message
|
||||
let msg = create_message();
|
||||
add_message_to_folder(folder, msg);
|
||||
|
||||
// Make sure we're in the right folder
|
||||
be_in_folder(folder);
|
||||
|
||||
// Open the latest message
|
||||
let curMessage = select_click_row(-1);
|
||||
|
||||
// Make sure the star is clicked, and we add the
|
||||
// new contact to our address book
|
||||
let toDescription = mc.a('expandedtoBox', {class: "headerValue"});
|
||||
|
||||
// Ensure that the inline contact editing panel is not open
|
||||
let contactPanel = mc.eid('editContactPanel').getNode();
|
||||
assert_not_equals(contactPanel.state, "open");
|
||||
|
||||
subtest_more_widget_star_click(toDescription);
|
||||
|
||||
// Ok, if we're here, then the star has been clicked, and
|
||||
// the contact has been added to our AB.
|
||||
let addrs = toDescription.getElementsByTagName('mail-emailaddress');
|
||||
let lastAddr = addrs[addrs.length-1];
|
||||
|
||||
// Click on the star, and ensure that the inline contact
|
||||
// editing panel opens
|
||||
mc.click(mc.aid(lastAddr, {class: 'emailStar'}));
|
||||
assert_equals(contactPanel.state, "open");
|
||||
|
||||
let abDrop = mc.eid('editContactAddressBookList').getNode();
|
||||
let warningMsg = mc.eid('contactMoveDisabledText').getNode();
|
||||
|
||||
// Ensure that the address book dropdown is not disabled
|
||||
assert_true(!abDrop.disabled);
|
||||
// We should not be displaying any warning
|
||||
assert_true(warningMsg.collapsed);
|
||||
|
||||
// Now close the popup
|
||||
contactPanel.hidePopup();
|
||||
|
||||
// For the contact that was added, create a mailing list in the
|
||||
// address book it resides in, and then add that contact to the
|
||||
// mailing list
|
||||
addrs = toDescription.getElementsByTagName('mail-emailaddress');
|
||||
let targetAddr = addrs[addrs.length-1].getAttribute("emailAddress");
|
||||
|
||||
let cards = get_cards_in_all_address_books_for_email(targetAddr);
|
||||
|
||||
// There should be only one copy of this email address
|
||||
// in the address books.
|
||||
assert_equals(cards.length, 1);
|
||||
let card = cards[0];
|
||||
|
||||
// Remove the card from any of the address books
|
||||
ensure_no_card_exists(targetAddr);
|
||||
|
||||
// Add the card to a new address book, and insert it
|
||||
// into a mailing list under that address book
|
||||
let ab = create_mork_address_book(ADDRESS_BOOK_NAME);
|
||||
ab.dropCard(card, false);
|
||||
let ml = create_mailing_list(MAILING_LIST_DIRNAME);
|
||||
ab.addMailList(ml);
|
||||
|
||||
// Now we have to retrieve the mailing list from
|
||||
// the address book, in order for us to add and
|
||||
// delete cards from it.
|
||||
ml = get_mailing_list_from_address_book(ab, MAILING_LIST_DIRNAME);
|
||||
|
||||
ml.addressLists.appendElement(card, false);
|
||||
|
||||
// Re-open the inline contact editing panel
|
||||
mc.click(mc.aid(lastAddr, {class: 'emailStar'}));
|
||||
assert_equals(contactPanel.state, "open");
|
||||
|
||||
// The dropdown should be disabled now
|
||||
assert_true(abDrop.disabled);
|
||||
// We should be displaying a warning
|
||||
assert_true(!warningMsg.collapsed);
|
||||
|
||||
contactPanel.hidePopup();
|
||||
|
||||
// And if we remove the contact from the mailing list, the
|
||||
// warning should be gone and the address book switching
|
||||
// menu re-enabled.
|
||||
|
||||
let cardArray = Cc["@mozilla.org/array;1"]
|
||||
.createInstance(Ci.nsIMutableArray);
|
||||
cardArray.appendElement(card, false);
|
||||
ml.deleteCards(cardArray);
|
||||
|
||||
// Re-open the inline contact editing panel
|
||||
mc.click(mc.aid(lastAddr, {class: 'emailStar'}));
|
||||
assert_equals(contactPanel.state, "open");
|
||||
|
||||
// Ensure that the address book dropdown is not disabled
|
||||
assert_true(!abDrop.disabled);
|
||||
// We should not be displaying any warning
|
||||
assert_true(warningMsg.collapsed);
|
||||
|
||||
contactPanel.hidePopup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that clicking the adding an address node adds it to the address book.
|
||||
*/
|
||||
|
@ -731,3 +881,4 @@ function test_get_msg_button_customize_header_toolbar(){
|
|||
originalServerCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,12 @@ function installInto(module) {
|
|||
module.create_ldap_address_book = create_ldap_address_book;
|
||||
module.create_contact = create_contact;
|
||||
module.create_mailing_list = create_mailing_list;
|
||||
module.get_mailing_list_from_address_book =
|
||||
get_mailing_list_from_address_book;
|
||||
module.load_contacts_into_address_book = load_contacts_into_address_book;
|
||||
module.load_contacts_into_mailing_list = load_contacts_into_mailing_list;
|
||||
module.get_cards_in_all_address_books_for_email =
|
||||
get_cards_in_all_address_books_for_email;
|
||||
module.get_address_book_tree_view_index = get_address_book_tree_view_index;
|
||||
module.set_address_books_collapsed = set_address_books_collapsed;
|
||||
module.set_address_books_expanded = set_address_books_expanded;
|
||||
|
@ -81,7 +85,6 @@ function installInto(module) {
|
|||
// alias them here.
|
||||
module.set_address_book_collapsed = set_address_books_collapsed;
|
||||
module.set_address_book_expanded = set_address_books_expanded;
|
||||
|
||||
module.is_address_book_collapsed = is_address_book_collapsed;
|
||||
module.is_address_book_collapsible = is_address_book_collapsible;
|
||||
module.get_name_of_address_book_element_at = get_name_of_address_book_element_at;
|
||||
|
@ -125,6 +128,26 @@ function ensure_no_card_exists(emailAddress)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all address book cards for a particular email address
|
||||
* @param aEmailAddress the address to search for
|
||||
*/
|
||||
function get_cards_in_all_address_books_for_email(aEmailAddress)
|
||||
{
|
||||
var books = MailServices.ab.directories;
|
||||
var result = [];
|
||||
|
||||
while (books.hasMoreElements()) {
|
||||
var ab = books.getNext().QueryInterface(Ci.nsIAbDirectory);
|
||||
var card = ab.cardForEmailAddress(aEmailAddress);
|
||||
if (card) {
|
||||
result.push(card);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the address book interface
|
||||
* @returns a controller for the address book
|
||||
|
@ -192,6 +215,24 @@ function create_mailing_list(aMailingListName)
|
|||
return mailList;
|
||||
}
|
||||
|
||||
/* Finds and returns a mailing list with a given dirName within a
|
||||
* given address book.
|
||||
* @param aAddressBook the address book to search
|
||||
* @param aDirName the dirName of the mailing list
|
||||
*/
|
||||
function get_mailing_list_from_address_book(aAddressBook, aDirName)
|
||||
{
|
||||
let mailingLists = aAddressBook.childNodes;
|
||||
while (mailingLists.hasMoreElements())
|
||||
{
|
||||
let item = mailingLists.getNext();
|
||||
let list = item.QueryInterface(Ci.nsIAbDirectory);
|
||||
if (list && list.dirName == aDirName)
|
||||
return list;
|
||||
}
|
||||
throw Error("Could not find a mailing list with dirName " + aDirName);
|
||||
}
|
||||
|
||||
/* Given some address book, adds a collection of contacts to that
|
||||
* address book.
|
||||
* @param aAddressBook an address book to add the contacts to
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||
|
||||
.editContactPanel_rowLabel {
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
#editContactPanel {
|
||||
-moz-appearance: menupopup;
|
||||
color: MenuText;
|
||||
|
@ -63,9 +67,12 @@
|
|||
min-width: 20em;
|
||||
}
|
||||
|
||||
.editContactTextbox[readonly="true"] {
|
||||
-moz-appearance: none;
|
||||
margin: 4px 7px;
|
||||
border: none;
|
||||
background-color: inherit;
|
||||
#contactMoveDisabledText {
|
||||
margin-top: 8px;
|
||||
margin-bottom: 5px;
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
#editContactAddressBookList[disabled="true"] {
|
||||
color: GrayText !important;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||
|
||||
.editContactPanel_rowLabel {
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
#editContactPanel {
|
||||
-moz-appearance: none;
|
||||
background-color: rgba(68,68,68,0.9);
|
||||
|
@ -137,6 +141,7 @@
|
|||
|
||||
.editContactTextbox[focused="true"] {
|
||||
outline: 2px solid -moz-mac-focusring;
|
||||
padding: 1px;
|
||||
outline-offset: -1px;
|
||||
-moz-outline-radius: 1px;
|
||||
background-color: #eeeeee;
|
||||
|
@ -170,6 +175,10 @@
|
|||
-moz-outline-radius: 5px;
|
||||
}
|
||||
|
||||
#editContactAddressBookList[disabled="true"] {
|
||||
color: GrayText !important;
|
||||
}
|
||||
|
||||
#editContactAddressBookList > .menulist-dropmarker {
|
||||
-moz-appearance: none;
|
||||
display: -moz-box;
|
||||
|
@ -182,3 +191,8 @@
|
|||
#editContactAddressBookList > .menulist-dropmarker > .dropmarker-icon {
|
||||
list-style-image: url("chrome://messenger/skin/hud-style-dropmarker-double-arrows.png");
|
||||
}
|
||||
|
||||
#contactMoveDisabledText {
|
||||
margin-left: 8px;
|
||||
width: 20em;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||
|
||||
.editContactPanel_rowLabel {
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
#editContactPanel {
|
||||
-moz-appearance: menupopup;
|
||||
color: MenuText;
|
||||
|
@ -69,3 +73,11 @@
|
|||
border: none;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
#editContactAddressBookList[disabled="true"] {
|
||||
color: grey !important;
|
||||
}
|
||||
|
||||
#contactMoveDisabledText {
|
||||
width: 20em;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче