[hg] galaxy 1647: allow users to specify that label for input da...
details: http://www.bx.psu.edu/hg/galaxy/rev/15bf910890d5 changeset: 1647:15bf910890d5 user: James Taylor <james@jamestaylor.org> date: Tue Dec 02 17:17:23 2008 -0500 description: allow users to specify that label for input dataset modules. 4 file(s) affected in this change: lib/galaxy/web/controllers/workflow.py lib/galaxy/workflow/modules.py templates/workflow/editor_generic_form.mako templates/workflow/editor_tool_form.mako diffs (140 lines): diff -r f242b5a3fedc -r 15bf910890d5 lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py Tue Dec 02 13:49:32 2008 -0500 +++ b/lib/galaxy/web/controllers/workflow.py Tue Dec 02 17:17:23 2008 -0500 @@ -166,7 +166,7 @@ return trans.fill_template( "workflow/editor.mako", workflow_id=id ) @web.json - def editor_tool_form( self, trans, type='tool', tool_id=None, **incoming ): + def editor_form_post( self, trans, type='tool', tool_id=None, **incoming ): """ Accepts a tool state and incoming values, and generates a new tool form and some additional information, packed into a json dictionary. diff -r f242b5a3fedc -r 15bf910890d5 lib/galaxy/workflow/modules.py --- a/lib/galaxy/workflow/modules.py Tue Dec 02 13:49:32 2008 -0500 +++ b/lib/galaxy/workflow/modules.py Tue Dec 02 17:17:23 2008 -0500 @@ -5,6 +5,7 @@ from galaxy.tools import DefaultToolState from galaxy.tools.parameters.grouping import Repeat, Conditional from galaxy.util.bunch import Bunch +from galaxy.util.json import from_json_string, to_json_string class WorkflowModule( object ): @@ -78,20 +79,48 @@ class InputDataModule( WorkflowModule ): type = "data_input" name = "Input dataset" - _runtime_inputs = { - 'input' : DataToolParameter( None, Element( "param", name="input", label="Input Dataset", type="data", format="data" ) ) - } - + + @classmethod + def new( Class, trans, tool_id=None ): + module = Class( trans ) + module.state = dict( name="Input Dataset" ) + return module + @classmethod + def from_dict( Class, trans, d ): + module = Class( trans ) + state = from_json_string( d["tool_state"] ) + module.state = dict( name=state.get( "name", "Input Dataset" ) ) + return module + @classmethod + def from_workflow_step( Class, trans, step ): + module = Class( trans ) + module.state = dict( name="Input Dataset" ) + if step.tool_inputs and "name" in step.tool_inputs: + module.state['name'] = step.tool_inputs[ 'name' ] + return module + def save_to_step( self, step ): + step.type = self.type + step.tool_id = None + step.tool_inputs = self.state + def get_data_inputs( self ): return [] def get_data_outputs( self ): return [ dict( name='output', extension='input' ) ] def get_config_form( self ): + form = web.FormBuilder( title=self.name ) \ + .add_text( "name", "Name", value=self.state['name'] ) return self.trans.fill_template( "workflow/editor_generic_form.mako", - form = web.FormBuilder( title=self.name ) ) + module=self, form=form ) + def get_state( self ): + return to_json_string( self.state ) + + def update_state( self, incoming ): + self.state['name'] = incoming.get( 'name', 'Input Dataset' ) def get_runtime_inputs( self ): - return self._runtime_inputs + label = self.state.get( "name", "Input Dataset" ) + return dict( input=DataToolParameter( None, Element( "param", name="input", label=label, type="data", format="data" ) ) ) def get_runtime_state( self ): state = DefaultToolState() state.inputs = dict( input=None ) @@ -106,7 +135,7 @@ return state def update_runtime_state( self, trans, state, values ): errors = {} - for name, param in self._runtime_inputs.iteritems(): + for name, param in self.get_runtime_inputs().iteritems(): value, error = check_param( trans, param, values.get( name, None ), values ) state.inputs[ name ] = value if error: @@ -146,7 +175,6 @@ tool_id = step.tool_id module = Class( trans, tool_id ) module.state = DefaultToolState() - print step.tool_inputs module.state.inputs = module.tool.params_from_strings( step.tool_inputs, trans.app, ignore_errors=True ) module.errors = step.tool_errors return module @@ -229,4 +257,4 @@ type = step.type return self.module_types[type].from_workflow_step( trans, step ) -module_factory = WorkflowModuleFactory( dict( data_input=InputDataModule, tool=ToolModule ) ) \ No newline at end of file +module_factory = WorkflowModuleFactory( dict( data_input=InputDataModule, tool=ToolModule ) ) diff -r f242b5a3fedc -r 15bf910890d5 templates/workflow/editor_generic_form.mako --- a/templates/workflow/editor_generic_form.mako Tue Dec 02 13:49:32 2008 -0500 +++ b/templates/workflow/editor_generic_form.mako Tue Dec 02 17:17:23 2008 -0500 @@ -1,8 +1,8 @@ <div class="toolForm"> <div class="toolFormTitle">${form.title}</div> <div class="toolFormBody"> - <form name="$form.name" action="${h.url_for(form.action)}" method="post"> - <table cellpadding="0" cellspacing="0" border="0"> + <form name="${form.name}" action="${h.url_for( action='editor_form_post' )}" method="post"> + <input type="hidden" name="type" value="${module.type}" /> %if form.inputs: %for input in form.inputs: <% @@ -33,9 +33,9 @@ </div> %endfor - <tr><td></td><td><input type="submit" value="${form.submit_text}"> + <div class="form-row"><input type="submit" value="${form.submit_text}"></div> %else: - <tr><td colspan="2"><i>No options</i></td></tr> + <div class="form-row"><i>No options</i></div> %endif </table> </form> diff -r f242b5a3fedc -r 15bf910890d5 templates/workflow/editor_tool_form.mako --- a/templates/workflow/editor_tool_form.mako Tue Dec 02 13:49:32 2008 -0500 +++ b/templates/workflow/editor_tool_form.mako Tue Dec 02 17:17:23 2008 -0500 @@ -56,7 +56,7 @@ <div class="toolForm"> <div class="toolFormTitle">Tool: ${tool.name}</div> <div class="toolFormBody"> - <form method="get" action="${h.url_for( action='editor_tool_form' )}"> + <form method="post" action="${h.url_for( action='editor_form_post' )}"> <input type="hidden" name="tool_id" value="${tool.id}" /> %for i, inputs in enumerate( tool.inputs_by_page ): %if tool.has_multiple_pages:
participants (1)
-
Nate Coraor