Fix new protocol default role, fix reload of protocol access modal [SCI-8217]

This commit is contained in:
Martin Artnik 2023-03-28 16:22:38 +02:00
parent 6c3afee428
commit 6412a65d7e
4 changed files with 7 additions and 6 deletions

View file

@ -43,9 +43,8 @@
});
$(document).on('ajax:success', 'form#new-user-assignment-form', function(_e, data) {
$('.modal-backdrop').remove();
$('.user-assignments-modal').replaceWith(data.html);
$('.user-assignments-modal').modal('show');
$('#user_assignments_modal').replaceWith($(data.html).find('#user_assignments_modal'));
HelperModule.flashAlertMsg(data.flash, 'success');
});
$(document).on('ajax:error', 'form.member-item', function(_e, data) {

View file

@ -3,7 +3,9 @@
const protocolModal = '#newProtocolModal';
$(protocolModal)
.on('change', '#protocol_visibility', function() {
$('#roleSelectWrapper').toggleClass('hidden', !$(this)[0].checked);
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');

View file

@ -10,7 +10,7 @@
<%= t '.title', resource_name: assignable.name %>
</h4>
</div>
<%= form_with(url: create_path, method: :post, remote: true, html: { id: 'new-user-assignment-form', data: { action: 'replace-form', target: '#user_assignments_modal', object_type: assignable.class.to_s.downcase} }) do |f| %>
<%= form_with(url: create_path, method: :post, remote: true, html: { id: 'new-user-assignment-form', data: { object_type: assignable.class.to_s.downcase } }) do |f| %>
<div class="modal-body">
<div class="sci-input-container left-icon">
<%= text_field_tag :search_users, '',

View file

@ -31,7 +31,7 @@
<div class="sci-input-container">
<%= f.label :default_public_user_role_id, t("protocols.new_protocol_modal.role_label") %>
<% default_role = UserRole.find_by(name: I18n.t('user_roles.predefined.viewer')).id %>
<%= f.hidden_field :default_public_user_role_id, value: default_role %>
<%= f.hidden_field :default_public_user_role_id, value: nil, disabled: true %>
<%= f.select :role_selector, options_for_select(team_user_roles_for_select, default_role) %>
</div>
</div>