Fix user assign modal in experiment archived table view [SCI-7654] (#4742)

This commit is contained in:
ajugo 2023-01-05 12:00:12 +01:00 committed by GitHub
parent 194c519a9b
commit 32e9329bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 15 deletions

View file

@ -226,22 +226,28 @@ var ExperimnetTable = {
initManageUsersDropdown: function() {
$(this.table).on('show.bs.dropdown', '.assign-users-dropdown', (e) => {
let usersList = $(e.target).find('.users-list');
let isArchivedView = $('#experimentTable').hasClass('archived');
let checkbox = '';
usersList.find('.user-container').remove();
$.get(usersList.data('list-url'), (result) => {
$.each(result, (_i, user) => {
if (!isArchivedView) {
checkbox = `<div class="sci-checkbox-container">
<input type="checkbox"
class="sci-checkbox user-selector"
${user.params.designated ? 'checked' : ''}
value="${user.value}"
data-assign-url="${user.params.assign_url}"
data-unassign-url="${user.params.unassign_url}"
>
<span class="sci-checkbox-label"></span>
</div>`;
}
$(`
<div class="user-container">
<div class="sci-checkbox-container">
<input type="checkbox"
class="sci-checkbox user-selector"
${user.params.designated ? 'checked' : ''}
value="${user.value}"
data-assign-url="${user.params.assign_url}"
data-unassign-url="${user.params.unassign_url}"
>
<span class="sci-checkbox-label"></span>
</div>
<div class="user-avatar">
${checkbox}
<div class="user-avatar ${isArchivedView ? 'archived' : ''}">
<img src="${user.params.avatar_url}"></img>
</div>
<div class="user-name">

View file

@ -190,6 +190,10 @@
.user-avatar {
padding: 0 .75em;
&.archived {
padding-left: 0;
}
img {
border-radius: 50%;
}

View file

@ -64,7 +64,7 @@ class UserMyModulesController < ApplicationController
if params[:table]
render json: {
html: render_to_string(partial: 'experiments/assigned_users.html.erb',
locals: { my_module: @my_module, user: current_user }),
locals: { my_module: @my_module, user: current_user, skip_unassigned: false }),
unassign_url: my_module_user_my_module_path(@my_module, @um)
}
else
@ -99,7 +99,7 @@ class UserMyModulesController < ApplicationController
if params[:table]
render json: {
html: render_to_string(partial: 'experiments/assigned_users.html.erb',
locals: { my_module: @my_module, user: current_user })
locals: { my_module: @my_module, user: current_user, skip_unassigned: false })
}
else
render json: {}, status: :ok
@ -130,6 +130,7 @@ class UserMyModulesController < ApplicationController
users = users.map do |user|
next if params[:skip_assigned] && user.designated
next if ActiveModel::Type::Boolean.new.cast(params[:skip_unassigned]) && !user.designated
user_hash = {
value: user.id,

View file

@ -150,7 +150,9 @@ module Experiments
def assigned_presenter(my_module)
{ html: ApplicationController.renderer.render(
partial: 'experiments/assigned_users.html.erb',
locals: { my_module: my_module, user: @user }
locals: { my_module: my_module,
user: @user,
skip_unassigned: @params[:view_mode] == 'archived' }
) }
end

View file

@ -22,7 +22,8 @@
<input type="text" class="sci-input-field user-search" placeholder="<%= I18n.t('experiments.table.search') %>">
<i class="fas fa-search"></i>
</div>
<div class="users-list" data-list-url="<%= search_my_module_user_my_module_path(my_module, my_module_id: my_module.id) %>">
<div class="users-list"
data-list-url="<%= search_my_module_user_my_module_path(my_module, my_module_id: my_module.id, skip_unassigned: skip_unassigned) %>">
</div>
</div>
</div>