From f602aa9247007ada8569e34741280c8988221200 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 10 Feb 2016 13:29:56 -0800 Subject: [PATCH] [Create] Add filter to copyService Add an optional parameter to method signature of copyService, used to determine if a domain object should or should not be cloned. This will be used to support usages of copyService where links should remain links; https://github.com/nasa/openmctweb/pull/666/files#r52525612 --- .../entanglement/src/services/CopyService.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/entanglement/src/services/CopyService.js b/platform/entanglement/src/services/CopyService.js index bc825c0394..7cdd769018 100644 --- a/platform/entanglement/src/services/CopyService.js +++ b/platform/entanglement/src/services/CopyService.js @@ -54,16 +54,33 @@ define( ); }; + /** + * A function used to check if a domain object should be cloned + * or not. + * @callback platform/entanglement.CopyService~filter + * @param {DomainObject} domainObject the object to be cloned + * @returns {boolean} true if the object should be cloned; false + * if it should be linked + */ + /** * Creates a duplicate of the object tree starting at domainObject to * the new parent specified. - * @param domainObject - * @param parent - * @param progress + * + * Any domain objects which cannot be created will not be cloned; + * instead, these will appear as links. If a filtering function + * is provided, any objects which fail that check will also be + * linked instead of cloned + * + * @param {DomainObject} domainObject the object to duplicate + * @param {DomainObject} parent the destination for the clone + * @param {platform/entanglement.CopyService~filter} [filter] + * an optional function used to filter out objects from + * the cloning process * @returns a promise that will be completed with the clone of * domainObject when the duplication is successful. */ - CopyService.prototype.perform = function (domainObject, parent) { + CopyService.prototype.perform = function (domainObject, parent, filter) { var $q = this.$q, copyTask = new CopyTask(domainObject, parent, this.policyService, this.$q); if (this.validate(domainObject, parent)) {