Skip to content

Commit

Permalink
Merge branch 'dev' into fix_refresh_trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Apr 7, 2017
2 parents 2b4b431 + 8ea4cf2 commit ea17f2d
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 109 deletions.
13 changes: 12 additions & 1 deletion client/galaxy/scripts/mvc/collection/collection-view-edit.js
Expand Up @@ -3,9 +3,11 @@ define([
"mvc/collection/collection-model",
"mvc/collection/collection-li-edit",
"mvc/base-mvc",
"mvc/tag",
"ui/fa-icon-button",
"utils/localization",
"ui/editable-text",
], function( DC_VIEW, DC_MODEL, DC_EDIT, BASE_MVC, _l ){
], function( DC_VIEW, DC_MODEL, DC_EDIT, BASE_MVC, TAGS, faIconButton, _l ){

'use strict';
/* =============================================================================
Expand Down Expand Up @@ -47,6 +49,8 @@ var CollectionViewEdit = _super.extend(
return;
}

this.tagsEditorShown = true;

//TODO: extract
var panel = this,
nameSelector = '> .controls .name';
Expand All @@ -67,6 +71,13 @@ var CollectionViewEdit = _super.extend(
}
}
});
this.tagsEditor = new TAGS.TagsEditor({
model : this.model,
el : $where.find( '.tags-display' ),
onshowFirstTime : function(){ this.render(); },
usePrompt : false
});
this.tagsEditor.toggle( true );
},

// ........................................................................ misc
Expand Down
2 changes: 2 additions & 0 deletions client/galaxy/scripts/mvc/collection/collection-view.js
Expand Up @@ -169,6 +169,8 @@ CollectionView.prototype.templates = (function(){
'<% } %>',
'</div>',
'</div>',

'<div class="tags-display"></div>',
'</div>'
], 'collection' );

Expand Down
9 changes: 8 additions & 1 deletion client/galaxy/scripts/mvc/dataset/dataset-li.js
Expand Up @@ -59,7 +59,14 @@ var DatasetListItemView = _super.extend(
.done( function(){ self.render(); });

} else {
self.render();
if( _.has( model.changed, 'tags' ) && _.keys( model.changed ).length === 1 ){
// If only the tags have changed, rerender specifically
// the titlebar region. Otherwise default to the full
// render.
this.$( '> .title-bar' ).replaceWith( this._renderTitleBar() );
} else {
self.render();
}
}
}
});
Expand Down
6 changes: 4 additions & 2 deletions client/galaxy/scripts/mvc/history/hda-li.js
Expand Up @@ -45,8 +45,10 @@ HDAListItemView.prototype.templates = (function(){
'</div>',
'</br>',
'<span class="nametags">',
'<% _.each(dataset.nametags, function(tag){ %>',
'<span class="label label-info"><%- tag %></span>',
'<% _.each(dataset.tags, function(tag){ %>',
'<% if (tag.indexOf("name:") == 0){ %>',
'<span class="label label-info"><%- tag.slice(5) %></span>',
'<% } %>',
'<% }); %>',
'</span>',
'</div>'
Expand Down
10 changes: 8 additions & 2 deletions client/galaxy/scripts/mvc/history/hdca-li.js
Expand Up @@ -20,9 +20,8 @@ var HDCAListItemView = _super.extend(
/** event listeners */
_setUpListeners : function(){
_super.prototype._setUpListeners.call( this );

this.listenTo( this.model, {
'change:populated change:visible' : function( model, options ){ this.render(); },
'change:tags change:populated change:visible' : function( model, options ){ this.render(); },
});
},

Expand Down Expand Up @@ -85,6 +84,13 @@ HDCAListItemView.prototype.templates = (function(){
'<span class="name"><%- collection.name %></span>',
'</div>',
'<div class="subtitle"></div>',
'<span class="nametags">',
'<% _.each(collection.tags, function(tag){ %>',
'<% if (tag.indexOf("name:") == 0){ %>',
'<span class="label label-info"><%- tag.slice(5) %></span>',
'<% } %>',
'<% }); %>',
'</span>',
'</div>'
], 'collection' );

Expand Down
17 changes: 9 additions & 8 deletions client/galaxy/scripts/mvc/tag.js
Expand Up @@ -18,23 +18,25 @@ var TagsEditor = Backbone.View
initialize : function( options ){
//console.debug( this, options );
// only listen to the model only for changes to tags - re-render
this.listenTo( this.model, 'change:tags', function(){
this.render();
});
if (options.usePrompt === false) {
this.label = '';
} else {
this.label = '<label class="prompt">' + _l( 'Tags' ) + '</label>';
}
this.hiddenUntilActivated( options.$activator, options );
},

/** Build the DOM elements, call select to on the created input, and set up behaviors */
render : function(){
var view = this;
var self = this;
this.$el.html( this._template() );

this.$input().select2({
placeholder : 'Add tags',
width : '100%',
tags : function(){
// initialize possible tags in the dropdown based on all the tags the user has used so far
return view._getTagsUsed();
return self._getTagsUsed();
}
});

Expand All @@ -45,8 +47,7 @@ var TagsEditor = Backbone.View
/** @returns {String} the html text used to build the view's DOM */
_template : function(){
return [
//TODO: make prompt optional
'<label class="prompt">', _l( 'Tags' ), '</label>',
this.label,
// set up initial tags by adding as CSV to input vals (necc. to init select2)
'<input class="tags-input" value="', this.tagsToCSV(), '" />'
].join( '' );
Expand Down Expand Up @@ -79,7 +80,7 @@ var TagsEditor = Backbone.View
var view = this;
this.$input().on( 'change', function( event ){
// save the model's tags in either remove or added event
view.model.save({ tags: event.val }, { silent: true });
view.model.save({ tags: event.val });
// if it's new, add the tag to the users tags
if( event.added ){
//??: solve weird behavior in FF on test.galaxyproject.org where
Expand Down
7 changes: 5 additions & 2 deletions client/package.json
Expand Up @@ -5,12 +5,15 @@
"keywords": [
"galaxy"
],
"repository": { "type": "git",
"url": "https://github.com/galaxyproject/galaxy.git"
"repository": {
"type": "git",
"url": "https://github.com/galaxyproject/galaxy.git"
},
"license": "AFL-3.0",
"dependencies": {
"amdi18n-loader": "^0.2.0",
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"grunt": "^0.4.5",
"grunt-bower-install-simple": "^1.1.0",
"grunt-check-modules": "^1.0.0",
Expand Down
4 changes: 4 additions & 0 deletions client/webpack.config.js
Expand Up @@ -54,6 +54,10 @@ module.exports = {
},
module : {
loaders : [
{ test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: { compact: false } },
],
},
resolveLoader : {
Expand Down
52 changes: 20 additions & 32 deletions lib/galaxy/managers/collections.py
Expand Up @@ -36,24 +36,15 @@ def __init__( self, app ):

self.hda_manager = hdas.HDAManager( app )
self.history_manager = histories.HistoryManager( app )
self.tag_manager = tags.TagManager( app )
self.tag_manager = tags.GalaxyTagManager( app )
self.ldda_manager = lddas.LDDAManager( app )

def create(
self,
trans,
parent,
# PRECONDITION: security checks on ability to add to parent
# occurred during load.
name,
collection_type,
element_identifiers=None,
elements=None,
implicit_collection_info=None,
trusted_identifiers=None, # Trust preloaded element objects
hide_source_items=False,
):
def create( self, trans, parent, name, collection_type, element_identifiers=None,
elements=None, implicit_collection_info=None, trusted_identifiers=None,
hide_source_items=False, tags=None):
"""
PRECONDITION: security checks on ability to add to parent
occurred during load.
"""
# Trust embedded, newly created objects created by tool subsystem.
if trusted_identifiers is None:
Expand Down Expand Up @@ -107,17 +98,17 @@ def create(
message = "Internal logic error - create called with unknown parent type %s" % type( parent )
log.exception( message )
raise MessageException( message )
tags = tags or []
if implicit_collection_info:
for k, v in implicit_collection_info.get('implicit_inputs', []):
tags.extend(v.tags)
for tag in tags:
dataset_collection_instance.tags.append(tag.copy())

return self.__persist( dataset_collection_instance )

def create_dataset_collection(
self,
trans,
collection_type,
element_identifiers=None,
elements=None,
hide_source_items=False,
):
def create_dataset_collection( self, trans, collection_type, element_identifiers=None, elements=None,
hide_source_items=None ):
if element_identifiers is None and elements is None:
raise RequestParameterInvalidException( ERROR_INVALID_ELEMENTS_SPECIFICATION )
if not collection_type:
Expand Down Expand Up @@ -188,15 +179,11 @@ def update( self, trans, instance_type, id, payload ):
changed = self._set_from_dict( trans, dataset_collection_instance, payload )
return changed

def copy(
self,
trans,
parent,
# PRECONDITION: security checks on ability to add to parent
# occurred during load.
source,
encoded_source_id,
):
def copy( self, trans, parent, source, encoded_source_id ):
"""
PRECONDITION: security checks on ability to add to parent occurred
during load.
"""
assert source == "hdca" # for now
source_hdca = self.__get_history_collection_instance( trans, encoded_source_id )
new_hdca = source_hdca.copy()
Expand All @@ -213,6 +200,7 @@ def _set_from_dict( self, trans, dataset_collection_instance, new_data ):
dataset_collection_instance.add_item_annotation( trans.sa_session, trans.get_user(), dataset_collection_instance, new_data[ 'annotation' ] )
changed[ 'annotation' ] = new_data[ 'annotation' ]
if 'tags' in new_data.keys() and trans.get_user():
# set_tags_from_list will flush on its own, no need to add to 'changed' here and incur a second flush.
self.tag_manager.set_tags_from_list( trans.get_user(), dataset_collection_instance, new_data[ 'tags' ] )

if changed.keys():
Expand Down
15 changes: 1 addition & 14 deletions lib/galaxy/managers/hdas.py
Expand Up @@ -261,7 +261,7 @@ def __init__( self, app ):
'state',
'extension',
'deleted', 'purged', 'visible',
'nametags',
'tags',
'type',
'url',
'create_time',
Expand All @@ -286,7 +286,6 @@ def __init__( self, app ):
'creating_job',
'rerunnable',

'tags',
'uuid',
'permissions',
'file_name',
Expand Down Expand Up @@ -332,7 +331,6 @@ def add_serializers( self ):
'misc_blurb' : self._remap_from( 'blurb' ),
'file_ext' : self._remap_from( 'extension' ),
'file_path' : self._remap_from( 'file_name' ),
'nametags' : self.serialize_nametags,
'resubmitted' : lambda i, k, **c: self.hda_manager.has_been_resubmitted( i ),
'display_apps' : self.serialize_display_apps,
'display_types' : self.serialize_old_display_applications,
Expand Down Expand Up @@ -386,17 +384,6 @@ def serialize_display_apps( self, hda, key, trans=None, **context ):

return display_apps

def serialize_nametags( self, hda, key, trans=None, **context ):
"""
Return list of 'name' child tags attached to this dataset.
TODO: investigate faster ways to fetch 'name' tags and values
"""
nametags = []
for tag in hda.tags:
if tag.tag.name == 'name':
nametags.append(tag.value)
return nametags

def serialize_old_display_applications( self, hda, key, trans=None, **context ):
"""
Return dictionary containing old-style display app urls.
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/managers/hdcas.py
Expand Up @@ -235,6 +235,7 @@ def __init__( self, app ):
'visible',
'type', 'url',
'create_time', 'update_time',
'tags', # TODO: detail view only (maybe)
])
self.add_view( 'detailed', [
'elements'
Expand Down
4 changes: 4 additions & 0 deletions lib/galaxy/managers/tags.py
Expand Up @@ -306,6 +306,10 @@ def __init__( self, app ):
ItemTagAssocInfo( model.HistoryDatasetAssociation,
model.HistoryDatasetAssociationTagAssociation,
model.HistoryDatasetAssociationTagAssociation.table.c.history_dataset_association_id )
self.item_tag_assoc_info["HistoryDatasetCollectionAssociation"] = \
ItemTagAssocInfo( model.HistoryDatasetCollectionAssociation,
model.HistoryDatasetCollectionTagAssociation,
model.HistoryDatasetCollectionTagAssociation.table.c.history_dataset_collection_id )
self.item_tag_assoc_info["Page"] = ItemTagAssocInfo( model.Page,
model.PageTagAssociation,
model.PageTagAssociation.table.c.page_id )
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/tools/actions/__init__.py
Expand Up @@ -405,6 +405,7 @@ def handle_output( name, output, hidden=None ):
output_collections.create_collection(
output=output,
name=name,
tags=preserved_tags,
**element_kwds
)
else:
Expand Down Expand Up @@ -678,7 +679,7 @@ def __init__(self, trans, history, tool, tool_action, input_collections, mapping
self.out_collections = {}
self.out_collection_instances = {}

def create_collection(self, output, name, **element_kwds):
def create_collection(self, output, name, tags=None, **element_kwds):
input_collections = self.input_collections
collections_manager = self.trans.app.dataset_collections_service
collection_type = output.structure.collection_type
Expand Down Expand Up @@ -729,6 +730,7 @@ def create_collection(self, output, name, **element_kwds):
name=hdca_name,
collection_type=collection_type,
trusted_identifiers=True,
tags=tags,
**element_kwds
)
# name here is name of the output element - not name
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/collection/collection-view-edit.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea17f2d

Please sign in to comment.