Fix for 197773. Prompt users for deleting mailing lists from the results pane. r/sr=sspitzer.

This commit is contained in:
cavin%netscape.com 2003-03-19 21:32:48 +00:00
Родитель cd0db808a1
Коммит 1d7452f4e7
2 изменённых файлов: 59 добавлений и 2 удалений

Просмотреть файл

@ -53,6 +53,13 @@ const kDefaultDescending = "descending";
const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab"; const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab"; const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab";
// List/card selections in the results pane.
const kNothingSelected = 0;
const kListsAndCards = 1;
const kMultipleListsOnly = 2;
const kSingleListOnly = 3;
const kCardsOnly = 4;
// Controller object for Results Pane // Controller object for Results Pane
var ResultsPaneController = var ResultsPaneController =
{ {
@ -310,10 +317,58 @@ function SetupAbCommandUpdateHandlers()
gAbResultsTree.controllers.appendController(ResultsPaneController); gAbResultsTree.controllers.appendController(ResultsPaneController);
} }
function GetSelectedCardTypes()
{
var cards = GetSelectedAbCards();
if (!cards)
return kNothingSelected; // no view
var count = cards.length;
if (!count)
return kNothingSelected; // nothing selected
var mailingListCnt = 0;
var cardCnt = 0;
for (var i = 0; i < count; i++) {
if (cards[i].isMailList)
mailingListCnt++;
else
cardCnt++;
}
if (mailingListCnt && cardCnt)
return kListsAndCards; // lists and cards selected
else if (mailingListCnt && !cardCnt) {
if (mailingListCnt > 1)
return kMultipleListsOnly; // only multiple mailing lists selected
else
return kSingleListOnly; // only single mailing list
}
else if (!mailingListCnt && cardCnt)
return kCardsOnly; // only card(s) selected
}
function AbDelete() function AbDelete()
{ {
if (gAbView) var types = GetSelectedCardTypes();
gAbView.deleteSelectedCards(); if (types == kNothingSelected)
return;
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
// If at least one mailing list is selected then prompt users for deletion.
if (types != kCardsOnly)
{
var confirmDeleteMessage;
if (types == kListsAndCards)
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteListsAndCards");
else if (types == kMultipleListsOnly)
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingLists");
else
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingList");
if (!promptService.confirm(window, null, confirmDeleteMessage))
return;
}
gAbView.deleteSelectedCards();
} }
function AbNewCard(abListItem) function AbNewCard(abListItem)

Просмотреть файл

@ -38,6 +38,8 @@ cannotDeleteTitle=Delete Failed
cannotDeleteMessage=You are not allowed to delete the Personal or Collected Addresses address books. cannotDeleteMessage=You are not allowed to delete the Personal or Collected Addresses address books.
confirmDeleteAddressbook=Are you sure you want to delete the selected address book? confirmDeleteAddressbook=Are you sure you want to delete the selected address book?
confirmDeleteMailingList=Are you sure you want to delete the selected mailing list? confirmDeleteMailingList=Are you sure you want to delete the selected mailing list?
confirmDeleteListsAndCards=Are you sure you want to delete the selected cards and mailing lists?
confirmDeleteMailingLists=Are you sure you want to delete the selected mailing lists?
propertyPrimaryEmail=Email propertyPrimaryEmail=Email
propertyListName=List Name propertyListName=List Name