Changeset 6946


Ignore:
Timestamp:
Sep 7, 2015, 9:08:13 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1941: Store experimental factor values as part experiments

Adding 'check all' icons to the annotations list and put some operations in a submenu to save space.

Location:
trunk/www
Files:
1 added
3 edited

Legend:

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

    r6945 r6946  
    4646    annotations = Data.json('page-data', 'annotations');
    4747    // Loop through all annotations and build the selection list
    48     var firstInherited = false;
     48    var numPrimary = 0;
    4949    for (var i = 0; i < annotations.length; i++)
    5050    {
    51       var ann = annotations[i];
    52       if (!firstInherited && ann.source != 'PRIMARY')
    53       {
    54         annotate.createAnnotationEntryInList(annotations[i], true);
    55         firstInherited = true;
    56       }
    57       else
    58       {
    59         annotate.createAnnotationEntryInList(annotations[i], false);
    60       }
    61     }
     51      annotate.createAnnotationEntryInList(annotations[i], true);
     52      if (annotations[i].source == 'PRIMARY') numPrimary++;
     53    }
     54    if (numPrimary == 0) Doc.hide('primary-list');
     55    if (numPrimary == annotations.length) Doc.hide('inherited-list');
    6256
    6357    // Event handlers for input fields
     
    9892    Events.addEventHandler('unit', 'change', annotate.unitOnChange);
    9993   
     94    // Check/uncheck all
     95    Events.addEventHandler('check-all-primary', 'click', annotate.checkAllPrimary);
     96    Events.addEventHandler('check-all-inherited', 'click', annotate.checkAllInherited);
     97   
    10098    // Sync modified clone
    10199    Events.addEventHandler('sync-modified', 'click', annotate.syncSelectedClone);
    102100    Buttons.addClickHandler('btnSync', annotate.syncAllCheckedClones);
    103101   
    104     // Convert inherited annotation to cloned
     102    // Convert between inherited/cloned
    105103    Events.addEventHandler('convert-to-cloned', 'click', annotate.convertSelectedToCloned);
    106104    Buttons.addClickHandler('btnClone', annotate.convertAllCheckedToCloned);
    107    
    108     Buttons.addClickHandler('btnDeclone', annotate.convertAllCheckedToInherited);
    109    
    110     // Delete an inherited/cloned annotation
     105    Buttons.addClickHandler('btnUnclone', annotate.convertAllCheckedToInherited);
     106   
     107    // Delete annotations
    111108    Buttons.addClickHandler('btnDelete', annotate.deleteAllChecked);
    112109   
     
    136133    var ann = entry.annotation;
    137134    var at = entry.annotationType;
    138    
    139     if (firstInherited)
    140     {
    141       var fi = document.createElement('div');
    142       fi.className = 'first-inherited';
    143       Doc.element('annotation-list').appendChild(fi);
    144     }
    145135   
    146136    var div = document.createElement('div');
     
    167157   
    168158    Events.addEventHandler(div, 'click', annotate.annotationOnClick);
    169     Doc.element('annotation-list').appendChild(div);
     159    Doc.element(entry.source == 'PRIMARY' ? 'primary-list' : 'inherited-list').appendChild(div);
    170160  }
    171161 
     
    186176
    187177      var show = false;
    188       if (categoryId == -1)
     178      if (entry.modified == 'DELETE' && entry.source != 'PRIMARY')
     179      {} // Do not show deleted annotations that are not PRIMARY
     180      else if (categoryId == -1)
    189181      {
    190182        // show all
     
    683675
    684676  /**
     677    Toggle the checkbox for all primary annotations. Holding down
     678    CTRL/SHIFT/ALT will selected or deselect all.
     679  */
     680  annotate.checkAllPrimary = function(event)
     681  {
     682    var specialKey = event.altKey || event.ctrlKey || event.shiftKey;
     683    var first = null;
     684    for (var i = 0; i < annotations.length; i++)
     685    {
     686      var entry = annotations[i];
     687      if (entry.source == 'PRIMARY')
     688      {
     689        var checkbox = Doc.element('check.'+entry.id);
     690        if (first == null) first = checkbox.checked;
     691        checkbox.checked = specialKey ? !first : !checkbox.checked;
     692      }
     693    }
     694  }
     695 
     696  /**
     697    Toggle the checkbox for all inherited/cloned annotations. Holding down
     698    CTRL/SHIFT/ALT will selected or deselect all.
     699  */
     700  annotate.checkAllInherited = function(event)
     701  {
     702    var specialKey = event.altKey || event.ctrlKey || event.shiftKey;
     703    var first = null;
     704    for (var i = 0; i < annotations.length; i++)
     705    {
     706      var entry = annotations[i];
     707      if (entry.source != 'PRIMARY')
     708      {
     709        var checkbox = Doc.element('check.'+entry.id);
     710        if (first == null) first = checkbox.checked;
     711        checkbox.checked = specialKey ? !first : !checkbox.checked;
     712      }
     713    }
     714  }
     715 
     716  /**
    685717    Call the given method for all annotations that
    686718    have been checked. The method must take a single
     
    803835  /**
    804836    Converts a CLONED annotation to an INHERITED annotation.
     837    If the annotation is not CLONED or if the parent item
     838    is unknown, nothing is done.
    805839  */
    806840  annotate.convertToInherited = function(entry)
     
    810844    var ann = entry.annotation;
    811845    var inherited = entry.inherited;
     846    if (!inherited) return false;
    812847   
    813848    entry.source = 'INHERITED';
     
    819854  }
    820855
     856  /**
     857    Delete all checked annotations.
     858  */
    821859  annotate.deleteAllChecked = function()
    822860  {
     
    827865  }
    828866 
     867  /**
     868    Delete an annotation. PRIMARY annotations have all their values removed.
     869    INHERITED/CLONED annotations are deleted.
     870  */
    829871  annotate.deleteAnnotation = function(entry)
    830872  {
    831873    App.debug(entry.id);
    832     entry.modified = DELETE;
    833874    if (entry.source == 'PRIMARY')
    834875    {
     876      entry.modified = MODIFIED;
    835877      entry.annotation.values = [];
    836878      entry.annotation.unit = null;
     
    839881    else
    840882    {
     883      entry.modified = DELETE;
    841884      Doc.hide(entry.id);
    842885    }
  • trunk/www/common/annotations/annotate.jsp

    r6945 r6946  
    7474<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    7575<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
     76<%@ taglib prefix="m" uri="/WEB-INF/menu.tld" %>
    7677<%!
    7778private JSONObject makeJSON(DbControl dc, AnnotationType at, Annotation a, boolean isProtocolParameter, Set<AnnotationTypeCategory> allCategories)
     
    416417  %>
    417418  <base:page type="<%=standalone ? "popup" : "iframe"%>" title="<%=title%>">
    418   <base:head scripts="~annotate.js" styles="parameters.css,toolbar.css">
     419  <base:head scripts="~annotate.js,menu.js" styles="parameters.css,toolbar.css,menu.css">
    419420  <style>
    420421  .first-primary:before
     
    450451  }
    451452 
    452   .parameterlist .param input
     453  .parameterlist .param input, .parameterlist .check-all
    453454  {
    454455    position: absolute;
    455456    right: 1px;
    456457    margin-top: 1px;
     458  }
     459  .parameterlist .check-all
     460  {
     461    padding-right: 2px;
    457462  }
    458463 
     
    633638    <form name="annotations">
    634639   
     640    <m:menu
     641      id="more-actions"
     642      style="display: none;">
     643      <m:menuitem id="btnSync" title="Sync" icon="cloned-outofsync.png"
     644        tooltip="Synchronize the selected annotation"
     645      />
     646      <m:menuitem id="btnClone" title="Clone" icon="cloned.png"
     647        tooltip="Clone the selected annotations"
     648      />
     649      <m:menuitem id="btnUnclone" title="Unclone" icon="inherited.png"
     650        tooltip="Revert cloned annotations to inherited"
     651      />
     652    </m:menu>
     653   
     654   
    635655    <div class="absolutefull">
    636656      <div class="absolutefull bg-filled-100 rightborder" style="width: 18em;">
    637657        <div class="absolutefull" style="height: 2em;">
    638658          <table style="margin: auto; height: 100%;"><tr><td>
    639           <select name="categories" id="categories" style="width: 17em;">
     659          <base:icon image="filter.png" />
     660          <select name="categories" id="categories" style="width: 15em;">
    640661          <option value="-1">- all -
    641662          <%
     
    665686       
    666687        <div id="annotation-list" class="absolutefull parameterlist topborder"
    667           style="top: 2em; bottom: 6em;">
    668           <div class="first-primary"></div>
    669           <%
    670           if (annotationTypes.size() == 0 && inherited.size() == 0)
    671           {
     688          style="top: 2em; bottom: 3em;">
     689          <tbl:toolbar subclass="bottomborder">
     690            <tbl:button id="btnAdd" title="Inherit&hellip;" image="add.png"
     691              tooltip="Inherit more annotations..."
     692            />
     693            <tbl:button id="btnDelete" title="Delete" image="remove.png"
     694              tooltip="Delete annotations"
     695            />
     696            <tbl:button id="btnMore"
     697              subclass="auto-init"
     698              data-auto-init="menu-anchor"
     699              data-menu-id="more-actions"
     700              title="<img src=\"../../images/mini_scroll_down.png\">" image="menu.png"
     701              tooltip="More actions..."
     702              />
     703          </tbl:toolbar>
     704          <div id="primary-list">
     705            <div class="first-primary">
     706              <base:icon id="check-all-primary" image="check_uncheck.png" subclass="check-all"
     707                tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)"
     708              />
     709            </div>
     710            <%
     711            if (annotationTypes.size() == 0 && inherited.size() == 0)
     712            {
     713              %>
     714              <div class="messagecontainer error">
     715                There are no annotation types defined for this kind of item.
     716              </div>
     717              <%
     718            }
    672719            %>
    673             <div class="messagecontainer error">
    674               There are no annotation types defined for this kind of item.
    675             </div>
    676             <%
    677           }
    678           %>
     720          </div>
     721          <div id="inherited-list">
     722            <div class="first-inherited">
     723              <base:icon id="check-all-inherited" image="check_uncheck.png" subclass="check-all"
     724                tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)"
     725              />
     726            </div>
     727          </div>
    679728        </div>
    680         <div class="absolutefull topborder" style="top: auto; bottom: 0em; height: 7em;">
    681           <tbl:toolbar subclass="bottomborder">
    682             <tbl:button id="btnDelete" title="Delete" image="remove.png" />
    683             <tbl:button id="btnAdd" title="Add" image="add.png" />
    684           </tbl:toolbar>
    685           <tbl:toolbar subclass="bottomborder">
    686             <tbl:button id="btnSync" title="Sync" image="refresh.png" />
    687             <tbl:button id="btnClone" title="Clone" image="copy.png" />
    688             <tbl:button id="btnDeclone" title="De-clone" />
    689           </tbl:toolbar>
    690           <table style="height: 3em; margin:auto;"><tr><td>
     729       
     730        <div class="absolutefull topborder" style="top: auto; bottom: 0em; height: 3em;">
     731          <table style="height: 100%; margin:auto;"><tr><td>
    691732          <base:icon image="hasvalues.png" /> = has value(s)<br>
    692733          <base:icon image="parameter.png" /> = protocol parameter
  • trunk/www/include/styles/parameters.css

    r6945 r6946  
    4545.parameterlist .param:last-child
    4646{
    47   margin-bottom: 6px !important;
    4847}
    4948
Note: See TracChangeset for help on using the changeset viewer.