Bug 73801. Disable the delete menu item, context menu item and button when either a Collected or Personal address book is selected. r=neil, sr=bienvenu

This commit is contained in:
technutz%netscape.net 2003-11-11 02:56:36 +00:00
Родитель 294415c97e
Коммит 8329de6c2e
4 изменённых файлов: 48 добавлений и 66 удалений

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

@ -168,6 +168,8 @@ var DirPaneController =
if (command == "cmd_delete")
goSetMenuValue(command, "valueAddressBook");
selectedDir = GetSelectedDirectory();
if (selectedDir == kPersonalAddressbookURI || selectedDir == kCollectedAddressbookURI)
return false;
if (selectedDir) {
// If the selected directory is an ldap directory
// and if the prefs for this directory are locked

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

@ -239,7 +239,8 @@ function SetNameColumn(cmd)
function CommandUpdate_AddressBook()
{
goUpdateCommand('button_delete');
goUpdateCommand('cmd_delete');
goUpdateCommand('button_delete');
}
function ResultsPaneSelectionChanged()
@ -401,35 +402,36 @@ function AbPrintCardInternal(doPrintPreview, msgType)
if (!uri)
return;
var statusFeedback;
statusFeedback = Components.classes["@mozilla.org/messenger/statusfeedback;1"].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
var statusFeedback;
statusFeedback = Components.classes["@mozilla.org/messenger/statusfeedback;1"].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
var selectionArray = new Array(numSelected);
var selectionArray = new Array(numSelected);
var totalCard = 0;
var totalCard = 0;
for(var i = 0; i < numSelected; i++)
{
var card = selectedItems[i];
var printCardUrl = CreatePrintCardUrl(card);
if (printCardUrl)
{
selectionArray[totalCard++] = printCardUrl;
}
}
for (var i = 0; i < numSelected; i++)
{
var card = selectedItems[i];
var printCardUrl = CreatePrintCardUrl(card);
if (printCardUrl)
{
selectionArray[totalCard++] = printCardUrl;
}
}
if (!gPrintSettings) {
if (!gPrintSettings)
{
gPrintSettings = GetPrintSettings();
}
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
totalCard, selectionArray, statusFeedback,
gPrintSettings, doPrintPreview, msgType);
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
totalCard, selectionArray, statusFeedback,
gPrintSettings, doPrintPreview, msgType);
return;
return;
}
function AbPrintCard()
@ -524,55 +526,34 @@ function AbExport()
function AbDeleteDirectory()
{
var selectedABURI = GetSelectedDirectory();
if (!selectedABURI) return;
var selectedABURI = GetSelectedDirectory();
if (!selectedABURI)
return;
var isPersonalOrCollectedAbsSelectedForDeletion = false;
var parentArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
if (!parentArray)
return;
var parentArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
if (!parentArray)
return;
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
// check to see if personal or collected address books is selected for deletion.
// if yes, prompt the user an appropriate message saying these cannot be deleted
if ((selectedABURI != kCollectedAddressbookURI) &&
(selectedABURI != kPersonalAddressbookURI)) {
var parentRow = GetParentRow(dirTree, dirTree.currentIndex);
var parentId;
if (parentRow == -1)
parentId = "moz-abdirectory://";
else
parentId = dirTree.builderView.getResourceAtIndex(parentRow).Value;
var parentRow = GetParentRow(dirTree, dirTree.currentIndex);
var parentId = (parentRow == -1) ? "moz-abdirectory://" : dirTree.builderView.getResourceAtIndex(parentRow).Value;
var parentDir = GetDirectoryFromURI(parentId);
parentArray.AppendElement(parentDir);
var parentDir = GetDirectoryFromURI(parentId);
parentArray.AppendElement(parentDir);
}
else {
promptService.alert(window,
gAddressBookBundle.getString("cannotDeleteTitle"),
gAddressBookBundle.getString("cannotDeleteMessage"));
return;
}
var directory = GetDirectoryFromURI(selectedABURI);
var confirmDeleteMessage = gAddressBookBundle.getString(directory.isMailList ? "confirmDeleteMailingList" : "confirmDeleteAddressbook");
var confirmDeleteMessage;
if (!promptService.confirm(window, null, confirmDeleteMessage))
return;
var directory = GetDirectoryFromURI(selectedABURI);
if (directory.isMailList)
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingList");
else
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteAddressbook");
var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
var selectedABResource = GetDirectoryFromURI(selectedABURI).QueryInterface(Components.interfaces.nsIRDFResource);
if (!promptService.confirm(window, null, confirmDeleteMessage))
return;
resourceArray.AppendElement(selectedABResource);
var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
var selectedABResource = GetDirectoryFromURI(selectedABURI).QueryInterface(Components.interfaces.nsIRDFResource);
resourceArray.AppendElement(selectedABResource);
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, resourceArray);
SelectFirstAddressBook();
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, resourceArray);
SelectFirstAddressBook();
}
function SetStatusText(total)

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

@ -215,7 +215,7 @@ Contributor(s):
<menuitem id="menu_cut"/>
<menuitem id="menu_copy"/>
<menuitem id="menu_paste"/>
<menuitem id="menu_delete" observes="button_delete"/>
<menuitem id="menu_delete"/>
<menuseparator/>
<menuitem id="menu_selectAll"/>
<menuseparator/>

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

@ -46,7 +46,6 @@ mailListNameExistsMessage=A Mailing List with that name already exists. Please c
# used in the addressbook
cannotDeleteTitle=Delete Failed
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?
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?