Experiment table - fix view moda for assigned users [SCI-7693]

This commit is contained in:
Anton 2023-01-06 11:43:23 +01:00
parent 631608e7db
commit 802e0e602b
4 changed files with 34 additions and 27 deletions

View file

@ -227,11 +227,12 @@ var ExperimnetTable = {
$(this.table).on('show.bs.dropdown', '.assign-users-dropdown', (e) => {
let usersList = $(e.target).find('.users-list');
let isArchivedView = $('#experimentTable').hasClass('archived');
let viewOnly = $(e.target).data('view-only');
let checkbox = '';
usersList.find('.user-container').remove();
$.get(usersList.data('list-url'), (result) => {
$.each(result, (_i, user) => {
if (!isArchivedView) {
if (!isArchivedView && !viewOnly) {
checkbox = `<div class="sci-checkbox-container">
<input type="checkbox"
class="sci-checkbox user-selector"

View file

@ -152,7 +152,8 @@ module Experiments
partial: 'experiments/assigned_users.html.erb',
locals: { my_module: my_module,
user: @user,
skip_unassigned: @params[:view_mode] == 'archived' }
skip_unassigned: @params[:view_mode] == 'archived' ||
!can_manage_my_module_designated_users?(@user, my_module) }
) }
end

View file

@ -1,29 +1,33 @@
<% users = my_module.designated_users.order(:full_name) %>
<div ref="dropdown" class="assign-users-dropdown dropdown">
<div class="assigned-users-container" data-toggle="dropdown">
<% users[0..3].each_with_index do |user, i| %>
<span class="avatar-container" style="z-index: <%= 5 - i %>">
<%= image_tag avatar_path(user, :icon_small), title: user.full_name %>
</span>
<% end %>
<% if users.length > 4 %>
<span class="more-users avatar-container" title="<%= sanitize_input(users[4..].map(&:full_name).join('&#013;')) %>">
+<%= users.length - 4 %>
</span>
<% end %>
<% if can_manage_my_module_users?(user, my_module) %>
<span class="new-user avatar-container">
<i class="fas fa-plus"></i>
</span>
<% end %>
</div>
<div class="dropdown-menu">
<div class="sci-input-container left-icon">
<input type="text" class="sci-input-field user-search" placeholder="<%= I18n.t('experiments.table.search') %>">
<i class="fas fa-search"></i>
<% if users.empty? && !can_manage_my_module_designated_users?(user, my_module) %>
<%= I18n.t('experiments.table.not_set') %>
<% else %>
<div ref="dropdown" class="assign-users-dropdown dropdown" data-view-only="<%= !can_manage_my_module_designated_users?(user, my_module) %>">
<div class="assigned-users-container" data-toggle="dropdown">
<% users[0..3].each_with_index do |user, i| %>
<span class="avatar-container" style="z-index: <%= 5 - i %>">
<%= image_tag avatar_path(user, :icon_small), title: user.full_name %>
</span>
<% end %>
<% if users.length > 4 %>
<span class="more-users avatar-container" title="<%= sanitize_input(users[4..].map(&:full_name).join('&#013;')) %>">
+<%= users.length - 4 %>
</span>
<% end %>
<% if can_manage_my_module_designated_users?(user, my_module) %>
<span class="new-user avatar-container">
<i class="fas fa-plus"></i>
</span>
<% end %>
</div>
<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 class="dropdown-menu">
<div class="sci-input-container left-icon">
<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, skip_unassigned: skip_unassigned) %>">
</div>
</div>
</div>
</div>
<% end %>

View file

@ -1385,6 +1385,7 @@ en:
active_tasks: 'Go to Active tasks'
add_tag: '+ Add tag'
search: 'Search...'
not_set: 'not set'
archive_group:
success_flash: "<strong>%{number}</strong> task(s) successfully archived."
error_flash: "Failed to archive task(s)."