VerticalMenuView 'focusItemAtTop' property, and selection by node ID on WFC

* Add new property to change how focus items are handed in VM
* Select node by node iD (key press) on WFC
This commit is contained in:
Bryan Ashby
2022-06-04 16:32:50 -06:00
parent 3d191a9c6c
commit 0b11e629a6
4 changed files with 50 additions and 13 deletions

View File

@@ -76,13 +76,16 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(null);
}
const index = parseInt(formData.ch); // 1-based
if (isNaN(index) || nodeStatusView.getCount() < index) {
const nodeId = parseInt(formData.ch); // 1-based
if (isNaN(nodeId)) {
return cb(null);
}
this.selectedNodeStatusIndex = index - 1;
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
const index = this._getNodeByNodeId(nodeStatusView, nodeId);
if (index > -1) {
this.selectedNodeStatusIndex = index;
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
}
return cb(null);
}
}
@@ -322,6 +325,10 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(null);
}
_getNodeByNodeId(nodeStatusView, nodeId) {
return nodeStatusView.getItems().findIndex(entry => entry.node == nodeId);
}
_selectNodeByIndex(nodeStatusView, index) {
if (index >= 0 && nodeStatusView.getFocusItemIndex() !== index) {
nodeStatusView.setFocusItemIndex(index);