summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2012-12-21 23:13:17 +0100
committerDave Lawrence <dlawrence@mozilla.com>2012-12-21 23:13:17 +0100
commit1e95913315c21a2ce181007d66294c5f1f975038 (patch)
treebd8424a67bed0a121478603999d44ee3cf63ce44 /extensions
parent63ed510dfa9ac705d16df4344da5e41fcab6137e (diff)
downloadbugzilla-1e95913315c21a2ce181007d66294c5f1f975038.tar.gz
bugzilla-1e95913315c21a2ce181007d66294c5f1f975038.tar.xz
- Converted several pages to use the new ProdCompSearch extension
- Other MyDashboard improvements/fixes
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/template/en/default/global/choose-product.html.tmpl22
-rw-r--r--extensions/BMO/template/en/default/global/header.html.tmpl1
-rw-r--r--extensions/BMO/web/js/prod_comp_search.js85
-rw-r--r--extensions/BMO/web/styles/prod_comp_search.css22
-rw-r--r--extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl26
-rw-r--r--extensions/MyDashboard/lib/Queries.pm3
-rw-r--r--extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl24
-rw-r--r--extensions/MyDashboard/web/js/flags.js6
-rw-r--r--extensions/MyDashboard/web/js/prod_comp_search.js88
-rw-r--r--extensions/MyDashboard/web/js/query.js65
-rw-r--r--extensions/MyDashboard/web/styles/mydashboard.css21
11 files changed, 85 insertions, 278 deletions
diff --git a/extensions/BMO/template/en/default/global/choose-product.html.tmpl b/extensions/BMO/template/en/default/global/choose-product.html.tmpl
index b9cd02cfc..c185989d1 100644
--- a/extensions/BMO/template/en/default/global/choose-product.html.tmpl
+++ b/extensions/BMO/template/en/default/global/choose-product.html.tmpl
@@ -39,11 +39,9 @@
[% h2 = "Which product would you like to have described?" %]
[% END %]
-[% yui = [ 'autocomplete' ] %]
-[% javascript_urls = [ "js/field.js", "js/create_bug.js",
- "extensions/BMO/web/js/prod_comp_search.js" ] %]
-[% onload = "YAHOO.util.Dom.get('prod_comp_search').focus();" %]
-[% style_urls.push("extensions/BMO/web/styles/prod_comp_search.css") %]
+[% javascript_urls = [ "extensions/ProdCompSearch/web/js/prod_comp_search.js" ] %]
+[% onload = "document.getElementById('prod_comp_search').focus();" %]
+[% style_urls.push("extensions/ProdCompSearch/web/styles/prod_comp_search.css") %]
[% DEFAULT title = "Choose a Product" %]
[% PROCESS global/header.html.tmpl %]
@@ -60,7 +58,19 @@
<h2>[% h2 FILTER html %]</h2>
-[% PROCESS "global/prod-comp-search.html.tmpl" %]
+<script>
+ [% IF format %]
+ ProdCompsearch.format = '[% format FILTER js %]';
+ [% END %]
+ [% IF cloned_bug_id %]
+ ProdCompSearch.cloned_bug_id = '[% cloned_bug_id FILTER js %]';
+ [% END %]
+</script>
+<div id="prod_comp_search_main">
+ [% PROCESS prodcompsearch/form.html.tmpl
+ input_label = "Type to find product and component by name or description:"
+ %]
+</div>
<h2>or choose from the following selections</h2>
diff --git a/extensions/BMO/template/en/default/global/header.html.tmpl b/extensions/BMO/template/en/default/global/header.html.tmpl
index c2e3de08c..0ef406e7c 100644
--- a/extensions/BMO/template/en/default/global/header.html.tmpl
+++ b/extensions/BMO/template/en/default/global/header.html.tmpl
@@ -78,6 +78,7 @@
[% SET starting_js_urls = [
"js/yui/yahoo-dom-event/yahoo-dom-event.js",
"js/yui/cookie/cookie-min.js",
+ "js/yui3/yui/yui-min.js"
] %]
diff --git a/extensions/BMO/web/js/prod_comp_search.js b/extensions/BMO/web/js/prod_comp_search.js
deleted file mode 100644
index ada296f52..000000000
--- a/extensions/BMO/web/js/prod_comp_search.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0.
- */
-
-YAHOO.bugzilla.prodCompSearch = {
- counter : 0,
- format : '',
- cloned_bug_id : '',
- dataSource : null,
- autoComplete: null,
- generateRequest : function (enteredText) {
- YAHOO.bugzilla.prodCompSearch.counter = YAHOO.bugzilla.prodCompSearch.counter + 1;
- YAHOO.util.Connect.setDefaultPostHeader('application/json', true);
- var json_object = {
- method : "BMO.prod_comp_search",
- id : YAHOO.bugzilla.prodCompSearch.counter,
- params : [ {
- search : decodeURIComponent(enteredText)
- } ]
- };
- YAHOO.util.Dom.removeClass('prod_comp_throbber', 'hidden');
- return YAHOO.lang.JSON.stringify(json_object);
- },
- resultListFormat : function(oResultData, enteredText, sResultMatch) {
- return YAHOO.lang.escapeHTML(oResultData[0]) + " :: " +
- YAHOO.lang.escapeHTML(oResultData[1]);
- },
- init_ds : function(){
- this.dataSource = new YAHOO.util.XHRDataSource("jsonrpc.cgi");
- this.dataSource.connTimeout = 30000;
- this.dataSource.connMethodPost = true;
- this.dataSource.connXhrMode = "cancelStaleRequests";
- this.dataSource.maxCacheEntries = 5;
- this.dataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
- this.dataSource.responseSchema = {
- resultsList : "result.products",
- metaFields : { error: "error", jsonRpcId: "id"},
- fields : [ "product", "component" ]
- };
- },
- init : function(field, container, format, cloned_bug_id) {
- if (this.dataSource == null)
- this.init_ds();
- this.format = format;
- this.cloned_bug_id = cloned_bug_id;
- this.autoComplete = new YAHOO.widget.AutoComplete(field, container, this.dataSource);
- this.autoComplete.generateRequest = this.generateRequest;
- this.autoComplete.formatResult = this.resultListFormat;
- this.autoComplete.minQueryLength = 3;
- this.autoComplete.autoHighlight = false;
- this.autoComplete.queryDelay = 0.05;
- this.autoComplete.useIFrame = true;
- this.autoComplete.maxResultsDisplayed = 25;
- this.autoComplete.suppressInputUpdate = true;
- this.autoComplete.doBeforeLoadData = function(sQuery, oResponse, oPayload) {
- YAHOO.util.Dom.addClass('prod_comp_throbber', 'hidden');
- return true;
- };
- this.autoComplete.textboxFocusEvent.subscribe(function () {
- var input = YAHOO.util.Dom.get(field);
- if (input.value && input.value.length > 3) {
- this.sendQuery(input.value);
- }
- });
- this.autoComplete.itemSelectEvent.subscribe(function (e, args) {
- var oData = args[2];
- var url = "enter_bug.cgi?product=" + encodeURIComponent(oData[0]) +
- "&component=" + encodeURIComponent(oData[1]);
- var format = YAHOO.bugzilla.prodCompSearch.format;
- if (format)
- url += "&format=" + encodeURIComponent(format);
- var cloned_bug_id = YAHOO.bugzilla.prodCompSearch.cloned_bug_id;
- if (cloned_bug_id)
- url += "&cloned_bug_id=" + encodeURIComponent(cloned_bug_id);
- window.location.href = url;
- });
- this.autoComplete.dataReturnEvent.subscribe(function(type, args) {
- args[0].autoHighlight = args[2].length == 1;
- });
- }
-}
diff --git a/extensions/BMO/web/styles/prod_comp_search.css b/extensions/BMO/web/styles/prod_comp_search.css
deleted file mode 100644
index 24c0a2cf8..000000000
--- a/extensions/BMO/web/styles/prod_comp_search.css
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0. */
-
-#prod_comp_search_main {
- width: 400px;
- margin-right: auto;
- margin-left: auto;
-}
-
-#prod_comp_search_main .hidden {
- display: none;
-}
-
-#prod_comp_search_main li.yui-ac-highlight a {
- text-decoration: none;
- color: #FFFFFF;
- display: block;
-}
diff --git a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl
index 93d036f7b..ddae5443b 100644
--- a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl
+++ b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl
@@ -112,26 +112,24 @@ dupes.setLabels(
%]
</table>
-[% IF BMO %]
+[% IF BMO %]
<h3>
Or search for a Product:
</h3>
+ <script>
+ [% IF format %]
+ ProdCompsearch.format = '[% format FILTER js %]';
+ [% END %]
+ [% IF cloned_bug_id %]
+ ProdCompSearch.cloned_bug_id = '[% cloned_bug_id FILTER js %]';
+ [% END %]
+ </script>
<div id="prod_comp_search_main">
- <div id="prod_comp_search_autocomplete">
- <div id="prod_comp_search_label">
- Type to find product and component by name or description:
- <img id="prod_comp_throbber" src="extensions/GuidedBugEntry/web/images/throbber.gif"
- class="hidden" width="16" height="11">
- </div>
- <input id="prod_comp_search" type="text" size="60">
- <div id="prod_comp_search_autocomplete_container"></div>
- </div>
+ [% PROCESS prodcompsearch/form.html.tmpl
+ input_label = "Type to find product and component by name or description:"
+ %]
</div>
- <script type="text/javascript">
- if (typeof(YAHOO.bugzilla.prodCompSearch) !== 'undefined' && YAHOO.bugzilla.prodCompSearch != null)
- YAHOO.bugzilla.prodCompSearch.init('prod_comp_search', 'prod_comp_search_autocomplete_container', 'guided');
- </script>
[% END %]
</div>
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm
index 628e26a73..79247bf73 100644
--- a/extensions/MyDashboard/lib/Queries.pm
+++ b/extensions/MyDashboard/lib/Queries.pm
@@ -133,6 +133,9 @@ sub query_bugs {
my $qdef = shift;
my $dbh = Bugzilla->dbh;
+ ## HACK to remove POST
+ delete $ENV{REQUEST_METHOD};
+
my $params = new Bugzilla::CGI($qdef->{params});
my $search = new Bugzilla::Search( fields => [ SELECT_COLUMNS ],
diff --git a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
index a386b6716..dcaad0441 100644
--- a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
+++ b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
@@ -10,11 +10,11 @@
[% PROCESS global/header.html.tmpl
title = "My Dashboard"
- style_urls = [ "extensions/MyDashboard/web/styles/mydashboard.css" ]
- javascript_urls = [ "js/yui3/yui/yui-min.js",
- "extensions/MyDashboard/web/js/query.js",
+ style_urls = [ "extensions/MyDashboard/web/styles/mydashboard.css",
+ "extensions/ProdCompSearch/web/styles/prod_comp_search.css" ]
+ javascript_urls = [ "extensions/MyDashboard/web/js/query.js",
"extensions/MyDashboard/web/js/flags.js",
- "extensions/MyDashboard/web/js/prod_comp_search.js" ]
+ "extensions/ProdCompSearch/web/js/prod_comp_search.js" ]
%]
[% standard_queries = [] %]
@@ -51,22 +51,16 @@
<div class="query_description"></div>
<span class="items_found" id="query_bugs_found">0 bugs found</span>
| <a class="refresh" href="javascript:void(0);" id="query_refresh">Refresh</a>
- <span class="status">Loading...</span>
<div id="query_pagination_top"></div>
<div id="query_table"></div>
</div>
</div>
<div id="right">
- <div id="prod_comp_search_container">
- <div id="prod_comp_search_main">
- <div id="prod_comp_search_label">
- File [% terms.Bug %]:
- <img id="prod_comp_throbber" src="extensions/BMO/web/images/throbber.gif"
- class="bz_default_hidden" width="16" height="11">
- </div>
- <input id="prod_comp_search" type="text" size="60">
- </div>
+ <div id="prod_comp_search_main">
+ [% PROCESS prodcompsearch/form.html.tmpl
+ input_label = "File a $terms.Bug:"
+ %]
</div>
<div id="requestee_container">
@@ -75,7 +69,6 @@
</div>
<span class="items_found" id="requestee_flags_found">0 flags found</span>
| <a class="refresh" href="javascript:void(0);" id="requestee_refresh">Refresh</a>
- <span class="status">Loading...</span>
<div id="requestee_table"></div>
</div>
@@ -85,7 +78,6 @@
</div>
<span class="items_found" id="requester_flags_found">0 flags found</span>
| <a class="refresh" href="javascript:void(0);" id="requester_refresh">Refresh</a>
- <span class="status">Loading...</span>
<div id="requester_table"></div>
</div>
</div>
diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js
index b1605e04e..925cb8b6a 100644
--- a/extensions/MyDashboard/web/js/flags.js
+++ b/extensions/MyDashboard/web/js/flags.js
@@ -33,9 +33,7 @@ YUI({
if (e.response) {
Y.one("#" + type + "_flags_found").setHTML(
e.response.results.length + ' flags found');
- Y.one("#" + type + "_container .status").addClass('bz_default_hidden');
dataTable[type].set('data', e.response.results);
- dataTable[type].render("#" + type + "_table");
}
},
failure: function(o) {
@@ -53,7 +51,9 @@ YUI({
var stringified = Y.JSON.stringify(json_object);
- Y.one("#" + type + "_container .status").removeClass('bz_default_hidden');
+ dataTable[type].set('data', []);
+ dataTable[type].render("#" + type + "_table");
+ dataTable[type].showMessage('loadingMessage');
dataSource[type].sendRequest({
request: stringified,
diff --git a/extensions/MyDashboard/web/js/prod_comp_search.js b/extensions/MyDashboard/web/js/prod_comp_search.js
deleted file mode 100644
index d56baebec..000000000
--- a/extensions/MyDashboard/web/js/prod_comp_search.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0.
- */
-
-// Product and component search to file a new bug
-YUI({
- base: 'js/yui3/',
- combine: false
-}).use("node", "json-stringify", "autocomplete", "escape",
- "datasource-io", "datasource-jsonschema", "array-extras", function (Y) {
- var counter = 0,
- format = '',
- cloned_bug_id = '',
- dataSource = null,
- autoComplete = null;
-
- var resultListFormat = function(query, results) {
- return Y.Array.map(results, function (result) {
- var data = result.raw;
- return Y.Escape.html(data.product) + " :: " +
- Y.Escape.html(data.component);
- });
- };
-
- var requestTemplate = function(query) {
- counter = counter + 1;
- var json_object = {
- version: "1.1",
- method : "MyDashboard.prod_comp_search",
- id : counter,
- params : { search: query }
- };
- return Y.JSON.stringify(json_object);
- };
-
- var dataSource = new Y.DataSource.IO({
- source: 'jsonrpc.cgi',
- ioConfig: {
- method: "POST",
- headers: { 'Content-Type': 'application/json' }
- }
- });
-
- dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator : "result.products",
- resultFields : [ "product", "component" ]
- }
- });
-
- var input = Y.one('#prod_comp_search');
-
- input.plug(Y.Plugin.AutoComplete, {
- enableCache: true,
- source: dataSource,
- minQueryLength: 3,
- queryDelay: 0.05,
- resultFormatter: resultListFormat,
- maxResultsDisplayed: 25,
- suppressInputUpdate: true,
- maxResults: 25,
- requestTemplate: requestTemplate,
- on: {
- query: function() {
- Y.one("#prod_comp_throbber").removeClass('bz_default_hidden');
- },
- results: function() {
- Y.one("#prod_comp_throbber").addClass('bz_default_hidden');
- },
- select: function(e) {
- var data = e.result.raw;
- var url = "enter_bug.cgi?product=" + encodeURIComponent(data.product) +
- "&component=" + encodeURIComponent(data.component);
- window.location.href = url;
- }
- },
- });
-
- input.on('focus', function (e) {
- if (e.target.value && e.target.value.length > 3) {
- dataSource.load(e.target.value);
- }
- });
-});
diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js
index b9248bf6b..746717e75 100644
--- a/extensions/MyDashboard/web/js/query.js
+++ b/extensions/MyDashboard/web/js/query.js
@@ -10,12 +10,28 @@
YUI({
base: 'js/yui3/',
combine: false
-}).use("node", "datatable", "datatable-sort", "json-stringify",
- "datatable-datasource", "datasource-io", "datasource-jsonschema",
- "gallery-paginator-view", "gallery-datatable-paginator", function (Y) {
+}).use("node", "datatable", "datatable-sort", "datatable-message", "json-stringify",
+ "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie", function (Y) {
var counter = 0,
dataSource = null,
- dataTable = null;
+ dataTable = null,
+ default_query = "assignedbugs";
+
+ // Grab last used query name from cookie or use default
+ var query_cookie = Y.Cookie.get("my_dashboard_query");
+ if (query_cookie) {
+ var cookie_value_found = 0;
+ Y.one("#query").get("options").each( function() {
+ if (this.get("value") == query_cookie) {
+ this.set('selected', true);
+ default_query = query_cookie;
+ cookie_value_found = 1;
+ }
+ });
+ if (!cookie_value_found) {
+ Y.Cookie.set("my_dashboard_query", "");
+ }
+ }
var updateQueryTable = function(query_name) {
if (!query_name) return;
@@ -30,9 +46,7 @@ YUI({
Y.one("#query_bugs_found").setHTML(
'<a href="buglist.cgi?' + e.response.meta.buffer +
'">' + e.response.results.length + ' bugs found</a>');
- Y.one("#query_container .status").addClass('bz_default_hidden');
dataTable.set('data', e.response.results);
- dataTable.render("#query_table");
}
},
failure: function(o) {
@@ -50,7 +64,9 @@ YUI({
var stringified = Y.JSON.stringify(json_object);
- Y.one("#query_container .status").removeClass('bz_default_hidden');
+ dataTable.set('data', []);
+ dataTable.render("#query_table");
+ dataTable.showMessage('loadingMessage');
dataSource.sendRequest({
request: stringified,
@@ -63,6 +79,19 @@ YUI({
};
dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+
+ dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.bugs",
+ resultFields: ["bug_id", "changeddate", "bug_status", "short_desc"],
+ metaFields: {
+ description: "result.result.description",
+ heading: "result.result.heading",
+ buffer: "result.result.buffer"
+ }
+ }
+ });
+
dataTable = new Y.DataTable({
columns: [
{ key:"bug_id", label:"Bug", sortable:true,
@@ -71,38 +100,20 @@ YUI({
{ key:"bug_status", label:"Status", sortable:true },
{ key:"short_desc", label:"Summary", sortable:true },
],
- strings: {
- emptyMessage: 'No query data found.',
- },
- paginator: new Y.PaginatorView({
- model: new Y.PaginatorModel({ itemsPerPage: 25 }),
- container: 'query_pagination_top',
- })
});
dataTable.plug(Y.Plugin.DataTableSort);
dataTable.plug(Y.Plugin.DataTableDataSource, {
datasource: dataSource,
- initialRequest: updateQueryTable("assignedbugs"),
- });
-
- dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.bugs",
- resultFields: ["bug_id", "changeddate", "bug_status", "short_desc"],
- metaFields: {
- description: "result.result.description",
- heading: "result.result.heading",
- buffer: "result.result.buffer"
- }
- }
+ initialRequest: updateQueryTable(default_query),
});
Y.one('#query').on('change', function(e) {
var index = e.target.get('selectedIndex');
var selected_value = e.target.get("options").item(index).getAttribute('value');
updateQueryTable(selected_value);
+ Y.Cookie.set("my_dashboard_query", selected_value, { expires: new Date("January 12, 2025") });
});
Y.one('#query_refresh').on('click', function(e) {
diff --git a/extensions/MyDashboard/web/styles/mydashboard.css b/extensions/MyDashboard/web/styles/mydashboard.css
index fd441ec7a..dc253c0d1 100644
--- a/extensions/MyDashboard/web/styles/mydashboard.css
+++ b/extensions/MyDashboard/web/styles/mydashboard.css
@@ -38,29 +38,16 @@
width: 40%;
}
-.items_found, .refresh, .status {
+.items_found, .refresh {
font-size: 80%;
}
-.status {
- color: red;
- float: right;
-}
-
#query_list_container {
text-align:center;
}
-#prod_comp_search_container,
-#query_list_container {
- margin-bottom: 10px;
- border: 1px solid rgb(116,126,147);
- padding: 10px;
- height: 40px;
-}
-
+#query_list_container,
#prod_comp_search_main {
- margin-left: auto;
- margin-right: auto;
- text-align: left;
+ padding: 20px !important;
+ height: 40px;
}