Ignore:
Timestamp:
Sep 23, 2010, 11:09:55 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #1512: Add support for datetime annotation types

Makes it possible to crete TIMESTAMP annotation types and to enter values for them.

This is basically 3) in the ticket description.

File:
1 edited

Legend:

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

    r5075 r5423  
    22  ------------------------------------------------------------------
    33  Copyright (C) 2005 Nicklas Nordborg
    4   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
     4  Copyright (C) 2006 Jari Hkkinen, Nicklas Nordborg
    55  Copyright (C) 2007 Nicklas Nordborg
    66
     
    8888  String htmlDateFormat = HTML.encodeTags(dateFormat);
    8989
     90  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
     91  String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc);
     92  String jsDateTimeFormat = HTML.javaScriptEncode(dateTimeFormat);
     93  String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat);
     94 
    9095  final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
    9196  final boolean writePermission = item == null ? true : item.hasPermission(Permission.WRITE);
     
    190195      List values = null;
    191196      Unit unit = at.getDefaultUnit();
     197      Type valueType = at.getValueType();
    192198      if (existing != null && existing.containsKey(at))
    193199      {
     
    206212        for (Object value : values)
    207213        {
    208           if (value instanceof Date) value = dateFormatter.format((Date)value);
     214          if (value instanceof Date)
     215          {
     216            if (valueType == Type.TIMESTAMP)
     217            {
     218              value = dateTimeFormatter.format((Date)value);
     219            }
     220            else
     221            {
     222              value = dateFormatter.format((Date)value);
     223            }
     224          }
    209225          %>
    210226          values[values.length] = '<%=HTML.javaScriptEncode(value.toString())%>';
     
    807823            <%
    808824          }
     825          else if (valueType == Type.TIMESTAMP)
     826          {
     827            %>
     828            <table>
     829            <tr>
     830            <td>
     831              <b><%=HTML.encodeTags(at.getName())%></b> (Timestamp)<br>
     832              <input <%=clazz%> type="text" name="<%=inputName%>" value=""
     833                size="30" maxlength="30" title="Enter date + time in format: <%=htmlDateTimeFormat%>"
     834                onblur="valueOnBlur(this.value)">
     835            </td>
     836            <td>
     837                <br>
     838                <base:button
     839                  onclick="<%="Dates.selectDateTime('Value', 'annotations', '"+inputName+"', 'setDateCallback', '"+jsDateTimeFormat+"')"%>"
     840                  image="calendar.png"
     841                  title="Calendar&hellip;"
     842                  tooltip="Select date and time from a calendar"
     843                />
     844            </td>
     845            </tr>
     846            </table>
     847            <%
     848          }
    809849          if (at.supportUnits() && !at.isEnumeration())
    810850          {
Note: See TracChangeset for help on using the changeset viewer.