Basic selection display

This commit is contained in:
Bryan Ashby 2022-06-23 22:23:11 -06:00
parent 3d50c4e80d
commit 2040ccd551
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
3 changed files with 40 additions and 21 deletions

View File

@ -296,6 +296,8 @@
}
statusAvailableIndicators: [ "N", "Y" ]
statusVisibleIndicators: [ "N", "Y" ]
nodeStatusSelectionFormat: "|00|10{realName}"
}
0: {
mci: {

View File

@ -90,11 +90,22 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(null);
}
const index = this._getNodeByNodeId(nodeStatusView, nodeId);
const index = this._getNodeStatusIndexByNodeId(nodeStatusView, nodeId);
if (index > -1) {
this.selectedNodeStatusIndex = index;
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
const nodeStatusSelectionView = this.getView(
'main',
MciViewIds.main.selectedNodeStatusInfo
);
if (nodeStatusSelectionView) {
const item = nodeStatusView.getItems()[index];
this._updateNodeStatusSelection(nodeStatusSelectionView, item);
}
}
return cb(null);
},
kickSelectedNode: (formData, extraArgs, cb) => {
@ -172,18 +183,14 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
'main',
MciViewIds.main.selectedNodeStatusInfo
);
const nodeStatusSelectionFormat =
this.config.nodeStatusSelectionFormat || '{text}';
if (nodeStatusView && nodeStatusSelectionView) {
nodeStatusView.on('index update', index => {
const item = nodeStatusView.getItems()[index];
if (item) {
nodeStatusSelectionView.setText(
stringFormat(nodeStatusSelectionFormat, item)
this._updateNodeStatusSelection(
nodeStatusSelectionView,
item
);
// :TODO: Update view
// :TODO: this is not triggered by key-presses (1, 2, ...) -- we need to handle that as well
}
});
}
@ -202,16 +209,6 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
);
}
_displayHelpPage(cb) {
this._stopRefreshing();
this.displayAsset(this.menuConfig.config.art.help, { clearScreen: true }, () => {
this.client.waitForKeyPress(() => {
return this._displayMainPage(true, cb);
});
});
}
enter() {
this.client.stopIdleMonitor();
this._applyOpVisibility();
@ -231,6 +228,26 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
super.leave();
}
_updateNodeStatusSelection(nodeStatusSelectionView, item) {
if (item) {
const nodeStatusSelectionFormat =
this.config.nodeStatusSelectionFormat || '{text}';
nodeStatusSelectionView.setText(
stringFormat(nodeStatusSelectionFormat, item)
);
}
}
_displayHelpPage(cb) {
this._stopRefreshing();
this.displayAsset(this.menuConfig.config.art.help, { clearScreen: true }, () => {
this.client.waitForKeyPress(() => {
return this._displayMainPage(true, cb);
});
});
}
_getSelectedNodeItem() {
const nodeStatusView = this.getView('main', MciViewIds.main.nodeStatus);
if (!nodeStatusView) {
@ -460,7 +477,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(null);
}
_getNodeByNodeId(nodeStatusView, nodeId) {
_getNodeStatusIndexByNodeId(nodeStatusView, nodeId) {
return nodeStatusView.getItems().findIndex(entry => entry.node == nodeId);
}