fix for some mail view issues

bug #189543 [Mailviews: View dropdown menu items should be in View:Messages Menu]
bug #187990 [dropdown out of sync if view set in View|Messages]
bug #190187 [mail view list, remove cancel button (doesn't work).  instead, prompt on delete, like filters]

r/sr=bienvenu, a=sspitzer
This commit is contained in:
sspitzer%netscape.com 2003-04-30 07:37:16 +00:00
parent 4d8a66e48f
commit f7bbce7579
14 changed files with 187 additions and 92 deletions

View File

@ -323,6 +323,15 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
function SwitchView(command)
{
// when switching thread views, we might be coming out of quick search
// or a message view.
// first set view picker to all
ViewMessagesBy("viewPickerAll");
// clear the QS text, if we need to
ClearQSIfNecessary();
// now switch views
var oldSortType = gDBView ? gDBView.sortType : nsMsgViewSortType.byThread;
var oldSortOrder = gDBView ? gDBView.sortOrder : nsMsgViewSortOrder.ascending;
var viewFlags = gCurViewFlags;

View File

@ -374,7 +374,7 @@ var DefaultController =
case "cmd_viewThreadsWithUnread":
case "cmd_viewWatchedThreadsWithUnread":
case "cmd_viewIgnoredThreads":
return gDBView && gDBView.supportsThreading;
return gDBView;
case "cmd_stop":
return true;
case "cmd_undo":

View File

@ -167,11 +167,6 @@ function view_init()
message_menuitem.setAttribute('checked',!IsThreadAndMessagePaneSplitterCollapsed());
}
}
var threadColumn = document.getElementById('ThreadColumnHeader');
var thread_menuitem=document.getElementById('menu_showThreads');
if (threadColumn && thread_menuitem){
thread_menuitem.setAttribute('checked',threadColumn.getAttribute('currentView')=='threaded');
}
// Initialize the View Attachment Inline menu
var viewAttachmentInline = pref.getBoolPref("mail.inline_attachments");
@ -229,32 +224,97 @@ function InitViewSortByMenu()
function InitViewMessagesMenu()
{
var allMenuItem = document.getElementById("viewAllMessagesMenuItem");
var viewFlags = gDBView.viewFlags;
var viewType = gDBView.viewType;
if(allMenuItem)
allMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) == 0 && (viewType == nsMsgViewType.eShowAllThreads));
var allMenuItem = document.getElementById("viewAllMessagesMenuItem");
if (allMenuItem)
allMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) == 0 && (viewType == nsMsgViewType.eShowAllThreads));
var unreadMenuItem = document.getElementById("viewUnreadMessagesMenuItem");
if(unreadMenuItem)
unreadMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) != 0);
var theadedMenuItem = document.getElementById("menu_showThreads");
if (theadedMenuItem)
theadedMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kThreadedDisplay) != 0);
document.commandDispatcher.updateCommands('create-menu-view');
if (unreadMenuItem)
unreadMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) != 0);
var theadsWithUnreadMenuItem = document.getElementById("viewThreadsWithUnreadMenuItem");
if(theadsWithUnreadMenuItem)
theadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowThreadsWithUnread);
if (theadsWithUnreadMenuItem)
theadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowThreadsWithUnread);
var watchedTheadsWithUnreadMenuItem = document.getElementById("viewWatchedThreadsWithUnreadMenuItem");
if(watchedTheadsWithUnreadMenuItem)
watchedTheadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowWatchedThreadsWithUnread);
if (watchedTheadsWithUnreadMenuItem)
watchedTheadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowWatchedThreadsWithUnread);
var ignoredTheadsMenuItem = document.getElementById("viewIgnoredThreadsMenuItem");
if(ignoredTheadsMenuItem)
ignoredTheadsMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kShowIgnored) != 0);
if (ignoredTheadsMenuItem)
ignoredTheadsMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kShowIgnored) != 0);
}
function InitViewMessageViewMenu()
{
var currentViewValue = document.getElementById("viewPicker").value;
var allMenuItem = document.getElementById("viewAll");
if(allMenuItem)
allMenuItem.setAttribute("checked", currentViewValue == 0); // from msgViewPickerOveraly.xul <menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
var unreadMenuItem = document.getElementById("viewUnread");
if(unreadMenuItem)
unreadMenuItem.setAttribute("checked", currentViewValue == 1); // from msgViewPickerOveraly.xul, <menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
for (var i = 1; i <= 5; i++) {
var prefString = gPrefs.getComplexValue("mailnews.labels.description." + i, Components.interfaces.nsIPrefLocalizedString).data;
var viewLabelMenuItem = document.getElementById("viewLabelMenuItem" + i);
viewLabelMenuItem.setAttribute("label", prefString);
viewLabelMenuItem.setAttribute("checked", (i == (currentViewValue - 1))); // 1=2-1, from msgViewPickerOveraly.xul, <menuitem value="2" id="labelMenuItem1"/>
}
viewRefreshCustomMailViews(currentViewValue);
}
function viewRefreshCustomMailViews(aCurrentViewValue)
{
// for each mail view in the msg view list, add a menu item
var mailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);
// XXX TODO, fix code in msgViewPickerOverlay.js, to be like this.
// remove any existing entries...
var menupopupNode = document.getElementById('viewMessageViewPopup');
var userDefinedItems = menupopupNode.getElementsByAttribute("userdefined","true");
for (var i=0; i<userDefinedItems.length; i++)
{
menupopupNode.removeChild(userDefinedItems[i]);
}
// now rebuild the list
var numItems = mailViewList.mailViewCount;
var viewCreateCustomViewSeparator = document.getElementById('viewCreateCustomViewSeparator');
for (i = 0; i < numItems; i++)
{
var newMenuItem = document.createElement("menuitem");
newMenuItem.setAttribute("label", mailViewList.getMailViewAt(i).mailViewName);
newMenuItem.setAttribute("userdefined", "true");
var oncommandStr = "ViewMessagesBy('userdefinedview" + (kLastDefaultViewIndex + i) + "');";
newMenuItem.setAttribute("oncommand", oncommandStr);
var item = menupopupNode.insertBefore(newMenuItem, viewCreateCustomViewSeparator);
item.setAttribute("value", kLastDefaultViewIndex + i);
item.setAttribute("type", "radio"); // for checked
item.setAttribute("name", "viewmessages"); // for checked
item.setAttribute("checked", (kLastDefaultViewIndex + i == aCurrentViewValue));
}
if (!numItems)
viewCreateCustomViewSeparator.setAttribute('collapsed', true);
else
viewCreateCustomViewSeparator.removeAttribute('collapsed');
}
// called by the View | Messages | Views ... menu items
// see mailWindowOverlay.xul
function ViewMessagesBy(id)
{
var viewPicker = document.getElementById('viewPicker');
viewPicker.selectedItem = document.getElementById(id);
viewChange(viewPicker);
}
function InitMessageMenu()

