unify button update

This commit is contained in:
j 2021-11-24 19:42:00 +01:00
parent d4b4f131e9
commit e190daac2c

View File

@ -330,7 +330,7 @@ function formatDict(position) {
return pos.trim()
}
function updateButtons(disabed, is_active) {
function updateButtons(disabled, is_active) {
$('button.run_from').attr({disabled: disabled})
$('button.loop').attr({disabled: disabled})
$('button.hour_loop').attr({disabled: disabled})
@ -346,11 +346,12 @@ function updateStatus() {
api('status', {}, function(response) {
if (response.result) {
var gotSelection = grid.getSelectedRows().length > 0
var disabled = !gotSelection || response.result.status == 'Active'
var is_active = response.result.status == 'Active'
var disabled = !gotSelection || is_active
$('#status').html(response.result.status)
updateButtons(disabled, response.result.status == 'Active')
if (response.result.duration && response.result.status == 'Active') {
updateButtons(disabled, is_active)
if (response.result.duration && is_active) {
$('#duration').html(formatDuration(response.result.duration))
} else {
$('#duration').html(formatDuration(totalDuration()))
@ -414,8 +415,9 @@ function updateStatus() {
}
var gotSelection = grid.getSelectedRows().length > 0
var disabled = !gotSelection
updateButtons(disabled, document.querySelector('#status').innerText == 'Active')
var is_active = document.querySelector('#status').innerText == 'Active'
var disabled = !gotSelection || is_active
updateButtons(disabled, is_active)
}