diff --git a/client/galaxy/scripts/apps/analysis.js b/client/galaxy/scripts/apps/analysis.js index bc09ddaa8dc..bd6cbb7b4fe 100644 --- a/client/galaxy/scripts/apps/analysis.js +++ b/client/galaxy/scripts/apps/analysis.js @@ -13,7 +13,6 @@ var jQuery = require( 'jquery' ), GridShared = require( 'mvc/grid/grid-shared' ), Workflows = require( 'mvc/workflow/workflow' ), HistoryList = require( 'mvc/history/history-list' ), - WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' ), ToolFormComposite = require( 'mvc/tool/tool-form-composite' ), Utils = require( 'utils/utils' ), Ui = require( 'mvc/ui/ui-misc' ), @@ -93,7 +92,6 @@ window.app = function app( options, bootstrapped ){ '(/)workflows/list_published(/)' : 'show_workflows_published', '(/)histories(/)(:action_id)' : 'show_histories', '(/)datasets(/)list(/)' : 'show_datasets', - '(/)workflow/configure_menu(/)' : 'show_configure_menu', '(/)workflow/import_workflow' : 'show_import_workflow', '(/)custom_builds' : 'show_custom_builds', '(/)datasets/edit': 'show_dataset_edit_attributes' @@ -102,8 +100,7 @@ window.app = function app( options, bootstrapped ){ require_login: [ 'show_user', 'show_user_form', - 'show_workflows', - 'show_configure_menu' + 'show_workflows' ], loginRequired: function() { @@ -162,10 +159,6 @@ window.app = function app( options, bootstrapped ){ this.page.display( new Workflows.ImportWorkflowView() ); }, - show_configure_menu : function(){ - this.page.display( new WorkflowsConfigureMenu.View() ); - }, - show_custom_builds : function() { var self = this; var historyPanel = this.page.historyPanel.historyView; diff --git a/client/galaxy/scripts/mvc/user/user-preferences.js b/client/galaxy/scripts/mvc/user/user-preferences.js index 06a504e48cd..f43bac73036 100644 --- a/client/galaxy/scripts/mvc/user/user-preferences.js +++ b/client/galaxy/scripts/mvc/user/user-preferences.js @@ -65,14 +65,6 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) { window.location.href = Galaxy.root + 'custom_builds'; } }, - 'configure_menu': { - title : 'Configure workflow menu', - description : 'Configure your workflow items which appear in the Tool panel.', - icon : 'fa-cog', - onclick : function() { - window.location.href = Galaxy.root + 'workflow/configure_menu'; - } - }, 'logout': { title : 'Sign out', description : 'Click here to sign out of all sessions.', @@ -127,7 +119,6 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) { if( config.enable_openid && !config.use_remote_user ) { self._addLink( 'openids' ); } - self._addLink( 'configure_menu' ); self._addLink( 'logout' ); self.$preferences.append( self._templateFooter( data ) ); self.$el.empty().append( self.$preferences ); diff --git a/client/galaxy/scripts/mvc/workflow/workflow-configure-menu.js b/client/galaxy/scripts/mvc/workflow/workflow-configure-menu.js deleted file mode 100644 index 4e262aa56f9..00000000000 --- a/client/galaxy/scripts/mvc/workflow/workflow-configure-menu.js +++ /dev/null @@ -1,153 +0,0 @@ -/** Configure Workflow Menu View */ -define( [], function() { - var View = Backbone.View.extend({ - - initialize: function( options ) { - this.setElement( '
' ); - this.render(); - }, - - render: function() { - var self = this; - $.getJSON( Galaxy.root + 'api/workflows/menu/', function( response ) { - var workflows = response.workflows, - ids_in_menu = response.ids_in_menu, - $el_config_worflow = null; - - // Add configure workflow header - self.$el.empty().append( self._templateConfigWorkflowHeader() ); - $el_config_worflow = self.$el.find( '.configure-workflows' ); - $el_config_worflow.append( self._templateActionButtons() ); - if( workflows.length > 0 ) { - $el_config_worflow.append( self._templateConfigureWorkflow( self, workflows, ids_in_menu ) ); - self.save_workflow_menu( self ); - self.make_checked( self, ids_in_menu ); - self.register_check_uncheck_all( self ); - } - else { - $el_config_worflow.append( self._templateNoWorkflow() ); - } - }); - }, - - /** Register check and uncheck all callbacks*/ - register_check_uncheck_all: function( self ) { - var $el_check_all = self.$el.find( '.check-all-wf' ), - $el_uncheck_all = self.$el.find( '.uncheck-all-wf' ); - - $el_check_all.click(function( e ) { - self.check_uncheck_all( self, true ); - }); - $el_uncheck_all.click(function( e ) { - self.check_uncheck_all( self, false ); - }); - }, - - /** Check or uncheck all workflows */ - check_uncheck_all: function( self, checked ) { - $.each(self.$el.find( '.wf-config-item' ), function() { - var wf_checkbox = $( this )[0]; - wf_checkbox.checked = checked; - }); - }, - - /** Make the worflows as checked if present in the menu */ - make_checked: function( self, ids_in_menu ) { - $.each(self.$el.find( '.wf-config-item' ), function() { - var wf_checkbox = $( this )[0]; - _.each( ids_in_menu, function( id ) { - if ( parseInt( wf_checkbox.value ) === id ) { - wf_checkbox.checked = true; - } - }); - }); - }, - - /** Save the changes for workflow menu */ - save_workflow_menu: function( self ) { - var $el_save_workflow_menu = self.$el.find( '.wf-save-menu' ); - $el_save_workflow_menu.click( function( e ) { - var ids = []; - $.each(self.$el.find( '.wf-config-item' ), function() { - var wf_checkbox = $( this )[0]; - if( wf_checkbox.checked || wf_checkbox.checked === 'true' ) { - ids.push( parseInt( wf_checkbox.value ) ); - } - }); - $.ajax({ - type: 'PUT', - url: Galaxy.root + 'api/workflows/menu/', - data: JSON.stringify( { 'workflow_ids': ids } ), - contentType : 'application/json' - }).done( function( response ) { - window.location = Galaxy.root + 'user'; - }); - }); - }, - - /** Template for actions buttons */ - _templateActionButtons: function() { - return ''; - }, - - /** Template for configure workflow table */ - _templateConfigureWorkflow: function( self, workflows, ids_in_menu ) { - var tableHtml = "", trHtml = ""; - tableHtml = tableHtml + '' + - '' + - '' + - '' + - '' + - '' + - ''; - _.each( workflows, function( wf ) { - trHtml = trHtml + '' + - '' + - '' + - '' + - '' + - ''; - }); - tableHtml = tableHtml + '' + trHtml + '
NameOwner# of StepsShow in menu
' + _.escape( wf.name ) +'' + ( wf.owner === Galaxy.user.attributes.username ? "You" : wf.owner ) +'' + wf.number_of_steps + '' + self._templateInputCheckbox( self, wf, ids_in_menu ) + '
'; - tableHtml = tableHtml + '' + - 'Save' + - '' + - '' + - 'Back to User Preferences' + - ''; - return tableHtml; - }, - - /** Template for no workflow */ - _templateNoWorkflow: function() { - return '
You do not have any accessible workflows.
'; - }, - - /** Template for checkboxes */ - _templateInputCheckbox: function( self, wf ) { - return ''; - }, - - /** Template for main config workflow menu */ - _templateConfigWorkflowHeader: function() { - return '
' + - '
' + - '

