From 0cb856babf290b012c87234820db33e0801c4e5c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 22 Apr 2011 02:20:14 +0200 Subject: Add the roll-down list for selection of categories. --- data/lib/otherButtons.js | 6 ++++- data/lib/rhbzpage.js | 4 ++++ data/lib/xorgBugCategories.js | 51 +++++++++++++++++++++++++++++++++++++++++++ lib/main.js | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 data/lib/xorgBugCategories.js 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 with 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); +} diff --git a/lib/main.js b/lib/main.js index f3de753..645669a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -118,6 +118,7 @@ var contentScriptLibraries = [ self.data.url("lib/jumpNextBug.js"), self.data.url("lib/queries.js"), self.data.url("lib/preprocessDuplicates.js"), + self.data.url("lib/xorgBugCategories.js"), self.data.url("lib/viewSource.js"), self.data.url("lib/color.js"), self.data.url("lib/addNewLinks.js"), -- cgit