Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved: Add a date range picker form field (OFBIZ-13209) #879

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions framework/webtools/widget/MiscForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,49 @@ under the License.
<option key="N" description="${uiLabelMap.CommonNo}" />
</radio>
</field>
<field name="oneDate">
<date-range-picker single-date-picker="true" time-picker-increment="3" min-year="2010" max-year="2030" max-span="9"/>
</field>
<field name="oneDateTime">
<date-range-picker single-date-picker="true" time-picker="true" time-picker-increment="3" linked-calendars="false" min-year="2010" max-year="2030" drops="up"/>
</field>
<field name="oneDateTimeSeconds">
<date-range-picker single-date-picker="true" time-picker="true" time-picker-seconds="true" linked-calendars="false" min-year="2010" max-year="2030" drops="up"/>
</field>
<field name="dateRange">
<date-range-picker single-date-picker="false" linked-calendars="false" min-year="2010" max-year="2030" show-week-numbers="true" drops="up"/>
</field>
<field name="dateTimeRange">
<date-range-picker single-date-picker="false" time-picker="true" max-span="6" clear-title="EMPTY THE INPUT PLEASE" drops="up"/>
</field>
<field name="dateTimeRangeSeconds">
<date-range-picker single-date-picker="false" time-picker="true" time-picker-seconds="true" time-picker-increment="30" linked-calendars="false" drops="up"/>
</field>
<field name="submitButton" title="${uiLabelMap.CommonSave}"><submit button-type="button"/></field>
<field name="cancelButton" title=" " widget-style="smallSubmit">
<hyperlink description="${uiLabelMap.CommonCancel}" target="${demoTargetUrl}"/>
</field>
<sort-order>
<sort-field name="name"/>
<sort-field name="description"/>
<sort-field name="default"/>
<sort-field name="quantity"/>
<sort-field name="amount"/>
<sort-field name="spelled"/>
<sort-field name="percentage"/>
<sort-field name="accounting"/>
<sort-field name="dropDown"/>
<sort-field name="checkBox"/>
<sort-field name="radioButton"/>
<field-group title="Date Range Picker">
<sort-field name="oneDate"/>
<sort-field name="oneDateTime"/>
<sort-field name="oneDateTimeSeconds"/>
<sort-field name="dateRange"/>
<sort-field name="dateTimeRange"/>
<sort-field name="dateTimeRangeSeconds"/>
</field-group>
</sort-order>
</form>

