Commit e9b95131 by kevalbhatt

ATLAS-2244 : UI - Basic Search Table not using referredEntities to render entity details

parent 3b9ea1dd
...@@ -510,15 +510,24 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -510,15 +510,24 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
titleBoxEl.fadeIn(); titleBoxEl.fadeIn();
} }
Utils.findAndMergeRefEntity = function(attributeObject, referredEntities) { Utils.findAndMergeRefEntity = function(attributeObject, referredEntities) {
var megeObject = function(obj) {
if (obj) {
if (obj.attributes) {
Utils.findAndMergeRefEntity(obj.attributes, referredEntities);
} else if (referredEntities[obj.guid]) {
_.extend(obj, referredEntities[obj.guid]);
}
}
}
if (attributeObject && referredEntities) { if (attributeObject && referredEntities) {
_.each(attributeObject, function(obj, key) { _.each(attributeObject, function(obj, key) {
if (_.isObject(obj)) { if (_.isObject(obj)) {
if (_.isArray(obj)) { if (_.isArray(obj)) {
_.each(obj, function(value) { _.each(obj, function(value) {
_.extend(value, referredEntities[value.guid]); megeObject(value);
}); });
} else { } else {
_.extend(obj, referredEntities[obj.guid]); megeObject(obj);
} }
} }
}); });
......
...@@ -241,7 +241,7 @@ define(['require', ...@@ -241,7 +241,7 @@ define(['require',
} }
this.triggerUrl(); this.triggerUrl();
var attributes = this.searchCollection.filterObj.attributes; var attributes = this.searchCollection.filterObj.attributes;
if (excludeDefaultColumn && attributes && excludeDefaultColumn.length > attributes.length) { if ((excludeDefaultColumn && attributes) && (excludeDefaultColumn.length > attributes.length || _.difference(excludeDefaultColumn, attributes).length)) {
this.fetchCollection(this.value); this.fetchCollection(this.value);
} }
} }
...@@ -410,10 +410,12 @@ define(['require', ...@@ -410,10 +410,12 @@ define(['require',
return; return;
} }
if (isPostMethod) { if (isPostMethod) {
that.searchCollection.referredEntities = dataOrCollection.rnoRecordFoeferredEntities; that.searchCollection.referredEntities = dataOrCollection.referredEntities;
Utils.findAndMergeRefEntity(dataOrCollection.entities, dataOrCollection.referredEntities);
that.searchCollection.reset(dataOrCollection.entities, { silent: true }); that.searchCollection.reset(dataOrCollection.entities, { silent: true });
} }
/*Next button check. /*Next button check.
It's outside of Previous button else condition It's outside of Previous button else condition
because when user comes from 2 page to 1 page than we need to check next button.*/ because when user comes from 2 page to 1 page than we need to check next button.*/
...@@ -712,17 +714,14 @@ define(['require', ...@@ -712,17 +714,14 @@ define(['require',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { fromRaw: function(rawValue, model) {
var modelObj = model.toJSON(); var modelObj = model.toJSON();
if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) { if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) {
var tempObj = { var tempObj = {
'scope': that, 'scope': that,
'attributeDefs': [obj], 'attributeDefs': [obj],
'valueObject': {}, 'valueObject': {},
'isTable': false 'isTable': false
} };
tempObj.valueObject[key] = modelObj.attributes[key];
tempObj.valueObject[key] = modelObj.attributes[key]
Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
return CommonViewFunction.propertyTable(tempObj); return CommonViewFunction.propertyTable(tempObj);
} }
} }
...@@ -770,10 +769,8 @@ define(['require', ...@@ -770,10 +769,8 @@ define(['require',
// 'attributeDefs': // 'attributeDefs':
'valueObject': {}, 'valueObject': {},
'isTable': false 'isTable': false
} };
tempObj.valueObject[key] = modelObj[key];
tempObj.valueObject[key] = modelObj[key]
Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
return CommonViewFunction.propertyTable(tempObj); return CommonViewFunction.propertyTable(tempObj);
} }
} }
......
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