Compare commits

...

1 Commits

Author SHA1 Message Date
555bd81c5c implement view policies without angular 2021-07-05 23:00:33 -07:00

View File

@ -32,6 +32,7 @@ define(['EventEmitter'], function (EventEmitter) {
function ViewRegistry() {
EventEmitter.apply(this);
this.providers = {};
this.policies = [];
}
ViewRegistry.prototype = Object.create(EventEmitter.prototype);
@ -59,7 +60,9 @@ define(['EventEmitter'], function (EventEmitter) {
return this.getAllProviders()
.filter(function (provider) {
return provider.canView(item, objectPath);
}).sort(byPriority);
})
.filter(view => this.checkPolicy(view, item))
.sort(byPriority);
};
/**
@ -107,6 +110,14 @@ define(['EventEmitter'], function (EventEmitter) {
})[0];
};
ViewRegistry.prototype.addPolicy = function (policy) {
this.policies.push(policy);
};
ViewRegistry.prototype.checkPolicy = function (view, domainObject) {
return this.policies.every(policy => policy(view, domainObject));
};
/**
* A View is used to provide displayable content, and to react to
* associated life cycle events.