mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
[Creation] Expose creation capability
...adding usage of to avoid circular dependencies.
This commit is contained in:
@ -193,6 +193,11 @@
|
|||||||
"key": "delegation",
|
"key": "delegation",
|
||||||
"implementation": "capabilities/DelegationCapability.js",
|
"implementation": "capabilities/DelegationCapability.js",
|
||||||
"depends": [ "$q" ]
|
"depends": [ "$q" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "creation",
|
||||||
|
"implementation": "capabilities/CreationCapability.js",
|
||||||
|
"depends": [ "$injector" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -26,17 +26,31 @@ define(
|
|||||||
function (DomainObjectImpl, uuid) {
|
function (DomainObjectImpl, uuid) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function CreationCapability(capabilityService, domainObject) {
|
function CreationCapability($injector, domainObject) {
|
||||||
this.capabilityService = capabilityService;
|
this.$injector = $injector;
|
||||||
this.domainObject = domainObject;
|
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) {
|
CreationCapability.prototype.create = function (model) {
|
||||||
var id = uuid(),
|
var id = uuid(),
|
||||||
capabilities = this.capabilityService.getCapabilities(model);
|
capabilities = this.capabilityService.getCapabilities(model);
|
||||||
return new DomainObjectImpl(id, model, capabilities);
|
return new DomainObjectImpl(id, model, capabilities);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CreationCapability.prototype.invoke =
|
||||||
|
CreationCapability.prototype.create;
|
||||||
|
|
||||||
return CreationCapability;
|
return CreationCapability;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user