← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~dooferlad/launchpad/upcomingwork-expand-all into lp:launchpad

 

James Tunnicliffe has proposed merging lp:~dooferlad/launchpad/upcomingwork-expand-all into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1002380 in Launchpad itself: "Upcoming Work view needs expand all link"
  https://bugs.launchpad.net/launchpad/+bug/1002380

For more details, see:
https://code.launchpad.net/~dooferlad/launchpad/upcomingwork-expand-all/+merge/107083

-- Summary
Feature Request: Upcoming work page should have expand all links. I also added collapse all and set back to default links since these seemed like logical extensions of the same feature (and likely to be requested if they weren’t present).

-- Proposed fix
Add JavaScript links to upcoming work view to expand / collapse / restore all work item lists for a blueprint.

-- Pre-implementation notes
None.

-- Implementation details
person-upcomingwork.pt updated with three new JS functions, one per link type. While initializing expanders, each expander object and its default state is stored in a new array, expanders[blueprint index][work item list index][expander object, default state]; This array is used to look up the required expanders when one of the links is selected.

-- LOC Rationale
Added a few lines because of new functionality. These will be more than offset by:
https://code.launchpad.net/~danilo/launchpad/kill-feedback-requests/+merge/106119

-- Tests
None. 

-- Demo and Q/A
1. In a dev instance run http://paste.ubuntu.com/992291/ to generate some work items
2. Visit https://launchpad.dev/~hwdb-team/+upcomingwork  and select the new links on the right hand side of the Blueprint column. If feeling adventurous you can create a new milestone for one of the blueprints that is within the next 60 days, but on a different day to the existing milestone and that will show up as a separate table. Links should only modify one table.

-- Lint
None.
-- 
https://code.launchpad.net/~dooferlad/launchpad/upcomingwork-expand-all/+merge/107083
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~dooferlad/launchpad/upcomingwork-expand-all into lp:launchpad.
=== modified file 'lib/lp/registry/templates/person-upcomingwork.pt'
--- lib/lp/registry/templates/person-upcomingwork.pt	2012-05-21 19:40:33 +0000
+++ lib/lp/registry/templates/person-upcomingwork.pt	2012-05-23 17:24:25 +0000
@@ -12,6 +12,8 @@
     <script type="text/javascript">
       LPJS.use('node', 'event', 'lp.app.widgets.expander', function(Y) {
           Y.on('domready', function() {
+            var expanders = new Array();
+
             Y.all('[class=expandable]').each(function(e) {
               var expander_icon = e.one('[class=expander]');
               // Our parent's first sibling is the tbody we want to collapse.
@@ -19,7 +21,41 @@
               var expander = new Y.lp.app.widgets.expander.Expander(
                   expander_icon, widget_body);
               expander.setUp(true);
-            })
+
+              var index = e.ancestor('[class=workitems-group]').get('id');
+
+              // We record the expanders so we can reference them later
+              // First we have an array indexed by each milestone
+              if (expanders[index] === undefined){
+                expanders[index] = new Array();
+              }
+
+              // For each milestone, store an array containing the expander
+              // object and the default state for it
+              expanders[index].push(new Array(expander,
+                                              widget_body.hasClass('default-expanded')));
+            });
+
+            Y.all('.expandall_link').on("click", function(link){
+              var index = link.currentTarget.get('id');
+              Y.Array.forEach(expanders[index], function(expander, i){
+                expander[0].render(true, false);
+              });
+            });
+
+            Y.all('.collapseall_link').on("click", function(link){
+              var index = link.currentTarget.get('id');
+              Y.Array.forEach(expanders[index], function(expander, i){
+                expander[0].render(false, false);
+              });
+            });
+
+            Y.all('.defaultall_link').on("click", function(link){
+              var index = link.currentTarget.get('id');
+              Y.Array.forEach(expanders[index], function(expander, i){
+                expander[0].render(expander[1], false);
+              });
+            });
           })
         });
     </script>
@@ -38,7 +74,8 @@
 
 <div metal:fill-slot="main">
 
-  <div tal:repeat="pair view/work_item_containers" class="workitems-group">
+  <div tal:repeat="pair view/work_item_containers" class="workitems-group"
+       tal:attributes="id string:milestone_${repeat/pair/index}">
   <div tal:define="date python: pair[0]; containers python: pair[1]">
     <h2>Work items due in <span tal:replace="date/fmt:date" /></h2>
 
@@ -78,7 +115,16 @@
     <table class="listing">
       <thead>
       <tr>
-        <th>Blueprint</th>
+        <th>Blueprint
+          <div style="float: right; font-weight: normal;">
+            All: <a href="#expandall" class="expandall_link"
+                           tal:attributes="id string:milestone_${repeat/pair/index}">Expand</a>
+            <a href="#collapseall" class="collapseall_link"
+               tal:attributes="id string:milestone_${repeat/pair/index}">Collapse</a>
+            <a href="#defaultall" class="defaultall_link"
+            tal:attributes="id string:milestone_${repeat/pair/index}">Default</a>
+        </div>
+        </th>
         <th>Target</th>
         <th>Assignee</th>
         <th>Priority</th>
@@ -111,13 +157,15 @@
 
       <tal:conditional condition="container/has_incomplete_work">
         <tal:block define="global upcoming_work_class_name string:expanded"/>
+        <tal:block define="global expander_init_state string:default-expanded"/>
       </tal:conditional>
 
       <tal:conditional condition="not: container/has_incomplete_work">
         <tal:block define="global upcoming_work_class_name string:"/>
+        <tal:block define="global expander_init_state string:default-collapsed"/>
       </tal:conditional>
 
-      <tbody tal:attributes="class string:collapsible-body ${upcoming_work_class_name}">
+      <tbody tal:attributes="class string:collapsible-body ${upcoming_work_class_name} ${expander_init_state}">
         <tr tal:repeat="workitem container/items" class="padded">
           <td>
             <span tal:condition="not: container/spec|nothing"


Follow ups