mirror of
https://github.com/nasa/openmct.git
synced 2025-02-09 04:11:56 +00:00
rescope objects
This commit is contained in:
parent
d42b2dd023
commit
d3825fc554
@ -35,34 +35,34 @@ export default class DuplicateAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
invoke(objectPath) {
|
invoke(objectPath) {
|
||||||
this.object = objectPath[0];
|
const object = objectPath[0];
|
||||||
this.parent = objectPath[1];
|
const parent = objectPath[1];
|
||||||
|
|
||||||
this.showForm(this.object, this.parent);
|
this.showForm(object, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
inNavigationPath() {
|
inNavigationPath(object) {
|
||||||
return this.openmct.router.path
|
return this.openmct.router.path
|
||||||
.some(objectInPath => this.openmct.objects.areIdsEqual(objectInPath.identifier, this.object.identifier));
|
.some(objectInPath => this.openmct.objects.areIdsEqual(objectInPath.identifier, object.identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSave(changes) {
|
async onSave(object, parent, changes) {
|
||||||
this.startTransaction();
|
this.startTransaction();
|
||||||
|
|
||||||
let inNavigationPath = this.inNavigationPath();
|
let inNavigationPath = this.inNavigationPath(object);
|
||||||
if (inNavigationPath && this.openmct.editor.isEditing()) {
|
if (inNavigationPath && this.openmct.editor.isEditing()) {
|
||||||
this.openmct.editor.save();
|
this.openmct.editor.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
let duplicationTask = new DuplicateTask(this.openmct);
|
let duplicationTask = new DuplicateTask(this.openmct);
|
||||||
if (changes.name && (changes.name !== this.object.name)) {
|
if (changes.name && (changes.name !== object.name)) {
|
||||||
duplicationTask.changeName(changes.name);
|
duplicationTask.changeName(changes.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentDomainObjectpath = changes.location || [this.parent];
|
const parentDomainObjectpath = changes.location || [parent];
|
||||||
const parent = parentDomainObjectpath[0];
|
const parentObject = parentDomainObjectpath[0];
|
||||||
|
|
||||||
await duplicationTask.duplicate(this.object, parent);
|
await duplicationTask.duplicate(object, parentObject);
|
||||||
|
|
||||||
return this.saveTransaction();
|
return this.saveTransaction();
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ export default class DuplicateAction {
|
|||||||
control: "locator",
|
control: "locator",
|
||||||
required: true,
|
required: true,
|
||||||
parent: parentDomainObject,
|
parent: parentDomainObject,
|
||||||
validate: this.validate(parentDomainObject),
|
validate: this.validate(domainObject, parentDomainObject),
|
||||||
key: 'location'
|
key: 'location'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -97,16 +97,19 @@ export default class DuplicateAction {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.openmct.forms.showForm(formStructure)
|
this.openmct.forms.showForm(formStructure)
|
||||||
.then(this.onSave.bind(this));
|
.then(changes => {
|
||||||
|
let onSave = this.onSave.bind(this);
|
||||||
|
onSave(domainObject, parentDomainObject, changes);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(currentParent) {
|
validate(domainObject, currentParent) {
|
||||||
return (data) => {
|
return (data) => {
|
||||||
const parentCandidate = data.value[0];
|
const parentCandidate = data.value[0];
|
||||||
|
|
||||||
let currentParentKeystring = this.openmct.objects.makeKeyString(currentParent.identifier);
|
let currentParentKeystring = this.openmct.objects.makeKeyString(currentParent.identifier);
|
||||||
let parentCandidateKeystring = this.openmct.objects.makeKeyString(parentCandidate.identifier);
|
let parentCandidateKeystring = this.openmct.objects.makeKeyString(parentCandidate.identifier);
|
||||||
let objectKeystring = this.openmct.objects.makeKeyString(this.object.identifier);
|
let objectKeystring = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
|
|
||||||
if (!this.openmct.objects.isPersistable(parentCandidate.identifier)) {
|
if (!this.openmct.objects.isPersistable(parentCandidate.identifier)) {
|
||||||
return false;
|
return false;
|
||||||
@ -125,7 +128,7 @@ export default class DuplicateAction {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parentCandidate && this.openmct.composition.checkPolicy(parentCandidate, this.object);
|
return parentCandidate && this.openmct.composition.checkPolicy(parentCandidate, domainObject);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user