[Timeline] Watch for configuration object

...to address #908 in a manner which does not cause #957
This commit is contained in:
Victor Woeltjen 2016-05-25 11:21:20 -07:00
parent ed69a65f9b
commit 70b593e28a
2 changed files with 20 additions and 3 deletions

View File

@ -97,6 +97,8 @@ define(
}
}
$scope.$watch("configuration", swimlanePopulator.configure);
// Recalculate swimlane state on changes
$scope.$watch("domainObject", swimlanePopulator.populate);

View File

@ -43,8 +43,7 @@ define(
var swimlanes = [],
start = Number.POSITIVE_INFINITY,
end = Number.NEGATIVE_INFINITY,
colors = (configuration.colors || {}),
assigner = new TimelineColorAssigner(colors),
assigner,
lastDomainObject;
// Track extremes of start/end times
@ -152,8 +151,15 @@ define(
recalculateSwimlanes(lastDomainObject);
}
function initialize() {
var colors = (configuration.colors || {});
assigner = new TimelineColorAssigner(colors);
configuration.colors = colors;
recalculateSwimlanes(lastDomainObject);
}
// Ensure colors are exposed in configuration
configuration.colors = colors;
initialize();
return {
/**
@ -188,6 +194,15 @@ define(
*/
end: function () {
return end;
},
/**
* Pass a new configuration object (to retrieve and store
* swimlane configuration)
* @param newConfig
*/
configure: function (newConfig) {
configuration = newConfig;
initialize();
}
};
}