Configure workflow menu

' + - '
'+ - '
'; - } - }); - - return { - View : View - }; -}); diff --git a/client/galaxy/scripts/mvc/workflow/workflow.js b/client/galaxy/scripts/mvc/workflow/workflow.js index 35f4b07ff14..988cabe6144 100644 --- a/client/galaxy/scripts/mvc/workflow/workflow.js +++ b/client/galaxy/scripts/mvc/workflow/workflow.js @@ -1,19 +1,17 @@ /** Workflow view */ -define( [ 'utils/utils' ], function( Utils ) { +define( [ 'utils/utils', 'mvc/ui/ui-misc' ], function( Utils, Ui ) { /** Build messages after user action */ - function build_messages( self ) { - var $el_message = self.$el.find( '.response-message' ), - status = Utils.getQueryString( 'status' ), - message = Utils.getQueryString( 'message' ); - - if( message && message !== null && message !== "" ) { - $el_message.addClass( status + 'message' ); - $el_message.html( '

' + _.escape( message ) + '

' ); - } - else { - $el_message.html(""); - } + function build_messages() { + var $el_message = this.$( '.response-message' ), + response = {}; + response = { + 'status': Utils.getQueryString( 'status' ), + 'message': _.escape( Utils.getQueryString( 'message' ) ), + 'persistent': true, + 'cls': Utils.getQueryString( 'status' ) + 'message' + }; + $el_message.empty().html( new Ui.Message( response ).$el ); } /** View of the main workflow list page */ @@ -32,8 +30,8 @@ define( [ 'utils/utils' ], function( Utils ) { // Add workflow header self.$el.empty().append( self._templateHeader() ); // Add user actions message if any - build_messages( self ); - $el_workflow = self.$el.find( '.user-workflows' ); + build_messages(); + $el_workflow = self.$( '.user-workflows' ); // Add the actions buttons $el_workflow.append( self._templateActionButtons() ); if( workflows.length > 0) { @@ -41,10 +39,11 @@ define( [ 'utils/utils' ], function( Utils ) { self.adjust_actiondropdown( $el_workflow ); // Register delete and run workflow events _.each( workflows, function( wf ) { - self.confirm_delete( self, wf ); + self.confirm_delete( wf ); }); + self.register_show_tool_menu(); // Register search workflow event - self.search_workflow( self, self.$el.find( '.search-wf' ), self.$el.find( '.workflow-search tr' ), min_query_length ); + self.search_workflow( self.$( '.search-wf' ), self.$( '.workflow-search tr' ), min_query_length ); } else { $el_workflow.append( self._templateNoWorkflow() ); @@ -52,10 +51,34 @@ define( [ 'utils/utils' ], function( Utils ) { }); }, + // Save the workflow as an item in Tool panel + register_show_tool_menu: function() { + var $el_checkboxes = this.$( '.show-in-tool-panel' ); + $el_checkboxes.on( 'click', function( e ) { + var ids = []; + // Look for all the checked checkboxes + for( var item = 0; item < $el_checkboxes.length; item++ ) { + var checkbox = $el_checkboxes[ item ]; + if( checkbox.checked ) { + ids.push( checkbox.value ); + } + } + // Save all the checked workflows + $.ajax({ + type: 'PUT', + url: Galaxy.root + 'api/workflows/menu/', + data: JSON.stringify( { 'workflow_ids': ids } ), + contentType : 'application/json' + }).done( function( response ) { + window.location = Galaxy.root + 'workflow'; + }); + }); + }, + /** Add confirm box before removing/unsharing workflow */ - confirm_delete: function( self, workflow ) { - var $el_wf_link = self.$el.find( '.link-confirm-' + workflow.id ), - $el_shared_wf_link = self.$el.find( '.link-confirm-shared-' + workflow.id ); + confirm_delete: function( workflow ) { + var $el_wf_link = this.$( '.link-confirm-' + workflow.id ), + $el_shared_wf_link = this.$( '.link-confirm-shared-' + workflow.id ); $el_wf_link.click( function() { return confirm( "Are you sure you want to delete workflow '" + workflow.name + "'?" ); }); @@ -65,7 +88,7 @@ define( [ 'utils/utils' ], function( Utils ) { }, /** Implement client side workflow search/filtering */ - search_workflow: function( self, $el_searchinput, $el_tabletr, min_querylen ) { + search_workflow: function( $el_searchinput, $el_tabletr, min_querylen ) { $el_searchinput.on( 'keyup', function () { var query = $( this ).val(); // Filter when query is at least 3 characters @@ -128,8 +151,10 @@ define( [ 'utils/utils' ], function( Utils ) { 'Owner' + '# of Steps' + 'Published' + + 'Show in tools panel' + ''; _.each( workflows, function( wf ) { + var checkbox_html = ''; trHtml = trHtml + '' + '' + '