View File

@ -1174,7 +1174,22 @@ Rights Reserved.
<menuitem id="sortDescending" type="radio" name="sortdirection" label="&sortDescending.label;" accesskey="&sortDescending.accesskey;" oncommand="MsgSortDescending()"/>
</menupopup>
</menu>
<menu label="&msgsMenu.label;" id="viewMessagesMenu" accesskey="&msgsMenu.accesskey;">
<menu label="&msgsMenu.label;" id="viewMessageViewMenu" accesskey="&msgsMenu.accesskey;">
<menupopup id="viewMessageViewPopup" onpopupshowing="InitViewMessageViewMenu()">
<menuitem id="viewAll" type="radio" name="viewmessages" label="&viewAll.label;" accesskey="&viewAll.accesskey;" oncommand="ViewMessagesBy('viewPickerAll');"/>
<menuitem id="viewUnread" type="radio" name="viewmessages" label="&viewUnread.label;" accesskey="&viewUnread.accesskey;" oncommand="ViewMessagesBy('viewPickerUnread');"/>
<menuseparator/>
<menuitem id="viewLabelMenuItem1" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem1');" />
<menuitem id="viewLabelMenuItem2" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem2');" />
<menuitem id="viewLabelMenuItem3" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem3');" />
<menuitem id="viewLabelMenuItem4" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem4');" />
<menuitem id="viewLabelMenuItem5" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem5');" />
<menuseparator id="viewLastDefaultView"/>
<menuseparator id="viewCreateCustomViewSeparator"/>
<menuitem id="viewCreateCustomView" label="&viewCustomView.label;" accesskey="&viewCustomView.accesskey;" oncommand="LaunchCustomizeDialog();" />
</menupopup>
</menu>
<menu label="&threads.label;" id="viewMessagesMenu" accesskey="&threads.accesskey;">
<menupopup onpopupshowing="InitViewMessagesMenu()">
<menuitem id="viewAllMessagesMenuItem" type="radio" name="viewmessages" label="&allMsgsCmd.label;" accesskey="&allMsgsCmd.accesskey;" disabled="true" observes="cmd_viewAllMsgs"/>
<menuitem id="viewUnreadMessagesMenuItem" type="radio" name="viewmessages" label="&unreadMsgsCmd.label;" accesskey="&unreadMsgsCmd.accesskey;" disabled="true" observes="cmd_viewUnreadMsgs"/>

