mirror of
https://github.com/nasa/openmct.git
synced 2025-01-27 06:39:21 +00:00
Merge branch 'open338' into rems_data
This commit is contained in:
commit
1fef6b30b7
@ -27,23 +27,19 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A policy for determining whether objects of a certain type can be
|
* A policy for determining whether objects of a given type can be
|
||||||
* created.
|
* created.
|
||||||
* @returns {{allow: Function}}
|
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @implements {Policy}
|
||||||
|
* @memberof platform/commonUI/browse
|
||||||
*/
|
*/
|
||||||
function CreationPolicy() {
|
function CreationPolicy() {
|
||||||
return {
|
|
||||||
/**
|
|
||||||
* Only allow creation of object types that have the
|
|
||||||
* Creation capability
|
|
||||||
*/
|
|
||||||
allow: function (type) {
|
|
||||||
return type.hasFeature("creation");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreationPolicy.prototype.allow = function (type) {
|
||||||
|
return type.hasFeature("creation");
|
||||||
|
};
|
||||||
|
|
||||||
return CreationPolicy;
|
return CreationPolicy;
|
||||||
}
|
}
|
||||||
);
|
);
|
@ -23,8 +23,8 @@
|
|||||||
/*global define */
|
/*global define */
|
||||||
|
|
||||||
define(
|
define(
|
||||||
["uuid"],
|
[],
|
||||||
function (uuid) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +53,8 @@ define(
|
|||||||
|
|
||||||
parent.getModel().composition.push(child.getId());
|
parent.getModel().composition.push(child.getId());
|
||||||
|
|
||||||
//Check if the object being composed is a link
|
//If a location is not specified, set it.
|
||||||
if (!child.getCapability("location").isLink()) {
|
if (!child.getModel().location) {
|
||||||
child.getModel().location = parent.getId();
|
child.getModel().location = parent.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
function addClonesToParent(self) {
|
function addClonesToParent(self) {
|
||||||
return self.firstClone.getCapability("persistence").persist()
|
return self.firstClone.getCapability("persistence").persist()
|
||||||
.then(function(){self.parent.getCapability("composition").add(self.firstClone.getId())})
|
.then(function(){self.parent.getCapability("composition").add(self.firstClone.getId());})
|
||||||
.then(function(){return self.parent.getCapability("persistence").persist();})
|
.then(function(){return self.parent.getCapability("persistence").persist();})
|
||||||
.then(function(){return self.firstClone;});
|
.then(function(){return self.firstClone;});
|
||||||
}
|
}
|
||||||
@ -132,11 +132,8 @@ define(
|
|||||||
* cloning objects, and composing them with their child clones
|
* cloning objects, and composing them with their child clones
|
||||||
* as it goes
|
* as it goes
|
||||||
* @private
|
* @private
|
||||||
* @param originalObject
|
|
||||||
* @param originalParent
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
*/
|
||||||
CopyTask.prototype.copy = function(originalObject, originalParent) {
|
CopyTask.prototype.copy = function(originalObject) {
|
||||||
var self = this,
|
var self = this,
|
||||||
clone;
|
clone;
|
||||||
|
|
||||||
@ -148,7 +145,7 @@ define(
|
|||||||
// creation capability of the targetParent to create the
|
// creation capability of the targetParent to create the
|
||||||
// new clone. This will ensure that the correct persistence
|
// new clone. This will ensure that the correct persistence
|
||||||
// space is used.
|
// space is used.
|
||||||
clone = this.parent.hasCapability("instantiation") && this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel()));
|
clone = this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel()));
|
||||||
|
|
||||||
//Iterate through child tree
|
//Iterate through child tree
|
||||||
return this.$q.when(originalObject.useCapability('composition')).then(function(composees){
|
return this.$q.when(originalObject.useCapability('composition')).then(function(composees){
|
||||||
@ -203,10 +200,6 @@ define(
|
|||||||
CopyTask.prototype.perform = function(){
|
CopyTask.prototype.perform = function(){
|
||||||
this.deferred = this.$q.defer();
|
this.deferred = this.$q.defer();
|
||||||
|
|
||||||
if (!this.parent.hasCapability('composition')){
|
|
||||||
return this.$q.reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.buildCopyPlan()
|
this.buildCopyPlan()
|
||||||
.then(persistObjects)
|
.then(persistObjects)
|
||||||
.then(addClonesToParent)
|
.then(addClonesToParent)
|
||||||
|
@ -174,7 +174,6 @@ define(
|
|||||||
['notify', 'resolve', 'reject']
|
['notify', 'resolve', 'reject']
|
||||||
);
|
);
|
||||||
mockDeferred.notify.andCallFake(function(notification){});
|
mockDeferred.notify.andCallFake(function(notification){});
|
||||||
mockDeferred.reject.andCallFake(function(){});
|
|
||||||
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
|
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
|
||||||
mockDeferred.promise = {
|
mockDeferred.promise = {
|
||||||
then: function(callback){
|
then: function(callback){
|
||||||
@ -413,15 +412,23 @@ define(
|
|||||||
object = domainObjectFactory({
|
object = domainObjectFactory({
|
||||||
name: 'object',
|
name: 'object',
|
||||||
capabilities: {
|
capabilities: {
|
||||||
type: { type: 'object' }
|
type: { type: 'object' },
|
||||||
|
location: locationCapability,
|
||||||
|
persistence: persistenceCapability
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
newParent = domainObjectFactory({
|
newParent = domainObjectFactory({
|
||||||
name: 'parentCandidate',
|
name: 'parentCandidate',
|
||||||
capabilities: {
|
capabilities: {
|
||||||
type: { type: 'parentCandidate' }
|
type: { type: 'parentCandidate' },
|
||||||
|
instantiation: instantiationCapability,
|
||||||
|
composition: compositionCapability,
|
||||||
|
persistence: persistenceCapability
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
instantiationCapability.invoke.andReturn(object);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error", function () {
|
it("throws an error", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user