From 474afdf8ef8e0d27b410af54e93e467fc2fe0b90 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 5 Nov 2015 15:08:52 -0800 Subject: [PATCH] [Creation] Expose creation capability ...adding usage of to avoid circular dependencies. --- platform/core/bundle.json | 5 +++++ .../src/capabilities/CreationCapability.js | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/platform/core/bundle.json b/platform/core/bundle.json index 330ac1c2b9..0c68dcfacd 100644 --- a/platform/core/bundle.json +++ b/platform/core/bundle.json @@ -193,6 +193,11 @@ "key": "delegation", "implementation": "capabilities/DelegationCapability.js", "depends": [ "$q" ] + }, + { + "key": "creation", + "implementation": "capabilities/CreationCapability.js", + "depends": [ "$injector" ] } ], "services": [ diff --git a/platform/core/src/capabilities/CreationCapability.js b/platform/core/src/capabilities/CreationCapability.js index 1b19bc106b..ec43d5c071 100644 --- a/platform/core/src/capabilities/CreationCapability.js +++ b/platform/core/src/capabilities/CreationCapability.js @@ -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; } );