commit/galaxy-central: guerler: Grids: Unify operation handling, use new popups, refactor, bug fixes
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3f630f92f598/ Changeset: 3f630f92f598 User: guerler Date: 2013-11-23 22:14:59 Summary: Grids: Unify operation handling, use new popups, refactor, bug fixes Affected #: 19 files diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c lib/galaxy/web/framework/helpers/grids.py --- a/lib/galaxy/web/framework/helpers/grids.py +++ b/lib/galaxy/web/framework/helpers/grids.py @@ -323,7 +323,7 @@ def __init__( self, label, key=None, model_class=None, method=None, format=None, \ link=None, attach_popup=False, visible=True, nowrap=False, \ # Valid values for filterable are ['standard', 'advanced', None] - filterable=None, sortable=True, label_id_prefix=None ): + filterable=None, sortable=True, label_id_prefix=None, inbound=False ): """Create a grid column.""" self.label = label self.key = key @@ -331,6 +331,7 @@ self.method = method self.format = format self.link = link + self.inbound = inbound self.nowrap = nowrap self.attach_popup = attach_popup self.visible = visible @@ -734,7 +735,7 @@ class GridOperation( object ): def __init__( self, label, key=None, condition=None, allow_multiple=True, allow_popup=True, target=None, url_args=None, async_compatible=False, confirm=None, - global_operation=None ): + global_operation=None, inbound=False ): self.label = label self.key = key self.allow_multiple = allow_multiple @@ -743,6 +744,7 @@ self.target = target self.url_args = url_args self.async_compatible = async_compatible + self.inbound = inbound # if 'confirm' is set, then ask before completing the operation self.confirm = confirm # specify a general operation that acts on the full grid @@ -772,9 +774,10 @@ return { 'action' : 'display_by_username_and_slug', 'username' : item.user.username, 'slug' : item.slug } class GridAction( object ): - def __init__( self, label=None, url_args=None ): + def __init__( self, label=None, url_args=None, inbound=False ): self.label = label self.url_args = url_args + self.inbound = inbound class GridColumnFilter( object ): def __init__( self, label, args=None ): diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -99,8 +99,8 @@ columns = [ grids.TextColumn( "Name", key="name", # Link name to dataset's history. - link=( lambda item: iff( item.history.deleted, None, dict( operation="switch", id=item.id ) ) ), filterable="advanced", attach_popup=True ), - HistoryColumn( "History", key="history", sortable=False, + link=( lambda item: iff( item.history.deleted, None, dict( operation="switch", id=item.id ) ) ), filterable="advanced", attach_popup=True, inbound=True ), + HistoryColumn( "History", key="history", sortable=False, inbound=True, link=( lambda item: iff( item.history.deleted, None, dict( operation="switch_history", id=item.id ) ) ) ), grids.IndividualTagsColumn( "Tags", key="tags", model_tag_association_class=model.HistoryDatasetAssociationTagAssociation, filterable="advanced", grid_name="HistoryDatasetAssocationListGrid" ), StatusColumn( "Status", key="deleted", attach_popup=False ), diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c lib/galaxy/webapps/galaxy/controllers/history.py --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -34,14 +34,14 @@ for state in ( 'ok', 'running', 'queued', 'error' ): count = state_count_dict.get( state, 0 ) if count: - rval += '<div class="count-box state-color-%s">%s</div>' % (state, count) + rval += '<div class="count-box state-color-%s">%s</div> ' % (state, count) return rval class HistoryListNameColumn( NameColumn ): def get_link( self, trans, grid, history ): link = None if not history.deleted: - link = dict( operation="Switch", id=history.id, use_panels=grid.use_panels ) + link = dict( operation="Switch", id=history.id, use_panels=grid.use_panels, async_compatible=True ) return link @@ -85,10 +85,10 @@ key="free-text-search", visible=False, filterable="standard" ) ) operations = [ - grids.GridOperation( "Switch", allow_multiple=False, condition=( lambda item: not item.deleted ), async_compatible=False ), - grids.GridOperation( "View", allow_multiple=False ), + grids.GridOperation( "Switch", allow_multiple=False, condition=( lambda item: not item.deleted ), async_compatible=True ), + grids.GridOperation( "View", allow_multiple=False, inbound=True ), grids.GridOperation( "Share or Publish", allow_multiple=False, condition=( lambda item: not item.deleted ), async_compatible=False ), - grids.GridOperation( "Rename", condition=( lambda item: not item.deleted ), async_compatible=False ), + grids.GridOperation( "Rename", condition=( lambda item: not item.deleted ), async_compatible=False, inbound=True ), grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ), async_compatible=True ), grids.GridOperation( "Delete Permanently", condition=( lambda item: not item.purged ), confirm="History contents will be removed from disk, this cannot be undone. Continue?", async_compatible=True ), grids.GridOperation( "Undelete", condition=( lambda item: item.deleted and not item.purged ), async_compatible=True ), diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c lib/galaxy/webapps/galaxy/controllers/page.py --- a/lib/galaxy/webapps/galaxy/controllers/page.py +++ b/lib/galaxy/webapps/galaxy/controllers/page.py @@ -95,7 +95,6 @@ # Grid definition. show_item_checkboxes = True template = "/page/select_items_grid.mako" - async_template = "/page/select_items_grid_async.mako" default_filter = { "deleted" : "False" , "sharing" : "All" } default_sort_key = "-update_time" use_async = True diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -56,7 +56,7 @@ datasets_action = 'list_history_datasets' datasets_param = "f-history" columns = [ - NameColumn( "History Name", key="name", filterable="standard" ), + NameColumn( "History Name", key="name", filterable="standard", inbound=True ), grids.GridColumn( "Last Updated", key="update_time", format=time_ago, visible=False ), DbKeyPlaceholderColumn( "Dbkey", key="dbkey", model_class=model.HistoryDatasetAssociation, visible=False ) ] @@ -77,7 +77,7 @@ datasets_action = 'list_library_datasets' datasets_param = "f-library" columns = [ - NameColumn( "Library Name", key="name", filterable="standard" ) + NameColumn( "Library Name", key="name", filterable="standard", inbound=True ) ] num_rows_per_page = 10 use_async = True @@ -196,15 +196,15 @@ key="free-text-search", visible=False, filterable="standard" ) ) global_actions = [ - grids.GridAction( "Create new visualization", dict( action='create' ) ) + grids.GridAction( "Create new visualization", dict( action='create' ), inbound=True ) ] operations = [ grids.GridOperation( "Open", allow_multiple=False, url_args=get_url_args ), grids.GridOperation( "Open in Circster", allow_multiple=False, condition=( lambda item: item.type == 'trackster' ), url_args=dict( action='circster' ) ), - grids.GridOperation( "Edit Attributes", allow_multiple=False, url_args=dict( action='edit') ), - grids.GridOperation( "Copy", allow_multiple=False, condition=( lambda item: not item.deleted ), async_compatible=False, url_args=dict( action='copy') ), + grids.GridOperation( "Edit Attributes", allow_multiple=False, url_args=dict( action='edit'), inbound=True), + grids.GridOperation( "Copy", allow_multiple=False, condition=( lambda item: not item.deleted )), grids.GridOperation( "Share or Publish", allow_multiple=False, condition=( lambda item: not item.deleted ), async_compatible=False ), - grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ), async_compatible=True, confirm="Are you sure you want to delete this visualization?" ), + grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ), confirm="Are you sure you want to delete this visualization?" ), ] def apply_query_filter( self, trans, query, **kwargs ): return query.filter_by( user=trans.user, deleted=False ) @@ -327,6 +327,7 @@ @web.expose @web.require_login( "use Galaxy visualizations", use_panels=True ) def list( self, trans, *args, **kwargs ): + # Handle operation if 'operation' in kwargs and 'id' in kwargs: session = trans.sa_session @@ -338,6 +339,8 @@ item.deleted = True if operation == "share or publish": return self.sharing( trans, **kwargs ) + if operation == "copy": + self.copy( trans, **kwargs ) session.flush() # Build list of visualizations shared with user. @@ -350,8 +353,7 @@ .all() return trans.fill_template( "visualization/list.mako", grid=self._user_list_grid( trans, *args, **kwargs ), shared_by_others=shared_by_others ) - - + # # -- Functions for operating on visualizations. -- # @@ -364,7 +366,7 @@ @web.expose @web.require_login() - def copy(self, trans, id, *args, **kwargs): + def copy(self, trans, id, **kwargs): visualization = self.get_visualization( trans, id, check_ownership=False ) user = trans.get_user() owner = ( visualization.user == user ) @@ -381,7 +383,7 @@ # Display the management page trans.set_message( 'Created new visualization with name "%s"' % copied_viz.title ) - return self.list( trans ) + return @web.expose @web.require_login( "use Galaxy visualizations" ) diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c static/scripts/galaxy.grids.js --- a/static/scripts/galaxy.grids.js +++ b/static/scripts/galaxy.grids.js @@ -4,6 +4,9 @@ // not appended to the identifier of a nested array. jQuery.ajaxSettings.traditional = true; +// dependencies +define(['mvc/ui'], function() { + /** * A Galaxy grid. */ @@ -137,8 +140,7 @@ // Initialize initialize: function(grid) { - this.grid = grid; - this.init_grid_elements(); + this.init_grid(grid); this.init_grid_controls(); // Initialize text filters to select text on click and use normal font when user is typing. @@ -147,7 +149,14 @@ .keyup(function () { $(this).css("font-style", "normal"); }); }); }, - + + // Initialize + init_grid: function(grid) + { + this.grid = grid; + this.init_grid_elements(); + }, + // Initialize grid controls init_grid_controls: function() { // Initialize submit image elements. @@ -174,14 +183,6 @@ }); }); - // Initialize page links. - $('.page-link > a').each( function() { - $(this).click( function() { - self.set_page( $(this).attr('page_num') ); - return false; - }); - }); - // Initialize categorical filters. $('.categorical-filter > a').each( function() { $(this).click( function() { @@ -227,7 +228,6 @@ // Initialize grid elements. init_grid_elements : function() { - // Initialize grid selection checkboxes. $(".grid").each( function() { var checkboxes = $(this).find("input.grid-row-select-checkbox"); @@ -242,34 +242,94 @@ update_checked(); }); - // Initialize item labels. - var self = this; - $(".label").each( function() { - // If href has an operation in it, do operation when clicked. Otherwise do nothing. - var href = $(this).attr('href'); - if ( href !== undefined && href.indexOf('operation=') != -1 ) { - $(this).click( function() { - self.do_operation_from_href( $(this).attr('href') ); - return false; - }); - } - }); - // Initialize ratings. if ($('.community_rating_star').length !== 0) $('.community_rating_star').rating({}); + + // get options + var options = this.grid.attributes; + var self = this; - // Initialize item menu operations. - make_popup_menus(); - }, - - // Go back to page one; this is useful when a filter is applied. - go_page_one: function () { - // Need to go back to page 1 if not showing all. - var cur_page = this.grid.get('cur_page'); - if (cur_page !== null && cur_page !== undefined && cur_page !== 'all') { - this.grid.set('cur_page', 1); - } + // + // add page click events + // + $('.page-link > a').each( function() { + $(this).click( function() { + self.set_page( $(this).attr('page_num') ); + return false; + }); + }); + + // + // add inbound/outbound events + // + $(".use-inbound").each( function() { + $(this).click( function(e) { + self.execute({ + href : $(this).attr('href'), + inbound : true + }); + return false; + + }); + }); + + $(".use-outbound").each( function() { + $(this).click( function(e) { + self.execute({ + href : $(this).attr('href') + }); + return false; + }); + }); + + // + // add operation popup menus + // + for (var i in options['items']) + { + // get identifiers + var button = $('#grid-' + i + '-popup'); + button.off(); + var popup = new PopupMenu(button); + + // load details + var item = options['items'][i]; + for (var j in options['operations']) + { + // get operation details + var operation = options['operations'][j]; + var operation_id = operation['label']; + var operation_settings = item['operation_config'][operation_id]; + var encode_id = item['encode_id']; + + // check + if (operation_settings['allowed'] && operation['allow_popup']) + { + // popup configuration + var popupConfig = + { + html : operation['label'], + href : operation_settings['url_args'], + target : operation_settings['target'], + confirmation_text : operation['confirm'], + inbound : operation['inbound'] + }; + + // add popup function + popupConfig.func = function(e) + { + e.preventDefault(); + var label = $(e.target).html(); + var options = this.findItemByHtml(label); + self.execute(options); + }; + + // add item + popup.addItem(popupConfig); + } + } + } }, // Add a condition to the grid filter; this adds the condition and refreshes the grid. @@ -294,14 +354,14 @@ $(this).remove(); self.go_page_one(); - self.update_grid(); + self.execute(); }); var container = $('#' + name + "-filtering-criteria"); container.append(t); this.go_page_one(); - this.update_grid(); + this.execute(); }, // Set sort condition for grid. @@ -331,7 +391,7 @@ // Update grid. this.grid.set('sort_key', new_sort); this.go_page_one(); - this.update_grid(); + this.execute(); }, // Set new value for categorical filter. @@ -366,7 +426,7 @@ // Update grid. this.grid.add_filter(name, new_value); this.go_page_one(); - this.update_grid(); + this.execute(); }, // Set page to view. @@ -394,88 +454,160 @@ $(this).removeClass("inactive-link"); var t = $("<a href='#'>" + text + "</a>"); t.click(function() { - set_page(page_num); + self.set_page(page_num); }); $(this).append(t); } }); - var maintain_page_links = true; if (new_page === "all") { this.grid.set('cur_page', new_page); - maintain_page_links = false; } else { this.grid.set('cur_page', parseInt(new_page, 10)); } - this.update_grid(maintain_page_links); + this.execute(); }, - // Perform a grid operation. - do_operation: function (operation, item_ids) { - operation = operation.toLowerCase(); - - // Update grid. - this.grid.set({ - operation: operation, - item_ids: item_ids + // confirmation/submission of operation request + submit_operation: function (selected_button, confirmation_text) + { + // verify in any item is selected + var number_of_checked_ids = $('input[name="id"]:checked').length; + if (!number_of_checked_ids > 0) + return false; + + // collect ids + var operation_name = $(selected_button).val(); + var item_ids = []; + $('input[name=id]:checked').each(function() { + item_ids.push( $(this).val() ); + }); + this.execute({ + operation: operation_name, + id: item_ids, + confirmation_text: confirmation_text }); - // Do operation. If operation cannot be performed asynchronously, redirect to location. - if (this.grid.can_async_op(operation)) { - this.update_grid(true); + // return + return true; + }, + + // execute operations and hyperlink requests + execute: function (options) { + // get url + var id = null; + var href = null; + var operation = null; + var confirmation_text = null; + var inbound = null; + + // check for options + if (options) + { + // get options + href = options.href; + operation = options.operation; + id = options.id; + confirmation_text = options.confirmation_text; + inbound = options.inbound; + + // check if input contains the operation tag + if (href !== undefined && href.indexOf('operation=') != -1) { + // Get operation, id in hyperlink's href. + var href_parts = href.split("?"); + if (href_parts.length > 1) { + var href_parms_str = href_parts[1]; + var href_parms = href_parms_str.split("&"); + for (var index = 0; index < href_parms.length; index++) { + if (href_parms[index].indexOf('operation') != -1) { + // Found operation parm; get operation value. + operation = href_parms[index].split('=')[1]; + operation = operation.replace (/\+/g, ' '); + } else if (href_parms[index].indexOf('id') != -1) { + // Found id parm; get id value. + id = href_parms[index].split('=')[1]; + } + } + } + } } - else { - this.go_to_URL(); + + // check for operation details + if (operation && id) { + // show confirmation box + if (confirmation_text && confirmation_text != '' && confirmation_text != 'None') + if(!confirm(confirmation_text)) + return false; + + // use small characters for operation?! + operation = operation.toLowerCase(); + + // Update grid. + this.grid.set({ + operation: operation, + item_ids: id + }); + + // Do operation. If operation cannot be performed asynchronously, redirect to location. + if (this.grid.can_async_op(operation)) { + this.update_grid(); + } else { + this.go_to(inbound, ''); + } + + // done + return false; } + + // check for href details + if (href) + { + this.go_to(inbound, href); + return false; + } + + // refresh grid + if (this.grid.get('async')) { + this.update_grid(); + } else { + this.go_to(inbound, ''); + } + + // done + return false; }, - // Perform a hyperlink click that initiates an operation. If there is no operation, ignore click. - do_operation_from_href: function (href) { - // Get operation, id in hyperlink's href. - var href_parts = href.split("?"); - if (href_parts.length > 1) { - var href_parms_str = href_parts[1]; - var href_parms = href_parms_str.split("&"); - var operation = null; - var id = -1; - for (var index = 0; index < href_parms.length; index++) { - if (href_parms[index].indexOf('operation') != -1) { - // Found operation parm; get operation value. - operation = href_parms[index].split('=')[1]; - } else if (href_parms[index].indexOf('id') != -1) { - // Found id parm; get id value. - id = href_parms[index].split('=')[1]; - } - } - // Do operation. - this.do_operation(operation, id); - return false; - } - }, - - // Navigate window to the URL defined by url_args. This method can be used to short-circuit grid AJAXing. - go_to_URL: function () { - // Not async request. + // go to url + go_to: function (inbound, href) { + + var async = this.grid.get('async'); this.grid.set('async', false); - // Go. - window.location = this.grid.get('url_base') + "?" + $.param(this.grid.get_url_data()); - + // get default url + if(!href) + href = this.grid.get('url_base') + "?" + $.param(this.grid.get_url_data()); + // Clear grid of transient request attributes. this.grid.set({ operation: undefined, - item_ids: undefined + item_ids: undefined, + async: async }); + + if (inbound) { + // this currently assumes that there is only a single grid shown at a time + var $div = $('.grid-header').closest('.inbound'); + if ($div.length !== 0) { + $div.load(href); + return; + } + } + + window.location = href; }, // Update grid. - update_grid: function (maintain_page_links) { - // If grid is not using async, then go to URL. - if (!this.grid.get('async')) { - this.go_to_URL(); - return; - } - + update_grid: function () { // If there's an operation, do POST; otherwise, do GET. var method = (this.grid.get('operation') ? "POST" : "GET" ); $('.loading-elt-overlay').show(); // Show overlay to indicate loading and prevent user actions. @@ -484,7 +616,7 @@ type: method, url: self.grid.get('url_base'), data: self.grid.get_url_data(), - error: function() { alert( "Grid refresh failed" ); }, + error: function(response) { alert( "Grid refresh failed" );}, success: function(response_text) { // HACK: use a simple string to separate the elements in the // response: (1) table body; (2) number of pages in table; and (3) message. @@ -498,11 +630,7 @@ // Trigger custom event to indicate grid body has changed. $('#grid-table-body').trigger('update'); - - // Init grid. - self.init_grid_elements(); - make_popup_menus(); - + // Hide loading overlay. $('.loading-elt-overlay').hide(); @@ -546,29 +674,20 @@ } this.init_grid_elements(); }, - - // confirmation/submission of operation request - submit_operation: function (selected_button, confirmation_text) - { - // verify in any item is selected - var number_of_checked_ids = $('input[name="id"]:checked').length; - if (!number_of_checked_ids > 0) - return false; - - // show confirmation box - if (confirmation_text != 'None' && confirmation_text != '') - if(!confirm(confirmation_text)) - return false; - - // collect ids - var operation_name = $(selected_button).val(); - var item_ids = []; - $('input[name=id]:checked').each(function() { - item_ids.push( $(this).val() ); - }); - this.do_operation(operation_name, item_ids); - - // return - return true; + + // Go back to page one; this is useful when a filter is applied. + go_page_one: function () { + // Need to go back to page 1 if not showing all. + var cur_page = this.grid.get('cur_page'); + if (cur_page !== null && cur_page !== undefined && cur_page !== 'all') { + this.grid.set('cur_page', 1); + } } }); + +return { + Grid : Grid, + GridView : GridView +}; + +}); \ No newline at end of file diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c static/scripts/mvc/ui.js --- a/static/scripts/mvc/ui.js +++ b/static/scripts/mvc/ui.js @@ -232,7 +232,7 @@ // if the option has 'func', call that function when the anchor is clicked if( option.func ){ - $( this ).children( 'a.popupmenu-option' ).click( function( event ){ + $( this ).children( 'a.popupmenu-option' ).mousedown( function( event ){ option.func.call( menu, event, option ); // bubble up so that an option click will call the close behavior //return false; @@ -292,7 +292,7 @@ // function to close popup and unbind itself var menu = this; var closePopupWhenClicked = function( $elClicked ){ - $elClicked.one( "click.close_popup", function(){ + $elClicked.one( "mousedown.close_popup", function(){ menu.remove(); }); }; diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/admin/requests/sample_datasets_grid.mako --- a/templates/admin/requests/sample_datasets_grid.mako +++ b/templates/admin/requests/sample_datasets_grid.mako @@ -2,8 +2,8 @@ <%namespace file="/requests/common/common.mako" import="common_javascripts" /><%namespace file="/requests/common/common.mako" import="transfer_status_updater" /> -<%def name="javascripts()"> - ${parent.javascripts()} - ${common_javascripts()} - ${transfer_status_updater()} +<%def name="load()"> + ${parent.load()} + ${common_javascripts()} + ${transfer_status_updater()} </%def> diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/base.mako --- a/templates/base.mako +++ b/templates/base.mako @@ -10,7 +10,7 @@ ${self.stylesheets()} ${self.javascripts()} </head> - <body> + <body class="inbound"> ${next.body()} </body></html> @@ -50,7 +50,8 @@ "libs/backbone/backbone-relational", "libs/handlebars.runtime", "galaxy.base", - "mvc/ui" + "mvc/ui", + 'libs/require' )} <script type="text/javascript"> @@ -69,6 +70,16 @@ error : function(){}, assert : function(){} }; + + ## configure require + require.config({ + baseUrl: "${h.url_for('/static/scripts') }", + shim: { + "libs/underscore": { exports: "_" }, + "libs/backbone/backbone": { exports: "Backbone" }, + "libs/backbone/backbone-relational": ["libs/backbone/backbone"] + } + }); </script> %if not form_input_auto_focus is UNDEFINED and form_input_auto_focus: diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/base/base_panels.mako --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -341,7 +341,7 @@ </div></div><!--end left--> %endif - <div id="center"> + <div id="center" class="inbound"> ${self.center_panel()} </div><!--end center--> %if self.has_right_panel: diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/grid_base.mako --- a/templates/grid_base.mako +++ b/templates/grid_base.mako @@ -16,6 +16,20 @@ <%namespace file="/refresh_frames.mako" import="handle_refresh_frames" /><%namespace file="/display_common.mako" import="get_class_plural" /> +<%def name="load(embedded = False)"> +<% + self.grid_javascripts() + if embedded: + self.init() + self.stylesheets() + self.render_grid_header( grid, False ) + self.render_grid_table( grid, show_item_checkboxes=show_item_checkboxes ) + else: + self.make_grid( grid ) + endif +%> +</%def> + <%def name="init()"><% self.has_left_panel = False @@ -47,7 +61,8 @@ 'get_class_plural' : get_class_plural( grid.model_class ).lower(), 'use_paging' : grid.use_paging, 'legend' : grid.legend, - 'current_item_id' : '' + 'current_item_id' : False, + 'use_panels' : context.get('use_panels') } ## add current item if exists @@ -94,6 +109,7 @@ 'target' : operation.target, 'label' : operation.label, 'confirm' : operation.confirm, + 'inbound' : operation.inbound, 'global_operation' : False }) if operation.allow_multiple: @@ -107,7 +123,8 @@ for action in grid.global_actions: self.grid_config['global_actions'].append({ 'url_args' : url(**action.url_args), - 'label' : action.label + 'label' : action.label, + 'inbound' : action.inbound }) endfor @@ -144,6 +161,9 @@ link = None endif + ## inbound + inbound = column.inbound + ## get value value = column.get_value( trans, grid, item ) @@ -158,7 +178,8 @@ ## Item dictionary item_dict['column_config'][column.label] = { 'link' : link, - 'value' : value + 'value' : value, + 'inbound' : inbound } endif endfor @@ -181,36 +202,29 @@ ## <%def name="center_panel()"> - ${self.grid_body( grid )} + ${self.grid_body()} </%def> ## Render the grid's basic elements. Each of these elements can be subclassed. <%def name="body()"> - ${self.grid_body( grid )} + ${self.grid_body()} </%def> ## Because body() is special and always exists even if not explicitly defined, ## it's not possible to override body() in the topmost template in the chain. ## Because of this, override grid_body() instead. -<%def name="grid_body( grid )"> - ${self.make_grid( grid )} +<%def name="grid_body()"> + ${self.load()} </%def><%def name="title()">${self.grid_config['title']}</%def> -<%def name="javascripts()"> - ${parent.javascripts()} - ${self.grid_javascripts()} -</%def> - <%def name="grid_javascripts()"> - ${h.js("libs/jquery/jquery.autocomplete", "galaxy.autocom_tagging", "libs/jquery/jquery.rating", "galaxy.grids" )} + ${h.js("libs/jquery/jquery.autocomplete", "galaxy.autocom_tagging", "libs/jquery/jquery.rating" )} ${handle_refresh_frames()} <script type="text/javascript"> - var gridView = null; - function add_tag_to_grid_filter (tag_name, tag_value) { // Put tag name and value together. @@ -218,23 +232,6 @@ $('#advanced-search').show('fast'); gridView.add_filter_condition("tags", tag, true); }; - - $(function() { - ## get configuration - var grid_config = ${ h.to_json_string( self.grid_config ) }; - - // Create grid. - var grid = new Grid(grid_config); - - // strip protocol and domain - var url = grid.get('url_base'); - url = url.replace(/^.*\/\/[^\/]+/, ''); - grid.set('url_base', url); - - // Create view. - gridView = new GridView(grid); - }); - </script></%def> @@ -290,16 +287,25 @@ %if self.grid_config['global_actions']: <ul class="manage-table-actions"> - %if len( self.grid_config['global_actions'] ) < 3: - %for action in self.grid_config['global_actions']: - <li><a class="action-button" href="${action['url_args']}">${action['label']}</a></li> - %endfor - %else: - <li><a class="action-button" id="action-8675309-popup" class="menubutton">Actions</a></li> - <div popupmenu="action-8675309-popup"> - %for action in self.grid_config['global_actions']: - <a class="action-button" href="${action['url_args']}">${action['label']}</a> - %endfor + <% + show_popup = len( self.grid_config['global_actions'] ) >= 3 + %> + %if show_popup: + <li><a class="action-button" id="popup-global-actions" class="menubutton">Actions</a></li> + <div popupmenu="popup-global-actions"> + %endif + %for action in self.grid_config['global_actions']: + <% + label_cls = "" + if action['inbound']: + label_cls = "use-inbound" + else: + label_cls = "use-outbound" + endif + %> + <li><a class="action-button ${label_cls}" href="${action['url_args']}" onclick="return false;">${action['label']}</a></li> + %endfor + %if show_popup: </div> %endif </ul> @@ -396,23 +402,21 @@ # load attributes link = column_settings['link'] value = column_settings['value'] + inbound = column_settings['inbound'] # check if formatting is defined value = str(value).replace('//', '/') # Attach popup menu? id = "" + cls = "" if column['attach_popup']: id = 'grid-%d-popup' % i - endif - - # Determine appropriate class - cls = "" - if column['attach_popup']: cls = "menubutton" if link: cls += " split" endif + cls += " popup" endif %><td ${nowrap}> @@ -420,7 +424,16 @@ %if len(self.grid_config['operations']) != 0: <div id="${id}" class="${cls}" style="float: left;"> %endif - <a class="label" href="${link}">${value}</a> + + <% + label_class = "" + if inbound: + label_class = "use-inbound" + else: + label_class = "use-outbound" + endif + %> + <a class="label ${label_class}" href="${link}" onclick="return false;">${value}</a> %if len(self.grid_config['operations']) != 0: </div> %endif @@ -430,32 +443,33 @@ </td> %endif %endfor - ## Actions column - <td> - <div popupmenu="${popupmenu_id}"> - %for operation in self.grid_config['operations']: - <% - operation_id = operation['label'] - operation_settings = item['operation_config'][operation_id] - %> - %if operation_settings['allowed'] and operation['allow_popup']: - <% - target = "" - if operation['target']: - target = "target='" + operation['target'] + "'" - %> - %if operation['confirm']: - <a class="action-button" ${target} confirm="${operation['confirm']}" href="${operation_settings['url_args']}">${operation_id}</a> - %else: - <a class="action-button" ${target} href="${operation_settings['url_args']}">${operation_id}</a> - %endif - %endif - %endfor - </div> - </td></tr><% num_rows_rendered += 1 %> %endfor + + ## update configuration + <script type="text/javascript"> + $(function() { + require(['galaxy.grids'], function(mod_grids) { + ## get configuration + var grid_config = ${ h.to_json_string( self.grid_config ) }; + + // Create grid. + var grid = new mod_grids.Grid(grid_config); + + // strip protocol and domain + var url = grid.get('url_base'); + url = url.replace(/^.*\/\/[^\/]+/, ''); + grid.set('url_base', url); + + // Create view. + if (!gridView) + gridView = new mod_grids.GridView(grid); + else + gridView.init_grid(grid); + }); + }); + </script></%def> ## Render grid table footer contents. @@ -510,24 +524,24 @@ %> Page: % if min_page > 1: - <span class='page-link' id="page-link-1"><a href="${url( page=1 )}" page_num="1">1</a></span> ... + <span class='page-link' id="page-link-1"><a href="${url( page=1 )}" page_num="1" onclick="return false;">1</a></span> ... % endif %for page_index in range(min_page, max_page + 1): %if page_index == cur_page_num: <span class='page-link inactive-link' id="page-link-${page_index}">${page_index}</span> %else: <% args = { 'page' : page_index } %> - <span class='page-link' id="page-link-${page_index}"><a href="${url( args )}" page_num='${page_index}'>${page_index}</a></span> + <span class='page-link' id="page-link-${page_index}"><a href="${url( args )}" onclick="return false;" page_num='${page_index}'>${page_index}</a></span> %endif %endfor %if max_page < num_pages: ... - <span class='page-link' id="page-link-${num_pages}"><a href="${url( page=num_pages )}" page_num="${num_pages}">${num_pages}</a></span> + <span class='page-link' id="page-link-${num_pages}"><a href="${url( page=num_pages )}" onclick="return false;" page_num="${num_pages}">${num_pages}</a></span> %endif </span> ## Show all link - <span class='page-link' id='show-all-link-span'> | <a href="${url( page='all' )}" page_num="all">Show All</a></span> + <span class='page-link' id='show-all-link-span'> | <a href="${url( page='all' )}" onclick="return false;" page_num="all">Show All</a></span></td></tr> %endif diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/tagging_common.mako --- a/templates/tagging_common.mako +++ b/templates/tagging_common.mako @@ -135,6 +135,7 @@ ## Build script that augments tags using progressive javascript. <script type="text/javascript"> + $(function() { // // Set up autocomplete tagger. // @@ -212,6 +213,8 @@ }; $('#${elt_id}').autocomplete_tagging(options); + + }); </script> ## Use style to hide/display the tag area. diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/user/openid_manage.mako --- a/templates/user/openid_manage.mako +++ b/templates/user/openid_manage.mako @@ -1,19 +1,10 @@ ## Template generates a grid that enables user to select items. -<%namespace file="../grid_base.mako" import="make_grid" /> +<%inherit file="../grid_base.mako" /> + <%namespace file="login.mako" import="render_openid_form" /> -<%inherit file="../grid_base.mako" /> - -<%def name="grid_body( grid )"> - ${make_grid( grid )} +<%def name="load()"> + ${parent.load()} <h2>Associate more OpenIDs</h2> ${render_openid_form( kwargs['redirect'], True, kwargs['openid_providers'] )} -</%def> - -<%def name="center_panel()"> - <div style="overflow: auto; height: 100%"> - <div class="page-container" style="padding: 10px;"> - ${grid_body( grid )} - </div> - </div> -</%def> +</%def> \ No newline at end of file diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/history/grid.mako --- a/templates/webapps/galaxy/history/grid.mako +++ b/templates/webapps/galaxy/history/grid.mako @@ -1,7 +1,7 @@ <%inherit file="../grid_base.mako"/> -<%def name="grid_body( grid )"> - ${self.make_grid( grid )} +<%def name="load()"> + ${parent.load()} <br/><div class="toolParamHelp" style="clear: both;"> Histories that have been deleted for more than a time period specified by the Galaxy administrator(s) may be permanently deleted. diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/page/select_items_grid.mako --- a/templates/webapps/galaxy/page/select_items_grid.mako +++ b/templates/webapps/galaxy/page/select_items_grid.mako @@ -1,7 +1,3 @@ ## Template generates a grid that enables user to select items. <%namespace file="../grid_base.mako" import="*" /> -${init()} -${grid_javascripts()} -${stylesheets()} -${render_grid_header( grid, False )} -${render_grid_table( grid, show_item_checkboxes=True )} +${load(True)} \ No newline at end of file diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/page/select_items_grid_async.mako --- a/templates/webapps/galaxy/page/select_items_grid_async.mako +++ /dev/null @@ -1,9 +0,0 @@ -<%namespace file="../grid_base.mako" import="*" /> -<%namespace file="/display_common.mako" import="render_message" /> -${init()} -## Always show item checkboxes so that users can select items. -${render_grid_table_body_contents( grid, show_item_checkboxes=show_item_checkboxes )} -***** -${num_pages} -***** -${render_message( message, status )} \ No newline at end of file diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/tracks/add_to_viz.mako --- a/templates/webapps/galaxy/tracks/add_to_viz.mako +++ b/templates/webapps/galaxy/tracks/add_to_viz.mako @@ -1,8 +1,3 @@ ## Template generates a grid that enables user to add tracks <%namespace file="../grid_base.mako" import="*" /> -${init()} -${stylesheets()} -${grid_javascripts()} -${render_grid_header( grid, False )} -${render_grid_table( grid, show_item_checkboxes=True )} - +${load(True)} diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/tracks/add_tracks.mako --- a/templates/webapps/galaxy/tracks/add_tracks.mako +++ b/templates/webapps/galaxy/tracks/add_tracks.mako @@ -1,7 +1,3 @@ ## Template generates a grid that enables user to add tracks <%namespace file="../grid_base.mako" import="*" /> -${init()} -${stylesheets()} -${grid_javascripts()} -${render_grid_header( grid, False )} -${render_grid_table( grid, show_item_checkboxes=True )} \ No newline at end of file +${load(True)} \ No newline at end of file diff -r 82e91d215acf573d96d3d377620ed8815368c86d -r 3f630f92f5983c28e1aedff312e7ff7e598fe23c templates/webapps/galaxy/tracks/history_select_grid.mako --- a/templates/webapps/galaxy/tracks/history_select_grid.mako +++ b/templates/webapps/galaxy/tracks/history_select_grid.mako @@ -3,19 +3,15 @@ ## can be easily subclassed. Importing methods like this template does ## not make it possible to easily subclass templates. ## -<%namespace file="../grid_base.mako" import="*" /> -${init()} -${stylesheets()} -${grid_javascripts()} +<%namespace name="grid_base" file="../grid_base.mako" import="*" /><%def name="select_header()"><script type="text/javascript"> // Load all grid URLs into modal-body element so that // grid + links stays embedded. $(document).ready(function() { - $(".addtracktab, #grid-table a").off(); - $(".addtracktab, #grid-table a").click(function() { - var modal_body = $(".modal-body"); + $(".addtracktab").click(function() { + var modal_body = $(this).closest('.inbound'); if (modal_body.length !== 0) { modal_body.load($(this).attr("href")); return false; @@ -78,12 +74,11 @@ <div class="divider"></div></%def> -${select_header()} ## Need to define title so that it can be overridden by child templates. <%def name="title()"></%def> -${self.title()} - -${render_grid_header( grid, False )} -${render_grid_table( grid, show_item_checkboxes=show_item_checkboxes )} - +<div class='inbound'> + ${select_header()} + ${self.title()} + ${grid_base.load(True)} +</div> 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.
participants (1)
-
commits-noreply@bitbucket.org