[hg] galaxy 1486: Between page reloads, Drill Down parameter typ...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[hg] galaxy 1486: Between page reloads, Drill Down parameter typ...

greg
details:   http://www.bx.psu.edu/hg/galaxy/rev/9e956e7b738f
changeset: 1486:9e956e7b738f
user:      Dan Blankenberg <[hidden email]>
date:      Wed Aug 27 16:36:41 2008 -0400
description:
Between page reloads, Drill Down parameter type will now keep parent nodes expanded when a descendant is selected.

3 file(s) affected in this change:

lib/galaxy/tools/parameters/basic.py
lib/galaxy/web/form_builder.py
templates/tool_form.tmpl

diffs (142 lines):

diff -r 19c03a96b338 -r 9e956e7b738f lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py Wed Aug 27 15:51:59 2008 -0400
+++ b/lib/galaxy/tools/parameters/basic.py Wed Aug 27 16:36:41 2008 -0400
@@ -729,13 +729,13 @@
     >>> print p.get_html()
     <div><ul class="toolParameterExpandableCollapsable">
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="checkbox" name="some_name" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="checkbox" name="some_name" value="option1"">Option 1
     </li>
     <li><input type="checkbox" name="some_name" value="option2"">Option 2
     </li>
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="checkbox" name="some_name" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="checkbox" name="some_name" value="option3"">Option 3
     </li>
     <li><input type="checkbox" name="some_name" value="option4"">Option 4
@@ -766,13 +766,13 @@
     >>> print p.get_html()
     <div><ul class="toolParameterExpandableCollapsable">
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="radio" name="some_name" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="radio" name="some_name" value="option1"">Option 1
     </li>
     <li><input type="radio" name="some_name" value="option2"">Option 2
     </li>
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="radio" name="some_name" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="radio" name="some_name" value="option3"">Option 3
     </li>
     <li><input type="radio" name="some_name" value="option4"">Option 4
diff -r 19c03a96b338 -r 9e956e7b738f lib/galaxy/web/form_builder.py
--- a/lib/galaxy/web/form_builder.py Wed Aug 27 15:51:59 2008 -0400
+++ b/lib/galaxy/web/form_builder.py Wed Aug 27 16:36:41 2008 -0400
@@ -203,13 +203,13 @@
     >>> print t.get_html()
     <div><ul class="toolParameterExpandableCollapsable">
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="checkbox" name="foo" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="checkbox" name="foo" value="option1"">Option 1
     </li>
     <li><input type="checkbox" name="foo" value="option2"">Option 2
     </li>
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="checkbox" name="foo" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="checkbox" name="foo" value="option3"">Option 3
     </li>
     <li><input type="checkbox" name="foo" value="option4"">Option 4
@@ -225,13 +225,13 @@
     >>> print t.get_html()
     <div><ul class="toolParameterExpandableCollapsable">
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="radio" name="foo" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="radio" name="foo" value="option1"">Option 1
     </li>
     <li><input type="radio" name="foo" value="option2"">Option 2
     </li>
     <li><span class="toolParameterExpandableCollapsable">[+]</span><input type="radio" name="foo" value="heading1"">Heading 1
-    <ul class="toolParameterExpandableCollapsable">
+    <ul class="toolParameterExpandableCollapsable" default_state="collapsed">
     <li><input type="radio" name="foo" value="option3"">Option 3
     </li>
     <li><input type="radio" name="foo" value="option4"">Option 4
@@ -266,22 +266,36 @@
         else:
             self.refresh_on_change_text = ''
     def get_html( self, prefix="" ):
-        def recurse_options( html, options ):
+        def find_expanded_options( expanded_options, options, parent_options = [] ):
+            for option in options:
+                if option['value'] in self.value:
+                    expanded_options.extend( parent_options )
+                if option['options']:
+                    new_parents = list( parent_options ) + [ option['value'] ]
+                    find_expanded_options( expanded_options, option['options'], new_parents )
+        def recurse_options( html, options, expanded_options = [] ):
             for option in options:
                 selected = ( option['value'] in self.value )
                 if selected: selected = ' checked'
                 else: selected = ''
                 if option['options']:
-                    html.append( '<li><span class="toolParameterExpandableCollapsable">[+]</span><input type="%s" name="%s%s" value="%s"%s">%s' % ( self.display, prefix, self.name, option['value'], selected, option['name']) )
-                    html.append( '<ul class="toolParameterExpandableCollapsable">')
-                    recurse_options( html, option['options'] )
+                    default_state = 'collapsed'
+                    default_icon = '[+]'
+                    if option['value'] in expanded_options:
+                        default_state = 'expanded'
+                        default_icon = '[-]'
+                    html.append( '<li><span class="toolParameterExpandableCollapsable">%s</span><input type="%s" name="%s%s" value="%s"%s">%s' % ( default_icon, self.display, prefix, self.name, option['value'], selected, option['name']) )
+                    html.append( '<ul class="toolParameterExpandableCollapsable" default_state="%s">' % default_state )
+                    recurse_options( html, option['options'], expanded_options )
                     html.append( '</ul>')
                 else:
                     html.append( '<li><input type="%s" name="%s%s" value="%s"%s">%s' % ( self.display, prefix, self.name, option['value'], selected, option['name']) )
                 html.append( '</li>' )
         rval = []
         rval.append( '<div><ul class="toolParameterExpandableCollapsable">' )
-        recurse_options( rval, self.options )
+        expanded_options = []
+        find_expanded_options( expanded_options, self.options )
+        recurse_options( rval, self.options, expanded_options )
         rval.append( '</ul></div>' )
         return '\n'.join( rval )
 
diff -r 19c03a96b338 -r 9e956e7b738f templates/tool_form.tmpl
--- a/templates/tool_form.tmpl Wed Aug 27 15:51:59 2008 -0400
+++ b/templates/tool_form.tmpl Wed Aug 27 16:36:41 2008 -0400
@@ -126,7 +126,7 @@
         <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
         
     #else
-    
+        
           <div style="display: none;">
             #if $tool_state.page == $tool.last_page
             <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
@@ -142,7 +142,7 @@
             <input type="submit" class="primary-button" name="runtool_btn" value="Next step">
             #end if
           </div>    
-    
+        
     #end if    
 
   </form>
@@ -178,7 +178,7 @@
            }
        });
        \$( 'ul ul' ).each( function(i) {
-           if ( \$( this )[0].className == 'toolParameterExpandableCollapsable' )
+           if ( \$( this )[0].className == 'toolParameterExpandableCollapsable' && this.attributes.getNamedItem( 'default_state' ).value == 'collapsed' )
            {
                \$( this ).hide();
            }