Commit 39892854 by kevalbhatt

ATLAS-3986: UI Allow user to update the date format from JAVA property file

parent 94d43c63
......@@ -272,6 +272,16 @@ require(['App',
if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version'];
}
if (response['atlas.ui.date.format'] !== undefined) {
Globals.dateTimeFormat = response['atlas.ui.date.format'];
var dateFormatSeperated = Globals.dateTimeFormat.split(' ');
if (dateFormatSeperated[0]) {
Globals.dateFormat = dateFormatSeperated[0]; //date
}
}
if (response['atlas.ui.date.timezone'] !== undefined) {
Globals.isDateTimeZone = response['atlas.ui.date.timezone'];
}
}
--that.asyncFetchCounter;
startApp();
......
......@@ -40,9 +40,11 @@ define(["require"], function(require) {
Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
Globals.dateFormat = "YYYY/MM/DD";
Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss";
Globals.meridiemFormat = "MM/DD/YYYY h:mm A z";
// Date Format
Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
Globals.dateFormat = "MM/DD/YYYY";
Globals.isDateTimeZone = true;
return Globals;
});
\ No newline at end of file
......@@ -917,32 +917,30 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
var dateValue = null,
dateFormat = Globals.dateTimeFormat,
isValidDate = false;
if (options) {
if (options.dateFormat) {
dateFormat = options.dateFormat;
}
if (options.date) {
if (options.date === "-") {
if (options && options.date) {
dateValue = options.date;
} else {
dateValue = moment(options.date)
if (dateValue !== "-") {
dateValue = parseInt(dateValue);
if (_.isNaN(dateValue)) {
dateValue = options.date;
}
dateValue = moment(dateValue);
if (dateValue._isValid) {
isValidDate = true;
dateValue = dateValue.format(dateFormat);
}
}
}
}
if (dateValue !== "-") {
if (isValidDate === false && options && options.defaultDate !== false) {
dateValue = moment().format(dateFormat);
}
if (Globals.isDateTimeZone) {
if (!options || options && options.zone !== false) {
dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
}
}
}
return dateValue;
}
return Utils;
......
......@@ -75,6 +75,13 @@ define(['require',
createTableWithValues: function(tableDetails) {
var attrTable = CommonViewFunction.propertyTable({
scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails
});
return attrTable;
......
......@@ -359,8 +359,8 @@ define(['require',
}
obj.singleDatePicker = false;
} else {
obj.startDate = moment(valueObj.value);
obj.endDate = moment(valueObj.value);
obj.startDate = moment(Date.parse(valueObj.value));
obj.endDate = obj.startDate;
obj.singleDatePicker = true;
}
}
......
......@@ -491,7 +491,7 @@ define(['require',
if (type == 'time') {
return Utils.millisecondsToTime(value);
} else if (type == 'day') {
return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
return Utils.formatDate({ date: value })
} else if (type == 'number') {
return _.numberFormatWithComma(value);
} else if (type == 'millisecond') {
......
......@@ -301,6 +301,16 @@ require(['App',
if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version'];
}
if (response['atlas.ui.date.format'] !== undefined) {
Globals.dateTimeFormat = response['atlas.ui.date.format'];
var dateFormatSeperated = Globals.dateTimeFormat.split(' ');
if (dateFormatSeperated[0]) {
Globals.dateFormat = dateFormatSeperated[0]; //date
}
}
if (response['atlas.ui.date.timezone'] !== undefined) {
Globals.isDateTimeZone = response['atlas.ui.date.timezone'];
}
}
--that.asyncFetchCounter;
startApp();
......
......@@ -40,8 +40,11 @@ define(["require"], function(require) {
Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
Globals.dateFormat = "YYYY/MM/DD";
Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss";
Globals.meridiemFormat = "MM/DD/YYYY h:mm A z";
// Date Format
Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
Globals.dateFormat = "MM/DD/YYYY";
Globals.isDateTimeZone = true;
return Globals;
});
\ No newline at end of file
......@@ -922,32 +922,30 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
var dateValue = null,
dateFormat = Globals.dateTimeFormat,
isValidDate = false;
if (options) {
if (options.dateFormat) {
dateFormat = options.dateFormat;
}
if (options.date) {
if (options.date === "-") {
if (options && options.date) {
dateValue = options.date;
} else {
dateValue = moment(options.date)
if (dateValue !== "-") {
dateValue = parseInt(dateValue);
if (_.isNaN(dateValue)) {
dateValue = options.date;
}
dateValue = moment(dateValue);
if (dateValue._isValid) {
isValidDate = true;
dateValue = dateValue.format(dateFormat);
}
}
}
}
if (dateValue !== "-") {
if (isValidDate === false && options && options.defaultDate !== false) {
dateValue = moment().format(dateFormat);
}
if (Globals.isDateTimeZone) {
if (!options || options && options.zone !== false) {
dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
}
}
}
return dateValue;
}
return Utils;
......
......@@ -75,6 +75,13 @@ define(['require',
createTableWithValues: function(tableDetails) {
var attrTable = CommonViewFunction.propertyTable({
scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails
});
return attrTable;
......
......@@ -359,8 +359,8 @@ define(['require',
}
obj.singleDatePicker = false;
} else {
obj.startDate = moment(valueObj.value);
obj.endDate = moment(valueObj.value);
obj.startDate = moment(Date.parse(valueObj.value));
obj.endDate = obj.startDate;
obj.singleDatePicker = true;
}
}
......
......@@ -398,7 +398,7 @@ define(['require',
if (type == 'time') {
return Utils.millisecondsToTime(value);
} else if (type == 'day') {
return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat })
return Utils.formatDate({ date: value })
} else if (type == 'number') {
return _.numberFormatWithComma(value);
} else if (type == 'millisecond') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment