mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
add selection class
This commit is contained in:
parent
d048af108e
commit
62b4975d57
@ -40,6 +40,7 @@ const ROW_HEIGHT = 100;
|
|||||||
const CONTAINER_CLASS = 'c-events-tsv-container';
|
const CONTAINER_CLASS = 'c-events-tsv-container';
|
||||||
const NO_ITEMS_CLASS = 'c-events-tsv__no-items';
|
const NO_ITEMS_CLASS = 'c-events-tsv__no-items';
|
||||||
const EVENT_WRAPPER_CLASS = 'c-events-tsv__event-wrapper';
|
const EVENT_WRAPPER_CLASS = 'c-events-tsv__event-wrapper';
|
||||||
|
const EVENT_SELECTED_CLASS = '.c-event-selected';
|
||||||
const ID_PREFIX = 'wrapper-';
|
const ID_PREFIX = 'wrapper-';
|
||||||
const AXES_PADDING = 20;
|
const AXES_PADDING = 20;
|
||||||
|
|
||||||
@ -65,7 +66,8 @@ export default {
|
|||||||
timeSystem: timeSystem,
|
timeSystem: timeSystem,
|
||||||
extendLines: false,
|
extendLines: false,
|
||||||
titleKey: null,
|
titleKey: null,
|
||||||
tooltip: null
|
tooltip: null,
|
||||||
|
selectedEvent: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -111,6 +113,9 @@ export default {
|
|||||||
this.unlisten = this.openmct.objects.observe(this.domainObject, '*', this.observeForChanges);
|
this.unlisten = this.openmct.objects.observe(this.domainObject, '*', this.observeForChanges);
|
||||||
this.extendedLinesBus.on('disable-extended-lines', this.disableExtendEventLines);
|
this.extendedLinesBus.on('disable-extended-lines', this.disableExtendEventLines);
|
||||||
this.extendedLinesBus.on('enable-extended-lines', this.enableExtendEventLines);
|
this.extendedLinesBus.on('enable-extended-lines', this.enableExtendEventLines);
|
||||||
|
this.extendedLinesBus.on('event-clicked', this.checkIfOurEvent);
|
||||||
|
|
||||||
|
document.addEventListener('click', this.checkIfOutsideClick);
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
if (this.eventStripResizeObserver) {
|
if (this.eventStripResizeObserver) {
|
||||||
@ -127,6 +132,9 @@ export default {
|
|||||||
|
|
||||||
this.extendedLinesBus.off('disable-extended-lines', this.disableExtendEventLines);
|
this.extendedLinesBus.off('disable-extended-lines', this.disableExtendEventLines);
|
||||||
this.extendedLinesBus.off('enable-extended-lines', this.enableExtendEventLines);
|
this.extendedLinesBus.off('enable-extended-lines', this.enableExtendEventLines);
|
||||||
|
this.extendedLinesBus.off('event-clicked', this.checkIfOurEvent);
|
||||||
|
|
||||||
|
document.removeEventListener('click', this.checkIfOutsideClick);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setTimeContext() {
|
setTimeContext() {
|
||||||
@ -320,12 +328,10 @@ export default {
|
|||||||
},
|
},
|
||||||
drawEvents() {
|
drawEvents() {
|
||||||
let eventContainer = this.getEventsContainer();
|
let eventContainer = this.getEventsContainer();
|
||||||
let index = 0;
|
|
||||||
if (this.eventHistory.length) {
|
if (this.eventHistory.length) {
|
||||||
this.eventHistory.forEach((currentEventObject) => {
|
this.eventHistory.forEach((currentEventObject) => {
|
||||||
if (this.isEventInBounds(currentEventObject)) {
|
if (this.isEventInBounds(currentEventObject)) {
|
||||||
this.plotEvents(currentEventObject, eventContainer, index);
|
this.plotEvents(currentEventObject, eventContainer);
|
||||||
index = index + 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -344,13 +350,13 @@ export default {
|
|||||||
|
|
||||||
return this.$el.querySelector(`.c-events-tsv__contents div[id=${id}]`);
|
return this.$el.querySelector(`.c-events-tsv__contents div[id=${id}]`);
|
||||||
},
|
},
|
||||||
plotEvents(item, containerElement, index) {
|
plotEvents(item, containerElement) {
|
||||||
const existingEventWrapper = this.getEventWrapper(item);
|
const existingEventWrapper = this.getEventWrapper(item);
|
||||||
// eventWrapper wraps the vertical tick and the EVENT
|
// eventWrapper wraps the vertical tick and the EVENT
|
||||||
if (existingEventWrapper) {
|
if (existingEventWrapper) {
|
||||||
this.updateExistingEventWrapper(existingEventWrapper, item);
|
this.updateExistingEventWrapper(existingEventWrapper, item);
|
||||||
} else {
|
} else {
|
||||||
const eventWrapper = this.createEventWrapper(index, item);
|
const eventWrapper = this.createEventWrapper(item);
|
||||||
containerElement.appendChild(eventWrapper);
|
containerElement.appendChild(eventWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +375,7 @@ export default {
|
|||||||
item: this.domainObject
|
item: this.domainObject
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.objectPath.forEach((pathObject, index) => {
|
this.objectPath.forEach((pathObject) => {
|
||||||
selection.push({
|
selection.push({
|
||||||
element: this.openmct.layout.$refs.browseObject.$el,
|
element: this.openmct.layout.$refs.browseObject.$el,
|
||||||
context: {
|
context: {
|
||||||
@ -409,7 +415,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.openmct.selection.select(selection, true);
|
this.openmct.selection.select(selection, true);
|
||||||
},
|
},
|
||||||
createEventWrapper(index, event) {
|
createEventWrapper(event) {
|
||||||
const id = `${ID_PREFIX}${event.time}`;
|
const id = `${ID_PREFIX}${event.time}`;
|
||||||
const eventWrapper = document.createElement('div');
|
const eventWrapper = document.createElement('div');
|
||||||
eventWrapper.ariaLabel = id;
|
eventWrapper.ariaLabel = id;
|
||||||
@ -440,6 +446,8 @@ export default {
|
|||||||
eventWrapper.addEventListener('click', (mouseEvent) => {
|
eventWrapper.addEventListener('click', (mouseEvent) => {
|
||||||
mouseEvent.stopPropagation();
|
mouseEvent.stopPropagation();
|
||||||
this.createSelectionForInspector(event);
|
this.createSelectionForInspector(event);
|
||||||
|
this.toggleEventSelection(eventTickElement);
|
||||||
|
this.extendedLinesBus.eventClicked(this.keyString);
|
||||||
});
|
});
|
||||||
|
|
||||||
return eventWrapper;
|
return eventWrapper;
|
||||||
@ -466,6 +474,27 @@ export default {
|
|||||||
toolTipLocation: this.openmct.tooltips.TOOLTIP_LOCATIONS.RIGHT,
|
toolTipLocation: this.openmct.tooltips.TOOLTIP_LOCATIONS.RIGHT,
|
||||||
parentElement: referenceElement
|
parentElement: referenceElement
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
checkIfOurEvent(keyString) {
|
||||||
|
if (this.keyString !== keyString) {
|
||||||
|
this.selectedEvent?.classList.remove(EVENT_SELECTED_CLASS);
|
||||||
|
this.selectedEvent = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleEventSelection(clickedEvent) {
|
||||||
|
this.selectedEvent?.classList.remove(EVENT_SELECTED_CLASS);
|
||||||
|
clickedEvent.classList.add(EVENT_SELECTED_CLASS);
|
||||||
|
this.selectedEvent = clickedEvent;
|
||||||
|
},
|
||||||
|
checkIfOutsideClick(event) {
|
||||||
|
if (
|
||||||
|
this.selectedEvent &&
|
||||||
|
!this.selectedEvent.contains(event.target) &&
|
||||||
|
!this.$refs.events.contains(event.target)
|
||||||
|
) {
|
||||||
|
this.selectedEvent.classList.remove(EVENT_SELECTED_CLASS);
|
||||||
|
this.selectedEvent = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,4 +31,7 @@ export default class ExtendedLinesBus extends EventEmitter {
|
|||||||
enableExtendEventLines(keyString) {
|
enableExtendEventLines(keyString) {
|
||||||
this.emit('enable-extended-lines', keyString);
|
this.emit('enable-extended-lines', keyString);
|
||||||
}
|
}
|
||||||
|
eventClicked(keyString) {
|
||||||
|
this.emit('event-clicked', keyString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user