<%! from galaxy.web.framework.helpers.grids import TextColumn import galaxy.util def inherit(context): if context.get('use_panels'): if context.get('webapp'): webapp = context.get('webapp') else: webapp = 'galaxy' return '/webapps/%s/base_panels.mako' % webapp else: return '/base.mako' %> <%inherit file="${inherit(context)}"/> <%namespace file="/display_common.mako" import="render_message" /> <%def name="init()"> <% self.has_left_panel=False self.has_right_panel=False self.message_box_visible=False self.active_view="user" self.overlay_visible=False %> ## ## Override methods from base.mako and base_panels.mako ## <%def name="center_panel()"> ${make_grid( grid )} ## Render the grid's basic elements. Each of these elements can be subclassed. <%def name="body()"> ${make_grid( grid )} <%def name="title()">${grid.title} <%def name="javascripts()"> ${parent.javascripts()} ${self.grid_javascripts()} <%def name="grid_javascripts()"> ${h.js("jquery.autocomplete", "autocomplete_tagging", "jquery.rating" )} <%def name="stylesheets()"> ${parent.stylesheets()} ${h.css( "autocomplete_tagging", "jquery.rating" )} ## ## Custom grid methods. ## <%namespace file="./grid_common.mako" import="*" /> <%def name="make_grid( grid )">
${self.render_grid_header( grid )}
${render_message( message, status )}
${self.render_grid_table( grid )} ## Render grid header. <%def name="render_grid_header( grid, render_title=True)">
%if render_title:

${grid.title}

%endif %if grid.global_actions: %endif ${render_grid_filters( grid )}
## Render grid. <%def name="render_grid_table( grid, show_item_checkboxes=False)"> <% # Set flag to indicate whether grid has operations that operate on multiple items. multiple_item_ops_exist = False for operation in grid.operations: if operation.allow_multiple: multiple_item_ops_exist = True # Show checkboxes if flag is set or if multiple item ops exist. if show_item_checkboxes or multiple_item_ops_exist: show_item_checkboxes = True %>
%if show_item_checkboxes: %endif %for column in grid.columns: %if column.visible: <% href = "" extra = "" if column.sortable: if sort_key.endswith(column.key): if not sort_key.startswith("-"): href = url( sort=( "-" + column.key ) ) extra = "↓" else: href = url( sort=( column.key ) ) extra = "↑" else: href = url( sort=column.key ) %> 1: colspan="${column.ncells}" %endif > %if href: ${column.label} %else: ${column.label} %endif ${extra} %endif %endfor ${render_grid_table_body_contents( grid, show_item_checkboxes )} ${render_grid_table_footer_contents( grid, show_item_checkboxes )}
## Render grid table body contents. <%def name="render_grid_table_body_contents(grid, show_item_checkboxes=False)"> <% num_rows_rendered = 0 %> %if query.count() == 0: ## No results. No Items <% num_rows_rendered = 1 %> %endif %for i, item in enumerate( query ): <% encoded_id = trans.security.encode_id( item.id ) %> ## Item selection column %if show_item_checkboxes: %endif ## Data columns %for column in grid.columns: %if column.visible: <% # Link link = column.get_link( trans, grid, item ) if link: href = url( **link ) else: href = None # Value (coerced to list so we can loop) value = column.get_value( trans, grid, item ) if column.ncells == 1: value = [ value ] %> %for cellnum, v in enumerate( value ): <% id = "" # Handle non-ascii chars. if isinstance(v, str): v = unicode(v, 'utf-8') # Attach popup menu? if column.attach_popup and cellnum == 0: id = 'grid-%d-popup' % i # Determine appropriate class cls = "" if column.attach_popup or href: cls = "menubutton" if column.attach_popup and href: cls = "menubutton split" %> %if href: %if len(grid.operations) != 0:
%endif ${v} %if len(grid.operations) != 0:
%endif %else:
%endif %endfor %endif %endfor ## Actions column
%for operation in grid.operations: %if operation.allowed( item ) and operation.allow_popup: <% target = "" if operation.target: target = "target='" + operation.target + "'" %> %if operation.confirm: ${operation.label} %else: ${operation.label} %endif %endif %endfor
<% num_rows_rendered += 1 %> %endfor ## Dummy rows to prevent table for moving too much. ##%if grid.use_paging: ## %for i in range( num_rows_rendered , grid.num_rows_per_page ): ## ## %endfor ##%endif ## Render grid table footer contents. <%def name="render_grid_table_footer_contents(grid, show_item_checkboxes=False)"> ## Row for navigating among pages. <%namespace file="/display_common.mako" import="get_class_plural" /> <% items_plural = get_class_plural( grid.model_class ).lower() %> %if grid.use_paging and num_pages > 1: %if show_item_checkboxes: %endif ## Page links. Page: %for page_index in range(1, num_pages + 1): %if page_index == cur_page_num: ${page_index} %else: <% args = { 'page' : page_index } %> ${page_index} %endif %endfor ## Show all link. <% args = { "page" : "all" } %> | Show all ${items_plural} on one page %endif ## Grid operations for multiple items. %if show_item_checkboxes: For selected ${items_plural}: %for operation in grid.operations: %if operation.allow_multiple: %endif %endfor %endif