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/xorgBugCategories.js | |
parent | a06ad7e29b9ca7e8e24f72ef3431f5972e23ec8c (diff) | |
download | bugzilla-triage-0cb856babf290b012c87234820db33e0801c4e5c.tar.gz |
Add the roll-down list for selection of categories.
Diffstat (limited to 'data/lib/xorgBugCategories.js')
-rw-r--r-- | data/lib/xorgBugCategories.js | 51 |
1 files changed, 51 insertions, 0 deletions
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); +} |