Commit 8fc70a32 by gutkaBinit Committed by Madhan Neethiraj

ATLAS-3076: UI: Relationship Tab improvements - #2

parent 3d266b08
...@@ -78,18 +78,20 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob ...@@ -78,18 +78,20 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob
extractJSON = options.extractJSON, extractJSON = options.extractJSON,
isTable = _.isUndefined(options.isTable) ? true : options.isTable, isTable = _.isUndefined(options.isTable) ? true : options.isTable,
attributeDefs = options.attributeDefs, attributeDefs = options.attributeDefs,
numberFormat = options.numberFormat; formatIntVal = options.formatIntVal,
showListCount = options.showListCount || true,
numberFormat = options.numberFormat || _.numberFormatWithComa;
var table = "", var table = "",
getValue = function(val) { getValue = function(val) {
if (val && numberFormat) { if (val) {
if (_.isNumber(val)) { if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) {
return numberFormat(val);
} else if (!_.isNaN(parseInt(val))) {
return numberFormat(val); return numberFormat(val);
} else {
return val;
} }
} else { } else {
return val || "N/A"; return "N/A";
} }
}, },
fetchInputOutputValue = function(id, defEntity) { fetchInputOutputValue = function(id, defEntity) {
...@@ -226,8 +228,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob ...@@ -226,8 +228,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob
if (key == "profileData") { if (key == "profileData") {
return; return;
} }
var keyValue = valueObject[key]; var keyValue = valueObject[key],
var count = _.isArray(keyValue) ? (keyValue.length) : 0; listCount = showListCount && _.isArray(keyValue) && keyValue.length > 0 ? ' (' + numberFormat(keyValue.length) + ')' : "";
var defEntity = _.find(attributeDefs, { name: key }); var defEntity = _.find(attributeDefs, { name: key });
if (defEntity && defEntity.typeName) { if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase(); var defEntityType = defEntity.typeName.toLocaleLowerCase();
...@@ -264,8 +266,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob ...@@ -264,8 +266,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob
htmlTag = '<pre class="shrink code-block ' + (isMatchJSONStringIsSingle ? 'fixed-height' : '') + '">' + expandCollapseButton + '<code>' + val + '</code></pre>'; htmlTag = '<pre class="shrink code-block ' + (isMatchJSONStringIsSingle ? 'fixed-height' : '') + '">' + expandCollapseButton + '<code>' + val + '</code></pre>';
} }
} }
var textToDisplay = count > 0 ? ' (' + getValue(count) + ')' : ''; table += '<tr><td>' + (_.escape(key) + listCount) + '</td><td>' + htmlTag + '</td></tr>';
table += '<tr><td>' + _.escape(key) + textToDisplay + '</td><td>' + htmlTag + '</td></tr>';
} else { } else {
table += '<div>' + val + '</div>'; table += '<div>' + val + '</div>';
} }
......
...@@ -70,8 +70,8 @@ define(['require', ...@@ -70,8 +70,8 @@ define(['require',
success: function(data) { success: function(data) {
var data = _.first(data.toJSON()), var data = _.first(data.toJSON()),
no_records = '<tr class="empty text-center"><td colspan="2"><span>No records found!</span></td></tr>', no_records = '<tr class="empty text-center"><td colspan="2"><span>No records found!</span></td></tr>',
activeEntityTable = _.isEmpty(data.entity.entityActive) ? no_records : CommonViewFunction.propertyTable({ scope: that, valueObject: data.entity.entityActive, numberFormat: _.numberFormatWithComa }), activeEntityTable = _.isEmpty(data.entity.entityActive) ? no_records : that.getTable({ valueObject: data.entity.entityActive }),
deleteEntityTable = _.isEmpty(data.entity.entityDeleted) ? no_records : CommonViewFunction.propertyTable({ scope: that, valueObject: data.entity.entityDeleted, numberFormat: _.numberFormatWithComa }); deleteEntityTable = _.isEmpty(data.entity.entityDeleted) ? no_records : that.getTable({ valueObject: data.entity.entityDeleted });
var totalActive = 0, var totalActive = 0,
totalDeleted = 0; totalDeleted = 0;
if (data.entity && data.general.entityCount) { if (data.entity && data.general.entityCount) {
...@@ -88,6 +88,9 @@ define(['require', ...@@ -88,6 +88,9 @@ define(['require',
that.ui.entityDeletedHeader.html("&nbsp;(" + _.numberFormatWithComa(totalDeleted) + ")"); that.ui.entityDeletedHeader.html("&nbsp;(" + _.numberFormatWithComa(totalDeleted) + ")");
} }
}); });
},
getTable: function(obj) {
return CommonViewFunction.propertyTable(_.extend({ scope: this, formatIntVal: true }, obj))
} }
}); });
return StatisticsView; return StatisticsView;
......
...@@ -460,7 +460,7 @@ define(['require', ...@@ -460,7 +460,7 @@ define(['require',
}, },
createTable: function() { createTable: function() {
this.entityModel = new VEntity({}); this.entityModel = new VEntity({});
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: this.entity.relationshipAttributes, attributeDefs: this.attributeDefs, numberFormat: _.numberFormatWithComa }); var table = CommonViewFunction.propertyTable({ scope: this, valueObject: this.entity.relationshipAttributes, attributeDefs: this.attributeDefs });
this.ui.relationshipDetailValue.html(table); this.ui.relationshipDetailValue.html(table);
}, },
relationshipViewToggle: function(checked) { relationshipViewToggle: function(checked) {
......
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