Changeset 7773


Ignore:
Timestamp:
Feb 17, 2020, 11:10:58 AM (22 months ago)
Author:
Nicklas Nordborg
Message:

References #2202: Include information from parent items in list pages

Implemented a simple dialog for selecting parent item columns. It currently allows selecting to display the name of a parent item or any annotation that is attached to it. It can probably be improved a bit more.

Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/list/ParentItemColumn.java

    r7770 r7773  
    5555        col.setTooltip(subtype.getName() + " › "+at.getName());
    5656        col.setValueType(at.getValueType());
     57        col.setClazz("parentitemcol");
    5758        col.setExportFormatter(FormatterFactory.getTypeFormatter(dc.getSessionControl(), at.getValueType()));
    5859        if (!helper.lazy) col.setFormatter(new CollectionFormatter(col.getExportFormatter()));
     
    7879        }
    7980        col.setValueType(Type.STRING);
     81        col.setClazz("parentitemcol");
    8082        if (property == null || property.getHibernateType().isEntityType())
    8183        {
  • trunk/src/clients/web/web-extensions.xml

    r7764 r7773  
    296296 
    297297  <extension
    298     id="parent-item-columns"
    299     extends="net.sf.basedb.clients.web.listcolumn.rawbioassay">
    300     <index>2</index>
     298    id="parent-item-columns">
     299    <extends>
     300      <ref index="2">net.sf.basedb.clients.web.listcolumn.rawbioassay</ref>
     301      <ref index="2">net.sf.basedb.clients.web.listcolumn.derivedbioassay</ref>
     302      <ref index="2">net.sf.basedb.clients.web.listcolumn.physicalbioassay</ref>
     303      <ref index="2">net.sf.basedb.clients.web.listcolumn.extract</ref>
     304      <ref index="2">net.sf.basedb.clients.web.listcolumn.sample</ref>
     305    </extends>
    301306    <about>
    302307      <name>Parent item data</name>
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r7605 r7773  
    233233      subclass="fulltable"
    234234      data-inherited-annotations="true"
     235      data-parent-columns="true"
    235236      >
    236237      <tbl:hidden
  • trunk/www/biomaterials/samples/list_samples.jsp

    r7605 r7773  
    208208      subclass="fulltable"
    209209      data-inherited-annotations="true"
     210      data-parent-columns="true"
    210211      >
    211212      <tbl:hidden
  • trunk/www/common/columns/ajax.jsp

    r7768 r7773  
    3434  import="net.sf.basedb.util.error.ThrowableUtil"
    3535  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
     36  import="net.sf.basedb.core.query.Restrictions"
     37  import="net.sf.basedb.core.query.Expressions"
     38  import="net.sf.basedb.core.query.Hql"
    3639  import="net.sf.basedb.clients.web.AnnotationUtil"
    3740  import="net.sf.basedb.clients.web.Base"
     
    8790   
    8891  }
     92  else if ("GetAnnotationTypesForCategory".equals(cmd))
     93  {
     94    dc = sc.newDbControl();
     95    String category = Values.getStringOrNull(request.getParameter("category"));
     96    JSONArray jsonAnnotationTypes = new JSONArray();
     97    if (category != null)
     98    {
     99      ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     100      annotationTypeQuery.join(Hql.innerJoin("categories", "c"));
     101      annotationTypeQuery.restrict(Restrictions.eq(Hql.property("c", "name"), Expressions.string(category)));
     102      for (AnnotationType at : annotationTypeQuery.list(dc))
     103      {
     104        JSONObject jsonAt = new JSONObject();
     105        jsonAt.put("id", at.getId());
     106        jsonAt.put("name", at.getName());
     107        jsonAnnotationTypes.add(jsonAt);
     108      }
     109    }
     110    json.put("annotationTypesCategory", jsonAnnotationTypes);
     111  }
    89112  else if ("GetLazyParentColumns".equals(cmd))
    90113  {
  • trunk/www/common/columns/configure.js

    r7604 r7773  
    5454      Buttons.addClickHandler('selectAnnotationTypes', configure.selectAnnotationTypes);
    5555      Events.addEventHandler('selectAnnotationTypes', 'base-selected', configure.annotationTypeSelected);
     56    }
     57    if (Doc.element('selectParentItemColumn'))
     58    {
     59      Buttons.addClickHandler('selectParentItemColumn', configure.selectParentItemColumn);
     60      Events.addEventHandler('selectParentItemColumn', 'base-selected', configure.parentItemColumnSelected);
    5661    }
    5762   
     
    212217  }
    213218 
     219 
     220  configure.selectParentItemColumn = function(event)
     221  {
     222    var frm = document.forms['columns'];
     223    var url = 'add_parent_column.jsp?ID='+App.getSessionId();
     224    url += '&item_type='+Data.get('page-data', 'item-type');
     225    Dialogs.openPopup(url, 'SelectParentItemColumn', 600, 400);
     226  }
     227
     228  configure.parentItemColumnSelected = function(event)
     229  {
     230    var frm = document.forms['columns'];
     231    var data = event.detail;
     232    // Do not add duplicates
     233    for (var i = 0; i < frm.visible.length; i++)
     234    {
     235      if (frm.visible[i].value == data.property) return;
     236    }
     237
     238    frm.visible[frm.visible.length] = new Option(data.title, data.property);
     239  }
     240 
    214241  /**
    215242    Save the current selection and close the dialog.
  • trunk/www/common/columns/configure.jsp

    r7605 r7773  
    5454final String tableId = request.getParameter("table_id");
    5555final boolean enableInheritedAnnotations = Values.getBoolean(request.getParameter("enableInheritedAnnotations"));
     56final boolean enableParentColumns = Values.getBoolean(request.getParameter("enableParentColumns"));
    5657final ItemContext cc = sc.getCurrentContext(itemType, subContext);
    5758
     
    7677    <table style="width: 100%; height: 100%;">
    7778    <%
    78     if (enableInheritedAnnotations)
     79    if (enableInheritedAnnotations || enableParentColumns)
    7980    {
    8081      %>
     
    8788            title="Add inherited annotations&hellip;"
    8889            tooltip="Add columns for inherited annotations"
     90            visible="<%=enableInheritedAnnotations %>"
     91           />
     92          <tbl:button
     93            id="selectParentItemColumn"
     94            image="add.png"
     95            title="Add parent item columns&hellip;"
     96            tooltip="Add columns from parent items"
     97            visible="<%=enableParentColumns %>"
    8998           />
    9099        </tbl:toolbar>
  • trunk/www/include/scripts/table.js

    r7419 r7773  
    884884    var subContext = Data.get(tableDiv, 'subcontext', '');
    885885    var enableInheritedAnnotations = Data.get(tableDiv, 'inherited-annotations');
     886    var enableParentColumns = Data.get(tableDiv, 'parent-columns');
    886887   
    887888    var url = App.getRoot()+'common/columns/configure.jsp?ID='+App.getSessionId();
     
    890891    {
    891892      url += '&enableInheritedAnnotations='+encodeURIComponent(enableInheritedAnnotations);
     893    }
     894    if (enableParentColumns)
     895    {
     896      url += '&enableParentColumns='+encodeURIComponent(enableParentColumns);
    892897    }
    893898    if (settingName) url += '&settingName='+settingName;
  • trunk/www/views/derivedbioassays/list_bioassays.jsp

    r7605 r7773  
    185185      subclass="fulltable"
    186186      data-inherited-annotations="true"
     187      data-parent-columns="true"
    187188      >
    188189      <tbl:hidden
  • trunk/www/views/physicalbioassays/list_bioassays.jsp

    r7605 r7773  
    175175      subclass="fulltable"
    176176      data-inherited-annotations="true"
     177      data-parent-columns="true"
    177178      >
    178179      <tbl:hidden
  • trunk/www/views/rawbioassays/list_rawbioassays.jsp

    r7605 r7773  
    188188      filterrows="<%=cc.getFilterRows()%>"
    189189      data-inherited-annotations="true"
     190      data-parent-columns="true"
    190191      >
    191192      <tbl:hidden
Note: See TracChangeset for help on using the changeset viewer.