mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 09:26:45 +00:00
[Creation] Expose creation capability
...adding usage of to avoid circular dependencies.
This commit is contained in:
parent
3f4ccd93ab
commit
474afdf8ef
@ -193,6 +193,11 @@
|
||||
"key": "delegation",
|
||||
"implementation": "capabilities/DelegationCapability.js",
|
||||
"depends": [ "$q" ]
|
||||
},
|
||||
{
|
||||
"key": "creation",
|
||||
"implementation": "capabilities/CreationCapability.js",
|
||||
"depends": [ "$injector" ]
|
||||
}
|
||||
],
|
||||
"services": [
|
||||
|
@ -26,17 +26,31 @@ define(
|
||||
function (DomainObjectImpl, uuid) {
|
||||
'use strict';
|
||||
|
||||
function CreationCapability(capabilityService, domainObject) {
|
||||
this.capabilityService = capabilityService;
|
||||
function CreationCapability($injector, domainObject) {
|
||||
this.$injector = $injector;
|
||||
this.domainObject = domainObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
CreationCapability.prototype.getCapabilities = function (model) {
|
||||
if (!this.capabilityService) {
|
||||
this.capabilityService =
|
||||
this.$injector.get('capabilityService');
|
||||
}
|
||||
return this.capabilityService.getCapabilities(model);
|
||||
};
|
||||
|
||||
CreationCapability.prototype.create = function (model) {
|
||||
var id = uuid(),
|
||||
capabilities = this.capabilityService.getCapabilities(model);
|
||||
return new DomainObjectImpl(id, model, capabilities);
|
||||
};
|
||||
|
||||
CreationCapability.prototype.invoke =
|
||||
CreationCapability.prototype.create;
|
||||
|
||||
return CreationCapability;
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user