[#4378] Ensure navigated object check works correctly when path is modified (#4433)

* [#4378] Emit event when router path is set. Handle the event when creating an object

Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
Shefali Joshi
2021-11-15 13:35:59 -08:00
committed by GitHub
parent 8ef3869325
commit 933ce7aa3c
3 changed files with 17 additions and 3 deletions

View File

@ -86,13 +86,22 @@ define(
})
.join('/');
openmct.router.navigate(url);
function editObject() {
const path = objectPath.slice(-1).map(obj => {
const objNew = obj.getCapability('adapter').invoke();
if (isFirstViewEditable(object.useCapability('adapter'), objectPath)) {
return objNew;
});
if (isFirstViewEditable(object.useCapability('adapter'), path)) {
openmct.editor.edit();
}
}
openmct.router.once('afterNavigation', editObject);
openmct.router.navigate(url);
}
newModel.type = this.type.getKey();
newModel.location = this.parent.getId();
newObject = this.parent.useCapability('instantiation', newModel);

View File

@ -147,6 +147,10 @@ class ApplicationRouter extends EventEmitter {
let targetObject = objectPath[0];
let navigatedObject = this.path[0];
if (!targetObject.identifier) {
return false;
}
return this.openmct.objects.areIdsEqual(targetObject.identifier, navigatedObject.identifier);
}

View File

@ -68,6 +68,7 @@ define([
objects = objects.reverse();
openmct.router.path = objects;
openmct.router.emit('afterNavigation');
browseObject = objects[0];
openmct.layout.$refs.browseBar.domainObject = browseObject;