Merge lp:~christopher-bradshaw-b/tiqit/attr into lp:tiqit

Proposed by Christopher Bradshaw
Status: Needs review
Proposed branch: lp:~christopher-bradshaw-b/tiqit/attr
Merge into: lp:tiqit
Diff against target: 169 lines (+45/-25)
3 files modified
scripts/pages/results.py (+12/-8)
static/scripts/multiedit.js (+27/-16)
static/scripts/updateresults.js (+6/-1)
To merge this branch: bzr merge lp:~christopher-bradshaw-b/tiqit/attr
Reviewer Review Type Date Requested Status
Matthew Earl Pending
Review via email: mp+279107@code.launchpad.net

Description of the change

Adding structure for plugins to add their own attribute fields
Adding custom event generator for "AttributesChanged"

To post a comment you must log in.
Revision history for this message
Sam Stoll (samstoll1) :

Unmerged revisions

6. By Christopher Bradshaw <email address hidden>

Adding structure for plugins to specify which additional attribute fields.
Adding custom event listener "AttributesChanged", when one of the attributes fields is changed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'scripts/pages/results.py'
--- scripts/pages/results.py 2014-11-10 14:11:37 +0000
+++ scripts/pages/results.py 2015-12-01 12:30:39 +0000
@@ -68,19 +68,22 @@
68# Build up the list of fields we need for correct operation68# Build up the list of fields we need for correct operation
69# These are parent fields and bannedIf fields of all the selected fields69# These are parent fields and bannedIf fields of all the selected fields
70#70#
71parents = set()71attr_fields = set()
72for field in selection:72for field in selection:
73 for parent in field._parentFields:73 for parent in field._parentFields:
74 parents.add(allFields[parent])74 attr_fields.add(allFields[parent])
7575
76 for bannedIf in field._bannedIf.keys():76 for bannedIf in field._bannedIf.keys():
77 parents.add(allFields[bannedIf])77 attr_fields.add(allFields[bannedIf])
7878
79 for defWith in field.defaultsWith:79 for defWith in field.defaultsWith:
80 parents.add(allFields[defWith])80 attr_fields.add(allFields[defWith])
81
82 for pluginField in plugins.getAttributeFields():
83 attr_fields.add(allFields[pluginField])
8184
82# We actually request the selected ones, and their dependees85# We actually request the selected ones, and their dependees
83requested = selection + list(parents)86requested = selection + list(attr_fields)
8487
85states, proj, buglist, usertype, username = parseAdvanced(args)88states, proj, buglist, usertype, username = parseAdvanced(args)
8689
@@ -97,6 +100,7 @@
97 function init() {100 function init() {
98 tiqitFilterInit("results");101 tiqitFilterInit("results");
99 tiqitTableInit("results", true, true);102 tiqitTableInit("results", true, true);
103 generateCustomEvent('ResultsLoad', document.getElementsByTagName('table'));
100 }104 }
101 tiqitSearchName = "%s";105 tiqitSearchName = "%s";
102 tiqitSearchQuery = %s;106 tiqitSearchQuery = %s;
@@ -217,7 +221,7 @@
217 printTableHeader(prikey, tableNameCounter)221 printTableHeader(prikey, tableNameCounter)
218222
219 # We'll be adding attributes to each row, so get the names once223 # We'll be adding attributes to each row, so get the names once
220 attr_names = [x.name for x in parents]224 attr_names = [x.name for x in attr_fields]
221225
222 for bug in matches:226 for bug in matches:
223 # Check whether we need to start a new table227 # Check whether we need to start a new table
@@ -232,11 +236,11 @@
232 # Construct the parent list. All parents should be there as236 # Construct the parent list. All parents should be there as
233 # attributes whether their values are empty or not237 # attributes whether their values are empty or not
234 # 238 #
235 attr_values = ["'%s'" % encodeHTML(bug[x.name]) for x in parents]239 attr_values = ["'%s'" % encodeHTML(bug[x.name]) for x in attr_fields]
236 attributes = map("=".join, zip(attr_names, attr_values))240 attributes = map("=".join, zip(attr_names, attr_values))
237241
238 pretty_vals = [bug.getSanitisedValue(x.name, outputType == FORMAT_NORMAL) for x in selection]242 pretty_vals = [bug.getSanitisedValue(x.name, outputType == FORMAT_NORMAL) for x in selection]
239243
240 print "<tr id='%s' lastupdate='%s'%s><td>%s</td></tr>" % (bug['Identifier'], bug['Sys-Last-Updated'], " ".join(attributes), "</td><td>".join(pretty_vals))244 print "<tr id='%s' lastupdate='%s'%s><td>%s</td></tr>" % (bug['Identifier'], bug['Sys-Last-Updated'], " ".join(attributes), "</td><td>".join(pretty_vals))
241245
242 printTableFooter()246 printTableFooter()
243247
=== modified file 'static/scripts/multiedit.js'
--- static/scripts/multiedit.js 2014-06-05 14:38:53 +0000
+++ static/scripts/multiedit.js 2015-12-01 12:30:39 +0000
@@ -42,25 +42,28 @@
42 }42 }
43 }43 }
4444
45 // Add a double click event handler45 // Add a double click event handler unless disabled in preferences
46 tables[i].addEventListener('dblclick', function(event) {46 if (Tiqit.prefs['miscDisableDblclkEdit'] == undefined ||
47 var cell = getAncestorOfType(event.target, 'TD');47 Tiqit.prefs['miscDisableDblclkEdit'] == 'false') {
48 if (cell) {48 tables[i].addEventListener('dblclick', function(event) {
49 var row = getAncestorOfType(cell, 'TR');49 var cell = getAncestorOfType(event.target, 'TD');
50 if (!row.tiqitSaving) {50 if (cell) {
51 var table = getAncestorOfType(row, 'TABLE');51 var row = getAncestorOfType(cell, 'TR');
52 var colIndex = cell.cellIndex;52 if (!row.tiqitSaving) {
53 var field = table.tHead.rows[0].cells[colIndex].getAttribute('field');53 var table = getAncestorOfType(row, 'TABLE');
54 if (contains(allEditableFields, field)) {54 var colIndex = cell.cellIndex;
55 if (cell.tiqitEditing) {55 var field = table.tHead.rows[0].cells[colIndex].getAttribute('field');
56 stopEditingCell(row, cell, field);56 if (contains(allEditableFields, field)) {
57 } else {57 if (cell.tiqitEditing) {
58 startEditingCell(row, cell, field);58 stopEditingCell(row, cell, field);
59 } else {
60 startEditingCell(row, cell, field);
61 }
59 }62 }
60 }63 }
61 }64 }
62 }65 }, false);
63 }, false);66 }
64 }67 }
65}68}
6669
@@ -213,12 +216,17 @@
213 if (event.target.status == 200 && event.target.responseXML) {216 if (event.target.status == 200 && event.target.responseXML) {
214 var bugs = event.target.responseXML.getElementsByTagName('bug');217 var bugs = event.target.responseXML.getElementsByTagName('bug');
215 for (var i = 0; i < bugs.length; i++) {218 for (var i = 0; i < bugs.length; i++) {
219 var attributesChanged = false;
216 var row = document.getElementById(bugs[i].getAttribute('identifier'));220 var row = document.getElementById(bugs[i].getAttribute('identifier'));
217 var table = getAncestorOfType(row, 'TABLE');221 var table = getAncestorOfType(row, 'TABLE');
218 var fields = event.target.responseXML.getElementsByTagName('field');222 var fields = event.target.responseXML.getElementsByTagName('field');
219 cancelRowSave(row);223 cancelRowSave(row);
220 row.setAttribute('lastupdate', bugs[i].getAttribute('lastupdate'));224 row.setAttribute('lastupdate', bugs[i].getAttribute('lastupdate'));
221 for (var j = 0; j < fields.length; j++) {225 for (var j = 0; j < fields.length; j++) {
226 if (row.hasAttribute(fields[j].getAttribute('name'))) {
227 row.setAttribute(fields[j].getAttribute('name'), fields[j].textContent.trim());
228 attributesChanged = true;
229 }
222 for (var k = 0; k < table.tHead.rows[0].cells.length; k++) {230 for (var k = 0; k < table.tHead.rows[0].cells.length; k++) {
223 var head = table.tHead.rows[0].cells[k];231 var head = table.tHead.rows[0].cells[k];
224 var field = head.getAttribute('field');232 var field = head.getAttribute('field');
@@ -245,6 +253,9 @@
245 }253 }
246 }254 }
247 }255 }
256 if (attributesChanged) {
257 generateCustomEvent("AttributesChanged", row);
258 }
248 }259 }
249 } else if (event.target.responseXML) {260 } else if (event.target.responseXML) {
250 var msgs = event.target.responseXML.getElementsByTagName('message');261 var msgs = event.target.responseXML.getElementsByTagName('message');
251262
=== modified file 'static/scripts/updateresults.js'
--- static/scripts/updateresults.js 2014-06-05 14:38:53 +0000
+++ static/scripts/updateresults.js 2015-12-01 12:30:39 +0000
@@ -289,12 +289,14 @@
289 var fields = bugs[i].getElementsByTagName('field');289 var fields = bugs[i].getElementsByTagName('field');
290290
291 if (oldLine) {291 if (oldLine) {
292 var attributesChanged = false;
292 for (var j = 0; j < fields.length; j++) {293 for (var j = 0; j < fields.length; j++) {
293 var field = fields[j].getAttribute('name');294 var field = fields[j].getAttribute('name');
294 var colIndex = colForField(field);295 var colIndex = colForField(field);
295 // If there is an attribute for this field, then update it.296 // If there is an attribute for this field, then update it.
296 if (oldLine.hasAttribute(field)) {297 if (oldLine.hasAttribute(field)) {
297 oldLine.setAttribute(field, fields[j].textContent.trim());298 attributesChanged = true;
299 oldLine.setAttribute(field, fields[j].textContent.trim());
298 }300 }
299 301
300 // Now check whether this field is displayed302 // Now check whether this field is displayed
@@ -421,6 +423,9 @@
421 oldLine.style.outline = 'solid red 2px';423 oldLine.style.outline = 'solid red 2px';
422 oldLine.style.backgroundColor = 'rgb(255, 240, 220)';424 oldLine.style.backgroundColor = 'rgb(255, 240, 220)';
423 }425 }
426 if (attributesChanged) {
427 generateCustomEvent("AttributesChanged", oldLine);
428 }
424 } else {429 } else {
425 // This is a brand new bug. Add a new line for it.430 // This is a brand new bug. Add a new line for it.
426 // We'll re-filter and group at the end, so just stick it in first431 // We'll re-filter and group at the end, so just stick it in first

Subscribers

People subscribed via source and target branches