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
extractJSON = options.extractJSON,
isTable = _.isUndefined(options.isTable) ? true : options.isTable,
attributeDefs = options.attributeDefs,
numberFormat = options.numberFormat;
formatIntVal = options.formatIntVal,
showListCount = options.showListCount || true,
numberFormat = options.numberFormat || _.numberFormatWithComa;
var table = "",
getValue = function(val) {
if (val && numberFormat) {
if (_.isNumber(val)) {
return numberFormat(val);
} else if (!_.isNaN(parseInt(val))) {
if (val) {
if ((_.isNumber(val) || !_.isNaN(parseInt(val))) && formatIntVal) {
return numberFormat(val);
} else {
return val;
}
} else {
return val || "N/A";
return "N/A";
}
},
fetchInputOutputValue = function(id, defEntity) {
......@@ -226,8 +228,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob
if (key == "profileData") {
return;
}
var keyValue = valueObject[key];
var count = _.isArray(keyValue) ? (keyValue.length) : 0;
var keyValue = valueObject[key],
listCount = showListCount && _.isArray(keyValue) && keyValue.length > 0 ? ' (' + numberFormat(keyValue.length) + ')' : "";
var defEntity = _.find(attributeDefs, { name: key });
if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
......@@ -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>';
}
}
var textToDisplay = count > 0 ? ' (' + getValue(count) + ')' : '';
table += '<tr><td>' + _.escape(key) + textToDisplay + '</td><td>' + htmlTag + '</td></tr>';
table += '<tr><td>' + (_.escape(key) + listCount) + '</td><td>' + htmlTag + '</td></tr>';
} else {
table += '<div>' + val + '</div>';
}
......
......@@ -70,8 +70,8 @@ define(['require',
success: function(data) {
var data = _.first(data.toJSON()),
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 }),
deleteEntityTable = _.isEmpty(data.entity.entityDeleted) ? no_records : CommonViewFunction.propertyTable({ scope: that, valueObject: data.entity.entityDeleted, numberFormat: _.numberFormatWithComa });
activeEntityTable = _.isEmpty(data.entity.entityActive) ? no_records : that.getTable({ valueObject: data.entity.entityActive }),
deleteEntityTable = _.isEmpty(data.entity.entityDeleted) ? no_records : that.getTable({ valueObject: data.entity.entityDeleted });
var totalActive = 0,
totalDeleted = 0;
if (data.entity && data.general.entityCount) {
......@@ -88,6 +88,9 @@ define(['require',
that.ui.entityDeletedHeader.html("&nbsp;(" + _.numberFormatWithComa(totalDeleted) + ")");
}
});
},
getTable: function(obj) {
return CommonViewFunction.propertyTable(_.extend({ scope: this, formatIntVal: true }, obj))
}
});
return StatisticsView;
......
......@@ -460,7 +460,7 @@ define(['require',
},
createTable: function() {
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);
},
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