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', ...@@ -272,6 +272,16 @@ require(['App',
if (response['atlas.ui.default.version'] !== undefined) { if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version']; 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; --that.asyncFetchCounter;
startApp(); startApp();
......
...@@ -40,9 +40,11 @@ define(["require"], function(require) { ...@@ -40,9 +40,11 @@ define(["require"], function(require) {
Globals.serviceTypeMap = {}; Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/"; Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2"; Globals.DEFAULT_UI = "v2";
Globals.dateFormat = "YYYY/MM/DD";
Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss"; // Date Format
Globals.meridiemFormat = "MM/DD/YYYY h:mm A z"; Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
Globals.dateFormat = "MM/DD/YYYY";
Globals.isDateTimeZone = true;
return Globals; return Globals;
}); });
\ No newline at end of file
...@@ -917,19 +917,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -917,19 +917,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
var dateValue = null, var dateValue = null,
dateFormat = Globals.dateTimeFormat, dateFormat = Globals.dateTimeFormat,
isValidDate = false; isValidDate = false;
if (options) { if (options && options.date) {
if (options.dateFormat) { dateValue = options.date;
dateFormat = options.dateFormat; if (dateValue !== "-") {
} dateValue = parseInt(dateValue);
if (options.date) { if (_.isNaN(dateValue)) {
if (options.date === "-") {
dateValue = options.date; dateValue = options.date;
} else { }
dateValue = moment(options.date) dateValue = moment(dateValue);
if (dateValue._isValid) { if (dateValue._isValid) {
isValidDate = true; isValidDate = true;
dateValue = dateValue.format(dateFormat); dateValue = dateValue.format(dateFormat);
}
} }
} }
} }
...@@ -937,12 +935,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -937,12 +935,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
if (isValidDate === false && options && options.defaultDate !== false) { if (isValidDate === false && options && options.defaultDate !== false) {
dateValue = moment().format(dateFormat); dateValue = moment().format(dateFormat);
} }
if (Globals.isDateTimeZone) {
if (!options || options && options.zone !== false) { if (!options || options && options.zone !== false) {
dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")"; dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
}
} }
} }
return dateValue; return dateValue;
} }
return Utils; return Utils;
......
...@@ -75,6 +75,13 @@ define(['require', ...@@ -75,6 +75,13 @@ define(['require',
createTableWithValues: function(tableDetails) { createTableWithValues: function(tableDetails) {
var attrTable = CommonViewFunction.propertyTable({ var attrTable = CommonViewFunction.propertyTable({
scope: this, scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails valueObject: tableDetails
}); });
return attrTable; return attrTable;
......
...@@ -359,8 +359,8 @@ define(['require', ...@@ -359,8 +359,8 @@ define(['require',
} }
obj.singleDatePicker = false; obj.singleDatePicker = false;
} else { } else {
obj.startDate = moment(valueObj.value); obj.startDate = moment(Date.parse(valueObj.value));
obj.endDate = moment(valueObj.value); obj.endDate = obj.startDate;
obj.singleDatePicker = true; obj.singleDatePicker = true;
} }
} }
......
...@@ -491,7 +491,7 @@ define(['require', ...@@ -491,7 +491,7 @@ define(['require',
if (type == 'time') { if (type == 'time') {
return Utils.millisecondsToTime(value); return Utils.millisecondsToTime(value);
} else if (type == 'day') { } else if (type == 'day') {
return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat }) return Utils.formatDate({ date: value })
} else if (type == 'number') { } else if (type == 'number') {
return _.numberFormatWithComma(value); return _.numberFormatWithComma(value);
} else if (type == 'millisecond') { } else if (type == 'millisecond') {
......
...@@ -301,6 +301,16 @@ require(['App', ...@@ -301,6 +301,16 @@ require(['App',
if (response['atlas.ui.default.version'] !== undefined) { if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version']; 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; --that.asyncFetchCounter;
startApp(); startApp();
......
...@@ -40,8 +40,11 @@ define(["require"], function(require) { ...@@ -40,8 +40,11 @@ define(["require"], function(require) {
Globals.serviceTypeMap = {}; Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/"; Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2"; Globals.DEFAULT_UI = "v2";
Globals.dateFormat = "YYYY/MM/DD";
Globals.dateTimeFormat = "YYYY/MM/DD HH:mm:ss"; // Date Format
Globals.meridiemFormat = "MM/DD/YYYY h:mm A z"; Globals.dateTimeFormat = "MM/DD/YYYY hh:mm:ss A";
Globals.dateFormat = "MM/DD/YYYY";
Globals.isDateTimeZone = true;
return Globals; return Globals;
}); });
\ No newline at end of file
...@@ -922,19 +922,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -922,19 +922,17 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
var dateValue = null, var dateValue = null,
dateFormat = Globals.dateTimeFormat, dateFormat = Globals.dateTimeFormat,
isValidDate = false; isValidDate = false;
if (options) { if (options && options.date) {
if (options.dateFormat) { dateValue = options.date;
dateFormat = options.dateFormat; if (dateValue !== "-") {
} dateValue = parseInt(dateValue);
if (options.date) { if (_.isNaN(dateValue)) {
if (options.date === "-") {
dateValue = options.date; dateValue = options.date;
} else { }
dateValue = moment(options.date) dateValue = moment(dateValue);
if (dateValue._isValid) { if (dateValue._isValid) {
isValidDate = true; isValidDate = true;
dateValue = dateValue.format(dateFormat); dateValue = dateValue.format(dateFormat);
}
} }
} }
} }
...@@ -942,12 +940,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -942,12 +940,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
if (isValidDate === false && options && options.defaultDate !== false) { if (isValidDate === false && options && options.defaultDate !== false) {
dateValue = moment().format(dateFormat); dateValue = moment().format(dateFormat);
} }
if (Globals.isDateTimeZone) {
if (!options || options && options.zone !== false) { if (!options || options && options.zone !== false) {
dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")"; dateValue += " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")";
}
} }
} }
return dateValue; return dateValue;
} }
return Utils; return Utils;
......
...@@ -75,6 +75,13 @@ define(['require', ...@@ -75,6 +75,13 @@ define(['require',
createTableWithValues: function(tableDetails) { createTableWithValues: function(tableDetails) {
var attrTable = CommonViewFunction.propertyTable({ var attrTable = CommonViewFunction.propertyTable({
scope: this, scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails valueObject: tableDetails
}); });
return attrTable; return attrTable;
......
...@@ -359,8 +359,8 @@ define(['require', ...@@ -359,8 +359,8 @@ define(['require',
} }
obj.singleDatePicker = false; obj.singleDatePicker = false;
} else { } else {
obj.startDate = moment(valueObj.value); obj.startDate = moment(Date.parse(valueObj.value));
obj.endDate = moment(valueObj.value); obj.endDate = obj.startDate;
obj.singleDatePicker = true; obj.singleDatePicker = true;
} }
} }
......
...@@ -398,7 +398,7 @@ define(['require', ...@@ -398,7 +398,7 @@ define(['require',
if (type == 'time') { if (type == 'time') {
return Utils.millisecondsToTime(value); return Utils.millisecondsToTime(value);
} else if (type == 'day') { } else if (type == 'day') {
return Utils.formatDate({ date: value, dateFormat: Globals.meridiemFormat }) return Utils.formatDate({ date: value })
} else if (type == 'number') { } else if (type == 'number') {
return _.numberFormatWithComma(value); return _.numberFormatWithComma(value);
} else if (type == 'millisecond') { } 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