mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
fix for #40374 - make action line dynamically update to reflect the action the user has chosen
r=sspitzer
This commit is contained in:
parent
d38cef7b0f
commit
4b192d81e3
@ -28,7 +28,8 @@ var gFilter;
|
||||
var gFilterNameElement;
|
||||
var gActionElement;
|
||||
var gActionTargetElement;
|
||||
|
||||
var gActionPriority;
|
||||
var Bundle;
|
||||
|
||||
var nsIMsgSearchValidityManager = Components.interfaces.nsIMsgSearchValidityManager;
|
||||
|
||||
@ -38,6 +39,9 @@ function filterEditorOnLoad()
|
||||
{
|
||||
initializeSearchWidgets();
|
||||
initializeFilterWidgets();
|
||||
|
||||
Bundle = srGetStrBundle("chrome://messenger/locale/filter.properties");
|
||||
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
var args = window.arguments[0];
|
||||
if (args.filter) {
|
||||
@ -48,15 +52,18 @@ function filterEditorOnLoad()
|
||||
gFilterList = args.filterList;
|
||||
if (gFilterList)
|
||||
setSearchScope(getScopeFromFilterList(gFilterList));
|
||||
// fake the first more button press
|
||||
onMore(null);
|
||||
}
|
||||
}
|
||||
|
||||
gFilterNameElement.focus();
|
||||
doSetOKCancel(onOk, null);
|
||||
}
|
||||
|
||||
function onOk()
|
||||
{
|
||||
saveFilter();
|
||||
if (!saveFilter()) return;
|
||||
|
||||
// parent should refresh filter list..
|
||||
// this should REALLY only happen when some criteria changes that
|
||||
@ -82,6 +89,8 @@ function initializeFilterWidgets()
|
||||
gFilterNameElement = document.getElementById("filterName");
|
||||
gActionElement = document.getElementById("actionMenu");
|
||||
gActionTargetElement = document.getElementById("actionTargetFolder");
|
||||
gActionValueDeck = document.getElementById("actionValueDeck");
|
||||
gActionPriority = document.getElementById("actionValuePriority");
|
||||
}
|
||||
|
||||
function initializeDialog(filter)
|
||||
@ -89,17 +98,25 @@ function initializeDialog(filter)
|
||||
gFilterNameElement.value = filter.filterName;
|
||||
|
||||
gActionElement.selectedItem=gActionElement.getElementsByAttribute("data", filter.action)[0];
|
||||
|
||||
showActionElementFor(gActionElement.selectedItem);
|
||||
|
||||
if (filter.action == nsMsgFilterAction.MoveToFolder) {
|
||||
// there are multiple sub-items that have given attribute
|
||||
var targets = gActionTargetElement.getElementsByAttribute("data", filter.actionTargetFolderUri);
|
||||
|
||||
if (targets && targets.length) {
|
||||
if (targets && targets.length > 0) {
|
||||
var target = targets[0];
|
||||
if (target.tagName == "menuitem")
|
||||
gActionTargetElement.selectedItem = target;
|
||||
}
|
||||
} else if (filter.action == nsMsgFilterAction.ChangePriority) {
|
||||
dump("initializing priority..\n");
|
||||
var selectedPriority = gActionPriority.getElementsByAttribute("data", filter.actionPriority);
|
||||
|
||||
if (selectedPriority && selectedPriority.length > 0) {
|
||||
var selectedPriority = selectedPriority[0];
|
||||
gActionPriority.selectedItem = selectedPriority;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +131,15 @@ function initializeDialog(filter)
|
||||
function saveFilter() {
|
||||
|
||||
var isNewFilter;
|
||||
|
||||
var filterName= gFilterNameElement.value;
|
||||
if (!filterName || filterName == "") {
|
||||
var str = Bundle.GetStringFromName("mustEnterName");
|
||||
window.alert(str);
|
||||
gFilterNameElement.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!gFilter) {
|
||||
gFilter = gFilterList.createFilter(gFilterNameElement.value);
|
||||
isNewFilter = true;
|
||||
@ -125,15 +151,46 @@ function saveFilter() {
|
||||
saveSearchTerms(gFilter.searchTerms, gFilter);
|
||||
|
||||
var action = gActionElement.selectedItem.getAttribute("data");
|
||||
dump("Action = " + action + "\n");
|
||||
gFilter.action = action;
|
||||
if (action == nsMsgFilterAction.MoveToFolder &&
|
||||
gActionElement.selectedItem)
|
||||
gFilter.actionTargetFolderUri =
|
||||
gActionTargetElement.selectedItem.getAttribute("data");
|
||||
else if (action == nsMsgFilterAction.ChangePriority)
|
||||
gFilter.actionPriority = 0; // whatever, fix this
|
||||
|
||||
if (action == nsMsgFilterAction.MoveToFolder) {
|
||||
var targetUri;
|
||||
if (gActionTargetElement)
|
||||
targetUri = gActionTargetElement.selectedItem.getAttribute("data");
|
||||
dump("folder target = " + gActionTargetElement.selectedItem + "\n");
|
||||
if (!targetUri || targetUri == "") {
|
||||
var str = Bundle.GetStringFromName("mustSelectFolder");
|
||||
window.alert(str);
|
||||
return false;
|
||||
}
|
||||
gFilter.actionTargetFolderUri = targetUri;
|
||||
}
|
||||
|
||||
else if (action == nsMsgFilterAction.ChangePriority) {
|
||||
if (!gActionPriority.selectedItem) {
|
||||
var str = Bundle.GetStringFromName("mustSelectPriority");
|
||||
window.alert(str);
|
||||
return false;
|
||||
}
|
||||
gFilter.actionPriority = gActionPriority.selectedItem.getAttribute("data");
|
||||
}
|
||||
|
||||
if (isNewFilter)
|
||||
gFilterList.insertFilterAt(0, gFilter);
|
||||
|
||||
// success!
|
||||
return true;
|
||||
}
|
||||
|
||||
function onActionChanged(event)
|
||||
{
|
||||
var menuitem = event.target;
|
||||
showActionElementFor(menuitem);
|
||||
}
|
||||
|
||||
function showActionElementFor(menuitem)
|
||||
{
|
||||
if (!menuitem) return;
|
||||
dump("showActionElementFor(" + menuitem.getAttribute("actionvalueindex") + ")\n");
|
||||
gActionValueDeck.setAttribute("index", menuitem.getAttribute("actionvalueindex"));
|
||||
}
|
||||
|
@ -37,48 +37,61 @@ Rights Reserved.
|
||||
<script language="JavaScript" src="chrome://messenger/content/FilterEditor.js"/>
|
||||
<script language="JavaScript" src="chrome://global/content/strres.js"/>
|
||||
<keyset id="keyset"/>
|
||||
<titledbox id="searchTermListBox"/>
|
||||
<box orient="horizontal" class="padded">
|
||||
<text value="&filterName.label;"/>
|
||||
<textfield flex="1" id="filterName"/>
|
||||
</box>
|
||||
<titledbox id="searchTermListBox"/>
|
||||
<titledbox>
|
||||
<title>
|
||||
<text value="&filterAction.label;"/>
|
||||
</title>
|
||||
<menulist id="actionMenu" flex="1">
|
||||
<menulist id="actionMenu" flex="1" oncommand="onActionChanged(event)">
|
||||
<menupopup>
|
||||
<menuitem data="1" value="&moveToFolder.label;"/>
|
||||
<menuitem data="2" value="&changePriority.label;"/>
|
||||
<menuitem data="3" value="&delete.label;"/>
|
||||
<menuitem data="4" value="&markRead.label;"/>
|
||||
<menuitem data="5" value="&ignoreThread.label;"/>
|
||||
<menuitem data="6" value="&watchThread.label;"/>
|
||||
<menuitem data="1" actionvalueindex="0" value="&moveToFolder.label;"/>
|
||||
<menuitem data="2" actionvalueindex="1" value="&changePriority.label;"/>
|
||||
<menuitem data="3" actionvalueindex="2" value="&delete.label;"/>
|
||||
<menuitem data="4" actionvalueindex="2" value="&markRead.label;"/>
|
||||
<menuitem data="5" actionvalueindex="2" value="&ignoreThread.label;"/>
|
||||
<menuitem data="6" actionvalueindex="2" value="&watchThread.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<menulist id="actionTargetFolder" flex="1"
|
||||
containment="http://home.netscape.com/NC-rdf#child"
|
||||
datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
|
||||
ref="msgaccounts:/">
|
||||
<template>
|
||||
<rule iscontainer="true" isempty="false">
|
||||
<menupopup>
|
||||
<menu uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name">
|
||||
<menupopup>
|
||||
<menuitem uri="..." data="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
<menuseparator/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." data="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
<deck id="actionValueDeck" flex="1">
|
||||
<menulist id="actionTargetFolder" flex="1"
|
||||
containment="http://home.netscape.com/NC-rdf#child"
|
||||
datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
|
||||
ref="msgaccounts:/">
|
||||
<template>
|
||||
<rule iscontainer="true" isempty="false">
|
||||
<menupopup>
|
||||
<menu uri="..." value="rdf:http://home.netscape.com/NC-rdf#Name">
|
||||
<menupopup>
|
||||
<menuitem uri="..." data="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
<menuseparator/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." data="..." value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
<menulist id="actionValuePriority">
|
||||
<menupopup>
|
||||
<!-- see MailNewsTypes2.idl -->
|
||||
<menuitem data="6" value="&highestPriorityCmd.label;"/>
|
||||
<menuitem data="5" value="&highPriorityCmd.label;"/>
|
||||
<menuitem data="4" value="&normalPriorityCmd.label;"/>
|
||||
<menuitem data="3" value="&lowPriorityCmd.label;"/>
|
||||
<menuitem data="2" value="&lowestPriorityCmd.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<text id="actionValueNone"/>
|
||||
</deck>
|
||||
</titledbox>
|
||||
<separator class="groove"/>
|
||||
<box id="okCancelButtons"/>
|
||||
|
@ -101,9 +101,12 @@ Rights Reserved.
|
||||
<button id="deleteButton" value="&deleteButton.label;" onclick="onDeleteFilter();"/>
|
||||
</box>
|
||||
</box>
|
||||
<!--
|
||||
take out for PR2
|
||||
<box orient="horizontal">
|
||||
<button value="&runFiltersNow.label;" width="0em"/>
|
||||
</box>
|
||||
-->
|
||||
<!-- <button onclick="DumpDOM(document.getElementById('filterTree'));" value="dump"/> -->
|
||||
<separator class="groove"/>
|
||||
<box id="okCancelButtons"/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!ENTITY window.title "Edit Filter">
|
||||
<!ENTITY window.title "Filter Rules">
|
||||
<!ENTITY subject.label "subject">
|
||||
<!ENTITY sender.label "sender">
|
||||
<!ENTITY date.label "date">
|
||||
@ -21,3 +21,9 @@
|
||||
<!ENTITY ignoreThread.label "Ignore thread">
|
||||
<!ENTITY watchThread.label "Watch thread">
|
||||
<!ENTITY filterName.label "Filter Name:">
|
||||
|
||||
<!ENTITY lowestPriorityCmd.label "Lowest">
|
||||
<!ENTITY lowPriorityCmd.label "Low">
|
||||
<!ENTITY normalPriorityCmd.label "Normal">
|
||||
<!ENTITY highPriorityCmd.label "High">
|
||||
<!ENTITY highestPriorityCmd.label "Highest">
|
||||
|
@ -5,4 +5,5 @@ SearchOptions.dtd
|
||||
search-attributes.properties
|
||||
search-operators.properties
|
||||
search.properties
|
||||
filter.properties
|
||||
searchTermOverlay.dtd
|
||||
|
@ -37,6 +37,7 @@ CHROME_L10N = \
|
||||
search-attributes.properties \
|
||||
search-operators.properties \
|
||||
search.properties \
|
||||
filter.properties \
|
||||
searchTermOverlay.dtd \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
mustSelectFolder=You must select a target folder.
|
||||
mustSelectPriority=You must select a priority.
|
||||
mustEnterName=You must give this filter a name.
|
@ -32,6 +32,7 @@ CHROME_L10N = \
|
||||
.\search-attributes.properties \
|
||||
.\search-operators.properties \
|
||||
.\search.properties \
|
||||
.\filter.properties \
|
||||
.\searchTermOverlay.dtd \
|
||||
$(NULL)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user