# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1290028751 18000 # Node ID c4441790bfaae82d4e84ad11ec58cea7715ea6ef # Parent 29227c9c599292f7608e61cdd4b2be424b7a7bfc Fixed naming of the library selectfield for sample operations Fixed the broken popup menu in the data transfer grid Fixed the missing required/optional field info in the request form --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1584,7 +1584,7 @@ class FormDefinition( object ): if field[ 'helptext' ]: helptext='%s (%s)' % ( field[ 'helptext' ], req ) else: - helptext = '' + helptext = '(%s)' % req widgets.append( dict( label=field[ 'label' ], widget=field_widget, helptext=helptext ) ) --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -185,7 +185,7 @@ class RequestsCommon( BaseController, Us if request_type is not None or status == 'error': # Either the user selected a request_type or an error exists on the form. if is_admin: - if not user_id_encoded: + if not user_id_encoded and user: selected_user_id = trans.security.encode_id( user.id ) else: selected_user_id = user_id @@ -465,7 +465,7 @@ class RequestsCommon( BaseController, Us sample_copy = self.__build_copy_sample_select_field( trans, displayable_sample_widgets ) libraries_select_field, folders_select_field = self.__build_library_and_folder_select_fields( trans, request.user, - 0, + 'sample_operation', libraries, None, **kwd ) @@ -810,7 +810,6 @@ class RequestsCommon( BaseController, Us # See if the user has selected a sample to copy. copy_sample_index = int( params.get( 'copy_sample_index', -1 ) ) for index in range( num_samples_to_add ): - id_index = len( displayable_sample_widgets ) + 1 if copy_sample_index != -1: # The user has selected a sample to copy. library_id = displayable_sample_widgets[ copy_sample_index][ 'library_select_field' ].get_selected( return_value=True ) @@ -826,7 +825,7 @@ class RequestsCommon( BaseController, Us # Build the library_select_field and folder_select_field for the new sample being added. library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans, user=request.user, - sample_index=id_index, + sample_index=len( displayable_sample_widgets ), libraries=libraries, sample=None, library_id=library_id, @@ -1080,13 +1079,8 @@ class RequestsCommon( BaseController, Us action='update_request_state', request_id=trans.security.encode_id( request.id ) ) ) elif sample_operation == trans.model.Sample.bulk_operations.SELECT_LIBRARY: - # TODO: fix the code so that the sample_operation_select_field does not use - # sample_0_library_id as it's name. it should use something like sample_operation_library_id - # and sample_operation_folder_id because the name sample_0_library_id should belong to the - # first sample since all other form field values are named like this. The library and folder - # are skewed to be named +1 resulting in the forced use of id_index everywhere... - library_id = params.get( 'sample_0_library_id', 'none' ) - folder_id = params.get( 'sample_0_folder_id', 'none' ) + library_id = params.get( 'sample_operation_library_id', 'none' ) + folder_id = params.get( 'sample_operation_folder_id', 'none' ) library, folder = self.__get_library_and_folder( trans, library_id, folder_id ) for sample_index in range( len( samples ) ): current_sample = samples[ sample_index ] @@ -1254,15 +1248,14 @@ class RequestsCommon( BaseController, Us if sample_operation != 'none': # The sample_operatin param has a value other than 'none', and a specified # set of samples was received. - library_id = util.restore_text( params.get( 'sample_0_library_id', 'none' ) ) - folder_id = util.restore_text( params.get( 'sample_0_folder_id', 'none' ) ) + library_id = util.restore_text( params.get( 'sample_operation_library_id', 'none' ) ) + folder_id = util.restore_text( params.get( 'sample_operation_folder_id', 'none' ) ) # Build the list of widgets which will be used to render each sample row on the request page if not request: return sample_widgets libraries = trans.app.security_agent.get_accessible_libraries( trans, request.user ) # Build the list if sample widgets, populating the values from kwd. for index, sample in enumerate( samples ): - id_index = index + 1 if sample is None: # Use the sample from the request object since it will not have updated values from kwd. sample = request.samples[ index ] @@ -1277,10 +1270,10 @@ class RequestsCommon( BaseController, Us sample_id = None name = util.restore_text( params.get( 'sample_%i_name' % index, sample.name ) ) bar_code = util.restore_text( params.get( 'sample_%i_bar_code' % index, sample.bar_code ) ) - library_id = util.restore_text( params.get( 'sample_%i_library_id' % id_index, '' ) ) + library_id = util.restore_text( params.get( 'sample_%i_library_id' % index, '' ) ) if not library_id and sample.library: library_id = trans.security.encode_id( sample.library.id ) - folder_id = util.restore_text( params.get( 'sample_%i_folder_id' % id_index, '' ) ) + folder_id = util.restore_text( params.get( 'sample_%i_folder_id' % index, '' ) ) if not folder_id and sample.folder: folder_id = trans.security.encode_id( sample.folder.id ) library, folder = self.__get_library_and_folder( trans, library_id, folder_id ) @@ -1290,7 +1283,7 @@ class RequestsCommon( BaseController, Us field_values.append( field_value ) library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans=trans, user=request.user, - sample_index=id_index, + sample_index=index, libraries=libraries, sample=sample, library_id=library_id, @@ -1311,17 +1304,16 @@ class RequestsCommon( BaseController, Us name = util.restore_text( params.get( 'sample_%i_name' % index, '' ) ) if not name: break - id_index = index + 1 bar_code = util.restore_text( params.get( 'sample_%i_bar_code' % index, '' ) ) - library_id = util.restore_text( params.get( 'sample_%i_library_id' % id_index, '' ) ) - folder_id = util.restore_text( params.get( 'sample_%i_folder_id' % id_index, '' ) ) + library_id = util.restore_text( params.get( 'sample_%i_library_id' % index, '' ) ) + folder_id = util.restore_text( params.get( 'sample_%i_folder_id' % index, '' ) ) library, folder = self.__get_library_and_folder( trans, library_id, folder_id ) field_values = [] for field_index in range( len( request.type.sample_form.fields ) ): field_values.append( util.restore_text( params.get( 'sample_%i_field_%i' % ( index, field_index ), '' ) ) ) library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans=trans, user=request.user, - sample_index=id_index, + sample_index=index, libraries=libraries, sample=None, library_id=library_id, @@ -1376,8 +1368,13 @@ class RequestsCommon( BaseController, Us # not have ACCESS permissions associated with them (only LIBRARY_ADD, LIBRARY_MODIFY, LIBRARY_MANAGE), so all folders will # be present in the folder_select_field for each library selected. params = util.Params( kwd ) - library_select_field_name= "sample_%i_library_id" % sample_index - folder_select_field_name = "sample_%i_folder_id" % sample_index + if sample_index == 'sample_operation': + # build the library selection widget for the bulk sample operation + library_select_field_name= "sample_operation_library_id" + folder_select_field_name = "sample_operation_folder_id" + else: + library_select_field_name= "sample_%i_library_id" % sample_index + folder_select_field_name = "sample_%i_folder_id" % sample_index if not library_id: library_id = params.get( library_select_field_name, None ) if not folder_id: --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -127,17 +127,14 @@ class DataTransferGrid( grids.Grid ): operations = [ grids.GridOperation( "Transfer", allow_multiple=True, - condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ), - url_args=dict( webapp="galaxy" ) ), + condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ) ), grids.GridOperation( "Rename", allow_multiple=True, allow_popup=False, - condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ), - url_args=dict( webapp="galaxy" ) ), + condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ) ), grids.GridOperation( "Delete", allow_multiple=True, - condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ), - url_args=dict( webapp="galaxy" ) ) + condition=( lambda item: item.status in [ model.SampleDataset.transfer_status.NOT_STARTED ] ) ) ] def apply_query_filter( self, trans, query, **kwd ): sample_id = kwd.get( 'sample_id', None ) --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1571,10 +1571,9 @@ class TwillTestCase( unittest.TestCase ) self.check_page_for_string( check_str ) for sample_index, ( sample_name, target_library_info, sample_field_values ) in enumerate( sample_value_tuples ): tc.fv( "1", "sample_%i_name" % sample_index, sample_name ) - lib_widget_index = sample_index + 1 - tc.fv( "1", "sample_%i_library_id" % lib_widget_index, target_library_info[ 'library' ] ) - self.refresh_form( "sample_%i_library_id" % lib_widget_index, target_library_info[ 'library' ] ) - tc.fv( "1", "sample_%i_folder_id" % lib_widget_index, target_library_info[ 'folder' ] ) + tc.fv( "1", "sample_%i_library_id" % sample_index, target_library_info[ 'library' ] ) + self.refresh_form( "sample_%i_library_id" % sample_index, target_library_info[ 'library' ] ) + tc.fv( "1", "sample_%i_folder_id" % sample_index, target_library_info[ 'folder' ] ) for field_index, field_value in enumerate( sample_field_values ): tc.fv( "1", "sample_%i_field_%i" % ( sample_index, field_index ), field_value ) # Do not click on Add sample button when all the sample have been added @@ -1592,10 +1591,9 @@ class TwillTestCase( unittest.TestCase ) self.check_page_for_string( check_str ) for sample_index, ( sample_name, target_library_info, sample_field_values ) in enumerate( sample_value_tuples ): tc.fv( "1", "sample_%i_name" % sample_index, sample_name ) - lib_widget_index = sample_index + 1 - tc.fv( "1", "sample_%i_library_id" % lib_widget_index, target_library_info[ 'library' ] ) - self.refresh_form( "sample_%i_library_id" % lib_widget_index, target_library_info[ 'library' ] ) - tc.fv( "1", "sample_%i_folder_id" % lib_widget_index, target_library_info[ 'folder' ] ) + tc.fv( "1", "sample_%i_library_id" % sample_index, target_library_info[ 'library' ] ) + self.refresh_form( "sample_%i_library_id" % sample_index, target_library_info[ 'library' ] ) + tc.fv( "1", "sample_%i_folder_id" % sample_index, target_library_info[ 'folder' ] ) for field_index, field_value in enumerate( sample_field_values ): tc.fv( "1", "sample_%i_field_%i" % ( sample_index, field_index ), field_value ) tc.submit( "save_samples_button" ) @@ -1631,6 +1629,7 @@ class TwillTestCase( unittest.TestCase ) for sample_id in sample_ids: tc.fv( "1", "select_sample_%i" % sample_id, True ) tc.fv( "1", "sample_operation", 'Change state' ) + # refresh on change to show the sample states selectfield self.refresh_form( "sample_operation", 'Change state' ) self.check_page_for_string( "Change current state" ) tc.fv( "1", "sample_state_id", new_sample_state_id ) @@ -1646,12 +1645,15 @@ class TwillTestCase( unittest.TestCase ) for sample_id in sample_ids: tc.fv( "1", "select_sample_%i" % sample_id, True ) tc.fv( "1", "sample_operation", 'Select data library and folder' ) + # refresh on change to show the data libraries selectfield self.refresh_form( "sample_operation", 'Select data library and folder' ) self.check_page_for_string( "Select data library:" ) - tc.fv( "1", "sample_0_library_id", new_library_id ) - self.refresh_form( "sample_0_library_id", new_library_id ) + tc.fv( "1", "sample_operation_library_id", new_library_id ) + # refresh on change to show the selectfield with the list of + # folders in the selected data library above + self.refresh_form( "sample_operation_library_id", new_library_id ) self.check_page_for_string( "Select folder:" ) - tc.fv( "1", "sample_0_folder_id", new_folder_id ) + tc.fv( "1", "sample_operation_folder_id", new_folder_id ) tc.submit( "save_samples_button" ) for check_str in strings_displayed_after_submit: self.check_page_for_string( check_str ) --- a/templates/requests/common/view_request.mako +++ b/templates/requests/common/view_request.mako @@ -72,7 +72,7 @@ <div class="toolFormBody"><div class="form-row"><label>Current state:</label> - ${request.state} + <a href="${h.url_for( controller='requests_common', action='view_request_history', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">${request.state}</a><div style="clear: both"></div></div><div class="form-row"> @@ -100,11 +100,7 @@ %><div class="form-row"><label>${field_label}:</label> - %if field_label == 'State': - <a href="${h.url_for( controller='requests_common', action='view_request_history', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">${field_value}</a> - %else: - ${field_value} - %endif + ${field_value} </div><div style="clear: both"></div> %endfor --- a/templates/requests/common/common.mako +++ b/templates/requests/common/common.mako @@ -476,13 +476,7 @@ <th>Name</th> %for index, field in fields_dict.items(): <th> - ${field['label']} - ## TODO: help comments in the grid header are UGLY! - ## If they are needed display them more appropriately, - ## if they are not, delete this commented code. - ##<div class="toolParamHelp" style="clear: both;"> - ## <i>${field['helptext']}</i> - ##</div> + <a class="display tooltip" title="${field['helptext']}" >${field['label']}</a></th> %endfor <th></th>