Changeset 6261


Ignore:
Timestamp:
Mar 27, 2013, 1:25:00 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1729 and #1730. Fixed for all biomaterial view pages.

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/tab/TabControl.java

    r6260 r6261  
    367367    tabs = new StringBuilder();
    368368    content = new StringBuilder();
     369    initialTab = null;
    369370
    370371    if (!noTabs)
  • trunk/www/biomaterials/bioplateeventtypes/bioplateeventtypes.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'BIOPLATEEVENTTYPE', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     49      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     50      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    4251    }
    4352    else if (pageId == 'list-page')
  • trunk/www/biomaterials/bioplateeventtypes/view_eventtype.jsp

    r6136 r6261  
    6969final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    7070final int itemId = cc.getId();
     71final String tab = Values.getStringOrNull(request.getParameter("tab"));
    7172final float scale = Base.getScale(sc);
    7273final DbControl dc = sc.newDbControl();
     
    8889  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    8990  %>
    90   <base:page title="<%=title%>">
    91   <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     91  <base:page title="<%=title%>" id="view-page">
     92  <base:head scripts="table.js,tabcontrol-2.js,~bioplateeventtypes.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
    9293    <ext:scripts context="<%=jspContext%>" />
    9394    <ext:stylesheets context="<%=jspContext%>" />
    94     <script>
    95     function editItem()
    96     {
    97       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    98     }
    99     function deleteItem()
    100     {
    101       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    102     }
    103     function restoreItem()
    104     {
    105       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    106     }
    107     function deleteItemPermanently()
    108     {
    109       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    110     }
    111     function itemDeleted()
    112     {
    113       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    114     }
    115     function showUsingItems()
    116     {
    117       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    118     }
    119     function runPlugin(cmd)
    120     {
    121       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    122     }
    123     </script>
    12495  </base:head>
    12596  <base:body>
     
    12899      /><p:pathelement title="<%=HTML.encodeTags(eventType.getName())%>"
    129100      /></p:path>
     101    <div id="page-data" data-item-id="<%=itemId%>"></div>
    130102   
    131103    <t:tabcontrol
    132104      id="main"
    133105      subclass="content mastertabcontrol"
    134       active="properties">
     106      active="<%=tab%>">
    135107    <t:tab id="properties" title="Properties">
    136108      <div>
     
    139111        <th class="itemstatus">
    140112          <base:icon
     113            id="btnDeletePermanently"
    141114            image="deleted.png"
    142             onclick="deleteItemPermanently()"
    143115            tooltip="This item has been flagged for deletion. Click to delete it now."
    144116            enabled="<%=deletePermanentlyPermission %>"
    145117            visible="<%=isRemoved%>"
    146118          />
    147           <base:icon image="used.png"
    148             onclick="showUsingItems()"
     119          <base:icon
     120            id="btnUsingItems"
     121            image="used.png"
    149122            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    150123            visible="<%=isRemoved && isUsed%>" />
     
    154127
    155128            <tbl:button
     129              id="btnEdit"
    156130              disabled="<%=!writePermission%>"
    157131              image="edit.png"
    158               onclick="editItem()"
    159132              title="Edit&hellip;"
    160133              tooltip="<%=writePermission ? "Edit this bioplate event type" : "You do not have permission to edit this bioplate event type"%>"
    161134            />
    162135            <tbl:button
     136              id="btnDelete"
    163137              disabled="<%=!deletePermission%>"
    164138              image="delete.png"
    165               onclick="deleteItem()"
    166139              title="Delete"
    167140              visible="<%=!eventType.isRemoved()%>"
     
    169142            />
    170143            <tbl:button
     144              id="btnRestore"
    171145              disabled="<%=!writePermission%>"
    172146              image="restore.png"
    173               onclick="restoreItem()"
    174147              title="Restore"
    175148              visible="<%=eventType.isRemoved()%>"
     
    177150            />
    178151            <tbl:button
     152              id="btnImport"
    179153              image="import.png"
    180               onclick="runPlugin('ImportItem')"
     154              data-plugin-type="IMPORT"
    181155              title="Import&hellip;"
    182156              tooltip="Import data"
     
    184158            />
    185159            <tbl:button
    186               image="export.png"
    187               onclick="runPlugin('ExportItem')"
     160              id="btnExport"
     161              image="export.png"
     162              data-plugin-type="EXPORT"
    188163              title="Export&hellip;"
    189164              tooltip="Export data"
     
    191166            />
    192167            <tbl:button
    193               image="runplugin.png"
    194               onclick="runPlugin('RunPlugin')"
     168              id="btnRunPlugin"
     169              image="runplugin.png" 
     170              data-plugin-type="OTHER"
    195171              title="Run plugin&hellip;"
    196172              tooltip="Run a plugin"
     
    201177            <tbl:button
    202178              image="help.png"
    203               onclick="<%="Main.openHelp('" + ID +"', 'bioplateeventtype.view.properties')"%>"
     179              subclass="auto-init"
     180              data-auto-init="help"
     181              data-help-id="bioplateeventtype.view.properties"
    204182              title="Help&hellip;"
    205183              tooltip="Get help about this page"
  • trunk/www/biomaterials/bioplates/bioplates.js

    r6260 r6261  
    2626{
    2727  var bioplates = {};
     28  var wellInfoCache = [];
    2829 
    2930  /**
     
    3940    else if (pageId == 'view-page')
    4041    {
    41       // TODO
     42      var itemId = Data.get('page-data', 'item-id');
     43      var attributes = {'item-type': 'BIOPLATE', 'item-id': itemId};
     44      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     45      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     46      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     47      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     48      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     49      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     50      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     51      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     52      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     53      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
     54     
     55      Buttons.addClickHandler('btnMoveBioMaterial', bioplates.moveBioMaterial);
     56      Buttons.addClickHandler('btnCreateChildBioPlate', bioplates.createChildBioPlate);
     57     
     58      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
     59      TabControl.addTabActivateListener('main.overview', Overview.loadOnce);
     60      TabControl.addTabActivateListener('main.history', History.loadOnce);
     61      TabControl.addTabActivateListener('main.events', bioplates.viewEvents);
     62      TabControl.addTabActivateListener('main.wells', bioplates.viewWells);
     63     
     64      Events.addEventHandler('bioplate', 'mouseleave', bioplates.hideWellInfo);
    4265    }
    4366    else if (pageId == 'list-page')
     
    6083  }
    6184 
     85  // Add event handlers to the 'well' icons
     86  bioplates.initElements = function(element, autoInit)
     87  {
     88    if (autoInit == 'well')
     89    {
     90      if (Data.int(element, 'allow-edit'))
     91      {
     92        Events.addEventHandler(element, 'click', bioplates.editWell);
     93      }
     94      if (Data.int(element, 'show-info'))
     95      {
     96        Events.addEventHandler(element, 'mouseover', bioplates.showWellInfo);
     97      }
     98      else
     99      {
     100        Events.addEventHandler(element, 'mouseover', bioplates.hideWellInfo);
     101      }
     102    }
     103  }
     104
     105 
     106  bioplates.viewWells = function()
     107  {
     108    var bioplateId = Data.get('page-data', 'item-id');
     109    var url = 'wells/index.jsp?ID='+App.getSessionId();
     110    url += '&bioplate_id='+bioplateId;
     111    location.replace(url);
     112  }
     113 
     114  bioplates.viewEvents = function()
     115  {
     116    var bioplateId = Data.get('page-data', 'item-id');
     117    var url = 'events/index.jsp?ID='+App.getSessionId();
     118    url += '&bioplate_id='+bioplateId;
     119    location.replace(url);
     120  }
     121 
     122  bioplates.moveBioMaterial = function()
     123  {
     124    var bioplateId = Data.get('page-data', 'item-id');
     125    var url = 'index.jsp?ID='+App.getSessionId();
     126    url += '&cmd=MoveBioMaterial';
     127    url += '&item_id='+bioplateId;
     128    Dialogs.openPopup(url, 'MoveBioMaterial', 900, 600);
     129  }
     130 
     131  bioplates.createChildBioPlate = function()
     132  {
     133    var bioplateId = Data.get('page-data', 'item-id');
     134    var url = 'index.jsp?ID='+App.getSessionId();
     135    url += '&cmd=CreateChildBioPlate';
     136    url += '&item_id='+bioplateId;
     137    Dialogs.openPopup(url, 'CreateChildBioPlate', 900, 600);
     138  }
     139 
     140  bioplates.editWell = function(event)
     141  {
     142    var well = event.currentTarget;
     143    var wellId = Data.get(well, 'item-id');
     144    Main.viewOrEditItem(App.getSessionId(), 'BIOWELL', wellId, true);
     145  }
     146 
     147  bioplates.showWellInfo = function(event)
     148  {
     149    var well = event.currentTarget;
     150    var wellId = Data.get(well, 'item-id');
     151    var coordinate = Data.get(well, 'coordinate');
     152   
     153    // Display the 'wellInfo' postit note
     154    var wellInfo = Doc.element('wellInfo');
     155    var wellTd = Doc.element('well.' + wellId);
     156    var contentPos = Main.getElementPosition(Doc.element('main.content'));
     157    var pos = Main.getElementPosition(wellTd);
     158    wellInfo.style.left = (pos.left + pos.width - 5 - contentPos.left) + 'px';
     159    wellInfo.style.top = (pos.top + 10-contentPos.top) + 'px';
     160    Main.show('wellInfo');
     161
     162    // Get the well information
     163    var info = wellInfoCache['well.'+wellId];
     164    if (!info)
     165    {
     166      // Use Ajax to load the information
     167      wellInfo.innerHTML = '[' + coordinate + '] loading, please wait...';
     168      info = bioplates.loadWellInfo(wellId);
     169    }
     170    var html;
     171    var bioMaterial = info.bioMaterial;
     172    if (bioMaterial)
     173    {
     174      if (bioMaterial.denied)
     175      {
     176        html = 'Denied';
     177      }
     178      else
     179      {
     180        var id = bioMaterial.id;
     181        var type = bioMaterial.type;
     182        var subtype = bioMaterial.subtype;
     183        html = Main.linkItem(App.getSessionId(), type, id, bioMaterial.editable, bioMaterial.name);
     184        html += ': <b>' + type + '</b>';
     185        if (subtype) html += ' <span class="itemsubtype">[' + subtype.name + ']</span>';
     186        html += '<br>'+bioMaterial.description;
     187      }
     188    }
     189    else
     190    {
     191      html = 'Empty';
     192    }
     193    wellInfo.innerHTML = html;
     194  }
     195
     196  bioplates.hideWellInfo = function()
     197  {
     198    Main.hide('wellInfo');
     199  }
     200
     201  bioplates.loadWellInfo = function(wellId)
     202  {
     203    var request = Ajax.getXmlHttpRequest();
     204    var url = 'wells/ajax.jsp?ID='+App.getSessionId();
     205    url += '&cmd=WellInfo&encodeStrings=1&item_id=' + wellId;
     206    request.open("GET", url, false);
     207   
     208    // NOTE! 'false' causes code to wait for the response. aka. 'Synchronous AJAX' or SJAX.
     209    request.send(null);
     210    var response = JSON.parse(request.responseText);
     211    if (response.status != 'ok')
     212    {
     213      alert(response.message);
     214      return false;
     215    }
     216
     217    wellInfoCache['well.'+wellId] = response;
     218    return response;
     219  }
     220
    62221  return bioplates;
    63222}();
    64223
     224Doc.addElementInitializer(BioPlates.initElements);
    65225Doc.onLoad(BioPlates.initPage);
  • trunk/www/biomaterials/bioplates/events/events.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'BIOPLATEEVENT', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     49      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     50      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     51      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     52      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    4253    }
    4354    else if (pageId == 'list-page')
  • trunk/www/biomaterials/bioplates/events/view_event.jsp

    r6210 r6261  
    7777final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    7878final int itemId = cc.getId();
     79final String tab = Values.getStringOrNull(request.getParameter("tab"));
    7980final float scale = Base.getScale(sc);
    8081final DbControl dc = sc.newDbControl();
     
    123124  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    124125  %>
    125   <base:page title="<%=title%>">
    126   <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     126  <base:page title="<%=title%>" id="view-page">
     127  <base:head scripts="table.js,tabcontrol-2.js,~events.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
    127128    <ext:scripts context="<%=jspContext%>" />
    128129    <ext:stylesheets context="<%=jspContext%>" />
     
    187188    }
    188189    %>
     190    <div id="page-data" data-item-id="<%=itemId%>"></div>
     191   
    189192    <t:tabcontrol id="main"
    190193      subclass="content mastertabcontrol"
    191       active="properties">
     194      active="<%=tab %>">
    192195    <t:tab id="properties" title="Properties">
    193196      <div>
     
    201204          />
    202205          <base:icon
     206            id="btnDeletePermanently"
     207            data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
    203208            image="deleted.png"
    204             onclick="deleteItemPermanently()"
    205209            tooltip="This item has been flagged for deletion. Click to delete it now."
    206210            enabled="<%=deletePermanentlyPermission %>"
    207211            visible="<%=isRemoved%>"
    208212          />
    209           <base:icon image="used.png"
     213          <base:icon
     214            id="btnUsingItems"
     215            image="used.png"
    210216            onclick="showUsingItems()"
    211217            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
     
    215221          <tbl:toolbar subclass="bottomborder">
    216222            <tbl:button
     223              id="btnEdit"
    217224              disabled="<%=!writePermission%>"
    218225              image="edit.png"
    219               onclick="editItem()"
    220226              title="Edit&hellip;"
    221227              tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>"
    222228            />
    223229            <tbl:button
     230              id="btnDelete"
     231              data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
    224232              disabled="<%=!deletePermission%>"
    225233              image="delete.png"
    226               onclick="deleteItem()"
    227234              title="Delete"
    228235              visible="<%=!event.isRemoved()%>"
     
    230237            />
    231238            <tbl:button
     239              id="btnRestore"
     240              data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
    232241              disabled="<%=!writePermission%>"
    233242              image="restore.png"
    234               onclick="restoreItem()"
    235243              title="Restore"
    236244              visible="<%=event.isRemoved()%>"
     
    238246            />
    239247            <tbl:button
     248              id="btnShare"
    240249              disabled="<%=!sharePermission%>"
    241250              image="share.png"
    242               onclick="shareItem()"
    243251              title="Share&hellip;"
    244252              tooltip="<%=sharePermission ? "Share this event to other user, groups and projects" : "You do not have permission to share this event"%>"
    245253            />
    246254            <tbl:button
     255              id="btnSetOwner"
    247256              disabled="<%=!setOwnerPermission%>"
    248257              image="take_ownership.png"
    249               onclick="setOwner()"
    250258              title="Set owner&hellip;"
    251259              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
    252260            />
    253261            <tbl:button
     262              id="btnImport"
    254263              image="import.png"
    255               onclick="runPlugin('ImportItem')"
     264              data-plugin-type="IMPORT"
    256265              title="Import&hellip;"
    257266              tooltip="Import data"
     
    259268            />
    260269            <tbl:button
    261               image="export.png"
    262               onclick="runPlugin('ExportItem')"
     270              id="btnExport"
     271              image="export.png"
     272              data-plugin-type="EXPORT"
    263273              title="Export&hellip;"
    264274              tooltip="Export data"
     
    266276            />
    267277            <tbl:button
    268               image="runplugin.png"
    269               onclick="runPlugin('RunPlugin')"
     278              id="btnRunPlugin"
     279              image="runplugin.png" 
     280              data-plugin-type="OTHER"
    270281              title="Run plugin&hellip;"
    271282              tooltip="Run a plugin"
  • trunk/www/biomaterials/bioplates/view_bioplate.jsp

    r6255 r6261  
    8383final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    8484final int itemId = cc.getId();
    85 final String tab = Values.getString(request.getParameter("tab"), "properties");
     85final String tab = Values.getStringOrNull(request.getParameter("tab"));
    8686final float scale = Base.getScale(sc);
    8787final DbControl dc = sc.newDbControl();
     
    107107  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    108108  %>
    109   <base:page title="<%=title%>">
    110   <base:head scripts="tabcontrol.js,table.js"
     109  <base:page title="<%=title%>" id="view-page">
     110  <base:head scripts="tabcontrol-2.js,table.js,~bioplates.js"
    111111    styles="toolbar.css,table.css,headertabcontrol.css,path.css,plate.css">
    112112    <ext:scripts context="<%=jspContext%>" />
    113113    <ext:stylesheets context="<%=jspContext%>" />
    114     <script>
    115     function editItem()
    116     {
    117       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    118     }
    119     function shareItem()
    120     {
    121       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400);
    122     }
    123     function deleteItem()
    124     {
    125       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    126     }
    127     function restoreItem()
    128     {
    129       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    130     }
    131     function deleteItemPermanently()
    132     {
    133       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    134     }
    135     function itemDeleted()
    136     {
    137       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    138     }
    139     function showUsingItems()
    140     {
    141       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    142     }
    143     function setOwner()
    144     {
    145       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
    146     }
    147     function runPlugin(cmd)
    148     {
    149       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    150     }
    151     function viewWells()
    152     {
    153       location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>';
    154     }
    155     function viewEvents()
    156     {
    157       location.href = 'events/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>';
    158     }
    159     function switchTab(tabControlId, tabId)
    160     {
    161       if (tabId == 'wells')
    162       {
    163         viewWells();
    164       }
    165       else if (tabId == 'events')
    166       {
    167         viewEvents();
    168       }
    169       else
    170       {
    171         TabControl.setActiveTab(tabControlId, tabId);
    172       }
    173     }
    174     function editWell(wellId)
    175     {
    176       Main.viewOrEditItem('<%=ID%>', 'BIOWELL', wellId, true);
    177     }
    178     function showWellInfo(evt, coordinate, wellId)
    179     {
    180       // Display the 'wellInfo' postit note
    181       var wellInfo = document.getElementById('wellInfo');
    182       var wellTd = document.getElementById('well.' + wellId);
    183       var pos = Main.getElementPosition(wellTd);
    184       wellInfo.style.left = (pos.left + pos.width - 5) + 'px';
    185       wellInfo.style.top = (pos.top + 10) + 'px';
    186       Main.show('wellInfo');
    187 
    188       // Get the well information
    189       var info = wellInfoCache['well.'+wellId];
    190       if (!info)
    191       {
    192         // Use Ajax to load the information
    193         wellInfo.innerHTML = '[' + coordinate + '] loading, please wait...';
    194         info = loadWellInfo(wellId);
    195       }
    196       var html;
    197       var bioMaterial = info.bioMaterial;
    198       if (bioMaterial)
    199       {
    200         if (bioMaterial.denied)
    201         {
    202           html = 'Denied';
    203         }
    204         else
    205         {
    206           var id = bioMaterial.id;
    207           var type = bioMaterial.type;
    208           var subtype = bioMaterial.subtype;
    209           html = Main.linkItem('<%=ID%>', type, id, bioMaterial.editable, bioMaterial.name);
    210           html += ': <b>' + type + '</b>';
    211           if (subtype) html += ' <span class="itemsubtype">[' + subtype.name + ']</span>';
    212           html += '<br>'+bioMaterial.description;
    213         }
    214       }
    215       else
    216       {
    217         html = 'Empty';
    218       }
    219       wellInfo.innerHTML = html;
    220     }
    221     function hideWellInfo()
    222     {
    223       Main.hide('wellInfo');
    224     }
    225     var wellInfoCache = new Array();
    226     function loadWellInfo(wellId)
    227     {
    228       var request = Ajax.getXmlHttpRequest();
    229       var url = 'wells/ajax.jsp?ID=<%=ID%>&cmd=WellInfo&encodeStrings=1&item_id=' + wellId;
    230       request.open("GET", url, false);
    231       // NOTE! 'false' causes code to wait for the response. aka. 'Synchronous AJAX' or SJAX.
    232       request.send(null);
    233       var response = JSON.parse(request.responseText);
    234       if (response.status != 'ok')
    235       {
    236         alert(response.message);
    237         return false;
    238       }
    239 
    240       wellInfoCache['well.'+wellId] = response;
    241       return response;
    242     }
    243     function viewOrEditWellItem(event, itemType, itemId, editable)
    244     {
    245       //Main.viewOrEditItem('<%=ID%>', itemType, itemId, editable);
    246       Main.itemOnClick(event, '<%=ID%>', itemType, itemId, editable);
    247     }
    248     function moveBioMaterial()
    249     {
    250       Main.openPopup('index.jsp?ID=<%=ID%>&item_id=<%=itemId%>&cmd=MoveBioMaterial', 'MoveBioMaterial', 900, 600);
    251     }
    252     function createChildBioPlate()
    253     {
    254       Main.openPopup('index.jsp?ID=<%=ID%>&item_id=<%=itemId%>&cmd=CreateChildBioPlate', 'CreateChildBioPlate', 900, 600);
    255     }
    256     </script>
    257114  </base:head>
    258115  <base:body>
     
    260117      title="Bioplates" href="<%="index.jsp?ID="+ID%>" /><p:pathelement
    261118      title="<%=HTML.encodeTags(bioplate.getName())%>" /></p:path>
     119    <div id="page-data" data-item-id="<%=itemId%>"></div>
    262120   
    263121    <t:tabcontrol id="main"
    264122      subclass="content mastertabcontrol"
    265       active="<%=tab%>" switch="switchTab" remember="false">
     123      active="<%=tab%>">
    266124    <t:tab id="properties" title="Properties">
    267125      <div>
     
    275133          />
    276134          <base:icon
     135            id="btnDeletePermanently"
    277136            image="deleted.png"
    278             onclick="deleteItemPermanently()"
    279137            tooltip="This item has been flagged for deletion. Click to delete it now."
    280138            enabled="<%=deletePermanentlyPermission %>"
    281139            visible="<%=isRemoved%>"
    282140          />
    283           <base:icon image="used.png"
    284             onclick="showUsingItems()"
     141          <base:icon
     142            id="btnUsingItems"
     143            image="used.png"
    285144            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    286145            visible="<%=isRemoved && isUsed%>" />
     
    289148          <tbl:toolbar subclass="bottomborder">
    290149            <tbl:button
     150              id="btnEdit"
    291151              disabled="<%=!writePermission%>"
    292152              image="edit.png"
    293               onclick="editItem()"
    294153              title="Edit&hellip;"
    295154              tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>"
    296155            />
    297156            <tbl:button
     157              id="btnDelete"
    298158              disabled="<%=!deletePermission%>"
    299159              image="delete.png"
    300               onclick="deleteItem()"
    301160              title="Delete"
    302161              visible="<%=!bioplate.isRemoved()%>"
     
    304163            />
    305164            <tbl:button
     165              id="btnRestore"
    306166              disabled="<%=!writePermission%>"
    307167              image="restore.png"
    308               onclick="restoreItem()"
    309168              title="Restore"
    310169              visible="<%=bioplate.isRemoved()%>"
     
    312171            />
    313172            <tbl:button
     173              id="btnShare"
    314174              disabled="<%=!sharePermission%>"
    315175              image="share.png"
    316               onclick="shareItem()"
    317176              title="Share&hellip;"
    318177              tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>"
    319178            />
    320179            <tbl:button
     180              id="btnSetOwner"
    321181              disabled="<%=!setOwnerPermission%>"
    322182              image="take_ownership.png"
    323               onclick="setOwner()"
    324183              title="Set owner&hellip;"
    325184              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
    326185            />
    327186            <tbl:button
     187              id="btnMoveBioMaterial"
    328188              image="move_to_plate.png"
    329               onclick="moveBioMaterial()"
    330189              title="Move biomaterial&hellip;"
    331190              tooltip="Move biomaterial on this plate to another plate"
    332191            />
    333192            <tbl:button
     193              id="btnCreateChildBioPlate"
    334194              image="add.png"
    335               onclick="createChildBioPlate()"
    336195              title="<%="Create child bioplate" + (bioMaterialType == Item.EXTRACT ? "/bioassay" : "") +"&hellip;"%>"
    337196              tooltip="Create one or more child biomaterial plates"
     
    339198            />
    340199            <tbl:button
     200              id="btnImport"
    341201              image="import.png"
    342               onclick="runPlugin('ImportItem')"
     202              data-plugin-type="IMPORT"
    343203              title="Import&hellip;"
    344204              tooltip="Import data"
     
    346206            />
    347207            <tbl:button
    348               image="export.png"
    349               onclick="runPlugin('ExportItem')"
     208              id="btnExport"
     209              image="export.png"
     210              data-plugin-type="EXPORT"
    350211              title="Export&hellip;"
    351212              tooltip="Export data"
     
    353214            />
    354215            <tbl:button
    355               image="runplugin.png"
    356               onclick="runPlugin('RunPlugin')"
     216              id="btnRunPlugin"
     217              image="runplugin.png" 
     218              data-plugin-type="OTHER"
    357219              title="Run plugin&hellip;"
    358220              tooltip="Run a plugin"
     
    363225            <tbl:button
    364226              image="help.png"
    365               onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>"
     227              subclass="auto-init"
     228              data-auto-init="help"
     229              data-help-id="plate.view.properties"
    366230              title="Help&hellip;"
    367231              tooltip="Get help about this page"
     
    433297      </table>
    434298      </td>
    435       <td style="width: 50%; padding: 1em;" onmouseout="hideWellInfo();">
    436         <table class="plate" onmouseout="event.cancelBubble=true">
     299      <td style="width: 50%; padding: 1em;" id="bioplate">
     300        <div class="postit" id="wellInfo" style="display:none; width: 20em; min-height: 3em;"></div>
     301        <table class="plate">
    437302        <%
    438303        int columns = geometry.getColumns();
     
    469334           
    470335            boolean deniedBioMaterial = false;
     336            boolean allowEdit = false;
     337            boolean showInfo = false;
    471338           
    472             String cls = "well";
     339            String cls = "well auto-init";
    473340            String tooltip = "";
    474             String onClick = null;
    475             String onMouseOver = "hideWellInfo()";
    476            
    477341            if (isEmpty)
    478342            {
     
    482346                // The used is allowed to add biomaterial to the empty well
    483347                cls += " editable";
    484                 onClick = "editWell(" + well.getId() + ")";
     348                allowEdit = true;
    485349                tooltip = "Add biomaterial to this well";
    486350              }
     
    489353                // The well has been used and it is not allowed to add biomaterial
    490354                cls += " wasused";
    491                 onMouseOver = "showWellInfo(event, '" + row + (c+1) + "', " + well.getId() + ")";
     355                showInfo = true;
    492356                tooltip = "This well has already been used";
    493357              }
     
    505369              {
    506370                MeasuredBioMaterial bioMaterial = well.getBioMaterial();
    507                 onMouseOver = "showWellInfo(event, '" + row + (c+1) + "', " + well.getId() + ")";
     371                showInfo = true;
    508372                if (usePermission && canClearBioMaterial && bioMaterial.hasPermission(Permission.WRITE))
    509373                {
    510374                  // The user is allowed to replace/remove the biomaterial in the well
    511375                  cls += " editable";
    512                   onClick = "editWell(" + well.getId() + ")";
     376                  allowEdit = true;
    513377                  if (canAddBioMaterial)
    514378                  {
     
    535399            }
    536400            %>
    537             <td class="<%=cls%>" id="well.<%=well.getId()%>"
    538               <%=onClick != null ? "onclick=\"" + onClick + "\"" : ""%>
    539               <%=onMouseOver != null ? "onmouseover=\"" + onMouseOver + "\"" : ""%>
     401            <td class="<%=cls%>"
     402              id="well.<%=well.getId()%>"
     403              data-auto-init="well"
     404              data-allow-edit="<%=allowEdit ? 1 : 0 %>"
     405              data-show-info="<%=showInfo ? 1 : 0 %>"
     406              data-item-id="<%=well.getId()%>"
     407              data-coordinate="<%=well.getCoordinate()%>"
    540408              title="<%=tooltip%>"></td>
    541409            <%
     
    567435     
    568436      <t:tab id="annotations" title="Annotations"
    569         tooltip="View annotation values" clazz="white"
    570         activate="AnnotationsList.loadOnce()">
     437        tooltip="View annotation values" clazz="white">
    571438        <jsp:include page="../../common/annotations/list_frameset.jsp">
    572439          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     
    579446      <t:tab id="events" title="Plate events" />
    580447      <t:tab id="overview" title="Overview"
    581         tooltip="Display a tree overview of related items"
    582         activate="Overview.loadOnce()">
     448        tooltip="Display a tree overview of related items">
    583449        <jsp:include page="../../common/overview/overview.jsp">
    584450          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     
    589455      <t:tab id="history" title="Change history"
    590456        tooltip="Displays a log of all modifications made to this item"
    591         visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>"
    592         activate="History.loadOnce()">
     457        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
    593458        <jsp:include page="../../common/history/frameset.jsp">
    594459          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     
    599464    </t:tabcontrol>
    600465   
    601     <div class="postit" id="wellInfo" style="display:none; width: 20em; min-height: 3em;" onmouseout="event.cancelBubble=true"></div>
    602466  </base:body>
    603467  </base:page>
  • trunk/www/biomaterials/bioplatetypes/bioplatetypes.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'BIOPLATETYPE', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     49      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     50      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    4251    }
    4352    else if (pageId == 'list-page')
  • trunk/www/biomaterials/bioplatetypes/view_platetype.jsp

    r6136 r6261  
    7070final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    7171final int itemId = cc.getId();
     72final String tab = Values.getStringOrNull(request.getParameter("tab"));
    7273final float scale = Base.getScale(sc);
    7374final DbControl dc = sc.newDbControl();
     
    8990  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    9091  %>
    91   <base:page title="<%=title%>">
    92   <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     92  <base:page title="<%=title%>" id="view-page">
     93  <base:head scripts="table.js,tabcontrol-2.js,~bioplatetypes.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
    9394    <ext:scripts context="<%=jspContext%>" />
    9495    <ext:stylesheets context="<%=jspContext%>" />
    95     <script>
    96     function editItem()
    97     {
    98       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    99     }
    100     function deleteItem()
    101     {
    102       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    103     }
    104     function restoreItem()
    105     {
    106       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    107     }
    108     function deleteItemPermanently()
    109     {
    110       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    111     }
    112     function itemDeleted()
    113     {
    114       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    115     }
    116     function showUsingItems()
    117     {
    118       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    119     }
    120     function runPlugin(cmd)
    121     {
    122       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    123     }
    124     </script>
    12596  </base:head>
    12697  <base:body>
     
    12899      /><p:pathelement title="<%=HTML.encodeTags(plateType.getName())%>"
    129100      /></p:path>
     101    <div id="page-data" data-item-id="<%=itemId%>"></div>
    130102   
    131103    <t:tabcontrol
    132104      id="main"
    133105      subclass="content mastertabcontrol"
    134       active="properties">
     106      active="<%=tab%>">
    135107    <t:tab id="properties" title="Properties">
    136108      <div>
     
    139111        <th class="itemstatus">
    140112          <base:icon
     113            id="btnDeletePermanently"
    141114            image="deleted.png"
    142             onclick="deleteItemPermanently()"
    143115            tooltip="This item has been flagged for deletion. Click to delete it now."
    144116            enabled="<%=deletePermanentlyPermission %>"
    145117            visible="<%=isRemoved%>"
    146118          />
    147           <base:icon image="used.png"
    148             onclick="showUsingItems()"
     119          <base:icon
     120            id="btnUsingItems"
     121            image="used.png"
    149122            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    150123            visible="<%=isRemoved && isUsed%>" />
     
    153126          <tbl:toolbar subclass="bottomborder">
    154127            <tbl:button
     128              id="btnEdit"
    155129              disabled="<%=!writePermission%>"
    156130              image="edit.png"
    157               onclick="editItem()"
    158131              title="Edit&hellip;"
    159132              tooltip="<%=writePermission ? "Edit this bioplate type" : "You do not have permission to edit this bioplate type"%>"
    160133            />
    161134            <tbl:button
     135              id="btnDelete"
    162136              disabled="<%=!deletePermission%>"
    163137              image="delete.png"
    164               onclick="deleteItem()"
    165138              title="Delete"
    166139              visible="<%=!plateType.isRemoved()%>"
     
    168141            />
    169142            <tbl:button
     143              id="btnRestore"
    170144              disabled="<%=!writePermission%>"
    171145              image="restore.png"
    172               onclick="restoreItem()"
    173146              title="Restore"
    174147              visible="<%=plateType.isRemoved()%>"
     
    176149            />
    177150            <tbl:button
     151              id="btnImport"
    178152              image="import.png"
    179               onclick="runPlugin('ImportItem')"
     153              data-plugin-type="IMPORT"
    180154              title="Import&hellip;"
    181155              tooltip="Import data"
     
    183157            />
    184158            <tbl:button
    185               image="export.png"
    186               onclick="runPlugin('ExportItem')"
     159              id="btnExport"
     160              image="export.png"
     161              data-plugin-type="EXPORT"
    187162              title="Export&hellip;"
    188163              tooltip="Export data"
     
    190165            />
    191166            <tbl:button
    192               image="runplugin.png"
    193               onclick="runPlugin('RunPlugin')"
     167              id="btnRunPlugin"
     168              image="runplugin.png" 
     169              data-plugin-type="OTHER"
    194170              title="Run plugin&hellip;"
    195171              tooltip="Run a plugin"
     
    200176            <tbl:button
    201177              image="help.png"
    202               onclick="<%="Main.openHelp('" + ID +"', 'bioplatetype.view.properties')"%>"
     178              subclass="auto-init"
     179              data-auto-init="help"
     180              data-help-id="bioplatetype.view.properties"
    203181              title="Help&hellip;"
    204182              tooltip="Get help about this page"
  • trunk/www/biomaterials/biosources/view_biosource.jsp

    r6255 r6261  
    8282final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    8383final int itemId = cc.getId();
    84 final String tab = Values.getString(request.getParameter("tab"), "properties");
     84final String tab = Values.getStringOrNull(request.getParameter("tab"));
    8585final float scale = Base.getScale(sc);
    8686final DbControl dc = sc.newDbControl();
  • trunk/www/biomaterials/events/events.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'BIOMATERIALEVENT', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItemPermanently, attributes);
     45      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     46      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     47      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    4248    }
    4349    else if (pageId == 'list-page')
  • trunk/www/biomaterials/events/view_event.jsp

    r6216 r6261  
    8181final int itemId = cc.getId();
    8282final Item bioMaterialType = Item.valueOf(request.getParameter("biomaterial_type"));
     83final String tab = Values.getStringOrNull(request.getParameter("tab"));
    8384final int bioMaterialId = Values.getInt(request.getParameter("biomaterial_id"));
    8485final float scale = Base.getScale(sc);
     
    128129  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    129130  %>
    130   <base:page title="<%=title%>">
    131   <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     131  <base:page title="<%=title%>" id="view-page">
     132  <base:head scripts="table.js,tabcontrol-2.js,~events.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
    132133    <ext:scripts context="<%=jspContext%>" />
    133134    <ext:stylesheets context="<%=jspContext%>" />
     
    156157        href="<%="index.jsp?ID="+ID+"&amp;biomaterial_id="+bioMaterialId+"&amp;biomaterial_type="+bioMaterialType.name()%>"
    157158      /><p:pathelement title="Event" /></p:path>
     159    <div id="page-data" data-item-id="<%=itemId%>"></div>
    158160   
    159161    <t:tabcontrol id="main"
    160162      subclass="content mastertabcontrol"
    161       active="properties">
     163      active="<%=tab%>">
    162164    <t:tab id="properties" title="Properties">
    163165      <div>
     
    168170          <tbl:toolbar subclass="bottomborder">
    169171            <tbl:button
     172              id="btnEdit"
    170173              disabled="<%=!writePermission%>"
     174              data-extra-url="<%="&biomaterial_type="+bioMaterialType.name()+"&biomaterial_id="+bioMaterialId%>"
    171175              image="edit.png"
    172               onclick="editItem()"
    173176              title="Edit&hellip;"
    174177              tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>"
    175178            />
    176179            <tbl:button
     180              id="btnDelete"
     181              data-confirm="1"
     182              data-extra-url="<%="&biomaterial_type="+bioMaterialType.name()+"&biomaterial_id="+bioMaterialId%>"
    177183              disabled="<%=!deletePermission%>"
    178184              image="delete.png"
    179               onclick="deleteItem()"
    180185              title="Delete"
    181186              tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to event this event"%>"
    182187            />
    183188            <tbl:button
     189              id="btnImport"
    184190              image="import.png"
    185               onclick="runPlugin('ImportItem')"
     191              data-plugin-type="IMPORT"
    186192              title="Import&hellip;"
    187193              tooltip="Import data"
     
    189195            />
    190196            <tbl:button
    191               image="export.png"
    192               onclick="runPlugin('ExportItem')"
     197              id="btnExport"
     198              image="export.png"
     199              data-plugin-type="EXPORT"
    193200              title="Export&hellip;"
    194201              tooltip="Export data"
     
    196203            />
    197204            <tbl:button
    198               image="runplugin.png"
    199               onclick="runPlugin('RunPlugin')"
     205              id="btnRunPlugin"
     206              image="runplugin.png" 
     207              data-plugin-type="OTHER"
    200208              title="Run plugin&hellip;"
    201209              tooltip="Run a plugin"
  • trunk/www/biomaterials/extracts/extracts.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'EXTRACT', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     49      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     50      Buttons.addClickHandler('btnNewExtract', extracts.newExtract, attributes);
     51      Buttons.addClickHandler('btnNewPhysicalBioAssay', extracts.newPhysicalBioAssay, attributes);
     52      Buttons.addClickHandler('btnNewRawBioAssay', extracts.newRawBioAssay, attributes);
     53      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     54      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     55      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
     56     
     57      TabControl.addTabActivateListener('main.events', extracts.viewEvents);
     58      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
     59      TabControl.addTabActivateListener('main.overview', Overview.loadOnce);
     60      TabControl.addTabActivateListener('main.history', History.loadOnce);
    4261    }
    4362    else if (pageId == 'list-page')
     
    5776      Buttons.addClickHandler('btnPlaceOnPlate', extracts.placeOnPlateOnClick);
    5877      Buttons.addClickHandler('btnNewPooledItem', extracts.newPooledItemOnClick);
    59       Buttons.addClickHandler('btnNewPhysicalBioAssay', extracts.newPhysicalBioAssayOnClick);
     78      Buttons.addClickHandler('btnNewPhysicalBioAssay', extracts.newPhysicalBioAssayFromTable);
    6079     
    6180      Buttons.addClickHandler('close', App.closeWindow);
     
    7897
    7998  /*
    80     Create a new sample with the current sample as the parent
     99    Create a new extract with the current extract as the parent
    81100  */
    82101  extracts.newExtract = function(event)
     
    87106 
    88107  /*
    89     Create a new extract with the current sample as the parent
     108    Create a new raw bioassay with the current extract as the parent
    90109  */
    91110  extracts.newRawBioAssay = function(event)
     
    93112    var extractId = Data.int(event.currentTarget, 'item-id');
    94113    Main.viewOrEditItem(App.getSessionId(), 'RAWBIOASSAY', 0, true, '&extract_id='+extractId);
     114  }
     115 
     116  /*
     117    Create a new physical bioassay with the current extract as the parent
     118  */
     119  extracts.newPhysicalBioAssay = function(event)
     120  {
     121    var extractId = Data.int(event.currentTarget, 'item-id');
     122    Main.viewOrEditItem(App.getSessionId(), 'PHYSICALBIOASSAY', 0, true, '&extract_id='+extractId);
    95123  }
    96124
     
    117145  }
    118146
    119   extracts.newPhysicalBioAssayOnClick = function()
     147  extracts.newPhysicalBioAssayFromTable = function()
    120148  {
    121149    if (!Table.checkIfSelected('extracts'))
     
    125153    Table.submitToPopup('extracts', 'NewPhysicalBioAssay', 750, 500);
    126154  }
     155 
     156  extracts.viewEvents = function()
     157  {
     158    var extractId = Data.get('page-data', 'item-id');
     159    var url = '../events/index.jsp?ID='+App.getSessionId();
     160    url += '&cmd=List&biomaterial_id='+extractId;
     161    url += '&biomaterial_type=EXTRACT';
     162    location.replace(url);
     163  }
    127164
    128165  return extracts;
  • trunk/www/biomaterials/extracts/view_extract.jsp

    r6255 r6261  
    9494final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    9595final int itemId = cc.getId();
    96 final String tab = Values.getString(request.getParameter("tab"), "properties");
     96final String tab = Values.getStringOrNull(request.getParameter("tab"));
    9797final float scale = Base.getScale(sc);
    9898final DbControl dc = sc.newDbControl();
     
    121121  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    122122  %>
    123   <base:page title="<%=title%>">
    124   <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
     123  <base:page title="<%=title%>" id="view-page">
     124  <base:head scripts="table.js,tabcontrol-2.js,~extracts.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
    125125    <ext:scripts context="<%=jspContext%>" />
    126126    <ext:stylesheets context="<%=jspContext%>" />
    127     <script>
    128     function editItem()
    129     {
    130       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    131     }
    132     function newExtract()
    133     {
    134       Main.viewOrEditItem('<%=ID%>', 'EXTRACT', 0, true, '&extract_id=<%=itemId%>');
    135     }
    136     function shareItem()
    137     {
    138       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareExtract', 600, 400);
    139     }
    140     function deleteItem()
    141     {
    142       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    143     }
    144     function restoreItem()
    145     {
    146       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    147     }
    148     function deleteItemPermanently()
    149     {
    150       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    151     }
    152     function itemDeleted()
    153     {
    154       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    155     }
    156     function showUsingItems()
    157     {
    158       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    159     }
    160     function setOwner()
    161     {
    162       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
    163     }
    164     function runPlugin(cmd)
    165     {
    166       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    167     }
    168     function viewEvents()
    169     {
    170       location.href = '../events/index.jsp?ID=<%=ID%>&cmd=List&biomaterial_id=<%=itemId%>&biomaterial_type=<%=itemType.name()%>';
    171     }
    172     function switchTab(tabControlId, tabId)
    173     {
    174       if (TabControl.isActive(tabControlId, tabId)) return;
    175       if (tabId == 'events')
    176       {
    177         viewEvents();
    178       }
    179       else
    180       {
    181         TabControl.setActiveTab(tabControlId, tabId);
    182       }
    183     }
    184     function newPhysicalBioAssay()
    185     {
    186       Main.viewOrEditItem('<%=ID%>', 'PHYSICALBIOASSAY', 0, true, '&extract_id='+<%=itemId%>);
    187     }
    188     function newRawBioAssay()
    189     {
    190       Main.viewOrEditItem('<%=ID%>', 'RAWBIOASSAY', 0, true, '&extract_id='+<%=itemId%>);
    191     }
    192     </script>
    193127  </base:head>
    194128  <base:body>
     
    196130      title="Extracts" href="<%="index.jsp?ID="+ID%>" /><p:pathelement
    197131      title="<%=HTML.encodeTags(extract.getName())%>" /></p:path>
     132    <div id="page-data" data-item-id="<%=itemId%>"></div>
    198133   
    199     <t:tabcontrol id="main" subclass="content mastertabcontrol" active="<%=tab%>" switch="switchTab" remember="false">
     134    <t:tabcontrol id="main" subclass="content mastertabcontrol" active="<%=tab%>">
    200135    <t:tab id="properties" title="Properties">
    201136      <div>
     
    209144          />
    210145          <base:icon
     146            id="btnDeletePermanently"
    211147            image="deleted.png"
    212             onclick="deleteItemPermanently()"
    213148            tooltip="This item has been flagged for deletion. Click to delete it now."
    214149            enabled="<%=deletePermanentlyPermission %>"
    215150            visible="<%=isRemoved%>"
    216151          />
    217           <base:icon image="used.png"
    218             onclick="showUsingItems()"
     152          <base:icon
     153            id="btnUsingItems"
     154            image="used.png"
    219155            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    220156            visible="<%=isRemoved && isUsed%>" />
     
    223159          <tbl:toolbar subclass="bottomborder">
    224160            <tbl:button
     161              id="btnEdit"
    225162              disabled="<%=!writePermission%>"
    226163              image="edit.png"
    227               onclick="editItem()"
    228164              title="Edit&hellip;"
    229165              tooltip="<%=writePermission ? "Edit this extract" : "You do not have permission to edit this extract"%>"
    230166            />
    231167            <tbl:button
     168              id="btnDelete"
    232169              disabled="<%=!deletePermission%>"
    233170              image="delete.png"
    234               onclick="deleteItem()"
    235171              title="Delete"
    236172              visible="<%=!extract.isRemoved()%>"
     
    238174            />
    239175            <tbl:button
     176              id="btnRestore"
    240177              disabled="<%=!writePermission%>"
    241178              image="restore.png"
    242               onclick="restoreItem()"
    243179              title="Restore"
    244180              visible="<%=extract.isRemoved()%>"
     
    246182            />
    247183            <tbl:button
     184              id="btnShare"
    248185              disabled="<%=!sharePermission%>"
    249186              image="share.png"
    250               onclick="shareItem()"
    251187              title="Share&hellip;"
    252188              tooltip="<%=sharePermission ? "Share this extract to other user, groups and projects" : "You do not have permission to share this extract"%>"
    253189            />
    254190            <tbl:button
     191              id="btnSetOwner"
    255192              disabled="<%=!setOwnerPermission%>"
    256193              image="take_ownership.png"
    257               onclick="setOwner()"
    258194              title="Set owner&hellip;"
    259195              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
    260196            />
    261197            <tbl:button
     198              id="btnNewExtract"
    262199              image="add.png"
    263               onclick="newExtract()"
    264200              title="New child extract&hellip;"
    265201              tooltip="Create a new child extract from this extract"
     
    267203            />
    268204            <tbl:button
     205              id="btnNewPhysicalBioAssay"
    269206              image="add.png"
    270               onclick="newPhysicalBioAssay()"
    271207              title="New physical bioassay&hellip;"
    272208              tooltip="Create a new physical bioassay from this extract"
     
    274210            />
    275211            <tbl:button
     212              id="btnNewRawBioAssay"
    276213              image="add.png"
    277               onclick="newRawBioAssay()"
    278214              title="New raw bioassay&hellip;"
    279215              tooltip="Create a new raw bioassay from this extract"
     
    281217            />
    282218            <tbl:button
     219              id="btnImport"
    283220              image="import.png"
    284               onclick="runPlugin('ImportItem')"
     221              data-plugin-type="IMPORT"
    285222              title="Import&hellip;"
    286223              tooltip="Import data"
     
    288225            />
    289226            <tbl:button
    290               image="export.png"
    291               onclick="runPlugin('ExportItem')"
     227              id="btnExport"
     228              image="export.png"
     229              data-plugin-type="EXPORT"
    292230              title="Export&hellip;"
    293231              tooltip="Export data"
     
    295233            />
    296234            <tbl:button
    297               image="runplugin.png"
    298               onclick="runPlugin('RunPlugin')"
     235              id="btnRunPlugin"
     236              image="runplugin.png" 
     237              data-plugin-type="OTHER"
    299238              title="Run plugin&hellip;"
    300239              tooltip="Run a plugin"
     
    305244            <tbl:button
    306245              image="help.png"
    307               onclick="<%="Main.openHelp('" + ID +"', 'extract.view.properties')"%>"
     246              subclass="auto-init"
     247              data-auto-init="help"
     248              data-help-id="extract.view.properties"
    308249              title="Help&hellip;"
    309250              tooltip="Get help about this page"
     
    610551     
    611552      <t:tab id="annotations" title="Annotations &amp; parameters"
    612         tooltip="View annotation values and protocol parameters" clazz="white"
    613         activate="AnnotationsList.loadOnce()">
     553        tooltip="View annotation values and protocol parameters" clazz="white">
    614554        <jsp:include page="../../common/annotations/list_frameset.jsp">
    615555          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     
    622562
    623563      <t:tab id="overview" title="Overview"
    624         tooltip="Display a tree overview of related items"
    625         activate="Overview.loadOnce()">
     564        tooltip="Display a tree overview of related items">
    626565        <jsp:include page="../../common/overview/overview.jsp">
    627566          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     
    632571      <t:tab id="history" title="Change history"
    633572        tooltip="Displays a log of all modifications made to this item"
    634         visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>"
    635         activate="History.loadOnce()">
     573        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
    636574        <jsp:include page="../../common/history/frameset.jsp">
    637575          <jsp:param name="item_type" value="<%=itemType.name()%>" />
  • trunk/www/biomaterials/lists/lists.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'BIOMATERIALLIST', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     49      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     50      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     51      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     52      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
     53      Buttons.addClickHandler('btnPlaceOnPlate', biomateriallists.placeOnPlateOnClick);
     54      Buttons.addClickHandler('btnMergeUnion', biomateriallists.mergeOnClick);
     55      Buttons.addClickHandler('btnMergeIntersection', biomateriallists.mergeOnClick);
     56      Buttons.addClickHandler('btnMergeComplement', biomateriallists.mergeOnClick);
     57     
     58      TabControl.addTabActivateListener('main.overview', Overview.loadOnce);
     59      TabControl.addTabActivateListener('main.members', biomateriallists.viewMembers);
    4260    }
    4361    else if (pageId == 'list-page')
     
    6078  }
    6179 
     80  biomateriallists.viewMembers = function()
     81  {
     82    var listId = Data.get('page-data', 'item-id');
     83    var url = 'members/index.jsp?ID='+App.getSessionId();
     84    url += '&cmd=List&list_id='+listId;
     85    location.replace(url);
     86  }
     87 
     88  biomateriallists.placeOnPlateOnClick = function()
     89  {
     90    var listId = Data.get('page-data', 'item-id');
     91    var url = 'members/index.jsp?ID='+App.getSessionId();
     92    url += '&cmd=PlaceOnPlate&list_id='+listId;
     93    Dialogs.openPopup(url, 'PlaceOnPlate', 900, 600);
     94  }
     95 
     96  biomateriallists.mergeOnClick = function(event)
     97  {
     98    var target = event.currentTarget;
     99    var mergeType = Data.get(target, 'merge-type');
     100    var listId = Data.get('page-data', 'item-id');
     101   
     102    var url = 'merge.jsp?ID='+App.getSessionId();
     103    url += '&item_id='+listId;
     104    url += '&mergeType='+mergeType;
     105   
     106    Dialogs.openPopup(url, 'Merge', 600, 400);
     107  }
     108
     109 
    62110  return biomateriallists;
    63111}();
  • trunk/www/biomaterials/lists/view_list.jsp

    r6242 r6261  
    7171final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    7272final int itemId = cc.getId();
    73 final String tab = Values.getString(request.getParameter("tab"), "properties");
     73final String tab = Values.getStringOrNull(request.getParameter("tab"));
    7474final float scale = Base.getScale(sc);
    7575final DbControl dc = sc.newDbControl();
     
    9393  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    9494  %>
    95   <base:page title="<%=title%>">
    96   <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
     95  <base:page title="<%=title%>" id="view-page">
     96  <base:head scripts="table.js,tabcontrol-2.js,~lists.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
    9797    <ext:scripts context="<%=jspContext%>" />
    9898    <ext:stylesheets context="<%=jspContext%>" />
    99     <script>
    100     function editItem()
    101     {
    102       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    103     }
    104     function shareItem()
    105     {
    106       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareBioMaterialList', 600, 400);
    107     }
    108     function deleteItem()
    109     {
    110       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    111     }
    112     function restoreItem()
    113     {
    114       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    115     }
    116     function deleteItemPermanently()
    117     {
    118       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    119     }
    120     function itemDeleted()
    121     {
    122       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    123     }
    124     function showUsingItems()
    125     {
    126       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    127     }
    128     function setOwner()
    129     {
    130       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
    131     }
    132     function runPlugin(cmd)
    133     {
    134       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    135     }
    136     function viewMembers()
    137     {
    138       location.href = 'members/index.jsp?ID=<%=ID%>&cmd=List&list_id=<%=itemId%>';
    139     }
    140     function switchTab(tabControlId, tabId)
    141     {
    142       if (TabControl.isActive(tabControlId, tabId)) return;
    143       if (tabId == 'members')
    144       {
    145         viewMembers();
    146       }
    147       else
    148       {
    149         TabControl.setActiveTab(tabControlId, tabId);
    150       }
    151     }
    152     function merge(mergeType)
    153     {
    154       Main.openPopup('merge.jsp?ID=<%=ID%>&item_id=<%=itemId%>&mergeType='+mergeType, 'Union', 600, 400);
    155     }
    156     function placeOnPlate()
    157     {
    158       Main.openPopup('members/index.jsp?ID=<%=ID%>&list_id=<%=itemId%>&cmd=PlaceOnPlate', 'PlaceOnPlate', 900, 600);
    159     }
    160     </script>
    16199  </base:head>
    162100  <base:body>
     
    165103      /><p:pathelement title="<%=HTML.encodeTags(list.getName())%>"
    166104      /></p:path>
     105    <div id="page-data" data-item-id="<%=itemId%>"></div>
    167106   
    168107    <t:tabcontrol
    169108      id="main"
    170109      subclass="content mastertabcontrol"
    171       active="<%=tab%>" switch="switchTab" remember="false">
     110      active="<%=tab%>">
    172111    <t:tab id="properties" title="Properties">
    173112      <div>
     
    181120          />
    182121          <base:icon
     122            id="btnDeletePermanently"
    183123            image="deleted.png"
    184             onclick="deleteItemPermanently()"
    185124            tooltip="This item has been flagged for deletion. Click to delete it now."
    186125            enabled="<%=deletePermanentlyPermission %>"
    187126            visible="<%=isRemoved%>"
    188127          />
    189           <base:icon image="used.png"
    190             onclick="showUsingItems()"
     128          <base:icon
     129            id="btnUsingItems"
     130            image="used.png"
    191131            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    192132            visible="<%=isRemoved && isUsed%>" />
     
    195135          <tbl:toolbar subclass="bottomborder">
    196136            <tbl:button
     137              id="btnEdit"
    197138              disabled="<%=!writePermission%>"
    198139              image="edit.png"
    199               onclick="editItem()"
    200140              title="Edit&hellip;"
    201141              tooltip="<%=writePermission ? "Edit this list" : "You do not have permission to edit this list"%>"
    202142            />
    203143            <tbl:button
     144              id="btnDelete"
    204145              disabled="<%=!deletePermission%>"
    205146              image="delete.png"
    206               onclick="deleteItem()"
    207147              title="Delete"
    208148              visible="<%=!list.isRemoved()%>"
     
    210150            />
    211151            <tbl:button
     152              id="btnRestore"
    212153              disabled="<%=!writePermission%>"
    213154              image="restore.png"
    214               onclick="restoreItem()"
    215155              title="Restore"
    216156              visible="<%=list.isRemoved()%>"
     
    218158            />
    219159            <tbl:button
     160              id="btnShare"
    220161              disabled="<%=!sharePermission%>"
    221162              image="share.png"
    222               onclick="shareItem()"
    223163              title="Share&hellip;"
    224164              tooltip="<%=sharePermission ? "Share this list to other user, groups and projects" : "You do not have permission to share this list"%>"
    225165            />
    226166            <tbl:button
     167              id="btnSetOwner"
    227168              disabled="<%=!setOwnerPermission%>"
    228169              image="take_ownership.png"
    229               onclick="setOwner()"
    230170              title="Set owner&hellip;"
    231171              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
    232172            />
    233173            <tbl:button
     174              id="btnPlaceOnPlate"
    234175              image="place_on_plate.png"
    235               onclick="placeOnPlate()"
    236176              title="Place on plate&hellip;"
    237177              tooltip="Place the biomaterial in this list on a bioplate"
     
    239179            />
    240180            <tbl:button
     181              id="btnMergeUnion"
     182              data-merge-type="union"
    241183              visible="<%=writePermission%>"
    242184              image="set_operations/union_small.png"
    243               onclick="merge('union')"
    244185              title="Union&hellip;"
    245186              tooltip="Add items from other lists to this list"
    246187            />
    247188            <tbl:button
     189              id="btnMergeIntersection"
     190              data-merge-type="intersection"
    248191              visible="<%=writePermission%>"
    249192              image="set_operations/intersection_small.png"
    250               onclick="merge('intersection')"
    251193              title="Intersection&hellip;"
    252194              tooltip="Keep only items that are present in other lists"
    253195            />
    254196            <tbl:button
     197              id="btnMergeComplement"
     198              data-merge-type="complement"
    255199              visible="<%=writePermission%>"
    256200              image="set_operations/complement_small.png"
    257               onclick="merge('complement')"
    258201              title="Complement&hellip;"
    259202              tooltip="Remove items found in other lists from this list"
    260203            />
    261204            <tbl:button
     205              id="btnImport"
    262206              image="import.png"
    263               onclick="runPlugin('ImportItem')"
     207              data-plugin-type="IMPORT"
    264208              title="Import&hellip;"
    265209              tooltip="Import data"
     
    267211            />
    268212            <tbl:button
    269               image="export.png"
    270               onclick="runPlugin('ExportItem')"
     213              id="btnExport"
     214              image="export.png"
     215              data-plugin-type="EXPORT"
    271216              title="Export&hellip;"
    272217              tooltip="Export data"
     
    274219            />
    275220            <tbl:button
    276               image="runplugin.png"
    277               onclick="runPlugin('RunPlugin')"
     221              id="btnRunPlugin"
     222              image="runplugin.png" 
     223              data-plugin-type="OTHER"
    278224              title="Run plugin&hellip;"
    279225              tooltip="Run a plugin"
     
    284230            <tbl:button
    285231              image="help.png"
    286               onclick="<%="Main.openHelp('" + ID +"', 'biomateriallist.view.properties')"%>"
     232              subclass="auto-init"
     233              data-auto-init="help"
     234              data-help-id="biomateriallist.view.properties"
    287235              title="Help&hellip;"
    288236              tooltip="Get help about this page"
     
    337285    <t:tab id="members" title="Members" />
    338286    <t:tab id="overview" title="Overview"
    339       tooltip="Display a tree overview of related items"
    340       activate="Overview.loadOnce()">
     287      tooltip="Display a tree overview of related items">
    341288      <jsp:include page="../../common/overview/overview.jsp">
    342289        <jsp:param name="item_type" value="<%=itemType.name()%>" />
  • trunk/www/biomaterials/samples/samples.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'SAMPLE', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     49      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     50      Buttons.addClickHandler('btnNewSample', samples.newSample, attributes);
     51      Buttons.addClickHandler('btnNewExtract', samples.newExtract, attributes);
     52      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     53      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     54      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
     55     
     56      TabControl.addTabActivateListener('main.events', samples.viewEvents);
     57      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
     58      TabControl.addTabActivateListener('main.overview', Overview.loadOnce);
     59      TabControl.addTabActivateListener('main.history', History.loadOnce);
    4260    }
    4361    else if (pageId == 'list-page')
     
    115133    Table.submitToPopup('samples', 'NewPooledItem', 750, 500);
    116134  }
    117    
     135 
     136  samples.viewEvents = function()
     137  {
     138    var sampleId = Data.get('page-data', 'item-id');
     139    var url = '../events/index.jsp?ID='+App.getSessionId();
     140    url += '&cmd=List&biomaterial_id='+sampleId;
     141    url += '&biomaterial_type=SAMPLE';
     142    location.replace(url);
     143  }
     144
     145 
    118146  return samples;
    119147}();
  • trunk/www/biomaterials/tags/tags.js

    r6260 r6261  
    3939    else if (pageId == 'view-page')
    4040    {
    41       // TODO
     41      var itemId = Data.get('page-data', 'item-id');
     42      var attributes = {'item-type': 'TAG', 'item-id': itemId};
     43      Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes);
     44      Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes);
     45      Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes);
     46      Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes);
     47      Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes);
     48      Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes);
     49      Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes);
     50      Buttons.addClickHandler('btnNewSample', biosources.newSample, attributes);
     51      Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes);
     52      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
     53      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
    4254    }
    4355    else if (pageId == 'list-page')
  • trunk/www/biomaterials/tags/view_tag.jsp

    r6136 r6261  
    7575final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    7676final int itemId = cc.getId();
     77final String tab = Values.getStringOrNull(request.getParameter("tab"));
    7778final float scale = Base.getScale(sc);
    7879final DbControl dc = sc.newDbControl();
     
    9798  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    9899  %>
    99   <base:page title="<%=title%>">
    100   <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
     100  <base:page title="<%=title%>" id="view-page">
     101  <base:head scripts="table.js,tabcontrol-2.js,~tags.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
    101102    <ext:scripts context="<%=jspContext%>" />
    102103    <ext:stylesheets context="<%=jspContext%>" />
    103     <script>
    104     function editItem()
    105     {
    106       Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
    107     }
    108     function shareItem()
    109     {
    110       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareTag', 600, 400);
    111     }
    112     function deleteItem()
    113     {
    114       location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
    115     }
    116     function restoreItem()
    117     {
    118       location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    119     }
    120     function deleteItemPermanently()
    121     {
    122       Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
    123     }
    124     function itemDeleted()
    125     {
    126       Main.listItems('<%=ID%>', '<%=itemType.name()%>');
    127     }
    128     function showUsingItems()
    129     {
    130       Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
    131     }
    132     function setOwner()
    133     {
    134       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
    135     }
    136     function runPlugin(cmd)
    137     {
    138       Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
    139     }
    140     </script>
    141104  </base:head>
    142105  <base:body>
     
    144107      title="Tags" href="<%="index.jsp?ID="+ID%>" /><p:pathelement
    145108      title="<%=HTML.encodeTags(tag.getName())%>" /></p:path>
     109    <div id="page-data" data-item-id="<%=itemId%>"></div>
    146110   
    147111    <t:tabcontrol
    148112      id="main"
    149113      subclass="content mastertabcontrol"
    150       active="properties">
     114      active="<%=tab%>">
    151115    <t:tab id="properties" title="Properties">
    152116      <div>
     
    160124          />
    161125          <base:icon
     126            id="btnDeletePermanently"
    162127            image="deleted.png"
    163             onclick="deleteItemPermanently()"
    164128            tooltip="This item has been flagged for deletion. Click to delete it now."
    165129            enabled="<%=deletePermanentlyPermission %>"
    166130            visible="<%=isRemoved%>"
    167131          />
    168           <base:icon image="used.png"
    169             onclick="showUsingItems()"
     132          <base:icon
     133            id="btnUsingItems"
     134            image="used.png"
    170135            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
    171136            visible="<%=isRemoved && isUsed%>" />
     
    174139          <tbl:toolbar subclass="bottomborder">
    175140            <tbl:button
     141              id="btnEdit"
    176142              disabled="<%=!writePermission%>"
    177143              image="edit.png"
    178               onclick="editItem()"
    179144              title="Edit&hellip;"
    180145              tooltip="<%=writePermission ? "Edit this tag" : "You do not have permission to edit this tag"%>"
    181146            />
    182147            <tbl:button
     148              id="btnDelete"
    183149              disabled="<%=!deletePermission%>"
    184150              image="delete.png"
    185               onclick="deleteItem()"
    186151              title="Delete"
    187152              visible="<%=!tag.isRemoved()%>"
     
    189154            />
    190155            <tbl:button
     156              id="btnRestore"
    191157              disabled="<%=!writePermission%>"
    192158              image="restore.png"
    193               onclick="restoreItem()"
    194159              title="Restore"
    195160              visible="<%=tag.isRemoved()%>"
     
    197162            />
    198163            <tbl:button
     164              id="btnShare"
    199165              disabled="<%=!sharePermission%>"
    200166              image="share.png"
    201               onclick="shareItem()"
    202167              title="Share&hellip;"
    203168              tooltip="<%=sharePermission ? "Share this tag to other user, groups and projects" : "You do not have permission to share this tag"%>"
    204169            />
    205170            <tbl:button
     171              id="btnSetOwner"
    206172              disabled="<%=!setOwnerPermission%>"
    207173              image="take_ownership.png"
    208               onclick="setOwner()"
    209174              title="Set owner&hellip;"
    210175              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
    211176            />
    212177            <tbl:button
     178              id="btnImport"
    213179              image="import.png"
    214               onclick="runPlugin('ImportItem')"
     180              data-plugin-type="IMPORT"
    215181              title="Import&hellip;"
    216182              tooltip="Import data"
     
    218184            />
    219185            <tbl:button
    220               image="export.png"
    221               onclick="runPlugin('ExportItem')"
     186              id="btnExport"
     187              image="export.png"
     188              data-plugin-type="EXPORT"
    222189              title="Export&hellip;"
    223190              tooltip="Export data"
     
    225192            />
    226193            <tbl:button
    227               image="runplugin.png"
    228               onclick="runPlugin('RunPlugin')"
     194              id="btnRunPlugin"
     195              image="runplugin.png" 
     196              data-plugin-type="OTHER"
    229197              title="Run plugin&hellip;"
    230198              tooltip="Run a plugin"
     
    235203            <tbl:button
    236204              image="help.png"
    237               onclick="<%="Main.openHelp('" + ID +"', 'tag.view.properties')"%>"
     205              subclass="auto-init"
     206              data-auto-init="help"
     207              data-help-id="tag.view.properties"
    238208              title="Help&hellip;"
    239209              tooltip="Get help about this page"
  • trunk/www/include/scripts/main-2.js

    r6260 r6261  
    730730    var itemType = Data.get(target, 'item-type');
    731731    var itemId = Data.int(target, 'item-id');
    732     Items.deleteItem(itemType, itemId);
     732    var extraUrl = Data.get(target, 'extra-url');
     733    Items.deleteItem(itemType, itemId, extraUrl);
    733734  }
    734735
     
    759760    var itemType = Data.get(target, 'item-type');
    760761    var itemId = Data.int(target, 'item-id');
    761     Items.restoreItem(itemType, itemId);
     762    var extraUrl = Data.get(target, 'extra-url');
     763    Items.restoreItem(itemType, itemId, extraUrl);
    762764  }
    763765 
     
    789791    var itemType = Data.get(target, 'item-type');
    790792    var itemId = Data.int(target, 'item-id');
    791     Items.deleteItemPermanently(itemType, itemId, true);
     793    var extraUrl = Data.get(target, 'extra-url');
     794    Items.deleteItemPermanently(itemType, itemId, true, extraUrl);
    792795  }
    793796 
     
    12711274    The current page is automatically reloaded.
    12721275  */
    1273   items.deleteItem = function(itemType, itemId, extraUrl)
     1276  items.deleteItem = function(itemType, itemId, ask, extraUrl)
    12741277  {
    12751278    internal.itemCommand('DeleteItem', itemType, itemId, extraUrl);
     
    12891292    The current page is automatically changed to the list page.
    12901293  */
    1291   items.deleteItemPermanently = function(itemType, itemId, ask)
     1294  items.deleteItemPermanently = function(itemType, itemId, ask, extraUrl)
    12921295  {
    12931296    if (ask)
     
    13031306      function()
    13041307      {
    1305         Items.list(itemType);
     1308        Items.list(itemType, extraUrl);
    13061309      }
    13071310    );
  • trunk/www/include/scripts/tabcontrol-2.js

    r6260 r6261  
    118118      tabControl.activeContent = content;
    119119    }
    120    
     120
     121    Data.setPageValue('last-tab.'+tabControl.id, tab.id);
     122
    121123    var evt = document.createEvent('Event');
    122124    evt.initEvent('base-activate', false, true);
    123125    tab.dispatchEvent(evt);
    124126   
    125     Data.setPageValue('last-tab.'+tabControl.id, tab.id);
    126127    return true;
    127128  }
Note: See TracChangeset for help on using the changeset viewer.