Changeset 5075


Ignore:
Timestamp:
Aug 24, 2009, 1:05:40 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1361: Unhandled item: ANNOTATION

The only "issue" is that there is no "view" page for annotations. So the "edit" page is used for that as well. The "Save" button will be disabled if the current user doesn't have write permission.

Location:
trunk/www
Files:
3 edited

Legend:

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

    r5074 r5075  
    8989
    9090  final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
     91  final boolean writePermission = item == null ? true : item.hasPermission(Permission.WRITE);
    9192  Protocol protocol = null;
    9293  boolean readProtocol = true;
     
    871872      %>
    872873      </div>
    873       <table align="center">
    874       <tr>
    875         <td width="50%"><base:button onclick="saveAnnotations()" title="Save" /></td>
    876         <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
    877       </tr>
    878       </table>
     874      <%
     875      if (writePermission)
     876      {
     877        %>
     878        <table align="center">
     879        <tr>
     880          <td width="50%"><base:button onclick="saveAnnotations()" title="Save" /></td>
     881          <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
     882        </tr>
     883        </table>
     884        <%
     885      }
     886      else
     887      {
     888        %>
     889        <div class="error">You do not have permission to change this information</div>
     890        <table align="center">
     891        <tr>
     892          <td><base:button onclick="window.close()" title="Close" /></td>
     893        </tr>
     894        </table>
     895        <%
     896      }
     897      %>
    879898      <form name="modified" method="post" action="index.jsp?ID=<%=ID%>">
    880899        <input type="hidden" name="cmd" value="SaveAnnotations">
  • trunk/www/common/annotations/index.jsp

    r5060 r5075  
    2929  import="net.sf.basedb.core.ItemContext"
    3030  import="net.sf.basedb.core.BasicItem"
     31  import="net.sf.basedb.core.Annotation"
     32  import="net.sf.basedb.core.AnnotationType"
    3133  import="net.sf.basedb.core.Annotatable"
    3234  import="net.sf.basedb.core.BaseException"
     
    4446final String ID = sc.getId();
    4547final String cmd = request.getParameter("cmd");
    46 final Item itemType = Item.valueOf(request.getParameter("item_type"));
    4748final int itemId = Values.getInt(request.getParameter("item_id"));
    4849
     
    5455try
    5556{
    56   if ("SaveAnnotations".equals(cmd))
     57  if ("EditItem".equals(cmd))
    5758  {
     59    newDc = sc.newDbControl();
     60    Annotation a = Annotation.getById(newDc, itemId);
     61    AnnotationType at = a.getAnnotationType();
     62    Annotatable item = a.getAnnotationSet().getItem();
     63   
     64    redirect = "annotate.jsp?ID=" + ID + "&item_id=" + item.getId() +
     65        "&item_type=" + item.getType().name() +
     66        "&annotationtype_id=" + at.getId() + "&standalone=1";
     67    newDc.close();
     68  }
     69  else if ("SaveAnnotations".equals(cmd))
     70  {
     71    final Item itemType = Item.valueOf(request.getParameter("item_type"));
    5872    newDc = sc.newDbControl();
    5973    oldDc = sc.newDbControl();
  • trunk/www/include/scripts/main.js

    r5048 r5075  
    475475    this.controllers['UNIT'] = { url:'admin/quantities/units/index.jsp', width:600, height:480 };
    476476    this.controllers['CHANGEHISTORY'] = { url:'common/history/index.jsp', width:600, height:480, edit:false, popup:true };
     477    this.controllers['ANNOTATION'] = { url:'common/annotations/index.jsp', width:700, height:480, edit:true, popup:true };
    477478  }
    478479 
Note: See TracChangeset for help on using the changeset viewer.