Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Rogers
0172ed1934 Remove unneccesary mixin invocation 2022-01-05 17:01:52 -06:00
Michael Rogers
00baf4286c Forcibly reset imageContainer size to prevent aspect ratio distortion 2022-01-05 17:01:43 -06:00
Michael Rogers
22c093371c Only preserve previous focused image if paused 2022-01-05 17:01:28 -06:00
Michael Rogers
5d41a3b2f2 Preserve the previousFocusedImage for subscription updates, bound change for local and fixed time 2022-01-05 17:01:04 -06:00
Shefali Joshi
433f1bf28e Fix object creation (#4675)
* Save the object before adding it to the parent so that transaction committing works properly
* Fix object creation - composition policy changes
2022-01-05 11:05:02 -08:00
6 changed files with 69 additions and 32 deletions

View File

@@ -39,8 +39,10 @@ export default class ConditionSetViewProvider {
return isConditionSet && this.openmct.router.isNavigatedObject(objectPath);
}
canEdit(domainObject) {
return domainObject.type === 'conditionSet';
canEdit(domainObject, objectPath) {
const isConditionSet = domainObject.type === 'conditionSet';
return isConditionSet && this.openmct.router.isNavigatedObject(objectPath);
}
view(domainObject, objectPath) {

View File

@@ -99,6 +99,7 @@ export default class CreateAction extends PropertiesAction {
*/
async _navigateAndEdit(domainObject, parentDomainObjectpath) {
let objectPath;
let self = this;
if (parentDomainObjectpath) {
objectPath = parentDomainObjectpath && [domainObject].concat(parentDomainObjectpath);
} else {
@@ -110,13 +111,18 @@ export default class CreateAction extends PropertiesAction {
.reverse()
.join('/');
this.openmct.router.navigate(url);
function editObject() {
const objectView = self.openmct.objectViews.get(domainObject, objectPath)[0];
const canEdit = objectView && objectView.canEdit && objectView.canEdit(domainObject, objectPath);
const objectView = this.openmct.objectViews.get(domainObject, objectPath)[0];
const canEdit = objectView && objectView.canEdit && objectView.canEdit(domainObject, objectPath);
if (canEdit) {
this.openmct.editor.edit();
if (canEdit) {
self.openmct.editor.edit();
}
}
this.openmct.router.once('afterNavigation', editObject);
this.openmct.router.navigate(url);
}
/**

View File

@@ -420,6 +420,11 @@ export default {
imageIndex = newSize > 0 ? newSize - 1 : undefined;
}
// preserve previous image if a subscription updates history size
if (this.isPaused) {
this.previousFocusedImage = this.focusedImage ? JSON.parse(JSON.stringify(this.focusedImage)) : undefined;
}
this.setFocusedImage(imageIndex, false);
this.scrollToRight();
},
@@ -510,12 +515,6 @@ export default {
this.timeContext.off("clock", this.trackDuration);
}
},
boundsChange(bounds, isTick) {
if (!isTick) {
this.previousFocusedImage = this.focusedImage ? JSON.parse(JSON.stringify(this.focusedImage)) : undefined;
this.requestHistory();
}
},
expand() {
const actionCollection = this.openmct.actions.getActionsCollection(this.objectPath, this.currentView);
const visibleActions = actionCollection.getVisibleActions();
@@ -676,14 +675,6 @@ export default {
this.$refs.thumbsWrapper.scrollLeft = scrollWidth;
});
},
matchIndexOfPreviousImage(previous, imageHistory) {
// match logic uses a composite of url and time to account
// for example imagery not having fully unique urls
return imageHistory.findIndex((x) => (
x.url === previous.url
&& x.time === previous.time
));
},
setFocusedImage(index, thumbnailClick = false) {
let focusedIndex = index;
if (!(Number.isInteger(index) && index > -1)) {
@@ -697,8 +688,6 @@ export default {
this.imageHistory
);
focusedIndex = matchIndex > -1 ? matchIndex : this.imageHistory.length - 1;
delete this.previousFocusedImage;
}
if (thumbnailClick) {
@@ -706,7 +695,10 @@ export default {
this.focusedImageTimestamp = undefined;
}
if (this.isPaused && !thumbnailClick && this.focusedImageTimestamp === undefined) {
this.focusedImageIndex = focusedIndex;
delete this.previousFocusedImage;
if (this.isPaused && !thumbnailClick && this.initFocusedImageIndex === undefined) {
this.nextImageIndex = focusedIndex;
//this could happen if bounds changes
if (this.focusedImageIndex > this.imageHistory.length - 1) {
@@ -716,8 +708,6 @@ export default {
return;
}
this.focusedImageIndex = focusedIndex;
if (thumbnailClick && !this.isPaused) {
this.paused(true);
}

View File

@@ -120,14 +120,49 @@ export default {
return this.timeFormatter.parse(datum);
},
boundsChange(bounds, isTick) {
if (!isTick) {
this.requestHistory();
if (isTick) {
return;
}
// the focusedImageIndex is calculated twice; once before and after request history arrives
const focusedImage = this.imageHistory[this.focusedImageIndex];
const previousFocusedImage = focusedImage ? JSON.parse(JSON.stringify(focusedImage)) : undefined;
this.updateFocusedImageIndex(previousFocusedImage, this.imageHistory);
// forcibly reset the imageContainer size to prevent an aspect ratio distortion
delete this.imageContainerWidth;
delete this.imageContainerHeight;
return this.requestHistory();
},
matchIndexOfPreviousImage(previous, imageHistory) {
// match logic uses a composite of url and time to account
// for example imagery not having fully unique urls
return imageHistory.findIndex((x) => (
x.url === previous.url
&& x.time === previous.time
));
},
updateFocusedImageIndex(previous, imageHistory) {
if (!previous) {
return;
}
const matchIndex = this.matchIndexOfPreviousImage(
previous,
imageHistory
);
this.focusedImageIndex = matchIndex > -1 ? matchIndex : this.imageHistory.length - 1;
},
async requestHistory() {
let bounds = this.timeContext.bounds();
this.requestCount++;
const requestId = this.requestCount;
// maintain previous focused image value to discern new index
const focusedImage = this.imageHistory[this.focusedImageIndex];
const previousFocusedImage = focusedImage ? JSON.parse(JSON.stringify(focusedImage)) : undefined;
this.imageHistory = [];
let data = await this.openmct.telemetry
@@ -141,7 +176,8 @@ export default {
imagery.push(image);
}
});
//this is to optimize anything that reacts to imageHistory length
this.updateFocusedImageIndex(previousFocusedImage, imagery);
this.imageHistory = imagery;
}
},

View File

@@ -29,10 +29,9 @@ define(
}
SummaryWidgetsCompositionPolicy.prototype.allow = function (parent, child) {
const parentType = parent.getCapability('type');
const newStyleChild = child.useCapability('adapter');
const parentType = parent.type;
if (parentType.instanceOf('summary-widget') && !this.openmct.telemetry.isTelemetryObject(newStyleChild)) {
if (parentType === 'summary-widget' && !this.openmct.telemetry.isTelemetryObject(child)) {
return false;
}

View File

@@ -445,6 +445,10 @@ export default {
}
// sorting composition items
if (!a.name || !b.name) {
return 0;
}
if (a.name.toLowerCase()
> b.name.toLowerCase()) {
return 1;