Changeset 6692


Ignore:
Timestamp:
Jan 21, 2015, 3:42:04 PM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1911: Quick-filter in edit inherited annotations dialog

Location:
trunk/www/common/annotations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/common/annotations/inherit.js

    r6684 r6692  
    2626{
    2727  var inherit = {};
     28  var joustTree;
    2829
    2930  inherit.initPage = function()
     
    3233    Buttons.addClickHandler('close', App.closeWindow);
    3334    Buttons.addClickHandler('btnSave', inherit.save);
     35   
     36    Events.addEventHandler('quickFilter', 'keyup', inherit.quickFilter);
    3437 
    3538    IconStore.addDefaultIcons();
     
    4144    Events.addEventHandler('joust', 'joust-select', inherit.onSelect);
    4245    Joust2.draw('joust');
     46    joustTree = Data.json('joust', 'joust-tree');
    4347  }
    4448
     
    155159  }
    156160
     161  inherit.quickFilter = function()
     162  {
     163    var frm = document.forms['annotations'];
     164    var filter = frm.quickFilter.value.toLowerCase();
     165    var totalVisible = 0;
     166    for (var itemNo = 0; itemNo < joustTree.length; itemNo++)
     167    {
     168      var menuItem = joustTree[itemNo];
     169      var childrenVisible = 0;
     170      for (var childNo = 0; childNo < menuItem.children.length; childNo++)
     171      {
     172        var childItem = menuItem.children[childNo];
     173        var visible = !filter || childItem.annotationType.toLowerCase().indexOf(filter)>=0;
     174        Doc.showHide(childItem.id, visible);
     175        if (visible) childrenVisible++;
     176      }
     177      totalVisible += childrenVisible;
     178      Doc.showHide(menuItem.id, childrenVisible > 0);
     179    }
     180
     181    Doc.showHide('noMatchingFilter', totalVisible == 0);
     182  }
    157183   
    158184   
  • trunk/www/common/annotations/inherit.jsp

    r6607 r6692  
    299299    <div class="absolutefull bg-filled-100 rightborder" style="width: 28em;">
    300300   
    301       <div class="absolutefull parameterlist" style="bottom: 3em;">
     301      <div class="absolutefull bottomborder" style="height: 2em;">
     302      <%
     303      if (parentAnnotations.size() > 0)
     304      {
     305        %>
     306        <table style="width: 100%;">
     307        <tr>
     308          <td style="padding-left: 4px; padding-right: 4px;"><base:icon image="filter.png"/></td>
     309          <td style="width: 100%; padding-top: 1px;">
     310            <input type="text" name="quickFilter" id="quickFilter"
     311              class="auto-init" data-auto-init="focus"
     312              style="width: calc(100% - 10px);"
     313              title="Type to filter annotation types">
     314          </td>
     315        </table>
     316        <%
     317      }
     318      %>
     319      </div>
     320      <div class="absolutefull parameterlist" style="top: 2em; bottom: 3em;">
    302321        <div id="joust" class="joust absolutefull"
    303322          data-joust-tree="<%=HTML.encodeTags(json.toJSONString()) %>"
     
    307326          {
    308327            %>
    309             <div class="messagecontainer error">There are no parent items with annotations.</div>
     328            <div class="messagecontainer error" style="margin: 2em;">There are no parent items with annotations.</div>
    310329            <%
    311330          }
    312331          %>
     332          <div id="noMatchingFilter" class="messagecontainer error" style="margin: 2em; display: none;">No annotations matches the filter.</div>
    313333        </div>
    314334      </div>
Note: See TracChangeset for help on using the changeset viewer.