Small fixes for global search [SCI-10737][SCI-10713][SCI-10720]

This commit is contained in:
Anton 2024-05-23 12:24:17 +02:00
parent f4003f9962
commit c7cb5875d3
5 changed files with 30 additions and 11 deletions

View file

@ -57,7 +57,7 @@
</button> </button>
</div> </div>
<button class="btn btn-light btn-sm" @click="filterModalOpened = true"> <button class="btn btn-light btn-sm" @click="filterModalOpened = true">
<i class="sn-icon sn-icon-search-options"></i> <i class="sn-icon sn-icon-search-options" :title="i18n.t('search.index.more_search_options')"></i>
<span class="tw-hidden xl:inline">{{ i18n.t('search.index.more_search_options') }}</span> <span class="tw-hidden xl:inline">{{ i18n.t('search.index.more_search_options') }}</span>
<span <span
v-if="activeFilters.length > 0" v-if="activeFilters.length > 0"
@ -69,12 +69,12 @@
<template v-if="activeFilters.length > 0"> <template v-if="activeFilters.length > 0">
<div class="h-4 w-[1px] bg-sn-grey"></div> <div class="h-4 w-[1px] bg-sn-grey"></div>
<button class="btn btn-light btn-sm" @click="resetFilters"> <button class="btn btn-light btn-sm" @click="resetFilters">
<i class="sn-icon sn-icon-close"></i> <i class="sn-icon sn-icon-close" :title="i18n.t('search.index.clear_filters')"></i>
<span class="tw-hidden xl:inline">{{ i18n.t('search.index.clear_filters') }}</span> <span class="tw-hidden xl:inline">{{ i18n.t('search.index.clear_filters') }}</span>
</button> </button>
</template> </template>
<button v-if="activeGroup" class="btn btn-light btn-sm" @click="resetGroup"> <button v-if="activeGroup" class="btn btn-light btn-sm" @click="resetGroup">
<i class="sn-icon sn-icon-undo"></i> <i class="sn-icon sn-icon-undo" :title="i18n.t('search.index.all_results')"></i>
<span class="tw-hidden xl:inline">{{ i18n.t('search.index.all_results') }}</span> <span class="tw-hidden xl:inline">{{ i18n.t('search.index.all_results') }}</span>
</button> </button>
</div> </div>
@ -151,6 +151,10 @@ export default {
currentTeam: { currentTeam: {
type: Number || String, type: Number || String,
required: true required: true
},
singleTeam: {
type: Boolean,
default: false
} }
}, },
components: { components: {
@ -227,7 +231,7 @@ export default {
to: null to: null
}, },
include_archived: urlParams.get('include_archived') === 'true', include_archived: urlParams.get('include_archived') === 'true',
teams: urlParams.getAll('teams[]').map((team) => parseInt(team, 10)), teams: (this.singleTeam ? [] : urlParams.getAll('teams[]').map((team) => parseInt(team, 10))),
users: urlParams.getAll('users[]').map((user) => parseInt(user, 10)), users: urlParams.getAll('users[]').map((user) => parseInt(user, 10)),
group: urlParams.get('group') group: urlParams.get('group')
}; };

View file

