Changeset 7780


Ignore:
Timestamp:
Feb 28, 2020, 1:31:08 PM (22 months ago)
Author:
Nicklas Nordborg
Message:

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

Improved column titles for parent items.

Location:
trunk
Files:
2 edited

Legend:

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

    r7779 r7780  
    11package net.sf.basedb.clients.web.extensions.list;
    22
     3import java.util.HashMap;
     4import java.util.Map;
    35import java.util.Set;
    46
     
    6870          property = m.getPropertyPath(path, false);
    6971          col = new ParentItemPropertyColumn(index, expr, parentFilter, helper, property);
    70           col.setTitle(subtype.getName()+"."+path);
     72          col.setTitle(subtype.getName()+"."+pathToTitle(path));
    7173          col.setTooltip(subtype.getName() + " › "+path);
    7274        }
     
    110112  }
    111113
     114  private static Map<String, String> pathTitles = new HashMap<>();
     115 
     116  static
     117  {
     118    // See also add_parent_columns.js
     119    pathTitles.put("externalId", "External ID");
     120    pathTitles.put("bioWell.bioPlate", "Bioplate");
     121    pathTitles.put("entryDate", "Registered");
     122    pathTitles.put("remainingQuantity", "Remaining quantity");
     123    pathTitles.put("creationEvent.entryDate", "Registered");
     124    pathTitles.put("creationEvent.protocol", "Protocol");
     125    pathTitles.put("creationEvent.hardware", "Hardware");
     126    pathTitles.put("remainingQuantity", "Remaining quantity");
     127  }
     128 
     129  /**
     130    Convert some paths to a more user-friendly title instead.
     131  */
     132  private static String pathToTitle(String path)
     133  {
     134    String title = pathTitles.get(path);
     135    return title == null ? path.substring(0, 1).toUpperCase() + path.substring(1) : title;
     136  }
     137 
    112138  private final int index;
    113139  private final Filter<Annotatable> filter;
  • trunk/www/common/columns/add_parent_column.js

    r7779 r7780  
    3232  var currentAnnotationTypesCategory;
    3333 
     34  // See also net.sf.basedb.clients.web.extensions.list.ParentItemColumn.pathTitles
     35
    3436  var nameCol = {'id': '.', 'text': 'Name'};
    3537  var externalIdCol = {'id': 'externalId', 'text': 'External ID'};
     
    181183      return;
    182184    }
     185    data.subtypeName = frm.subtype[frm.subtype.selectedIndex].text;
    183186
    184187    var numSelected = 0;
     
    190193        data.column = col.value;
    191194        data.property = '/'+data.parentType+'/'+data.subtype+'/'+data.column;
    192         data.title = col.value == '.' ? frm.subtype[frm.subtype.selectedIndex].text : col.text;
     195        data.title = data.subtypeName + (col.value == '.' ? '' : '.'+col.text);
    193196        Events.sendCustomEvent(window.opener.Doc.element('selectParentItemColumn'), 'base-selected', data);
    194197        numSelected++;
Note: See TracChangeset for help on using the changeset viewer.