Changeset 7852


Ignore:
Timestamp:
Oct 16, 2020, 2:34:11 PM (14 months ago)
Author:
Nicklas Nordborg
Message:

References #2222: Add support for manually adding any-to-any link column in table lists

Implemented a function for remembering the most recently used item types when adding a column. The most recent types are then displayed first in the selection list.

Location:
trunk/www/common/columns
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/common/columns/add_linkeditem_column.js

    r7851 r7852  
    5555    data.targetItemType = frm.targetItemType.value;
    5656    data.property = '|'+data.linkName;
    57     if (data.targetItemType) data.property += '|'+data.targetItemType;
     57    if (data.targetItemType)
     58    {
     59      data.property += '|'+data.targetItemType;
     60      // Store the selected target type in "recently used" list
     61      var url = 'ajax.jsp?ID='+App.getSessionId();
     62      url += '&cmd=AddRecentlyUsedLinkTargetType&itemType='+encodeURIComponent(data.targetItemType);
     63      var request = Ajax.getXmlHttpRequest();
     64      request.open("POST", url, true);
     65      request.send(null);
     66    }
    5867    data.title = data.linkName;
    5968    Events.sendCustomEvent(window.opener.Doc.element('selectLinkedItemColumn'), 'base-selected', data);
  • trunk/www/common/columns/add_linkeditem_column.jsp

    r7851 r7852  
    2121
    2222--%>
    23 <%@page import="net.sf.basedb.core.Metadata"%>
    2423<%@ page pageEncoding="UTF-8" session="false"
    2524  import="net.sf.basedb.core.SessionControl"
    2625  import="net.sf.basedb.core.Item"
     26  import="net.sf.basedb.core.ItemContext"
     27  import="net.sf.basedb.core.Metadata" 
    2728  import="net.sf.basedb.clients.web.Base"
    2829  import="net.sf.basedb.clients.web.util.HTML"
    2930  import="net.sf.basedb.util.Values"
     31  import="java.util.Arrays"
    3032  import="java.util.List"
    3133%>
     
    3537final String ID = sc.getId();
    3638final Item itemType = Item.valueOf(request.getParameter("item_type"));
     39final ItemContext cc = Base.getAndSetCurrentContext(sc, Item.ANYTOANY, null, null);
    3740%>
    3841<base:page type="popup" title="Add linked item column">
     
    6063        <option value="">- any -
    6164        <%
     65        List<String> recentTypes = cc.getRecent("toTypes");
     66        if (recentTypes.size() == 0)
     67        {
     68          recentTypes = Arrays.asList("FILE");
     69        }
     70        %>
     71        <option value="0" disabled class="recentheader">- recently used -
     72        <%
     73        for (String r : recentTypes)
     74        {
     75          %>
     76          <option value="<%=r%>"><%=r%>
     77          <%
     78        }
     79        %>
     80        <option value="0" disabled class="recentheader">- all -
     81        <%
    6282        for (Item targetItem : Metadata.getNameableItems())
    6383        {
     
    6585          {
    6686            %>
    67             <option value="<%=targetItem.name() %>"><%=targetItem.toString() %>
     87            <option value="<%=targetItem.name() %>"><%=targetItem.name() %>
    6888            <%
    6989          }
  • trunk/www/common/columns/ajax.jsp

    r7843 r7852  
    3030  import="net.sf.basedb.core.Type"
    3131  import="net.sf.basedb.core.ItemQuery"
     32  import="net.sf.basedb.core.ItemContext"
    3233  import="net.sf.basedb.core.ItemSubtype"
    3334  import="net.sf.basedb.core.RawDataTypes"
     
    165166    json.put("items", jsonLazy);
    166167  }
     168  else if ("AddRecentlyUsedLinkTargetType".equals(cmd))
     169  {
     170    ItemContext cc = Base.getAndSetCurrentContext(sc, Item.ANYTOANY, null, null);
     171    cc.setRecent("toTypes", itemType.name(), Base.getMaxRecent(sc));
     172    System.out.println("recently used:" + cc.getRecent("toTypes"));
     173  }
    167174  else
    168175  {
Note: See TracChangeset for help on using the changeset viewer.