diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js
index a46b2345f4..887f910335 100644
--- a/apps/common/main/lib/component/InputField.js
+++ b/apps/common/main/lib/component/InputField.js
@@ -701,6 +701,8 @@ define([
options.btnHint = options.btnHint || this.textDate;
Common.UI.InputFieldBtn.prototype.initialize.call(this, options);
+
+ this.dateValue = undefined;
},
render: function (parentEl) {
@@ -725,18 +727,29 @@ define([
firstday: 1
});
me.cmpCalendar.on('date:click', function (cmp, date) {
+ me.dateValue = date;
me.trigger('date:click', me, date);
menu.hide();
});
+ me.dateValue && me.cmpCalendar.setDate(me.dateValue);
menu.alignPosition();
}
me.cmpCalendar.focus();
- })
+ });
+ this._input.on('input', function() {
+ me.dateValue = undefined;
+ });
},
setDate: function(date) {
- if (this.cmpCalendar && date && date instanceof Date && !isNaN(date))
+ if (date && date instanceof Date && !isNaN(date)) {
this.cmpCalendar && this.cmpCalendar.setDate(date);
+ this.dateValue = date;
+ }
+ },
+
+ getDate: function() {
+ return this.dateValue;
},
textDate: 'Select date'
diff --git a/apps/common/main/lib/view/DocumentPropertyDialog.js b/apps/common/main/lib/view/DocumentPropertyDialog.js
index 47cd7bc179..5925a19076 100644
--- a/apps/common/main/lib/view/DocumentPropertyDialog.js
+++ b/apps/common/main/lib/view/DocumentPropertyDialog.js
@@ -164,23 +164,21 @@ define([], function () { 'use strict';
this.datepicker = new Common.UI.InputFieldBtnCalendar({
el: $('#id-dlg-value-date'),
- allowBlank : true,
- validateOnChange: false,
+ allowBlank : false,
+ blankError : this.txtPropertyValueBlankError,
validateOnBlur: false,
value : '',
dataHint : '1',
dataHintDirection: 'left',
- dataHintOffset: 'small',
- validation: function(value) {
- return value.length === 0 || isNaN(new Date(value).getTime()) ? this.txtPropertyValueBlankError : true;
- }
+ dataHintOffset: 'small'
});
if (this.options.defaultValue.value && currentType === 'date') {
- this.datepicker.setValue(this.options.defaultValue.value);
+ this.datepicker.setDate(this.options.defaultValue.value);
+ this.datepicker.setValue(this.dateToString(this.options.defaultValue.value));
}
this.datepicker.setVisible(this.options.defaultValue.type ? this.options.defaultValue.type === AscCommon.c_oVariantTypes.vtFiletime : currentType === 'date');
- this.datepicker.on('date:click', function (_, date) {
- this.datepicker.setValue(date);
+ this.datepicker.on('date:click', function (cmp, date) {
+ cmp.setValue(this.dateToString(date));
}.bind(this));
var $window = this.getChild();
@@ -230,8 +228,27 @@ define([], function () { 'use strict';
this.datepicker.focus();
return;
}
-
- ascValue = new Date(this.datepicker.getValue());
+ ascValue = this.datepicker.getDate();
+ if (!ascValue) {
+ ascValue = new Date(this.datepicker.getValue());
+ if (!ascValue || !(ascValue instanceof Date) || isNaN(ascValue))
+ ascValue = undefined;
+ }
+ if (!ascValue) {
+ var me = this;
+ Common.UI.warning({
+ msg: me.errorDate,
+ buttons: ['ok', 'cancel'],
+ callback: function(btn) {
+ if (btn==='ok') {
+ me.options.handler.call(this, state, title, AscCommon.c_oVariantTypes.vtLpwstr, me.datepicker.getValue());
+ me.close();
+ } else
+ me.datepicker.focus();
+ }
+ });
+ return;
+ }
ascType = AscCommon.c_oVariantTypes.vtFiletime;
} else {
if (this.inputTextOrNumber.checkValidate() !== true) {
@@ -266,6 +283,22 @@ define([], function () { 'use strict';
this.close();
},
+ dateToString: function (value) {
+ var text = '';
+ if (value) {
+ value = new Date(value)
+ var lang = (this.options.lang || 'en').replace('_', '-').toLowerCase();
+ try {
+ if ( lang == 'ar-SA'.toLowerCase() ) lang = lang + '-u-nu-latn-ca-gregory';
+ text = value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'});
+ } catch (e) {
+ lang = 'en';
+ text = value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'});
+ }
+ }
+ return text;
+ },
+
txtTitle: "New Document Property",
txtPropertyTitleLabel: "Title",
txtPropertyTitleBlankError: 'Property should have a title',
@@ -278,6 +311,7 @@ define([], function () { 'use strict';
txtPropertyTypeDate: "Date",
txtPropertyTypeBoolean: '"Yes" or "no"',
txtPropertyBooleanTrue: 'Yes',
- txtPropertyBooleanFalse: 'No'
+ txtPropertyBooleanFalse: 'No',
+ errorDate: 'You can choose a value from the calendar to store the value as Date.
If you enter a value manually, it will be stored as Text.'
}, Common.Views.DocumentPropertyDialog || {}));
});
\ No newline at end of file
diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js
index c4b69e496d..d31b79372c 100644
--- a/apps/documenteditor/main/app/view/FileMenuPanels.js
+++ b/apps/documenteditor/main/app/view/FileMenuPanels.js
@@ -1726,16 +1726,7 @@ define([], function () {
this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
if (this.coreProps) {
var value = this.coreProps.asc_getCreated();
- if (value) {
- var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
- try {
- if ( lang == 'ar-SA'.toLowerCase() ) lang = lang + '-u-nu-latn-ca-gregory';
- this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- } catch (e) {
- lang = 'en';
- this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- }
- }
+ this.lblDate.text(this.dateToString(value));
this._ShowHideInfoItem(this.lblDate, !!value);
} else if (pdfProps)
this.updatePdfInfo(pdfProps);
@@ -1759,17 +1750,7 @@ define([], function () {
if (props) {
var visible = false;
value = props.asc_getModified();
-
- if (value) {
- var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
- try {
- if ( lang == 'ar-SA'.toLowerCase() ) lang = lang + '-u-nu-latn-ca-gregory';
- this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- } catch (e) {
- lang = 'en';
- this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- }
- }
+ this.lblModifyDate.text(this.dateToString(value));
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
value = props.asc_getLastModifiedBy();
if (value)
@@ -1810,32 +1791,14 @@ define([], function () {
if (props) {
value = props.CreationDate;
- if (value) {
- value = new Date(value);
- var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
- try {
- if ( lang == 'ar-SA'.toLowerCase() ) lang = lang + '-u-nu-latn-ca-gregory';
- this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- } catch (e) {
- lang = 'en';
- this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- }
- }
+ value && (value = new Date(value));
+ this.lblDate.text(this.dateToString(value));
this._ShowHideInfoItem(this.lblDate, !!value);
var visible = false;
value = props.ModDate;
- if (value) {
- value = new Date(value);
- var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
- try {
- if ( lang == 'ar-SA'.toLowerCase() ) lang = lang + '-u-nu-latn-ca-gregory';
- this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- } catch (e) {
- lang = 'en';
- this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
- }
- }
+ value && (value = new Date(value));
+ this.lblModifyDate.text(this.dateToString(value));
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
visible = this._ShowHideInfoItem(this.lblModifyBy, false) || visible;
$('tr.divider.modify', this.el)[visible?'show':'hide']();
@@ -1995,6 +1958,8 @@ define([], function () {
tplCustomProperty: function(name, type, value) {
if (type === AscCommon.c_oVariantTypes.vtBool) {
value = value ? this.txtYes : this.txtNo;
+ } else if (type === AscCommon.c_oVariantTypes.vtFiletime) {
+ value = this.dateToString(new Date(value), true);
}
return '