Skip to content

Commit d448f01

Browse files
committed
Decimal support (5.14)
Added date and time pattern input fields (Fixed #5)
1 parent 6dbbc2f commit d448f01

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

src/formatstring/formatstring.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<attributeType name="Long"/>
6161
<attributeType name="DateTime"/>
6262
<attributeType name="Currency"/>
63+
<attributeType name="Decimal"/>
6364
</attributeTypes>
6465
</property>
6566
<property key="emptyReplacement" type="translatableString" required="false">
@@ -78,6 +79,16 @@
7879
<enumerationValue key="relative">Relative</enumerationValue>
7980
</enumerationValues>
8081
</property>
82+
<property key="datePattern" type="translatableString" required="false">
83+
<caption>Date pattern</caption>
84+
<category>Behaviour</category>
85+
<description>Optional, date pattern to override date part according to dojo/date/locale</description>
86+
</property>
87+
<property key="timePattern" type="translatableString" required="false">
88+
<caption>Time pattern</caption>
89+
<category>Behaviour</category>
90+
<description>Optional, time pattern to override time part according to dojo/date/locale</description>
91+
</property>
8192
<property key="renderHTML" type="boolean" defaultValue="false">
8293
<caption>Render value as HTML</caption>
8394
<category>Behaviour</category>

src/formatstring/widget/formatstring.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,17 @@ require([
252252

253253
_fetchAttr: function (obj, attr, renderAsHTML, i, emptyReplacement, decimalPrecision, groupDigits) {
254254
var returnvalue = "";
255+
var options = {};
255256

256257
if (obj.isDate(attr)) {
257-
returnvalue = this._parseDate(this.attributeList[i].datetimeformat, obj.get(attr));
258+
if(this.attributeList[i].datePattern !== '') {
259+
options.datePattern = this.attributeList[i].datePattern;
260+
}
261+
if(this.attributeList[i].timePattern !== '') {
262+
options.timePattern = this.attributeList[i].timePattern;
263+
}
264+
265+
returnvalue = this._parseDate(this.attributeList[i].datetimeformat, options, obj.get(attr));
258266
} else if (obj.isEnum(attr)) {
259267
returnvalue = this._checkString(obj.getEnumCaption(attr, obj.get(attr)), renderAsHTML);
260268

@@ -324,7 +332,7 @@ require([
324332
return string;
325333
},
326334

327-
_parseDate: function (format, value) {
335+
_parseDate: function (format, options, value) {
328336
var datevalue = value;
329337

330338
if (value === "")
@@ -333,9 +341,9 @@ require([
333341
if (format == 'relative')
334342
return this._parseTimeAgo(value);
335343
else {
336-
datevalue = dojo.date.locale.format(new Date(value), {
337-
selector: format
338-
});
344+
options.selector = format;
345+
346+
datevalue = dojo.date.locale.format(new Date(value), options);
339347
}
340348
return datevalue;
341349
},

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="formatstring" version="3.2" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="formatstring" version="4.0" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="formatstring/formatstring.xml"/>
66
</widgetFiles>

test/FormatString.mpr

122 KB
Binary file not shown.

test/widgets/FormatString.mpk

159 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)