Compare commits
2 Commits
fix-plot-p
...
view-polic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
555bd81c5c | ||
|
|
cbb3f32d1e |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openmct",
|
||||
"version": "1.7.4-SNAPSHOT",
|
||||
"version": "1.7.4",
|
||||
"description": "The Open MCT core platform",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -399,25 +399,25 @@ ObjectAPI.prototype._toMutable = function (object) {
|
||||
mutableObject = object;
|
||||
} else {
|
||||
mutableObject = MutableDomainObject.createMutable(object, this.eventEmitter);
|
||||
}
|
||||
|
||||
// Check if provider supports realtime updates
|
||||
let identifier = utils.parseKeyString(mutableObject.identifier);
|
||||
let provider = this.getProvider(identifier);
|
||||
// Check if provider supports realtime updates
|
||||
let identifier = utils.parseKeyString(mutableObject.identifier);
|
||||
let provider = this.getProvider(identifier);
|
||||
|
||||
if (provider !== undefined
|
||||
&& provider.observe !== undefined
|
||||
&& this.SYNCHRONIZED_OBJECT_TYPES.includes(object.type)) {
|
||||
let unobserve = provider.observe(identifier, (updatedModel) => {
|
||||
if (updatedModel.persisted > mutableObject.modified) {
|
||||
//Don't replace with a stale model. This can happen on slow connections when multiple mutations happen
|
||||
//in rapid succession and intermediate persistence states are returned by the observe function.
|
||||
mutableObject.$refresh(updatedModel);
|
||||
}
|
||||
});
|
||||
mutableObject.$on('$_destroy', () => {
|
||||
unobserve();
|
||||
});
|
||||
if (provider !== undefined
|
||||
&& provider.observe !== undefined
|
||||
&& this.SYNCHRONIZED_OBJECT_TYPES.includes(object.type)) {
|
||||
let unobserve = provider.observe(identifier, (updatedModel) => {
|
||||
if (updatedModel.persisted > mutableObject.modified) {
|
||||
//Don't replace with a stale model. This can happen on slow connections when multiple mutations happen
|
||||
//in rapid succession and intermediate persistence states are returned by the observe function.
|
||||
mutableObject.$refresh(updatedModel);
|
||||
}
|
||||
});
|
||||
mutableObject.$on('$_destroy', () => {
|
||||
unobserve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return mutableObject;
|
||||
|
||||
@@ -37,7 +37,15 @@ export default class DuplicateAction {
|
||||
let duplicationTask = new DuplicateTask(this.openmct);
|
||||
let originalObject = objectPath[0];
|
||||
let parent = objectPath[1];
|
||||
let userInput = await this.getUserInput(originalObject, parent);
|
||||
let userInput;
|
||||
|
||||
try {
|
||||
userInput = await this.getUserInput(originalObject, parent);
|
||||
} catch (error) {
|
||||
// user most likely canceled
|
||||
return;
|
||||
}
|
||||
|
||||
let newParent = userInput.location;
|
||||
let inNavigationPath = this.inNavigationPath(originalObject);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="isRealTime"
|
||||
<div v-if="isRealTime && !options.compact"
|
||||
class="c-button-set c-button-set--strip-h js-pause"
|
||||
>
|
||||
<button v-if="!isFrozen"
|
||||
|
||||
@@ -32,6 +32,7 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
function ViewRegistry() {
|
||||
EventEmitter.apply(this);
|
||||
this.providers = {};
|
||||
this.policies = [];
|
||||
}
|
||||
|
||||
ViewRegistry.prototype = Object.create(EventEmitter.prototype);
|
||||
@@ -59,7 +60,9 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
return this.getAllProviders()
|
||||
.filter(function (provider) {
|
||||
return provider.canView(item, objectPath);
|
||||
}).sort(byPriority);
|
||||
})
|
||||
.filter(view => this.checkPolicy(view, item))
|
||||
.sort(byPriority);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -107,6 +110,14 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
})[0];
|
||||
};
|
||||
|
||||
ViewRegistry.prototype.addPolicy = function (policy) {
|
||||
this.policies.push(policy);
|
||||
};
|
||||
|
||||
ViewRegistry.prototype.checkPolicy = function (view, domainObject) {
|
||||
return this.policies.every(policy => policy(view, domainObject));
|
||||
};
|
||||
|
||||
/**
|
||||
* A View is used to provide displayable content, and to react to
|
||||
* associated life cycle events.
|
||||
|
||||
@@ -10,7 +10,6 @@ define([
|
||||
let unobserve = undefined;
|
||||
let currentObjectPath;
|
||||
let isRoutingInProgress = false;
|
||||
let mutable;
|
||||
|
||||
openmct.router.route(/^\/browse\/?$/, navigateToFirstChildOfRoot);
|
||||
openmct.router.route(/^\/browse\/(.*)$/, (path, results, params) => {
|
||||
@@ -37,24 +36,10 @@ define([
|
||||
}
|
||||
|
||||
function viewObject(object, viewProvider) {
|
||||
if (mutable) {
|
||||
openmct.objects.destroyMutable(mutable);
|
||||
mutable = undefined;
|
||||
}
|
||||
|
||||
if (openmct.objects.supportsMutation(object.identifier)) {
|
||||
mutable = openmct.objects._toMutable(object);
|
||||
}
|
||||
|
||||
currentObjectPath = openmct.router.path;
|
||||
|
||||
if (mutable !== undefined) {
|
||||
openmct.layout.$refs.browseObject.show(mutable, viewProvider.key, true, currentObjectPath);
|
||||
openmct.layout.$refs.browseBar.domainObject = mutable;
|
||||
} else {
|
||||
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true, currentObjectPath);
|
||||
openmct.layout.$refs.browseBar.domainObject = object;
|
||||
}
|
||||
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true, currentObjectPath);
|
||||
openmct.layout.$refs.browseBar.domainObject = object;
|
||||
|
||||
openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user