mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Prevent double click on protocol creation modal [SCI-8466] (#5458)
This commit is contained in:
parent
b4a8fccaa8
commit
3036c24be3
2 changed files with 14 additions and 12 deletions
|
|
@ -1,17 +1,7 @@
|
||||||
/* global dropdownSelector HelperModule */
|
/* global dropdownSelector HelperModule */
|
||||||
(function() {
|
(function() {
|
||||||
const protocolModal = '#newProtocolModal';
|
const protocolModal = '#newProtocolModal';
|
||||||
$(protocolModal)
|
const submitButton = $('.create-protocol-button');
|
||||||
.on('change', '#protocol_visibility', function() {
|
|
||||||
let checked = $(this)[0].checked;
|
|
||||||
$('#roleSelectWrapper').toggleClass('hidden', !checked);
|
|
||||||
$('#protocol_default_public_user_role_id').prop('disabled', !checked);
|
|
||||||
})
|
|
||||||
.on('show.bs.modal', function() {
|
|
||||||
$(`${protocolModal} #protocol_name`).parent().removeClass('error');
|
|
||||||
$(`${protocolModal} #protocol_name`).val('');
|
|
||||||
$(this).find('.sci-input-field').focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
let roleSelector = `${protocolModal} #protocol_role_selector`;
|
let roleSelector = `${protocolModal} #protocol_role_selector`;
|
||||||
dropdownSelector.init(roleSelector, {
|
dropdownSelector.init(roleSelector, {
|
||||||
|
|
@ -25,11 +15,22 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$(protocolModal)
|
$(protocolModal)
|
||||||
|
.on('change', '#protocol_visibility', function() {
|
||||||
|
let checked = $(this)[0].checked;
|
||||||
|
$('#roleSelectWrapper').toggleClass('hidden', !checked);
|
||||||
|
$('#protocol_default_public_user_role_id').prop('disabled', !checked);
|
||||||
|
})
|
||||||
|
.on('submit', function() {
|
||||||
|
submitButton.attr('disabled', 'disabled');
|
||||||
|
})
|
||||||
.on('shown.bs.modal', function() {
|
.on('shown.bs.modal', function() {
|
||||||
|
$(`${protocolModal} #protocol_name`).parent().removeClass('error');
|
||||||
|
$(`${protocolModal} #protocol_name`).val('');
|
||||||
$(this).find('.sci-input-field').focus();
|
$(this).find('.sci-input-field').focus();
|
||||||
})
|
})
|
||||||
.on('ajax:error', 'form', function(e, error) {
|
.on('ajax:error', 'form', function(e, error) {
|
||||||
let msg = error.responseJSON.error;
|
let msg = error.responseJSON.error;
|
||||||
|
submitButton.removeAttr('disabled');
|
||||||
$(`${protocolModal} #protocol_name`).parent().addClass('error').attr('data-error-text', msg);
|
$(`${protocolModal} #protocol_name`).parent().addClass('error').attr('data-error-text', msg);
|
||||||
})
|
})
|
||||||
.on('ajax:success', 'form', function(e, data) {
|
.on('ajax:success', 'form', function(e, data) {
|
||||||
|
|
@ -37,6 +38,7 @@
|
||||||
HelperModule.flashAlertMsg(data.message, 'success');
|
HelperModule.flashAlertMsg(data.message, 'success');
|
||||||
}
|
}
|
||||||
$(`${protocolModal} #protocol_name`).parent().removeClass('error');
|
$(`${protocolModal} #protocol_name`).parent().removeClass('error');
|
||||||
|
submitButton.removeAttr('disabled');
|
||||||
$(protocolModal).modal('hide');
|
$(protocolModal).modal('hide');
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.cancel') %></button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.cancel') %></button>
|
||||||
<%= f.button t("protocols.new_protocol_modal.create_#{type}") , class: "btn btn-primary" %>
|
<%= f.button t("protocols.new_protocol_modal.create_#{type}") , class: "btn btn-primary create-protocol-button" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue