diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-04-22 02:20:14 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-04-22 02:20:14 +0200 |
commit | 0cb856babf290b012c87234820db33e0801c4e5c (patch) | |
tree | fe5cd5e1b3ff04539a36e1310f2c9f48068bdf4d /data/lib | |
parent | a06ad7e29b9ca7e8e24f72ef3431f5972e23ec8c (diff) | |
download | bugzilla-triage-0cb856babf290b012c87234820db33e0801c4e5c.tar.gz |
Add the roll-down list for selection of categories.
Diffstat (limited to 'data/lib')
-rw-r--r-- | data/lib/otherButtons.js | 6 | ||||
-rw-r--r-- | data/lib/rhbzpage.js | 4 | ||||
-rw-r--r-- | data/lib/xorgBugCategories.js | 51 |
3 files changed, 60 insertions, 1 deletions
diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js index 3a1f76a..7a11395 100644 --- a/data/lib/otherButtons.js +++ b/data/lib/otherButtons.js @@ -60,7 +60,11 @@ function markBugTriaged() { // /fedora-meeting.2009-11-24-15.11.log.html // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\ // /fedora-meeting.2009-11-24-15.11.log.html - addStuffToTextBox("keywords","Triaged"); + if (!hasXorgBugsCategory()) { + alert("This won't do! First set the category!"); + } else { + addStuffToTextBox("keywords","Triaged"); + } } function addingEmbelishments(list) { diff --git a/data/lib/rhbzpage.js b/data/lib/rhbzpage.js index 706c8c1..d36f33c 100644 --- a/data/lib/rhbzpage.js +++ b/data/lib/rhbzpage.js @@ -466,6 +466,10 @@ function RHBZinit() { setDefaultAssignee(); } + if (constantData.xorgBugsCategories) { + makeBugCategoriesList(constantData.xorgBugsCategories); + } + // Dig out backtrace protection against double-firing? btSnippet = ""; diff --git a/data/lib/xorgBugCategories.js b/data/lib/xorgBugCategories.js new file mode 100644 index 0000000..f47ad1d --- /dev/null +++ b/data/lib/xorgBugCategories.js @@ -0,0 +1,51 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php +"use strict"; + +function hasXorgBugsCategory() { + var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether + // there is already category tag in the Whiteboard + + var whiteboardContent = document. + getElementById("status_whiteboard").value; + return (catRE.test(whiteboardContent)); +} + +/** + * Create a category list to the upper toolbar + */ +function makeBugCategoriesList(catList) { + + // Create <select> element and add it first blank <option> + var targetDiv = document.getElementById("commit_top").parentNode; + var categoryList = document.createElement("select"); + categoryList.setAttribute("id", "xorgBugsCategoriesSelect"); + categoryList.setAttribute("name", "xorgBugsCategoriesSelect"); + var optionElement = document.createElement("option"); + optionElement.value = null; + optionElement.setAttribute("id", "catId_blank"); + optionElement.appendChild(document.createTextNode("---")); + categoryList.appendChild(optionElement); + + // Fill-in <select> with <options>s for each category one + catList.forEach(function (cat) { + optionElement = document.createElement("option"); + optionElement.value = cat; + optionElement.setAttribute("id", "catId_" + cat.replace(" ","").toLowerCase()); + optionElement.appendChild(document.createTextNode(cat)); + categoryList.appendChild(optionElement); + }); + + categoryList.addEventListener("change", function (evt) { + var selectedCategory = "[cat:" + this.value + "]"; + var whiteboardElement = document.getElementById("status_whiteboard"); + + if (hasXorgBugsCategory()) { + whiteboardElement.value = whiteboardElement. + value.replace(catRE, ""); + } + addStuffToTextBox("status_whiteboard", selectedCategory); + }, false); + + targetDiv.insertBefore(categoryList, targetDiv.firstChild); +} |