unify button update
This commit is contained in:
parent
d4b4f131e9
commit
e190daac2c
|
@ -330,7 +330,7 @@ function formatDict(position) {
|
||||||
return pos.trim()
|
return pos.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateButtons(disabed, is_active) {
|
function updateButtons(disabled, is_active) {
|
||||||
$('button.run_from').attr({disabled: disabled})
|
$('button.run_from').attr({disabled: disabled})
|
||||||
$('button.loop').attr({disabled: disabled})
|
$('button.loop').attr({disabled: disabled})
|
||||||
$('button.hour_loop').attr({disabled: disabled})
|
$('button.hour_loop').attr({disabled: disabled})
|
||||||
|
@ -346,11 +346,12 @@ function updateStatus() {
|
||||||
api('status', {}, function(response) {
|
api('status', {}, function(response) {
|
||||||
if (response.result) {
|
if (response.result) {
|
||||||
var gotSelection = grid.getSelectedRows().length > 0
|
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)
|
$('#status').html(response.result.status)
|
||||||
updateButtons(disabled, response.result.status == 'Active')
|
updateButtons(disabled, is_active)
|
||||||
if (response.result.duration && response.result.status == 'Active') {
|
if (response.result.duration && is_active) {
|
||||||
$('#duration').html(formatDuration(response.result.duration))
|
$('#duration').html(formatDuration(response.result.duration))
|
||||||
} else {
|
} else {
|
||||||
$('#duration').html(formatDuration(totalDuration()))
|
$('#duration').html(formatDuration(totalDuration()))
|
||||||
|
@ -414,8 +415,9 @@ function updateStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var gotSelection = grid.getSelectedRows().length > 0
|
var gotSelection = grid.getSelectedRows().length > 0
|
||||||
var disabled = !gotSelection
|
var is_active = document.querySelector('#status').innerText == 'Active'
|
||||||
updateButtons(disabled, document.querySelector('#status').innerText == 'Active')
|
var disabled = !gotSelection || is_active
|
||||||
|
updateButtons(disabled, is_active)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user