View File

@ -422,6 +422,10 @@ function HideMenus()
if (viewMessagesMenu)
viewMessagesMenu.setAttribute("hidden", "true");
var viewMessageViewMenu = document.getElementById('viewMessageViewMenu');
if (viewMessageViewMenu)
viewMessageViewMenu.setAttribute("hidden", "true");
var viewMessagesMenuSeparator = document.getElementById('viewMessagesMenuSeparator');
if (viewMessagesMenuSeparator)
viewMessagesMenuSeparator.setAttribute("hidden", "true");
@ -434,10 +438,6 @@ function HideMenus()
if (viewSortMenu)
viewSortMenu.setAttribute("hidden", "true");
var viewThreadedMenu = document.getElementById('menu_showThreads');
if (viewThreadedMenu)
viewThreadedMenu.setAttribute("hidden", "true");
var emptryTrashMenu = document.getElementById('menu_emptyTrash');
if (emptryTrashMenu)
emptryTrashMenu.setAttribute("hidden", "true");

View File

@ -1170,3 +1170,5 @@ var attachmentAreaDNDObserver = {
}
}
};

View File

@ -426,6 +426,16 @@ function disableQuickSearchClearButton()
gClearButton.setAttribute("disabled", true); //going out of search disable clear button
}
function ClearQSIfNecessary()
{
GetSearchInput();
if (gSearchInput.value == "")
return;
Search("");
}
function Search(str)
{
GetSearchInput();

View File

@ -178,6 +178,14 @@ Rights Reserved.
<!ENTITY sortDescending.accesskey "D">
<!ENTITY msgsMenu.label "Messages">
<!ENTITY msgsMenu.accesskey "M">
<!ENTITY viewAll.label "All">
<!ENTITY viewUnread.label "Unread">
<!ENTITY viewAll.accesskey "A">
<!ENTITY viewUnread.accesskey "U">
<!ENTITY viewCustomView.label "Customize...">
<!ENTITY viewCustomView.accesskey "C">
<!ENTITY threads.label "Threads">
<!ENTITY threads.accesskey "T">
<!ENTITY allMsgsCmd.label "All">
<!ENTITY allMsgsCmd.accesskey "A">
<!ENTITY expandOrCollapseMenu.label "Expand/Collapse">

View File

@ -277,3 +277,7 @@ newMail_Alert_Title=New Messages
# For the Quota tab in the mail folder properties dialog
quotaUsedFree=%S of %S KB used
quotaPercentUsed=%S%% full
# for message views
confirmViewDeleteTitle=Confirm
confirmViewDeleteMessage=Are you sure you want to delete this view?

View File

@ -24,8 +24,7 @@
var gMailListView;
var gListBox;
var gOkCallback = null;
var gCancelCallback = null;
var gCloseCallback = null;
var gEditButton;
var gDeleteButton;
@ -37,10 +36,8 @@ function mailViewListOnLoad()
if ("arguments" in window && window.arguments[0])
{
var args = window.arguments[0];
if ("onOkCallback" in args)
gOkCallback = window.arguments[0].onOkCallback;
if ("onCancelCallback" in args)
gCancelCallback = window.arguments[0].onCancelCallback;
if ("onCloseCallback" in args)
gCloseCallback = window.arguments[0].onCloseCallback;
}
// Construct list view based on current mail view list data
@ -49,22 +46,12 @@ function mailViewListOnLoad()
gDeleteButton = document.getElementById('deleteButton');
updateButtons();
doSetOKCancel(onOK, onCancel);
}
function onOK()
function mailViewListOnUnload()
{
if (gOkCallback)
gOkCallback(gListBox.selectedIndex);
return true;
}
function onCancel()
{
if (gCancelCallback)
gCancelCallback();
return true;
if (gCloseCallback)
gCloseCallback(gListBox.selectedIndex);
}
function refreshListView(aSelectedMailView)
@ -92,7 +79,15 @@ function onNewMailView()
}
function onDeleteMailView()
{
{
var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService);
var bundle = strBundleService.createBundle("chrome://messenger/locale/messenger.properties");
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
if (!promptService.confirm(window, bundle.GetStringFromName("confirmViewDeleteTitle"), bundle.GetStringFromName("confirmViewDeleteMessage")))
return;
// get the selected index
var selectedIndex = gListBox.selectedIndex;
if (selectedIndex >= 0)
@ -143,8 +138,4 @@ function updateButtons()
gDeleteButton.disabled = selectedIndex < 0;
}
function doHelpButton()
{
openHelp("message-views-using");
}

