Closed
Bug 909203
Opened 11 years ago
Closed 10 years ago
Use JSONRPC (if available) to populate the components on the edit flag type pages
Categories
(Bugzilla :: Administration, task)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: mail, Assigned: mail)
References
Details
(Keywords: perf)
Attachments
(2 obsolete files)
The edit flag types pages (both list and edit/new) generate and array of arrays in the HTML (of components for products). When you have 60,000 components (like brc does), this is inefficient, and causes the browser to hang. This patch will make these two pages use JSONRPC if it is available to populate the component list. Note: This means that if the SITE has JSONRPC available, then the admin USER must have Javascript enabled. It was decided at last months Bugzilla meeting that it was okay to assume that Bugzilla admin pages require Javascript to fully function. The changes have no effect if the site does not have JSONRPC available.
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #795277 -
Flags: review?(gerv)
Assignee | ||
Updated•11 years ago
|
Comment 2•11 years ago
|
||
Comment on attachment 795277 [details] [diff] [review] v1 patch >=== modified file 'template/en/default/global/js-products.html.tmpl' >+ function updateComponentList (target, item, anyval, sel) { >+ // Clear current selection. >+ target.options.length = 0; >+ >+ // Add special "Any" value back to the list. >+ if (anyval != null) >+ target.options[0] = new Option(anyval, ""); >+ >+ // Load elements of list into select element. >+ for (i = 0; i < item.length; i++) { >+ s = item[i].name == sel ? 1 : 0; >+ target.options[target.options.length] = new Option(item[i].name, item[i].name, s); >+ } >+ } >+ >+ YAHOO.util.Connect.setDefaultPostHeader('application/json', true); >+ // Make the call to the server for JSON data >+ function updateComponent (product, component, anyval, sel) { >+ var updateComponentCallback = { >+ // Successful XHR response handler >+ success : function (o) { >+ var messages = []; >+ >+ // Use the JSON Utility to parse the data returned from the server >+ try { >+ result = YAHOO.lang.JSON.parse(o.responseText); >+ } >+ catch (x) { >+ alert("JSON Parse failed! Please try again."); >+ return; >+ } >+ >+ // The returned data was parsed into an array of objects. >+ var components = result['result']['products'][0]['components']; >+ updateComponentList(component, components, anyval, sel); >+ }, >+ }; >+ >+ var findall = (product.selectedIndex == -1 >+ || (anyval != null && product.options[0].selected)); >+ >+ if (findall) { >+ updateComponentList(component, [], anyval, sel); >+ return; >+ } >+ >+ var productName = product.options[product.selectedIndex].text; >+ var json_object = { >+ "method": "Product.get", >+ "params": [ { >+ "names": [ decodeURIComponent(productName) ], >+ "include_fields": [ "components.name" ] >+ } ], >+ "id": 1 >+ }; >+ >+ var postData = YAHOO.lang.JSON.stringify(json_object); >+ YAHOO.util.Connect.asyncRequest('POST','jsonrpc.cgi', updateComponentCallback, postData); >+ } This code doesn't depend on data passed by TT at all. This means it can be moved inside js/*.js instead of being in templates. We shouldn't write JS code inside templates when that's not strictly needed.
Updated•11 years ago
|
Severity: normal → enhancement
Assignee | ||
Updated•11 years ago
|
Attachment #795277 -
Attachment is obsolete: true
Attachment #795277 -
Flags: review?(gerv)
Assignee | ||
Comment 3•11 years ago
|
||
Includes suggested change by Frédéric. Also doesn't load the YUI code if jsonrpc is not available.
Attachment #795773 -
Flags: review?(gerv)
Assignee | ||
Updated•11 years ago
|
Attachment #795773 -
Flags: review?(gerv) → review?(dkl)
Assignee | ||
Updated•11 years ago
|
Attachment #795773 -
Attachment is obsolete: true
Attachment #795773 -
Flags: review?(dkl)
Assignee | ||
Comment 4•11 years ago
|
||
I've dropped the original patch as the JS used in bug 227611 can be used for this code too. Once that bug hits trunk, I'll do a new patch for this bug.
Depends on: 227611
Assignee | ||
Updated•11 years ago
|
Attachment #795773 -
Attachment is obsolete: false
Attachment #795773 -
Flags: review?(dkl)
Assignee | ||
Updated•10 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
Target Milestone: Bugzilla 5.0 → ---
Assignee | ||
Updated•10 years ago
|
Attachment #795773 -
Attachment is obsolete: true
Attachment #795773 -
Flags: review?(dkl)
You need to log in
before you can comment on or make changes to this bug.
Description
•