Changeset 7803


Ignore:
Timestamp:
May 4, 2020, 10:52:09 AM (21 months ago)
Author:
Nicklas Nordborg
Message:

References #2209: Add items to existing item list from list page

Changed the popup dialog to use the same mechanism for selecting an item that is used in most other places in BASE. Eg. a list that is populated with the most recently used items and a "Select" buttons that opens the list view that allows for searching and filtering. The original implementation with a static list that was populated with all matching item lists can be hard to use if the number of items to select from is large.

Location:
branches/3.16-stable/www/views/itemlists
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.16-stable/www/views/itemlists/add_items.js

    r7801 r7803  
    3030  additems.initPage = function()
    3131  {
     32    // ItemList
     33    Buttons.addClickHandler('item_id.select', additems.selectList);
     34    Events.addEventHandler('item_id', 'base-selected', Items.onItemSelected);
     35   
    3236    // Find out what is selected in the parent form
    3337    var frm = document.forms['additems'];
     
    5054  }
    5155
     56  additems.selectList = function()
     57  {
     58    var frm = document.forms['additems'];
     59    var url = '&resetTemporary=1';
     60    url += '&tmpfilter:BOOLEAN:disableManualMembers=0';
     61    url += '&tmpfilter:INT:memberType='+Data.get('page-data', 'member-type');
     62    if (frm.item_id.length > 0)
     63    {
     64      var id = Math.abs(parseInt(frm.item_id[0].value));       
     65      url += '&item_id='+id;
     66    }
     67    Dialogs.selectItem('ITEMLIST', 'item_id', 0, url);
     68  }
     69 
    5270  // Submit the form
    5371  additems.save = function()
  • branches/3.16-stable/www/views/itemlists/add_items.jsp

    r7801 r7803  
    2929  import="net.sf.basedb.core.Permission"
    3030  import="net.sf.basedb.core.ItemList"
    31   import="net.sf.basedb.core.ItemQuery"
    32   import="net.sf.basedb.core.RawDataType"
    33   import="net.sf.basedb.core.RawDataTypes"
    34   import="net.sf.basedb.core.query.Orders"
    35   import="net.sf.basedb.core.query.Hql"
    36   import="net.sf.basedb.core.query.Expressions"
    37   import="net.sf.basedb.core.query.Restrictions"
    3831  import="net.sf.basedb.clients.web.Base"
    3932  import="net.sf.basedb.clients.web.util.HTML"
     
    5649 
    5750  ItemContext memberContext = sc.getCurrentContext(memberType, subContext);
    58   boolean hasSourceFilter = memberContext.getNumPropertyFilters() > 0;
    59   ItemList recentlyUsed = memberContext.getRecent(dc, Item.ITEMLIST, "AddMembers", 0);
    60  
    61   ItemQuery<ItemList> query = ItemList.getQuery();
    62   query.restrict(Restrictions.eq(
    63       Hql.property("memberType"),
    64       Expressions.integer(memberType.getValue())
    65     ));
    66   query.restrict(Restrictions.eq(Hql.property("disableManualMembers"), Expressions.bool(false)));
    67   query.setItemPermission(Permission.USE);
    68   query.order(Orders.asc(Hql.property("name")));
    69   List<ItemList> itemLists = query.list(dc);
     51  List<ItemList> recentLists = memberContext.getRecent(dc, Item.ITEMLIST, "AddMembers");
    7052  %>
    7153  <base:page type="popup" title="Add items to existing list">
    72   <base:head scripts="~add_items.js">
     54  <base:head scripts="~add_items.js,linkitems-2.js">
    7355  </base:head>
    7456  <base:body>
     
    8466    }
    8567    %>
     68    <div id="page-data" class="datacontainer"
     69      data-member-type="<%=memberType.getValue()%>"
     70    ></div>
     71   
    8672    <div class="content bottomborder">
    8773      <table class="fullform input100">
     
    8975        <th>Which list?</th>
    9076        <td>
    91           <select name="item_id" class="required selectionlist">
    92           <%
    93           for (ItemList list : itemLists)
    94           {
    95             String selected = list.equals(recentlyUsed) ? "selected" : "";
    96             %>
    97             <option value="<%=list.getId()%>" <%=selected%>><%=HTML.encodeTags(list.getName()) %> (<%=list.getSize()%> members)
    98             <%
    99           }
    100           %>
    101           </select>
     77          <base:select
     78            id="item_id"
     79            clazz="selectionlist"
     80            required="true"
     81            current="<%=null%>"
     82            recent="<%=recentLists%>"
     83          />
    10284        </td>
    10385        <td></td>
     
    11395          <input type="radio" name="source" id="sourceAll" value="all" checked
    11496            ><label for="sourceAll">All pages</label><br>
    115           <%
    116           if (itemLists.size() == 0)
    117           {
    118             %>
    119             <div class="messagecontainer error">
    120             Could not find any item lists.
    121             </div>
    122             <%
    123           }
    124           %>
    12597        </td>
    12698        <td></td>
  • branches/3.16-stable/www/views/itemlists/index.jsp

    r7801 r7803  
    562562    ItemList list = ItemList.getById(dc, Values.getInt(itemId));
    563563    String subContext = Values.getString(request.getParameter("subContext"), "");
    564 
     564    final int maxRecent = Base.getMaxRecent(sc);
     565   
    565566    ItemContext memberContext = sc.getCurrentContext(list.getMemberType(), subContext);
    566     memberContext.setRecent(Item.ITEMLIST, list, "AddMembers", 1);
     567    memberContext.setRecent(Item.ITEMLIST, list, "AddMembers", maxRecent);
    567568    ItemQuery<? extends Listable> query = memberContext.getQuery();
    568569    String source = request.getParameter("source");
  • branches/3.16-stable/www/views/itemlists/list_lists.jsp

    r7605 r7803  
    268268      />
    269269      <tbl:columndef
     270        id="disableManualMembers"
     271        property="disableManualMembers"
     272        datatype="boolean"
     273        title="Locked (manual)"
     274        sortable="true"
     275        filterable="true"
     276        exportable="true"
     277      />
     278      <tbl:columndef
     279        id="disableSyncFilters"
     280        property="disableSyncFilters"
     281        datatype="boolean"
     282        title="Locked (sync)"
     283        sortable="true"
     284        filterable="true"
     285        exportable="true"
     286      />
     287      <tbl:columndef
    270288        id="owner"
    271289        property="owner.name"
     
    566584                  /></tbl:cell>
    567585                <tbl:cell column="rawDataType"><%=HTML.encodeTags(item.getRawDataType() != null ? item.getRawDataType().getName() : "")%></tbl:cell>
     586                <tbl:cell column="disableManualMembers"><%=item.getDisableManualMembers() ? "Yes" : "No" %></tbl:cell>
     587                <tbl:cell column="disableSyncFilters"><%=item.getDisableSyncFilters() ? "Yes" : "No" %></tbl:cell>
    568588                <tbl:cell column="owner"
    569589                  ><base:propertyvalue
Note: See TracChangeset for help on using the changeset viewer.