mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Small fixes for global search [SCI-10676]
This commit is contained in:
parent
c7870addda
commit
12c4e1ca10
7 changed files with 25 additions and 7 deletions
|
@ -7,7 +7,7 @@
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-white rounded p-4 flex gap-2.5 items-center mb-4 sticky top-0">
|
<div class="bg-white rounded p-4 flex gap-2.5 z-10 items-center mb-4 sticky top-0">
|
||||||
<div class="left-icon sci-input-container-v2 w-72 input-sm"
|
<div class="left-icon sci-input-container-v2 w-72 input-sm"
|
||||||
:title="i18n.t('nav.search')" :class="{'error': invalidQuery}">
|
:title="i18n.t('nav.search')" :class="{'error': invalidQuery}">
|
||||||
<input ref="searchField" type="text" class="!pr-9" :value="localQuery" @change="changeQuery" :placeholder="i18n.t('nav.search')"/>
|
<input ref="searchField" type="text" class="!pr-9" :value="localQuery" @change="changeQuery" :placeholder="i18n.t('nav.search')"/>
|
||||||
|
@ -45,6 +45,7 @@
|
||||||
</div>
|
</div>
|
||||||
<template v-for="group in searchGroups">
|
<template v-for="group in searchGroups">
|
||||||
<component
|
<component
|
||||||
|
ref="groupComponents"
|
||||||
:key="group"
|
:key="group"
|
||||||
:is="group"
|
:is="group"
|
||||||
v-if="activeGroup === group || !activeGroup"
|
v-if="activeGroup === group || !activeGroup"
|
||||||
|
@ -53,8 +54,12 @@
|
||||||
:searchUrl="searchUrl"
|
:searchUrl="searchUrl"
|
||||||
:filters="filters"
|
:filters="filters"
|
||||||
@selectGroup="setActiveGroup"
|
@selectGroup="setActiveGroup"
|
||||||
|
@updated="calculateTotalElements"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<div v-if="totalElements === 0 && !loading" class="bg-white rounded p-4">
|
||||||
|
<NoSearchResult />
|
||||||
|
</div>
|
||||||
<teleport to='body'>
|
<teleport to='body'>
|
||||||
<FiltersModal
|
<FiltersModal
|
||||||
v-if="filterModalOpened"
|
v-if="filterModalOpened"
|
||||||
|
@ -83,6 +88,7 @@ import LabelTemplatesComponent from './groups/label_templates.vue';
|
||||||
import ReportsComponent from './groups/reports.vue';
|
import ReportsComponent from './groups/reports.vue';
|
||||||
import FiltersModal from './filters_modal.vue';
|
import FiltersModal from './filters_modal.vue';
|
||||||
import GeneralDropdown from '../shared/general_dropdown.vue';
|
import GeneralDropdown from '../shared/general_dropdown.vue';
|
||||||
|
import NoSearchResult from './groups/helpers/no_search_result.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
emits: ['search', 'selectGroup'],
|
emits: ['search', 'selectGroup'],
|
||||||
|
@ -122,7 +128,8 @@ export default {
|
||||||
LabelTemplatesComponent,
|
LabelTemplatesComponent,
|
||||||
ReportsComponent,
|
ReportsComponent,
|
||||||
FiltersModal,
|
FiltersModal,
|
||||||
GeneralDropdown
|
GeneralDropdown,
|
||||||
|
NoSearchResult
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -130,6 +137,7 @@ export default {
|
||||||
localQuery: this.query,
|
localQuery: this.query,
|
||||||
filterModalOpened: false,
|
filterModalOpened: false,
|
||||||
activeGroup: null,
|
activeGroup: null,
|
||||||
|
totalElements: 0,
|
||||||
searchGroups: [
|
searchGroups: [
|
||||||
'FoldersComponent',
|
'FoldersComponent',
|
||||||
'ProjectsComponent',
|
'ProjectsComponent',
|
||||||
|
@ -191,6 +199,15 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
calculateTotalElements() {
|
||||||
|
let total = 0;
|
||||||
|
if (this.$refs.groupComponents) {
|
||||||
|
this.$refs.groupComponents.forEach((group) => {
|
||||||
|
total += group.total;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.totalElements = total;
|
||||||
|
},
|
||||||
setActiveGroup(group) {
|
setActiveGroup(group) {
|
||||||
if (group === this.activeGroup) {
|
if (group === this.activeGroup) {
|
||||||
this.activeGroup = null;
|
this.activeGroup = null;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-[auto_80px_auto_auto_auto] items-center">
|
<div class="grid grid-cols-[auto_110px_auto_auto_auto] items-center">
|
||||||
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
||||||
<hr class="col-span-5 w-full m-0" v-if="index > 0">
|
<hr class="col-span-5 w-full m-0" v-if="index > 0">
|
||||||
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-[auto_80px_auto_auto_auto_auto_auto] items-center">
|
<div class="grid grid-cols-[auto_110px_auto_auto_auto_auto_auto] items-center">
|
||||||
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
||||||
<hr class="col-span-7 w-full m-0" v-if="index > 0">
|
<hr class="col-span-7 w-full m-0" v-if="index > 0">
|
||||||
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-[auto_80px_auto_auto_auto_auto] items-center">
|
<div class="grid grid-cols-[auto_110px_auto_auto_auto_auto] items-center">
|
||||||
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
||||||
<hr class="col-span-6 w-full m-0" v-if="index > 0">
|
<hr class="col-span-6 w-full m-0" v-if="index > 0">
|
||||||
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
<SortFlyout v-if="selected" :sort="sort" @changeSort="changeSort"></SortFlyout>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-[auto_80px_auto_auto_auto] items-center">
|
<div class="grid grid-cols-[auto_110px_auto_auto_auto] items-center">
|
||||||
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
<div v-for="(row, index) in preparedResults" :key="row.id" class="contents group">
|
||||||
<hr class="col-span-5 w-full m-0" v-if="index > 0">
|
<hr class="col-span-5 w-full m-0" v-if="index > 0">
|
||||||
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
<LinkTemplate :url="row.attributes.url" :value="labelName({ name: row.attributes.name, archived: row.attributes.archived})"/>
|
||||||
|
|
|
@ -137,6 +137,7 @@ export default {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.$emit('updated');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
searchValue() {
|
searchValue() {
|
||||||
window.open(`${this.searchUrl}?q=${this.searchQuery}`, '_self');
|
window.open(`${this.searchUrl}?q=${this.searchQuery}&teams[]=${this.currentTeam}`, '_self');
|
||||||
},
|
},
|
||||||
focusHistoryItem(event) {
|
focusHistoryItem(event) {
|
||||||
if (this.focusedHistoryItem === null && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
if (this.focusedHistoryItem === null && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
||||||
|
|
Loading…
Reference in a new issue