Merge pull request #7359 from wandji20/wb-SCI-10367

Fix task assigned users search query and CSS [SCI-10367]
This commit is contained in:
aignatov-bio 2024-03-26 09:15:31 +01:00 committed by GitHub
commit 539f58441a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 14 deletions

View file

@ -91,7 +91,8 @@ class UserMyModulesController < ApplicationController
users = @my_module.users
.joins("LEFT OUTER JOIN user_my_modules ON user_my_modules.user_id = users.id "\
"AND user_my_modules.my_module_id = #{@my_module.id}")
.search(false, params[:query])
.where('trim_html_tags(users.full_name) ILIKE ?',
"%#{ActiveRecord::Base.sanitize_sql_like(params[:query])}%")
.select('users.*', 'user_my_modules.id as user_my_module_id')
.select('CASE WHEN user_my_modules.id IS NOT NULL THEN true ELSE false END as designated')
.order('designated DESC', :full_name)

View file

@ -1,6 +1,6 @@
<template>
<div v-if="params.data.designated_users.length > 0 || params.data.permissions.manage_designated_users">
<GeneralDropdown @open="() => loadUsers(true)" @close="closeFlyout">
<GeneralDropdown @open="loadUsers" @close="closeFlyout">
<template v-slot:field>
<div v-if="!params.data.folder" class="flex items-center gap-1 cursor-pointer h-9" @click="openAccessModal">
<div v-for="(user, i) in visibleUsers" :key="i" :title="user.full_name">
@ -22,10 +22,10 @@
v-model="query"
class="sci-input-field"
autofocus="true"
:placeholder="i18n.t('experiments.table.search')" />
:placeholder="i18n.t('general.search')" />
<i class="sn-icon sn-icon-search"></i>
</div>
<perfect-scrollbar class="relative max-h-96 overflow-y-auto max-w-[280px] pr-4 gap-y-px">
<perfect-scrollbar class="flex flex-col relative max-h-96 overflow-y-auto max-w-[280px] pr-4 pl-2 gap-y-px">
<div v-for="user in allUsers"
:key="user.value"
@click="selectUser(user)"
@ -98,7 +98,7 @@ export default {
}
},
methods: {
loadUsers(setSelectedUsers = false) {
loadUsers() {
axios.get(`${this.params.data.urls.users_list}`, {
params: {
query: this.query,
@ -110,14 +110,8 @@ export default {
if (!Array.isArray(result)) result = [];
if (setSelectedUsers) {
this.selectedUsers = result.filter((item) => this.users.some((user) => user.id === item.value));
this.allUsers = result;
this.flyoutLoaded = true;
} else {
const nonAssignedUsers = result.filter((item) => !this.selectedUsers.some(({ value }) => value === item.value));
this.allUsers = this.selectedUsers.concat(nonAssignedUsers);
}
this.allUsers = result;
this.selectedUsers = result.filter((item) => this.users.some((user) => user.id === item.value));
});
},
closeFlyout() {

View file

@ -64,7 +64,7 @@ export default {
flyout.style.minWidth = `${width}px`;
}
if (window.innerWidth - (field.x + flyoutRect.width) < 0) { // when flyout is out of screen
if (window.innerWidth - (rect.x + flyoutRect.width) < 0) { // when flyout is out of screen
flyout.style.left = 'unset';
flyout.style.right = `${width - Math.abs(right)}px`;
} else if (this.position === 'right') {