Concurrent lock: Fix ownership handler in the backoffice

- Lost lock message will only be displayed once instead of being stacked every 60s 🤪
- Action buttons (except "Cancel") are disabled when the lock expires (regression from 3.0.0)
- Modal window is now larger
This commit is contained in:
Molkobain
2021-02-18 14:32:36 +01:00
parent 00008528a6
commit 38c6f8c76f
2 changed files with 10 additions and 7 deletions

View File

@@ -5137,8 +5137,8 @@ EOF
$sJSTitle = json_encode(Dict::S('UI:DisconnectedDlgTitle'));
$sJSOk = json_encode(Dict::S('UI:Button:Ok'));
$oPage->add_ready_script(
<<<EOF
window.setInterval(function() {
<<<JS
let hOwnershipLockHandlerInterval = window.setInterval(function() {
if (window.bInSubmit || window.bInCancel) return;
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'extend_lock', obj_class: $sJSClass, obj_key: $iKey, token: $sJSToken }, function(data) {
@@ -5147,22 +5147,24 @@ EOF
if ($('.lock_owned').length == 0)
{
$('.ui-layout-content').prepend('<div class="header_message message_error lock_owned">'+data.message+'</div>');
$('<div>'+data.popup_message+'</div>').dialog({title: $sJSTitle, modal: true, autoOpen: true, buttons:[ {text: $sJSOk, click: function() { $(this).dialog('close'); } }], close: function() { $(this).remove(); }});
$('<div>'+data.popup_message+'</div>').dialog({title: $sJSTitle, modal: true, autoOpen: true, minWidth: 600, buttons:[ {text: $sJSOk, click: function() { $(this).dialog('close'); } }], close: function() { $(this).remove(); }});
}
$('.wizContainer form button.action:not(.cancel)').prop('disabled', true);
$('.object-details form .ibo-toolbar .ibo-button:not([name="cancel"])').prop('disabled', true);
clearInterval(hOwnershipLockHandlerInterval);
}
else if ((data.operation == 'lost') || (data.operation == 'expired'))
{
if ($('.lock_owned').length == 0)
{
$('.ui-layout-content').prepend('<div class="header_message message_error lock_owned">'+data.message+'</div>');
$('<div>'+data.popup_message+'</div>').dialog({title: $sJSTitle, modal: true, autoOpen: true, buttons:[ {text: $sJSOk, click: function() { $(this).dialog('close'); } }], close: function() { $(this).remove(); }});
$('<div>'+data.popup_message+'</div>').dialog({title: $sJSTitle, modal: true, autoOpen: true, minWidth: 600, buttons:[ {text: $sJSOk, click: function() { $(this).dialog('close'); } }], close: function() { $(this).remove(); }});
}
$('.wizContainer form button.action:not(.cancel)').prop('disabled', true);
$('.object-details form .ibo-toolbar .ibo-button:not([name="cancel"])').prop('disabled', true);
clearInterval(hOwnershipLockHandlerInterval);
}
}, 'json');
}, $iInterval);
EOF
JS
);
}

View File

@@ -2394,6 +2394,7 @@ EOF
}
}
}
$oPage->SetContentType('application/json');
$oPage->add(json_encode($aResult));
break;