Changeset 2919


Ignore:
Timestamp:
Nov 15, 2006, 1:28:13 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #348: Take ownership of items

Implemented on all pages in the "Array LIMS" menu.

Location:
trunk/www
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/lims/arraybatches/index.jsp

    r2811 r2919  
    4343  import="net.sf.basedb.util.RemovableUtil"
    4444  import="net.sf.basedb.util.ShareableUtil"
     45  import="net.sf.basedb.util.OwnableUtil"
    4546  import="net.sf.basedb.clients.web.Base"
    4647  import="net.sf.basedb.clients.web.WebException"
     
    233234    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    234235  }
     236  else if ("TakeOwnershipOfItem".equals(cmd))
     237  {
     238    // Take ownership a single item and then return to the view page
     239    dc = sc.newDbControl();
     240    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     241    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     242    dc.commit();
     243    redirect = viewPage;
     244  }
     245  else if ("TakeOwnershipOfItems".equals(cmd))
     246  {
     247    // Take ownership all selected items on the list page
     248    dc = sc.newDbControl();
     249    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     250    int numTotal = cc.getSelected().size();
     251    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     252    dc.commit();
     253    if (numTotal != numOwned)
     254    {
     255      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     256    }
     257    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     258  }
    235259  else if ("ExportItems".equals(cmd))
    236260  {
  • trunk/www/lims/arraybatches/list_batches.jsp

    r2893 r2919  
    143143      frm.submit();
    144144    }
     145    function takeOwnership()
     146    {
     147      var frm = document.forms[formId];
     148      if (Forms.numChecked(frm) == 0)
     149      {
     150        alert('Please select at least one item in the list');
     151        return;
     152      }
     153      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     154      {
     155        frm.action = submitPage;
     156        frm.cmd.value = 'TakeOwnershipOfItems';
     157        frm.submit();
     158      }
     159    }
    145160    function shareItem(itemId)
    146161    {
     
    328343          title="Share…"
    329344          tooltip="Share the selected items"
     345        />
     346        <tbl:button
     347          image="take_ownership.png"
     348          onclick="takeOwnership()"
     349          title="Take ownership&hellip;"
     350          tooltip="Take ownership of the selected items"
    330351        />
    331352        <tbl:button
  • trunk/www/lims/arraybatches/view_batch.jsp

    r2875 r2919  
    8585  final boolean deletePermission = batch.hasPermission(Permission.DELETE);
    8686  final boolean sharePermission = batch.hasPermission(Permission.SET_PERMISSION);
    87 
     87  final boolean setOwnerPermission = batch.hasPermission(Permission.SET_OWNER);
     88  final boolean isOwner = batch.isOwner();
    8889  %>
    8990
     
    106107    {
    107108      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     109    }
     110    function takeOwnership()
     111    {
     112      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     113      {
     114        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     115      }
    108116    }
    109117    function runPlugin(cmd)
     
    175183        title="Share&hellip;"
    176184        tooltip="<%=sharePermission ? "Share this array batch to other user, groups and projects" : "You do not have permission to share this array batch"%>"
     185      />
     186      <tbl:button
     187        disabled="<%=setOwnerPermission ? false : true%>"
     188        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     189        onclick="takeOwnership()"
     190        title="Take ownership&hellip;"
     191        visible="<%=!isOwner%>"
     192        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    177193      />
    178194      <tbl:button
  • trunk/www/lims/arraydesigns/index.jsp

    r2811 r2919  
    4444  import="net.sf.basedb.util.RemovableUtil"
    4545  import="net.sf.basedb.util.ShareableUtil"
     46  import="net.sf.basedb.util.OwnableUtil"
    4647  import="net.sf.basedb.clients.web.Base"
    4748  import="net.sf.basedb.clients.web.WebException"
     
    228229    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    229230  }
     231  else if ("TakeOwnershipOfItem".equals(cmd))
     232  {
     233    // Take ownership a single item and then return to the view page
     234    dc = sc.newDbControl();
     235    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     236    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     237    dc.commit();
     238    redirect = viewPage;
     239  }
     240  else if ("TakeOwnershipOfItems".equals(cmd))
     241  {
     242    // Take ownership all selected items on the list page
     243    dc = sc.newDbControl();
     244    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     245    int numTotal = cc.getSelected().size();
     246    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     247    dc.commit();
     248    if (numTotal != numOwned)
     249    {
     250      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     251    }
     252    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     253  }
    230254  else if ("ExportItems".equals(cmd))
    231255  {
  • trunk/www/lims/arraydesigns/list_designs.jsp

    r2893 r2919  
    148148      frm.submit();
    149149    }
     150    function takeOwnership()
     151    {
     152      var frm = document.forms[formId];
     153      if (Forms.numChecked(frm) == 0)
     154      {
     155        alert('Please select at least one item in the list');
     156        return;
     157      }
     158      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     159      {
     160        frm.action = submitPage;
     161        frm.cmd.value = 'TakeOwnershipOfItems';
     162        frm.submit();
     163      }
     164    }
    150165    function shareItem(itemId)
    151166    {
     
    324339          title="Share&hellip;"
    325340          tooltip="Share the selected items"
     341        />
     342        <tbl:button
     343          image="take_ownership.png"
     344          onclick="takeOwnership()"
     345          title="Take ownership&hellip;"
     346          tooltip="Take ownership of the selected items"
    326347        />
    327348        <tbl:button
  • trunk/www/lims/arraydesigns/view_design.jsp

    r2753 r2919  
    8787  final boolean deletePermission = design.hasPermission(Permission.DELETE);
    8888  final boolean sharePermission = design.hasPermission(Permission.SET_PERMISSION);
     89  final boolean setOwnerPermission = design.hasPermission(Permission.SET_OWNER);
     90  final boolean isOwner = design.isOwner();
    8991  %>
    9092
     
    107109    {
    108110      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     111    }
     112    function takeOwnership()
     113    {
     114      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     115      {
     116        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     117      }
    109118    }
    110119    function runPlugin(cmd)
     
    177186        title="Share&hellip;"
    178187        tooltip="<%=sharePermission ? "Share this array design to other user, groups and projects" : "You do not have permission to share this array design"%>"
     188      />
     189      <tbl:button
     190        disabled="<%=setOwnerPermission ? false : true%>"
     191        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     192        onclick="takeOwnership()"
     193        title="Take ownership&hellip;"
     194        visible="<%=!isOwner%>"
     195        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    179196      />
    180197      <tbl:button
  • trunk/www/lims/arrayslides/index.jsp

    r2811 r2919  
    4343  import="net.sf.basedb.util.RemovableUtil"
    4444  import="net.sf.basedb.util.ShareableUtil"
     45  import="net.sf.basedb.util.OwnableUtil"
    4546  import="net.sf.basedb.clients.web.Base"
    4647  import="net.sf.basedb.clients.web.WebException"
     
    253254    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    254255  }
     256  else if ("TakeOwnershipOfItem".equals(cmd))
     257  {
     258    // Take ownership a single item and then return to the view page
     259    dc = sc.newDbControl();
     260    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     261    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     262    dc.commit();
     263    redirect = viewPage;
     264  }
     265  else if ("TakeOwnershipOfItems".equals(cmd))
     266  {
     267    // Take ownership all selected items on the list page
     268    dc = sc.newDbControl();
     269    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     270    int numTotal = cc.getSelected().size();
     271    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     272    dc.commit();
     273    if (numTotal != numOwned)
     274    {
     275      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     276    }
     277    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     278  }
    255279  else if ("ExportItems".equals(cmd))
    256280  {
  • trunk/www/lims/arrayslides/list_slides.jsp

    r2893 r2919  
    138138      frm.submit();
    139139    }
     140    function takeOwnership()
     141    {
     142      var frm = document.forms[formId];
     143      if (Forms.numChecked(frm) == 0)
     144      {
     145        alert('Please select at least one item in the list');
     146        return;
     147      }
     148      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     149      {
     150        frm.action = submitPage;
     151        frm.cmd.value = 'TakeOwnershipOfItems';
     152        frm.submit();
     153      }
     154    }
    140155    function shareItem(itemId)
    141156    {
     
    345360          title="Share&hellip;"
    346361          tooltip="Share the selected items"
     362        />
     363        <tbl:button
     364          image="take_ownership.png"
     365          onclick="takeOwnership()"
     366          title="Take ownership&hellip;"
     367          tooltip="Take ownership of the selected items"
    347368        />
    348369        <tbl:button
  • trunk/www/lims/arrayslides/view_slide.jsp

    r2753 r2919  
    8383  final boolean deletePermission = slide.hasPermission(Permission.DELETE);
    8484  final boolean sharePermission = slide.hasPermission(Permission.SET_PERMISSION);
     85  final boolean setOwnerPermission = slide.hasPermission(Permission.SET_OWNER);
     86  final boolean isOwner = slide.isOwner();
    8587  %>
    8688
     
    103105    {
    104106      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     107    }
     108    function takeOwnership()
     109    {
     110      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     111      {
     112        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     113      }
    105114    }
    106115    function runPlugin(cmd)
     
    150159        title="Share&hellip;"
    151160        tooltip="<%=sharePermission ? "Share this array slide to other user, groups and projects" : "You do not have permission to share this array slide"%>"
     161      />
     162      <tbl:button
     163        disabled="<%=setOwnerPermission ? false : true%>"
     164        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     165        onclick="takeOwnership()"
     166        title="Take ownership&hellip;"
     167        visible="<%=!isOwner%>"
     168        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    152169      />
    153170      <tbl:button
  • trunk/www/lims/platemappings/index.jsp

    r2811 r2919  
    4141  import="net.sf.basedb.util.RemovableUtil"
    4242  import="net.sf.basedb.util.ShareableUtil"
     43  import="net.sf.basedb.util.OwnableUtil"
    4344  import="net.sf.basedb.clients.web.Base"
    4445  import="net.sf.basedb.clients.web.WebException"
     
    219220    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    220221  }
     222  else if ("TakeOwnershipOfItem".equals(cmd))
     223  {
     224    // Take ownership a single item and then return to the view page
     225    dc = sc.newDbControl();
     226    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     227    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     228    dc.commit();
     229    redirect = viewPage;
     230  }
     231  else if ("TakeOwnershipOfItems".equals(cmd))
     232  {
     233    // Take ownership all selected items on the list page
     234    dc = sc.newDbControl();
     235    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     236    int numTotal = cc.getSelected().size();
     237    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     238    dc.commit();
     239    if (numTotal != numOwned)
     240    {
     241      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     242    }
     243    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     244  }
    221245  else if ("ExportItems".equals(cmd))
    222246  {
  • trunk/www/lims/platemappings/list_mappings.jsp

    r2753 r2919  
    135135      frm.submit();
    136136    }
     137    function takeOwnership()
     138    {
     139      var frm = document.forms[formId];
     140      if (Forms.numChecked(frm) == 0)
     141      {
     142        alert('Please select at least one item in the list');
     143        return;
     144      }
     145      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     146      {
     147        frm.action = submitPage;
     148        frm.cmd.value = 'TakeOwnershipOfItems';
     149        frm.submit();
     150      }
     151    }
    137152    function shareItem(itemId)
    138153    {
     
    304319          title="Share&hellip;"
    305320          tooltip="Share the selected items"
     321        />
     322        <tbl:button
     323          image="take_ownership.png"
     324          onclick="takeOwnership()"
     325          title="Take ownership&hellip;"
     326          tooltip="Take ownership of the selected items"
    306327        />
    307328        <tbl:button
  • trunk/www/lims/platemappings/view_mapping.jsp

    r2753 r2919  
    8686  final boolean deletePermission = mapping.hasPermission(Permission.DELETE);
    8787  final boolean sharePermission = mapping.hasPermission(Permission.SET_PERMISSION);
     88  final boolean setOwnerPermission = mapping.hasPermission(Permission.SET_OWNER);
     89  final boolean isOwner = mapping.isOwner();
    8890  %>
    8991
     
    106108    {
    107109      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     110    }
     111    function takeOwnership()
     112    {
     113      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     114      {
     115        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     116      }
    108117    }
    109118    function runPlugin(cmd)
     
    153162        title="Share&hellip;"
    154163        tooltip="<%=sharePermission ? "Share this plate mapping to other user, groups and projects" : "You do not have permission to share this plate mapping"%>"
     164      />
     165      <tbl:button
     166        disabled="<%=setOwnerPermission ? false : true%>"
     167        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     168        onclick="takeOwnership()"
     169        title="Take ownership&hellip;"
     170        visible="<%=!isOwner%>"
     171        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    155172      />
    156173      <tbl:button
  • trunk/www/lims/plates/index.jsp

    r2811 r2919  
    4343  import="net.sf.basedb.util.RemovableUtil"
    4444  import="net.sf.basedb.util.ShareableUtil"
     45  import="net.sf.basedb.util.OwnableUtil"
    4546  import="net.sf.basedb.clients.web.Base"
    4647  import="net.sf.basedb.clients.web.WebException"
     
    216217    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    217218  }
     219  else if ("TakeOwnershipOfItem".equals(cmd))
     220  {
     221    // Take ownership a single item and then return to the view page
     222    dc = sc.newDbControl();
     223    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     224    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     225    dc.commit();
     226    redirect = viewPage;
     227  }
     228  else if ("TakeOwnershipOfItems".equals(cmd))
     229  {
     230    // Take ownership all selected items on the list page
     231    dc = sc.newDbControl();
     232    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     233    int numTotal = cc.getSelected().size();
     234    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     235    dc.commit();
     236    if (numTotal != numOwned)
     237    {
     238      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     239    }
     240    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     241  }
    218242  else if ("ExportItems".equals(cmd))
    219243  {
  • trunk/www/lims/plates/list_plates.jsp

    r2893 r2919  
    155155      frm.submit();
    156156    }
     157    function takeOwnership()
     158    {
     159      var frm = document.forms[formId];
     160      if (Forms.numChecked(frm) == 0)
     161      {
     162        alert('Please select at least one item in the list');
     163        return;
     164      }
     165      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     166      {
     167        frm.action = submitPage;
     168        frm.cmd.value = 'TakeOwnershipOfItems';
     169        frm.submit();
     170      }
     171    }
    157172    function shareItem(itemId)
    158173    {
     
    369384          title="Share&hellip;"
    370385          tooltip="Share the selected items"
     386        />
     387        <tbl:button
     388          image="take_ownership.png"
     389          onclick="takeOwnership()"
     390          title="Take ownership&hellip;"
     391          tooltip="Take ownership of the selected items"
    371392        />
    372393        <tbl:button
  • trunk/www/lims/plates/view_plate.jsp

    r2753 r2919  
    9191  final boolean deletePermission = plate.hasPermission(Permission.DELETE);
    9292  final boolean sharePermission = plate.hasPermission(Permission.SET_PERMISSION);
     93  final boolean setOwnerPermission = plate.hasPermission(Permission.SET_OWNER);
     94  final boolean isOwner = plate.isOwner();
    9395  %>
    94 
    9596  <base:page title="<%=title%>">
    9697  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     
    111112    {
    112113      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     114    }
     115    function takeOwnership()
     116    {
     117      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     118      {
     119        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     120      }
    113121    }
    114122    function runPlugin(cmd)
     
    181189        title="Share&hellip;"
    182190        tooltip="<%=sharePermission ? "Share this plate to other user, groups and projects" : "You do not have permission to share this plate"%>"
     191      />
     192      <tbl:button
     193        disabled="<%=setOwnerPermission ? false : true%>"
     194        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     195        onclick="takeOwnership()"
     196        title="Take ownership&hellip;"
     197        visible="<%=!isOwner%>"
     198        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    183199      />
    184200      <tbl:button
  • trunk/www/lims/platetypes/index.jsp

    r2811 r2919  
    4141  import="net.sf.basedb.util.RemovableUtil"
    4242  import="net.sf.basedb.util.ShareableUtil"
     43  import="net.sf.basedb.util.OwnableUtil"
    4344  import="net.sf.basedb.clients.web.Base"
    4445  import="net.sf.basedb.clients.web.WebException"
     
    215216    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    216217  }
     218  else if ("TakeOwnershipOfItem".equals(cmd))
     219  {
     220    // Take ownership a single item and then return to the view page
     221    dc = sc.newDbControl();
     222    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     223    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     224    dc.commit();
     225    redirect = viewPage;
     226  }
     227  else if ("TakeOwnershipOfItems".equals(cmd))
     228  {
     229    // Take ownership all selected items on the list page
     230    dc = sc.newDbControl();
     231    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     232    int numTotal = cc.getSelected().size();
     233    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     234    dc.commit();
     235    if (numTotal != numOwned)
     236    {
     237      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     238    }
     239    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     240  }
    217241  else if ("ExportItems".equals(cmd))
    218242  {
  • trunk/www/lims/platetypes/list_platetypes.jsp

    r2753 r2919  
    144144      frm.submit();
    145145    }
     146    function takeOwnership()
     147    {
     148      var frm = document.forms[formId];
     149      if (Forms.numChecked(frm) == 0)
     150      {
     151        alert('Please select at least one item in the list');
     152        return;
     153      }
     154      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     155      {
     156        frm.action = submitPage;
     157        frm.cmd.value = 'TakeOwnershipOfItems';
     158        frm.submit();
     159      }
     160    }
    146161    function shareItem(itemId)
    147162    {
     
    281296          title="Share&hellip;"
    282297          tooltip="Share the selected items"
     298        />
     299        <tbl:button
     300          image="take_ownership.png"
     301          onclick="takeOwnership()"
     302          title="Take ownership&hellip;"
     303          tooltip="Take ownership of the selected items"
    283304        />
    284305        <tbl:button
  • trunk/www/lims/platetypes/view_platetype.jsp

    r2753 r2919  
    8080  final boolean deletePermission = plateType.hasPermission(Permission.DELETE);
    8181  final boolean sharePermission = plateType.hasPermission(Permission.SET_PERMISSION);
     82  final boolean setOwnerPermission = plateType.hasPermission(Permission.SET_OWNER);
     83  final boolean isOwner = plateType.isOwner();
    8284  %>
    8385
     
    100102    {
    101103      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     104    }
     105    function takeOwnership()
     106    {
     107      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     108      {
     109        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     110      }
    102111    }
    103112    function runPlugin(cmd)
     
    163172          title="Share&hellip;"
    164173          tooltip="<%=sharePermission ? "Share this plate type to other user, groups and projects" : "You do not have permission to share this plate type"%>"
     174        />
     175        <tbl:button
     176          disabled="<%=setOwnerPermission ? false : true%>"
     177          image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     178          onclick="takeOwnership()"
     179          title="Take ownership&hellip;"
     180          visible="<%=!isOwner%>"
     181          tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    165182        />
    166183        <tbl:button
  • trunk/www/my_base/projects/items/index.jsp

    r2753 r2919  
    3333  import="net.sf.basedb.core.Include"
    3434  import="net.sf.basedb.core.Project"
     35  import="net.sf.basedb.core.User"
    3536  import="net.sf.basedb.core.Permission"
    3637  import="net.sf.basedb.core.ItemContext"
    3738  import="net.sf.basedb.core.BasicItem"
    3839  import="net.sf.basedb.core.SharedItem"
     40  import="net.sf.basedb.core.Ownable"
    3941  import="net.sf.basedb.core.Removable"
    4042  import="net.sf.basedb.core.MultiPermissions"
     
    190192    redirect = "../../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name()+"&subcontext="+subContext;
    191193  }
     194  else if ("TakeOwnershipOfItems".equals(cmd))
     195  {
     196    // Take ownership of all selected items on the list page
     197    dc = sc.newDbControl();
     198    int numTotal = 0;
     199    int numOwned = 0;
     200
     201    Enumeration<String> names = (Enumeration<String>)request.getParameterNames();
     202    User user = User.getById(dc, sc.getLoggedInUserId());
     203    while (names.hasMoreElements())
     204    {
     205      String name = names.nextElement();
     206      if (name.startsWith("item:"))
     207      {
     208        Item itemType = Item.valueOf(name.substring(5));
     209        Integer[] ids = Values.getInt(request.getParameterValues(name));
     210        for (int itemId : ids)
     211        {
     212          numTotal++;
     213          BasicItem item = itemType.getById(dc, itemId);
     214          if (item instanceof Ownable && item.hasPermission(Permission.SET_OWNER))
     215          {
     216            ((Ownable)item).setOwner(user);
     217            numOwned++;
     218          }
     219        }
     220      }
     221    }
     222    dc.commit();
     223
     224    if (numTotal != numOwned)
     225    {
     226      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     227    }
     228    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     229  }
    192230  else
    193231  {
  • trunk/www/my_base/projects/items/list_items.jsp

    r2753 r2919  
    7575  String filterItem = cc.getPropertyValue("type");
    7676  Project project = Project.getById(dc, projectId);
    77 
    7877  try
    7978  {
     
    117116      frm.submit();
    118117    }
     118    function takeOwnership()
     119    {
     120      var frm = document.forms[formId];
     121      if (Forms.numChecked(frm, /item:/) == 0)
     122      {
     123        alert('Please select at least one item in the list');
     124        return;
     125      }
     126      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     127      {
     128        frm.action = submitPage;
     129        frm.cmd.value = 'TakeOwnershipOfItems';
     130        frm.submit();
     131      }
     132    }
    119133    function shareItem(itemId)
    120134    {
     
    225239          title="Share&hellip;"
    226240          tooltip="Share the selected items"
     241        />
     242        <tbl:button
     243          image="take_ownership.png"
     244          onclick="takeOwnership()"
     245          title="Take ownership&hellip;"
     246          tooltip="Take ownership of the selected items"
    227247        />
    228248        <tbl:button
Note: See TracChangeset for help on using the changeset viewer.