Merge lp:~matthew-constable/tiqit/tiqit into lp:tiqit

Proposed by Matthew Constable
Status: Needs review
Proposed branch: lp:~matthew-constable/tiqit/tiqit
Merge into: lp:tiqit
Diff against target: 67 lines (+35/-0)
2 files modified
static/scripts/coledit.js (+4/-0)
static/scripts/results.js (+31/-0)
To merge this branch: bzr merge lp:~matthew-constable/tiqit/tiqit
Reviewer Review Type Date Requested Status
Matthew Hall Needs Fixing
Review via email: mp+278934@code.launchpad.net

Description of the change

Enhanced coledit.js and results.js to produce the correct URL in the taskbar (and history) when a column is added/removed on a results page.

To post a comment you must log in.
Revision history for this message
Matthew Hall (matt.hall) wrote :

This is a good change, but unfortunately there's currently inconsistent behaviour displayed when search results are grouped by one of the fields.

* When a column is added using the buttons above any group, it is added to all groups and the URL updated. I think this is fine.

* When a column is removed using the buttons above any group but the first, it is removed from only that group and the URL isn't updated. The existing behaviour of the group isn't ideal, but at least your new URL handling is being consistent with it.

* When a column is remove using the buttons above the first group, it is removed from only that group and the URL *is* updated. Again, the existing grouping behavior arguably isn't ideal, but now there's also an inconsistency between the union of all columns displayed on the page and the columns listed in the URL.

We either need to avoid updating the URL when removing a column from the first group, or change the grouping behavior so that removing a column always affects all groups.

review: Needs Fixing

Unmerged revisions

6. By Matthew Constable <email address hidden>

Enhanced coledit.js and results.js to produce the correct URL in the taskbar (and history) when a column is added/removed on a results page.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'static/scripts/coledit.js' (properties changed: -x to +x)
2--- static/scripts/coledit.js 2014-06-05 14:38:53 +0000
3+++ static/scripts/coledit.js 2015-11-30 09:54:32 +0000
4@@ -113,6 +113,7 @@
5 // - Do some magic to make the auto-updater know about the new field
6 // - Force a background reload to get the first info
7 // - Suppress initial diffs for this col (but only this col)
8+ // - Update the URL
9
10 var tables = getTables('results');
11 var newIndex = -1;
12@@ -165,6 +166,7 @@
13 tgt.tableName = 'results';
14 generateCustomEvent('NewCol', tgt);
15
16+ updateURL();
17 refreshNow();
18 }
19 }
20@@ -194,6 +196,8 @@
21 for (var i = 0; i < table.rows.length; i++) {
22 table.rows[i].cells[colIndex].style.display = display;
23 }
24+
25+ updateURL();
26 }
27
28 function tiqitColMoveUp(event) {
29
30=== modified file 'static/scripts/results.js' (properties changed: -x to +x)
31--- static/scripts/results.js 2014-06-05 14:38:53 +0000
32+++ static/scripts/results.js 2015-11-30 09:54:32 +0000
33@@ -176,3 +176,34 @@
34
35 document.location.href = 'search?buglist=' + bugs.join(',');
36 }
37+
38+//
39+// Update URL (if columns on display are changed by the user for instance)
40+//
41+
42+function updateURL() {
43+ var local_table = getTables('results')[0];
44+ var sel_count = 1;
45+ var selections = tiqitSearchQuery.match(/(selection\d+=[\w\s-]+)/g);
46+ var split_url = tiqitSearchQuery.split("&");
47+
48+ for (var k in selections) {
49+ var temp_idx = split_url.indexOf(selections[k]);
50+ split_url.splice(temp_idx, 1);
51+ }
52+
53+ for (var k = 0; k < local_table.tHead.rows[0].cells.length; k++) {
54+ var head = local_table.tHead.rows[0].cells[k];
55+ var field = head.getAttribute('field');
56+
57+ // Don't want to display hidden fields.
58+ if (field && (head.style.display != "none")) {
59+ var temp_selection = "selection" + sel_count + "=" + field;
60+ split_url.push(temp_selection);
61+ sel_count++;
62+ }
63+ }
64+ var new_url = document.baseURI + "results?" + split_url.join("&");
65+
66+ history.replaceState(null, null, new_url);
67+}

Subscribers

People subscribed via source and target branches