<form name="LayoutDemoList" extends="CommonBasicList" extends-resource="component://common/widget/CommonForms.xml"
Expand Down
1 change: 1 addition & 0 deletions framework/webtools/widget/MiscScreens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ under the License.
<link text="${uiLabelMap.CommonDisabled}" style="disabled"/>
</container>
<include-form name="LayoutDemoList" location="component://webtools/widget/MiscForms.xml"/>
<include-form name="LayoutDemoForm" location="component://webtools/widget/MiscForms.xml"/>
</screenlet>
</widgets>
</section>
Expand Down
24 changes: 24 additions & 0 deletions framework/widget/config/conditionalUiLabels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,28 @@
<value xml:lang="zh">到今天为止</value>
<value xml:lang="zh-TW">到今天為止</value>
</property>
<property key="this_week">
<value xml:lang="en">This week</value>
<value xml:lang="fr">Cette semaine</value>
</property>
<property key="last_week">
<value xml:lang="en">Last week</value>
<value xml:lang="fr">La semaine dernière</value>
</property>
<property key="next_week">
<value xml:lang="en">Next week</value>
<value xml:lang="fr">La semaine prochaine</value>
</property>
<property key="this_month">
<value xml:lang="en">This month</value>
<value xml:lang="fr">Ce mois-ci</value>
</property>
<property key="last_month">
<value xml:lang="en">Last month</value>
<value xml:lang="fr">Le mois dernier</value>
</property>
<property key="next_month">
<value xml:lang="en">Next month</value>
<value xml:lang="fr">Le mois prochain</value>
</property>
</resource>
49 changes: 49 additions & 0 deletions framework/widget/dtd/widget-form.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,55 @@ under the License.
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="date-range-picker" substitutionGroup="AllFields">
<xs:annotation>
<xs:documentation>
A wrapper on top of https://www.daterangepicker.com/, see https://www.daterangepicker.com/#options for documentation.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="always-show-calendars" type="xs:boolean" default="true"/>
<xs:attribute name="apply-button-classes" type="xs:string"/>
<xs:attribute name="apply-label" type="xs:string"/>
<xs:attribute name="auto-apply" type="xs:boolean" default="true"/>
<xs:attribute name="button-classes" type="xs:string"/>
<xs:attribute name="cancel-button-classes" type="xs:string"/>
<xs:attribute name="cancel-label" type="xs:string"/>
<xs:attribute name="clear-title" type="xs:string"/>
<xs:attribute name="default-value" type="xs:string"/>
<xs:attribute name="drops" default="down">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="down"/>
<xs:enumeration value="up"/>
<xs:enumeration value="auto"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="linked-calendars" type="xs:boolean" default="true"/>
<xs:attribute name="max-span" type="xs:integer"/>
<xs:attribute name="max-year" type="xs:integer"/>
<xs:attribute name="min-year" type="xs:integer"/>
<xs:attribute name="opens" default="center">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
<xs:enumeration value="center"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="show-dropdowns" type="xs:boolean" default="true"/>
<xs:attribute name="show-iso-week-numbers" type="xs:boolean" default="false"/>
<xs:attribute name="show-ranges" type="xs:boolean" default="true"/>
<xs:attribute name="show-week-numbers" type="xs:boolean" default="false"/>
<xs:attribute name="single-date-picker" type="xs:boolean"/>
<xs:attribute name="time-picker" type="xs:boolean" default="false"/>
<xs:attribute name="time-picker-24-hour" type="xs:boolean" default="true"/>
<xs:attribute name="time-picker-increment" type="xs:integer"/>
<xs:attribute name="time-picker-seconds" type="xs:boolean" default="false"/>
</xs:complexType>
</xs:element>
<xs:element name="display" substitutionGroup="AllFields">
<xs:complexType>
<xs:sequence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.ofbiz.widget.model.ModelFormField.CheckField;
import org.apache.ofbiz.widget.model.ModelFormField.ContainerField;
import org.apache.ofbiz.widget.model.ModelFormField.DateFindField;
import org.apache.ofbiz.widget.model.ModelFormField.DateRangePickerField;
import org.apache.ofbiz.widget.model.ModelFormField.DateTimeField;
import org.apache.ofbiz.widget.model.ModelFormField.DisplayEntityField;
import org.apache.ofbiz.widget.model.ModelFormField.DisplayField;
Expand Down Expand Up @@ -414,6 +415,10 @@ public void visit(DateFindField dateTimeField) {
public void visit(DateTimeField dateTimeField) {
}

@Override
public void visit(DateRangePickerField dateRangePickerField) {
}

@Override
public void visit(DisplayEntityField displayField) {
if (displayField.getSubHyperlink() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public abstract class FieldInfo {
public static final int FORM = 23;
public static final int GRID = 24;
public static final int SCREEN = 25;
public static final int DATE_RANGE_PICKER = 26;
// the numbering here represents the priority of the source;
//when setting a new fieldInfo on a modelFormField it will only set
//the new one if the fieldSource is less than or equal to the existing
Expand Down Expand Up @@ -99,6 +100,7 @@ private static Map<String, Integer> createFieldTypeMap() {
fieldTypeByName.put("include-form", 23);
fieldTypeByName.put("include-grid", 24);
fieldTypeByName.put("include-screen", 25);
fieldTypeByName.put("date-range-picker", 26);
return Collections.unmodifiableMap(fieldTypeByName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.ofbiz.widget.model.ModelFormField.ContainerField;
import org.apache.ofbiz.widget.model.ModelFormField.DateFindField;
import org.apache.ofbiz.widget.model.ModelFormField.DateTimeField;
import org.apache.ofbiz.widget.model.ModelFormField.DateRangePickerField;
import org.apache.ofbiz.widget.model.ModelFormField.DisplayEntityField;
import org.apache.ofbiz.widget.model.ModelFormField.DisplayField;
import org.apache.ofbiz.widget.model.ModelFormField.DropDownField;
Expand Down Expand Up @@ -57,6 +58,8 @@ public interface ModelFieldVisitor {

void visit(DateTimeField dateTimeField) throws Exception;

void visit(DateRangePickerField dateRangePickerField) throws Exception;

void visit(DisplayEntityField displayEntityField) throws Exception;

void visit(DisplayField displayField) throws Exception;
Expand Down
Loading