Added mutation listener
This commit is contained in:
@@ -39,6 +39,7 @@ define(
|
||||
function TableConfiguration(domainObject, telemetryFormatter) {
|
||||
this.domainObject = domainObject;
|
||||
this.columns = [];
|
||||
this.columnConfiguration = {};
|
||||
this.telemetryFormatter = telemetryFormatter;
|
||||
}
|
||||
|
||||
@@ -144,16 +145,32 @@ define(
|
||||
{}).columns || {};
|
||||
};
|
||||
|
||||
function equal(obj1, obj2) {
|
||||
var obj1Keys = Object.keys(obj1),
|
||||
obj2Keys = Object.keys(obj2);
|
||||
return (obj1Keys.length === obj2Keys.length) &&
|
||||
obj1Keys.every(function(key){
|
||||
//To do a deep equals, could recurse here if typeof
|
||||
// obj1 === Object
|
||||
return obj1[key] === obj2[key];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the established configuration on the domain object
|
||||
* @private
|
||||
*/
|
||||
TableConfiguration.prototype.saveColumnConfiguration = function (columnConfig) {
|
||||
this.domainObject.useCapability('mutation', function (model) {
|
||||
model.configuration = model.configuration || {};
|
||||
model.configuration.table = model.configuration.table || {};
|
||||
model.configuration.table.columns = columnConfig;
|
||||
});
|
||||
var self = this;
|
||||
//Don't bother mutating if column configuration is unchanged
|
||||
if (!equal(this.columnConfiguration, columnConfig)) {
|
||||
this.domainObject.useCapability('mutation', function (model) {
|
||||
model.configuration = model.configuration || {};
|
||||
model.configuration.table = model.configuration.table || {};
|
||||
model.configuration.table.columns = columnConfig;
|
||||
self.columnConfiguration = columnConfig;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user