Changeset 6689


Ignore:
Timestamp:
Jan 21, 2015, 11:35:06 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1906: Display inherited annotations in list views

The "Configure columns" dialog can now be used to add inherited annotation columns. This must be enabled from the list page by setting <tbl:table ... data-inherited-annotations="true"> in the table definition.

First implementation is made in the list raw bioassays table.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r6282 r6689  
    10141014
    10151015  /**
     1016    Get a query returning all annotation types that are needed to display
     1017    inherited annotations for the given columns. The columns is a string with
     1018    comma-separated values that define the visible columns in a table.
     1019    Columns for inherited annotations are defined by 'ia'+<id>.
     1020    @since 3.5
     1021  */
     1022  public static ItemQuery<AnnotationType> getInheritedAnnotationColumns(String columns)
     1023  {
     1024    ItemQuery<AnnotationType> q = AnnotationType.getQuery(null);
     1025    q.order(Orders.asc(Hql.property("name")));
     1026    q.include(Include.ALL);
     1027    q.restrict(Restrictions.in(Hql.property("id"), Expressions.parameter("ids")));
     1028    List<Integer> ids = new ArrayList<Integer>();
     1029    ids.add(0);
     1030    if (columns != null)
     1031    {
     1032      for (String c : columns.split(","))
     1033      {
     1034        if (c.startsWith("ia")) ids.add(Integer.parseInt(c.substring(2)));
     1035      }
     1036    }
     1037    q.setParameter("ids", ids, Type.INT);
     1038    q.setCacheResult(true);
     1039    return q;
     1040  }
     1041 
     1042  /**
    10161043    Get a query that returns all subtypes for the given main item type.
    10171044    @param itemType The main item type
  • trunk/www/common/columns/configure.js

    r6684 r6689  
    4949    Buttons.addClickHandler('btnSavePreset', configure.savePresetAs);
    5050    Events.addEventHandler('presets', 'change', configure.presetOnChange);
     51    if (Doc.element('selectAnnotationTypes'))
     52    {
     53      Buttons.addClickHandler('selectAnnotationTypes', configure.selectAnnotationTypes);
     54      Events.addEventHandler('selectAnnotationTypes', 'base-selected', configure.annotationTypeSelected);
     55    }
    5156   
    5257    Buttons.addClickHandler('moveUp', configure.moveVisibleUpOrDown);
     
    146151    {
    147152      var temp = [];
    148       for (var i = 0; i < columnDefs.length; i++) // >
     153      for (var i = 0; i < columnDefs.length; i++)
    149154      {
    150155        var col = columnDefs[i];
     
    171176  }
    172177
     178 
     179  configure.selectAnnotationTypes = function(event)
     180  {
     181    var frm = document.forms['columns'];
     182    var exclude = [];
     183    for (var i = 0; i < frm.visible.length; i++)
     184    {
     185      if (frm.visible[i].value.indexOf('ia')==0)
     186      {
     187        exclude[exclude.length] = frm.visible[i].value.substring(2);
     188      }
     189    }
     190    var url = '&exclude='+exclude.join(',');
     191    Dialogs.selectItem('ANNOTATIONTYPE', event.currentTarget.id, 1, url);
     192  }
     193 
     194  configure.annotationTypeSelected = function(event)
     195  {
     196    var frm = document.forms['columns'];
     197    var item = event.detail;
     198    var colId = 'ia'+item.id;
     199    // Do not add duplicates
     200    for (var i = 0; i < frm.visible.length; i++)
     201    {
     202      if (frm.visible[i].value == colId) return;
     203    }
     204    // Remove from 'hidden' list
     205    for (var i = frm.hidden.length-1; i >= 0; i--)
     206    {
     207      if (frm.hidden[i].value == colId) frm.hidden[i] = null;
     208    }
     209    frm.visible[frm.visible.length] = new Option(item.name + ' [I]', colId);
     210  }
     211 
    173212  /**
    174213    Save the current selection and close the dialog.
  • trunk/www/common/columns/configure.jsp

    r6608 r6689  
    4646<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    4747<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
    48 
     48<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
    4949<%
    5050final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
     
    5353final String subContext = Values.getString(request.getParameter("subcontext"), "");
    5454final String tableId = request.getParameter("table_id");
     55final boolean enableInheritedAnnotations = Values.getBoolean(request.getParameter("enableInheritedAnnotations"));
    5556final ItemContext cc = sc.getCurrentContext(itemType, subContext);
    5657
     
    5960%>
    6061  <base:page type="popup" title="Set column order and visibility">
    61   <base:head scripts="~configure.js" />
     62  <base:head scripts="~configure.js" styles="toolbar.css" />
    6263  <base:body>
    6364    <h1>Set column order and visiblity <base:help helpid="columns.configure" /></h1>
     
    7475    <div class="content bg-filled-50 bottomborder">
    7576    <table style="width: 100%; height: 100%;">
     77    <%
     78    if (enableInheritedAnnotations)
     79    {
     80      %>
     81      <tr>
     82        <td colspan="4" style="vertical-align: top;">
     83        <tbl:toolbar subclass="bottomborder">
     84          <tbl:button
     85            id="selectAnnotationTypes"
     86            image="add.png"
     87            title="Add inherited annotations&hellip;"
     88            tooltip="Add columns for inherited annotations"
     89           />
     90        </tbl:toolbar>
     91        </td>
     92      </tr>
     93      <%
     94    }
     95    %>
    7696    <tr>
    7797      <td style="padding: 5px;">
     
    121141        </select>
    122142      </td>
    123     </tr>   
     143    </tr>
    124144    <tr>
    125145      <td colspan="4" >
  • trunk/www/include/scripts/table.js

    r6576 r6689  
    418418    var itemType = Data.get(tableDiv, 'item-type');
    419419    var subContext = Data.get(tableDiv, 'subcontext', '');
     420    var enableInheritedAnnotations = Data.get(tableDiv, 'inherited-annotations');
    420421   
    421422    var url = App.getRoot()+'common/columns/configure.jsp?ID='+App.getSessionId();
    422423    url += '&table_id='+tableDiv.id+'&item_type='+itemType+'&subcontext='+subContext;
     424    if (enableInheritedAnnotations)
     425    {
     426      url += '&enableInheritedAnnotations='+encodeURIComponent(enableInheritedAnnotations);
     427    }
    423428    if (settingName) url += '&settingName='+settingName;
    424429    Dialogs.openPopup(url, 'ConfigureColumns', 750, 450);
  • trunk/www/views/rawbioassays/list_rawbioassays.jsp

    r6604 r6689  
    109109try
    110110{
    111   final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     111  ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
    112112  SnapshotManager manager = new SnapshotManager();
    113113  for (AnnotationType at : annotationTypeQuery.list(dc))
    114114  {
    115115    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
     116  }
     117  annotationTypeQuery = Base.getInheritedAnnotationColumns(cc.getSetting("columns"));
     118  for (AnnotationType at : annotationTypeQuery.list(dc))
     119  {
     120    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at, false, true));
    116121  }
    117122
     
    171176      item="<%=itemType%>"
    172177      subclass="fulltable"
     178      data-inherited-annotations="true"
    173179      >
    174180      <tbl:hidden
     
    414420        %>
    415421        <tbl:columndef
    416           id="<%="at"+at.getId()%>"
    417           title="<%=HTML.encodeTags(at.getName())+" [A]"%>"
    418           property="<%="#"+at.getId()%>"
     422          id="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+at.getId()%>"
     423          title="<%=HTML.encodeTags(at.getName())+(loader.isSearchingInheritedAnnotations() ? " [I]" : " [A]")%>"
     424          property="<%=(loader.isSearchingInheritedAnnotations() ? "##" : "#")+at.getId()%>"
    419425          annotation="true"
    420426          datatype="<%=at.getValueType().getStringValue()%>"
    421427          enumeration="<%=annotationEnum%>"
    422428          smartenum="<%=at.getDisplayAsList() %>"
    423           sortable="<%=at.getMultiplicity() == 1%>"
     429          sortable="<%=at.getMultiplicity() == 1 && !loader.isSearchingInheritedAnnotations()%>"
    424430          filterable="true"
    425431          exportable="true"
     
    790796                      %>
    791797                      <tbl:cell
    792                         column="<%="at"+loader.getId()%>"
     798                        column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
    793799                        ><tbl:cellvalue
    794800                          list="<%=loader.getValues()%>"
Note: See TracChangeset for help on using the changeset viewer.