@ -36,7 +36,7 @@
:multiple="true" :multiple="true"
:value="selectedTeams" :value="selectedTeams"
:placeholder="i18n.t('search.filters.by_team_placeholder')" :placeholder="i18n.t('search.filters.by_team_placeholder')"
@change="(v) => {selectedTeams = v}" /> @change="selectTeams" />
</template> </template>
<div class="sci-label mb-2 flex items-center gap-2"> <div class="sci-label mb-2 flex items-center gap-2">
{{ i18n.t('search.filters.by_user') }} {{ i18n.t('search.filters.by_user') }}
@ -52,7 +52,7 @@
:with-checkboxes="true" :with-checkboxes="true"
:multiple="true" :multiple="true"
:placeholder="i18n.t('search.filters.by_user_placeholder')" :placeholder="i18n.t('search.filters.by_user_placeholder')"
@change="(v) => {selectedUsers = v}" /> @change="selectUsers" />
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="sci-checkbox-container"> <div class="sci-checkbox-container">
<input type="checkbox" v-model="includeArchived" class="sci-checkbox" /> <input type="checkbox" v-model="includeArchived" class="sci-checkbox" />
@ -178,6 +178,16 @@ export default {
this.users = response.data.data.map((user) => ([parseInt(user.id, 10), user.attributes.name, { avatar_url: user.attributes.avatar_url }])); this.users = response.data.data.map((user) => ([parseInt(user.id, 10), user.attributes.name, { avatar_url: user.attributes.avatar_url }]));
}); });
}, },
selectTeams(teams) {
if (Array.isArray(teams)) {
this.selectedTeams = teams;
}
},
selectUsers(users) {
if (Array.isArray(users)) {
this.selectedUsers = users;
}
},
clearFilters() { clearFilters() {
this.createdAt = { this.createdAt = {
on: null, on: null,

View file

@ -26,7 +26,7 @@
ref="search" ref="search"
v-else v-else
v-model="query" v-model="query"
:placeholder="label || placeholder || this.i18n.t('general.select_dropdown.placeholder')" :placeholder="placeholderRender"
class="w-full border-0 outline-none pl-0 placeholder:text-sn-grey" /> class="w-full border-0 outline-none pl-0 placeholder:text-sn-grey" />
</template> </template>
<div v-else class="flex items-center gap-1 flex-wrap"> <div v-else class="flex items-center gap-1 flex-wrap">
@ -142,6 +142,13 @@ export default {
}, },
mixins: [FixedFlyoutMixin], mixins: [FixedFlyoutMixin],
computed: { computed: {
placeholderRender() {
if (this.searchable && this.labelRenderer && this.label) {
return '';
}
return this.label || this.placeholder || this.i18n.t('general.select_dropdown.placeholder');
},
sizeClass() { sizeClass() {
switch (this.size) { switch (this.size) {
case 'xs': case 'xs':
@ -301,8 +308,6 @@ export default {
}); });
}, },
setValue(value) { setValue(value) {
this.query = '';
if (this.multiple) { if (this.multiple) {
if (this.newValue.includes(value)) { if (this.newValue.includes(value)) {
this.newValue = this.newValue.filter((v) => v !== value); this.newValue = this.newValue.filter((v) => v !== value);
@ -310,7 +315,6 @@ export default {
this.newValue = [...this.newValue, value]; this.newValue = [...this.newValue, value];
} }
} else { } else {
this.newValue = value;
this.$nextTick(() => { this.$nextTick(() => {
this.close(); this.close();
}); });

View file

@ -6,6 +6,7 @@
:search-url="'<%= search_path(format: :json) %>'" :search-url="'<%= search_path(format: :json) %>'"
teams-url="<%= visible_teams_teams_path %>" teams-url="<%= visible_teams_teams_path %>"
users-url="<%= visible_users_teams_path %>" users-url="<%= visible_users_teams_path %>"
:single-team="<%= current_user.teams.count == 1 %>"
current-team="<%= current_team.id %>" current-team="<%= current_team.id %>"
/> />
</div> </div>

View file

@ -479,7 +479,7 @@ en:
by_user_placeholder: "Filter by user" by_user_placeholder: "Filter by user"
by_user_info: "The 'Filter by user' option will refine search results based on records where the selected user is the creator, modifier, or is assigned to the entry." by_user_info: "The 'Filter by user' option will refine search results based on records where the selected user is the creator, modifier, or is assigned to the entry."
include_archived: "Include Archived objects" include_archived: "Include Archived objects"
clear: "Clear filters" clear: "Clear"
date: date:
today: "Today" today: "Today"
yesterday: "Yesterday" yesterday: "Yesterday"