From 0b6ffe0ac48356a884f159d6493722da432cf102 Mon Sep 17 00:00:00 2001 From: Aysam Guerler Date: Mon, 24 Jun 2013 13:47:06 -0400 Subject: [PATCH] Update: Scratchbook --- static/scripts/galaxy.frame.js | 3 +- static/scripts/mvc/dataset/hda-edit.js | 70 ++++++++++++++++++----- templates/webapps/galaxy/base_panels.mako | 2 +- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/static/scripts/galaxy.frame.js b/static/scripts/galaxy.frame.js index 0e2e5060885..47c9bf20b40 100644 --- a/static/scripts/galaxy.frame.js +++ b/static/scripts/galaxy.frame.js @@ -735,7 +735,6 @@ var GalaxyFrameManager = Backbone.View.extend( // untoggle $(".galaxy-frame-active .icon").removeClass("f-toggle"); - } else { // activate this.active = true; @@ -1034,7 +1033,7 @@ var GalaxyFrameManager = Backbone.View.extend( '
0
' + '
' + ''+ - '
' + + '
' + '
' + '
'; }, diff --git a/static/scripts/mvc/dataset/hda-edit.js b/static/scripts/mvc/dataset/hda-edit.js index 12397150d9d..296cb8127df 100644 --- a/static/scripts/mvc/dataset/hda-edit.js +++ b/static/scripts/mvc/dataset/hda-edit.js @@ -239,8 +239,25 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( * @returns {jQuery} rendered DOM */ _render_visualizationsButton : function(){ + var visualizations = this.model.get( 'visualizations' ); + if( ( !this.model.hasData() ) + || ( _.isEmpty( visualizations ) ) ){ + this.visualizationsButton = null; + return null; + } + + //TODO: this is a bridge to allow the framework to be switched off + // remove this fn and use the other when fully integrated + if( _.isObject( visualizations[0] ) ){ + return this._render_visualizationsFrameworkButton( visualizations ); + } + + if( !this.urls.visualization ){ + this.visualizationsButton = null; + return null; + } + var dbkey = this.model.get( 'dbkey' ), - visualizations = this.model.get( 'visualizations' ), visualization_url = this.urls.visualization, popup_menu_dict = {}, params = { @@ -250,17 +267,10 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( // Add dbkey to params if it exists. if( dbkey ){ params.dbkey = dbkey; } - if( !( this.model.hasData() ) - || !( visualizations && visualizations.length ) - || !( visualization_url ) ){ - this.visualizationsButton = null; - return null; - } - // render the icon from template this.visualizationsButton = new IconButtonView({ model : new IconButton({ title : _l( 'Visualize' ), - href : visualization_url, + href : this.urls.visualization, icon_class : 'chart_curve' })}); var $icon = this.visualizationsButton.render().$el; @@ -278,15 +288,14 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( case 'scatterplot': return create_scatterplot_action_fn( visualization_url, params ); default: - return function(){ - // add widget + return function(){// add widget parent.frame_manager.frame_new( { title : "Visualization", type : "url", content : visualization_url + '/' + visualization + '?' + $.param( params ) }); - }; + }; } } @@ -306,6 +315,40 @@ var HDAEditView = HDABaseView.extend( LoggableMixin ).extend( } return $icon; }, + + /** Render an icon-button or popupmenu of links based on the applicable visualizations + * @returns {jQuery} rendered DOM + */ + _render_visualizationsFrameworkButton : function( visualizations ){ + if( !( this.model.hasData() ) + || !( visualizations && !_.isEmpty( visualizations ) ) ){ + this.visualizationsButton = null; + return null; + } + + // render the icon from template + this.visualizationsButton = new IconButtonView({ model : new IconButton({ + title : _l( 'Visualize' ), + icon_class : 'chart_curve' + })}); + var $icon = this.visualizationsButton.render().$el; + $icon.addClass( 'visualize-icon' ); // needed? + + // No need for popup menu because there's a single visualization. + if( _.keys( visualizations ).length === 1 ) { + $icon.attr( 'title', _.keys( visualizations )[0] ); + $icon.attr( 'href', _.values( visualizations )[0] ); + + // >1: Populate menu dict with visualization fns, make the popupmenu + } else { + var popup_menu_options = []; + _.each( visualizations, function( linkData ) { + popup_menu_options.push( linkData ); + }); + var popup = new PopupMenu( $icon, popup_menu_options ); + } + return $icon; + }, // ......................................................................... secondary actions /** Render secondary actions: currently tagging and annotation (if user is allowed). @@ -567,7 +610,6 @@ HDAEditView.templates = { //TODO: should be imported from scatterplot.js OR abstracted to 'load this in the galaxy_main frame' function create_scatterplot_action_fn( url, params ){ action = function() { - // add widget parent.frame_manager.frame_new( { @@ -657,4 +699,4 @@ function create_trackster_action_fn(vis_url, dataset_params, dbkey) { //============================================================================== //return { // HDAView : HDAView, -//};}); +//};}); \ No newline at end of file diff --git a/templates/webapps/galaxy/base_panels.mako b/templates/webapps/galaxy/base_panels.mako index 16c469195e5..9df93066465 100644 --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -150,7 +150,7 @@ ${h.js( "mvc/base-mvc", "mvc/user/user-model", "mvc/user/user-quotameter" )} [_('New Track Browser'), "javascript:frame_manager.frame_new({title: 'Trackster', type: 'url', content: '/visualization/trackster'});"], [_('Saved Visualizations'), "javascript:frame_manager.frame_new({ type: 'url', content : '/visualization/list'});" ] ] - tab( "visualization", _("Visualization"), "javascript:frame_manager.frame_new({title: 'Trackster', type: 'url', content: '/visualization/trackster'});", menu_options=menu_options ) + tab( "visualization", _("Visualization"), "javascript:frame_manager.frame_new({title: 'Trackster', type: 'url', content: '/visualization/list'});", menu_options=menu_options ) %> ## Cloud menu.