mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
updates to date time pickers
- make them behave better as inline elements for hgroup support - respect minInclusive, maxInclusive, minExclusive and maxExclusive restrictions for date types. no support in dojo to support the same with the TimePicker. addresses feature request WCM-379. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5574 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,8 @@ package org.alfresco.web.forms.xforms;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import javax.xml.transform.*;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
@@ -2442,6 +2444,63 @@ public class Schema2XForms
|
||||
controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXLENGTH));
|
||||
}
|
||||
}
|
||||
if (SchemaUtil.getBuiltInType(controlType) == XSConstants.DATE_DT)
|
||||
{
|
||||
String minInclusive = null;
|
||||
String maxInclusive = null;
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE))
|
||||
{
|
||||
minInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINEXCLUSIVE);
|
||||
try
|
||||
{
|
||||
final Date d = sdf.parse(minInclusive);
|
||||
calendar.setTime(d);
|
||||
}
|
||||
catch (ParseException pe)
|
||||
{
|
||||
LOGGER.error(pe);
|
||||
}
|
||||
calendar.roll(Calendar.DATE, true);
|
||||
minInclusive = sdf.format(calendar.getTime());
|
||||
}
|
||||
else if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MININCLUSIVE))
|
||||
{
|
||||
minInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE);
|
||||
}
|
||||
if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE))
|
||||
{
|
||||
maxInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE);
|
||||
try
|
||||
{
|
||||
final Date d = sdf.parse(maxInclusive);
|
||||
calendar.setTime(d);
|
||||
}
|
||||
catch (ParseException pe)
|
||||
{
|
||||
LOGGER.error(pe);
|
||||
}
|
||||
calendar.roll(Calendar.DATE, false);
|
||||
maxInclusive = sdf.format(calendar.getTime());
|
||||
}
|
||||
else if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE))
|
||||
{
|
||||
maxInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE);
|
||||
}
|
||||
if (minInclusive != null)
|
||||
{
|
||||
result.setAttributeNS(NamespaceService.ALFRESCO_URI,
|
||||
NamespaceService.ALFRESCO_PREFIX + ":minInclusive",
|
||||
minInclusive);
|
||||
}
|
||||
if (maxInclusive != null)
|
||||
{
|
||||
result.setAttributeNS(NamespaceService.ALFRESCO_URI,
|
||||
NamespaceService.ALFRESCO_PREFIX + ":maxInclusive",
|
||||
maxInclusive);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setXFormsId(result);
|
||||
result.appendChild(this.createLabel(xformsDocument, caption));
|
||||
|
@@ -7,12 +7,51 @@
|
||||
<xs:sequence>
|
||||
<xs:element name="datetime" type="xs:dateTime" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="date" type="xs:date" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="restricted_date_inclusive" minOccurs="1" maxOccurs="1">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:date">
|
||||
<xs:minInclusive value="2005-05-05"/>
|
||||
<xs:maxInclusive value="2006-06-06"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="restricted_date_exclusive" minOccurs="1" maxOccurs="1">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:date">
|
||||
<xs:minExclusive value="2005-05-04"/>
|
||||
<xs:maxExclusive value="2006-06-07"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="time" type="xs:time" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="day" type="xs:gDay" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="month" type="xs:gMonth" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="year" type="xs:gYear" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="month_day" type="xs:gMonthDay" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="year_month" type="xs:gYearMonth" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="date_and_time_in_minimal_group">
|
||||
<xs:annotation><xs:appinfo><alf:appearance>minimal</alf:appearance></xs:appinfo></xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="date_with_default" type="xs:date" minOccurs="1" maxOccurs="1" default="1978-08-08"/>
|
||||
<xs:element name="time_with_default" type="xs:time" minOccurs="1" maxOccurs="1" default="09:30:00"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="individual_pickers">
|
||||
<xs:annotation><xs:appinfo><alf:appearance>minimal</alf:appearance></xs:appinfo></xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="day" type="xs:gDay" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="month" type="xs:gMonth" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="year" type="xs:gYear" minOccurs="1" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="combination_pickers">
|
||||
<xs:annotation><xs:appinfo><alf:appearance>minimal</alf:appearance></xs:appinfo></xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="month_day" type="xs:gMonthDay" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="year_month" type="xs:gYearMonth" minOccurs="1" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<!-- not supported by chiba -->
|
||||
<!-- xs:element name="duration" type="xs:duration" minOccurs="1" maxOccurs="1"/ -->
|
||||
</xs:sequence>
|
||||
|
@@ -590,7 +590,7 @@ dojo.declare("alfresco.xforms.TextField",
|
||||
: -1);
|
||||
this._length = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":length")
|
||||
? Number(this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":length"))
|
||||
: -1)
|
||||
: -1);
|
||||
|
||||
},
|
||||
{
|
||||
@@ -1455,6 +1455,14 @@ dojo.declare("alfresco.xforms.DatePicker",
|
||||
function(xform, xformsNode)
|
||||
{
|
||||
dojo.require("dojo.widget.DatePicker");
|
||||
this._minInclusive = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":minInclusive")
|
||||
? this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":minInclusive")
|
||||
: null);
|
||||
this._maxInclusive = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxInclusive")
|
||||
? this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxInclusive")
|
||||
: null);
|
||||
|
||||
// XXXarielb - change to a static
|
||||
this._noValueSet = (alfresco.xforms.constants.resources["eg"] + " " +
|
||||
dojo.date.format(new Date(),
|
||||
{datePattern: alfresco.xforms.constants.DATE_FORMAT,
|
||||
@@ -1466,11 +1474,19 @@ dojo.declare("alfresco.xforms.DatePicker",
|
||||
var datePickerDiv = document.createElement("div");
|
||||
this.domNode.parentNode.appendChild(datePickerDiv);
|
||||
|
||||
var dp_initial_value = this.getValue() || dojo.date.toRfc3339(new Date());
|
||||
var dp_initial_value = this.getValue() || null; //dojo.date.toRfc3339(new Date());
|
||||
var datePickerProperties = { value: dp_initial_value };
|
||||
if (this._minInclusive)
|
||||
{
|
||||
datePickerProperties.startDate = this._minInclusive;
|
||||
}
|
||||
if (this._maxInclusive)
|
||||
{
|
||||
datePickerProperties.endDate = this._maxInclusive;
|
||||
}
|
||||
|
||||
this.widget.picker = dojo.widget.createWidget("DatePicker",
|
||||
{
|
||||
value: dp_initial_value
|
||||
},
|
||||
datePickerProperties,
|
||||
datePickerDiv);
|
||||
this.domContainer.style.height =
|
||||
Math.max(this.widget.picker.domNode.offsetHeight +
|
||||
|
Reference in New Issue
Block a user