1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/2573ac2b9c58/ changeset: 2573ac2b9c58 user: kanwei date: 2011-08-01 23:35:18 summary: LibraryDataset Parameter: - Now allows multiple dataset selection instead of just one. As a result, the ValueWrapper is now an iterator that iterates over each selected library dataset. - Move #templates method to become an attribute of LDDAs instead of a helper method in ValueWrapper. affected #: 5 files (1.6 KB) --- a/lib/galaxy/model/__init__.py Fri Jul 29 14:33:34 2011 -0400 +++ b/lib/galaxy/model/__init__.py Mon Aug 01 17:35:18 2011 -0400 @@ -4,7 +4,9 @@ Naming: try to use class names that have a distinct plural form so that the relationship cardinalities are obvious (e.g. prefer Dataset to Data) """ - +import pkg_resources +pkg_resources.require( "simplejson" ) +import simplejson import galaxy.datatypes from galaxy.util.bunch import Bunch from galaxy import util @@ -1415,6 +1417,22 @@ else: return template.get_widgets( trans.user ) return [] + def templates_dict( self ): + """ + Returns a dict of template info + """ + template_data = {} + for temp_info in self.info_association: + template = temp_info.template + content = temp_info.info.content + tmp_dict = {} + for field in template.fields: + tmp_dict[field['label']] = content[field['name']] + template_data[template.name] = tmp_dict + return template_data + def templates_json( self ): + return simplejson.dumps( self.templates_dict() ) + def get_display_name( self ): """ LibraryDatasetDatasetAssociation name can be either a string or a unicode object. --- a/lib/galaxy/tools/__init__.py Fri Jul 29 14:33:34 2011 -0400 +++ b/lib/galaxy/tools/__init__.py Mon Aug 01 17:35:18 2011 -0400 @@ -1,7 +1,7 @@ """ Classes encapsulating galaxy tools and tool configuration. """ -import pkg_resources; +import pkg_resources pkg_resources.require( "simplejson" ) @@ -2026,21 +2026,16 @@ self.input = input self.value = value self._other_values = other_values + self.counter = 0 def __str__( self ): - return self.value.name - def templates( self ): - """ Returns JSON dict of templates => data """ - if not self.value: - return None - template_data = {} - for temp_info in self.value.info_association: - template = temp_info.template - content = temp_info.info.content - tmp_dict = {} - for field in template.fields: - tmp_dict[field['label']] = content[field['name']] - template_data[template.name] = tmp_dict - return simplejson.dumps( template_data ) + return self.value + def __iter__( self ): + return self + def next( self ): + if self.counter >= len(self.value): + raise StopIteration + self.counter += 1 + return self.value[self.counter-1] def __getattr__( self, key ): return getattr( self.value, key ) --- a/lib/galaxy/tools/parameters/basic.py Fri Jul 29 14:33:34 2011 -0400 +++ b/lib/galaxy/tools/parameters/basic.py Mon Aug 01 17:35:18 2011 -0400 @@ -725,7 +725,7 @@ dynamic options, we need to check whether the other parameters which determine what options are valid have been set. For the old style dynamic options which do not specify dependencies, this is always true - (must valiate at runtime). + (must validate at runtime). """ # Option list is statically defined, never need late validation if not self.is_dynamic: @@ -804,7 +804,7 @@ Select list that sets the last used genome build for the current history as "selected". - >>> # Create a mock transcation with 'hg17' as the current build + >>> # Create a mock transaction with 'hg17' as the current build >>> from galaxy.util.bunch import Bunch >>> trans = Bunch( history=Bunch( genome_build='hg17' ), db_builds=util.dbnames ) @@ -1539,20 +1539,26 @@ def from_html( self, value, trans, other_values={} ): if not value: return None - elif isinstance( value, trans.app.model.LibraryDatasetDatasetAssociation ): + elif isinstance( value, list ): return value else: - return trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( value ) ) + decoded_lst = [] + for encoded_id in value.split("||"): + decoded_lst.append( trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( encoded_id ) ) ) + return decoded_lst def to_string( self, value, app ): if not value: - return None - return value.id + return value + return [ldda.id for ldda in value] def to_python( self, value, app ): if not value: return value - return app.model.context.query( app.model.LibraryDatasetDatasetAssociation ).get( value ) + lddas = [] + for ldda_id in value: + lddas.append( app.model.context.query( app.model.LibraryDatasetDatasetAssociation ).get( ldda_id ) ) + return lddas # class RawToolParameter( ToolParameter ): # """ --- a/lib/galaxy/web/form_builder.py Fri Jul 29 14:33:34 2011 -0400 +++ b/lib/galaxy/web/form_builder.py Mon Aug 01 17:35:18 2011 -0400 @@ -656,17 +656,17 @@ class LibraryField( BaseField ): def __init__( self, name, value=None, trans=None ): self.name = name - self.ldda = value + self.lddas = value self.trans = trans def get_html( self, prefix="", disabled=False ): - if not self.ldda: - ldda = "" - text = "Choose a library dataset" + if not self.lddas: + ldda_ids = "" + text = "Select library dataset(s)" else: - ldda = self.trans.security.encode_id(self.ldda.id) - text = self.ldda.name + ldda_ids = "||".join( [ self.trans.security.encode_id( ldda.id ) for ldda in self.lddas ] ) + text = "<br />".join( [ "%s. %s" % (i+1, ldda.name) for i, ldda in enumerate(self.lddas)] ) return '<a href="javascript:void(0);" class="add-librarydataset">%s</a> \ - <input type="hidden" name="%s%s" value="%s">' % ( text, prefix, self.name, escape( str(ldda), quote=True ) ) + <input type="hidden" name="%s%s" value="%s">' % ( text, prefix, self.name, escape( str(ldda_ids), quote=True ) ) def get_display_text(self): if self.ldda: --- a/templates/tool_form.mako Fri Jul 29 14:33:34 2011 -0400 +++ b/templates/tool_form.mako Mon Aug 01 17:35:18 2011 -0400 @@ -79,12 +79,18 @@ hide_modal(); }, "Select": function() { + var names = []; + var ids = []; + counter = 1; $('input[name=ldda_ids]:checked').each(function() { var name = $.trim( $(this).siblings("div").find("a").text() ); var id = $(this).val(); - link.text(name); - link.siblings("input[type=hidden]").val(id); + names.push( counter + ". " + name ); + counter += 1; + ids.push(id); }); + link.html( names.join("<br/>") ); + link.siblings("input[type=hidden]").val( ids.join("||") ); hide_modal(); } } Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.