View File

@ -30,23 +30,22 @@ Rights Reserved.
%FilterListDialogDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
<dialog id="mailViewListDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="mailViewListOnLoad();"
onunload="mailViewListOnUnload()"
windowtype="mailnews:mailviewlist"
title="&mailViewListTitle.label;"
width="400" height="340"
buttons="accept,help"
ondialogaccept="window.close();"
ondialoghelp="return openHelp('message-views-using');"
persist="screenX screenY width height">
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/mailViewList.js"/>
<script type="application/x-javascript" src="chrome://help/content/contextHelp.js"/>
<keyset id="dialogKeys"/>
<vbox flex="1">
<separator/>
<hbox flex="1">
<listbox id="mailViewList" flex="1" onselect="onMailViewSelect(event);">
<listcols>
@ -63,13 +62,10 @@ Rights Reserved.
<button id="editButton" label="&editButton.label;" accesskey="&editButton.accesskey;" oncommand="onEditMailView();"/>
<button id="deleteButton" label="&deleteButton.label;" accesskey="&deleteButton.accesskey;" oncommand="onDeleteMailView();"/>
</vbox>
</hbox>
<separator class="thin"/>
<hbox id="okCancelHelpButtonsRight"/>
</vbox>
</dialog>
</window>

View File

@ -21,9 +21,11 @@
*/
const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
const kLabelOffset = 1; // 1=2-1, from msgViewPickerOveraly.xul, <menuitem value="2" id="labelMenuItem1"/>
const kLastDefaultViewIndex = 8; // 8, because 7 + 1, <menuitem id="createCustomView" value="7" label="&viewPickerCustomView.label;"/>
const kCustomItemValue = "7"; // from msgViewPickerOveraly.xul, <menuitem id="createCustomView" value="7" label="&viewPickerCustomView.label;"/>
var gMailViewList = null;
var gLastDefaultViewIndex = 8;
var gCurrentViewValue = "0"; // initialize to the first view ("All")
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
@ -36,7 +38,7 @@ function viewChange(aMenuList)
{
var val = aMenuList.value;
if (val == "7") {
if (val == kCustomItemValue) {
// restore to the previous view value, in case they cancel
aMenuList.value = gCurrentViewValue;
LaunchCustomizeDialog();
@ -56,15 +58,15 @@ function viewChange(aMenuList)
case "1": // Unread
ViewNewMail();
break;
case "2":
case "3":
case "4":
case "5":
case "6":
ViewLabel(parseInt(val) - 1);
case "2": // label 1
case "3": // label 2
case "4": // label 3
case "5": // label 4
case "6": // label 5
ViewLabel(parseInt(val) - kLabelOffset);
break;
default:
LoadCustomMailView(parseInt(val) - gLastDefaultViewIndex);
LoadCustomMailView(parseInt(val) - kLastDefaultViewIndex);
break;
} //
@ -121,9 +123,8 @@ function viewPickerOnLoad()
function LaunchCustomizeDialog()
{
// making it modal, see bug #191188
//OpenOrFocusWindow({onOkCallback: refreshCustomMailViews, onCancelCallback: cancelCustomMailViews}, 'mailnews:mailviewlist', 'chrome://messenger/content/mailViewList.xul');
window.openDialog("chrome://messenger/content/mailViewList.xul", "mailnews:mailviewlist", "chrome,modal,titlebar,resizable,centerscreen", {onOkCallback: refreshCustomMailViews});
// made it modal, see bug #191188
window.openDialog("chrome://messenger/content/mailViewList.xul", "mailnews:mailviewlist", "chrome,modal,titlebar,resizable,centerscreen", {onCloseCallback: refreshCustomMailViews});
}
function LoadCustomMailView(index)
@ -195,8 +196,9 @@ function refreshCustomMailViews(aDefaultSelectedIndex)
{
newMenuItem = document.createElement('menuitem');
newMenuItem.setAttribute('label', gMailViewList.getMailViewAt(index).mailViewName);
newMenuItem.setAttribute('id', "userdefinedview" + (kLastDefaultViewIndex + index));
item = menupopupNode.insertBefore(newMenuItem, customNode);
item.setAttribute('value', gLastDefaultViewIndex + index);
item.setAttribute('value', kLastDefaultViewIndex + index);
}
if (!numItems)
@ -207,9 +209,8 @@ function refreshCustomMailViews(aDefaultSelectedIndex)
if (aDefaultSelectedIndex >= 0)
{
var viewPicker = document.getElementById('viewPicker');
viewPicker.value = gLastDefaultViewIndex + aDefaultSelectedIndex;
gCurrentViewValue = viewPicker.value;
LoadCustomMailView(aDefaultSelectedIndex);
viewPicker.selectedItem = document.getElementsByAttribute("value", kLastDefaultViewIndex + aDefaultSelectedIndex)[0];
viewChange(viewPicker);
}
}

View File

@ -32,11 +32,11 @@
<hbox id="searchBox">
<hbox id="viewPickerBox" insertbefore="searchCriteria" align="center">
<label id="ViewPickerText" value="&ViewPicker.label;" control="viewPicker" accesskey="&ViewPicker.accesskey;"/>
<label value="&viewPicker.label;" control="viewPicker" accesskey="&viewPicker.accesskey;"/>
<menulist id="viewPicker" oncreate="FillLabelValues();" oncommand="viewChange(this);">
<menupopup id="viewPickerPopup">
<menuitem value="0" label="&ViewPickerAll.label;"/>
<menuitem value="1" label="&ViewPickerUnread.label;"/>
<menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
<menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
<menuseparator/>
<menuitem value="2" id="labelMenuItem1"/>
<menuitem value="3" id="labelMenuItem2"/>
@ -45,7 +45,7 @@
<menuitem value="6" id="labelMenuItem5"/>
<menuseparator id="lastDefaultView"/>
<menuseparator id="createCustomViewSeparator"/>
<menuitem id="createCustomView" value="7" label="&ViewPickerCustomView.label;"/>
<menuitem id="createCustomView" value="7" label="&viewPickerCustomView.label;"/>
</menupopup>
</menulist>
</hbox>

View File

@ -1,8 +1,7 @@
<!--LOCALIZATION NOTE msgViewPickerOverlay.dtd UI for showing various views on a folder -->
<!ENTITY ViewPicker.label "View:">
<!ENTITY ViewPicker.accesskey "i">
<!ENTITY ViewPickerPeople.label "People I Know">
<!ENTITY ViewPickerCustomView.label "Customize...">
<!ENTITY ViewPickerAll.label "All">
<!ENTITY ViewPickerUnread.label "Unread">
<!ENTITY viewPicker.label "View:">
<!ENTITY viewPicker.accesskey "i">
<!ENTITY viewPickerCustomView.label "Customize...">
<!ENTITY viewPickerAll.label "All">
<!ENTITY viewPickerUnread.label "Unread">