Skip to content

Commit

Permalink
UI, HDCAs: render element_count when available
Browse files Browse the repository at this point in the history
- Adds a change event for element_count that renders the subtitle
- Subtitle now renders the count or nothing if not available
  • Loading branch information
carlfeberhard committed May 9, 2016
1 parent 45ba2b4 commit a16ba6c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
37 changes: 21 additions & 16 deletions client/galaxy/scripts/mvc/collection/collection-li.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,18 @@ var DCListItemView = FoldoutListItemView.extend(
FoldoutListItemView.prototype._setUpListeners.call( this );
// re-rendering on deletion
this.listenTo( this.model, 'change', function( model, options ){
if( _.isEqual( _.keys( model.changed ), [ 'deleted' ] ) ){
if( _.has( model.changed, 'deleted' ) ){
this.render();
} else if( _.has( model.changed, 'element_count' ) ){
this.$( '> .title-bar .subtitle' ).replaceWith( this._renderSubtitle() );
}
});
},

// ......................................................................... rendering
//TODO:?? possibly move to listItem
/** render a subtitle to show the user what sort of collection this is */
_renderSubtitle : function(){
var $subtitle = $( '<div class="subtitle"></div>' );
//TODO: would be good to get this in the subtitle
//var len = this.model.elements.length;
switch( this.model.get( 'collection_type' ) ){
case 'list':
return $subtitle.text( _l( 'a list of datasets' ) );
case 'paired':
return $subtitle.text( _l( 'a pair of datasets' ) );
case 'list:paired':
return $subtitle.text( _l( 'a list of paired datasets' ) );
}
return $subtitle;
return $( this.templates.subtitle( this.model.toJSON(), this ) );
},

// ......................................................................... foldout
Expand Down Expand Up @@ -122,9 +112,24 @@ DCListItemView.prototype.templates = (function(){
'</div>'
], 'collection' );

// use element identifier
var subtitleTemplate = BASE_MVC.wrapTemplate([
'<div class="subtitle">',
'<% var countText = collection.element_count? ( collection.element_count + " " ) : ""; %>',
'<% if( collection.collection_type === "list" ){ %>',
_l( 'a list of <%- countText %>datasets' ),
'<% } else if( collection.collection_type === "paired" ){ %>',
_l( 'a pair of datasets' ),
'<% } else if( collection.collection_type === "list:paired" ){ %>',
_l( 'a list of <%- countText %>dataset pairs' ),
'<% } %>',
'</div>'
], 'collection' );

return _.extend( {}, FoldoutListItemView.prototype.templates, {
warnings : warnings,
titleBar : titleBarTemplate
warnings : warnings,
titleBar : titleBarTemplate,
subtitle : subtitleTemplate
});
}());

Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/collection/collection-li.js.map

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

18 changes: 9 additions & 9 deletions static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/mvc/collection/collection-li.js

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

0 comments on commit a16ba6c

Please sign in to comment.