Add List button and make Edit go directly to the selected Control as well as being a button.

pull/4422/head
Isaac Connor 2025-08-11 20:09:10 -04:00
parent 2ed2b270f6
commit 95ad036f73
2 changed files with 21 additions and 3 deletions

View File

@ -815,5 +815,20 @@ function devices_onchange(devices) {
device.style['display'] = 'inline';
}
}
function ControlId_onChange(ddm) {
const ControlEditButton = document.getElementById('ControlEditButton');
if (ControlEditButton) ControlEditButton.disabled = ddm.value ? false : true;
}
function ControlEdit_onClick() {
const ControlId = document.getElementById('ControlId');
if (ControlId) {
window.location = '?view=controlcap&cid='+ControlId.value;
}
}
function ControlList_onClick() {
window.location = '?view=options&tab=control';
}
window.addEventListener('DOMContentLoaded', initPage);

View File

@ -1444,9 +1444,12 @@ $codecs = array(
$controlTypes[$control->Id()] = $control->Name();
}
echo htmlSelect('newMonitor[ControlId]', $controlTypes, $monitor->ControlId());
if ( canEdit('Control') ) {
echo ' '.makeLink('?view=options&tab=control', translate('Edit'));
echo htmlSelect('newMonitor[ControlId]', $controlTypes, $monitor->ControlId(), ['id'=>'ControlId', 'data-on-click-this'=>'ControlId_onChange']);
if (canEdit('Control')) {
if ($monitor->ControlId()) {
echo '&nbsp;<button type="button" data-on-click="ControlEdit_onClick" id="ControlEdit">'.translate('Edit').'</button>';
}
echo '&nbsp;<button type="button" data-on-click="ControlList_onClick" id="ControlList">'.translate('List').'</button>';
}
?>
</li>