mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Fix user assign modal in experiment archived table view [SCI-7654] (#4742)
This commit is contained in:
parent
194c519a9b
commit
32e9329bcc
5 changed files with 29 additions and 15 deletions
|
@ -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">
|
||||
|
|
|
@ -190,6 +190,10 @@
|
|||
.user-avatar {
|
||||
padding: 0 .75em;
|
||||
|
||||
&.archived {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue