Merge lp:~dooferlad/launchpad/upcomingwork_show_incomplete_bp into lp:launchpad

Proposed by James Tunnicliffe on 2012-05-15
Status: Superseded
Proposed branch: lp:~dooferlad/launchpad/upcomingwork_show_incomplete_bp
Merge into: lp:launchpad
Diff against target: 58 lines (+25/-1)
3 files modified
lib/lp/registry/browser/person.py (+5/-0)
lib/lp/registry/browser/tests/test_person_upcomingwork.py (+10/-0)
lib/lp/registry/templates/person-upcomingwork.pt (+10/-1)
To merge this branch: bzr merge lp:~dooferlad/launchpad/upcomingwork_show_incomplete_bp
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Resubmit on 2012-05-17
Graham Binns (community) 2012-05-15 Needs Fixing on 2012-05-17
Review via email: mp+105846@code.launchpad.net

This proposal has been superseded by a proposal from 2012-05-18.

Description of the Change

The upcomingwork view shows blueprints that a team or individual is working on. Currently all blueprint work items start in the collapsed view, but we have had a request to have incomplete blueprints to be initially expanded.

This change adds an alt tag to the percentage complete image as well as a title, so it can be reliably found in the DOM and the information encoded in the alt tag used to find if a blueprint is complete or not. Of course, this has a pleasing side-effect of making the page more accessible.

To post a comment you must log in.
Graham Binns (gmb) wrote :

Hi James,

As mentioned on IRC the other day, I think a better way to do this is to work out whether or not the expander should be open on the server rather than doing it all in the JS. I've created a branch for this solution here: lp:~gmb/launchpad/upcomingwork_show_incomplete_bp - feel free to merge it into your branch.

I'm not hugely familiar with work items, so I don't know how to do QA on my solution (I can't seem to make items appear in the +upcomingwork view on launchpad.dev, no matter what I try). Please let me know if my solution's not working.

We also need to find something to remove from the LP codebase if we're going to land this, or we need to get it blessed as feature work by lifeless or flacoste. I'll look into the possible options.

Cheers,

Graham

review: Needs Fixing
James Tunnicliffe (dooferlad) wrote :

OK, have tested locally and got back to just your fix, so I hope you like it!

review: Resubmit
James Tunnicliffe (dooferlad) wrote :

Just trying to QA with more complex page on a clean checkout and I see the expander sprite (arrow picture) isn't there. Will attempt to track down.

James Tunnicliffe (dooferlad) wrote :

Ah, seems to be class="expander expanded" is causing problems. Will chase down a solution.

James Tunnicliffe (dooferlad) wrote :

Humm, would be because the JavaScript that adds the expander arrow looks for class="expander", so it would need a second search, if that one failed, to find class="expander expanded" and then do something different. What I think should be done is, if possible, add the CSS attribute that (if memory serves) is how the expander class knows if it is expanded or not in the template.

James Tunnicliffe (dooferlad) wrote :

Got it, but not a solution. <tbody class="collapsible-body"> needs to be <tbody class="collapsible-body expanded"> for elements that start open, but due to the fact that the template must be valid XML I can't do something like this:

<tbody class="collapsible-body"
       tal:condition="not: container/has_incomplete_work">
<tbody class="collapsible-body expanded"
       tal:condition="container/has_incomplete_work">

Still hunting...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/person.py'
2--- lib/lp/registry/browser/person.py 2012-05-07 16:43:13 +0000
3+++ lib/lp/registry/browser/person.py 2012-05-18 17:08:19 +0000
4@@ -4520,6 +4520,11 @@
5 return '{0:.0f}'.format(
6 100.0 * len(self.done_items) / len(self._items))
7
8+ @property
9+ def has_incomplete_work(self):
10+ """Return True if there are incomplete work items."""
11+ return len(self.done_items) < len(self._items)
12+
13 def append(self, item):
14 self._items.append(item)
15
16
17=== modified file 'lib/lp/registry/browser/tests/test_person_upcomingwork.py'
18--- lib/lp/registry/browser/tests/test_person_upcomingwork.py 2012-04-05 13:49:54 +0000
19+++ lib/lp/registry/browser/tests/test_person_upcomingwork.py 2012-05-18 17:08:19 +0000
20@@ -173,6 +173,16 @@
21 container.append(self.MockWorkItem(True))
22 self.assertEqual('67', container.percent_done)
23
24+ def test_has_incomplete_work(self):
25+ # If there are incomplete work items,
26+ # WorkItemContainer.has_incomplete_work will return True.
27+ container = WorkItemContainer()
28+ item = self.MockWorkItem(False)
29+ container.append(item)
30+ self.assertTrue(container.has_incomplete_work)
31+ item.is_complete = True
32+ self.assertFalse(container.has_incomplete_work)
33+
34
35 class TestPersonUpcomingWork(BrowserTestCase):
36
37
38=== modified file 'lib/lp/registry/templates/person-upcomingwork.pt'
39--- lib/lp/registry/templates/person-upcomingwork.pt 2012-04-05 13:45:31 +0000
40+++ lib/lp/registry/templates/person-upcomingwork.pt 2012-05-18 17:08:19 +0000
41@@ -108,7 +108,16 @@
42 </td>
43 </tr>
44 </tbody>
45- <tbody class="collapsible-body">
46+
47+ <tal:conditional condition="container/has_incomplete_work">
48+ <div tal:define="global classname string:expanded"/>
49+ </tal:conditional>
50+
51+ <tal:conditional condition="not: container/has_incomplete_work">
52+ <div tal:define="global classname string:"/>
53+ </tal:conditional>
54+
55+ <tbody tal:attributes="class string:collapsible-body ${classname}">
56 <tr tal:repeat="workitem container/items" class="padded">
57 <td>
58 <span tal:condition="not: container/spec|nothing"