poc: tweaks disable/enable functionality
This commit is contained in:
parent
d8b5d916ef
commit
3d0a1b146a
1 changed files with 12 additions and 5 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<h3 class="panel-title">${_('Ai Configuration')}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
${h.secure_form(h.route_path('admin_settings_ai_update'), request=request)}
|
||||
${h.secure_form(h.route_path('admin_settings_ai_update'), id='ai_features_form', request=request)}
|
||||
<div class="fields">
|
||||
|
||||
<div class="field" id="ai-features-toggle">
|
||||
|
|
@ -75,6 +75,7 @@ import json
|
|||
const $model = $('#rhodecode_ai_model');
|
||||
const $slot = $('#model_version_slot');
|
||||
const $enable = $('#rhodecode_ai_features_enabled');
|
||||
const $form = $('#ai_features_form');
|
||||
|
||||
function renderVersionField(model) {
|
||||
const versions = MODEL_MAP[model] || [];
|
||||
|
|
@ -146,10 +147,16 @@ import json
|
|||
setAIFieldsActive(this.checked);
|
||||
});
|
||||
|
||||
$('form').submit(function (e) {
|
||||
$(':disabled').each(function (e) {
|
||||
$(this).removeAttr('disabled');
|
||||
})
|
||||
$form.submit(function () {
|
||||
let $f = $(this);
|
||||
|
||||
let $tmpEnabled = $f.find(':disabled');
|
||||
$tmpEnabled.prop('disabled', false);
|
||||
|
||||
setTimeout(function () {
|
||||
// immediately re-enable disable property
|
||||
$tmpEnabled.prop('disabled', true);
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue