From d9a0057f8fb3e47ae11c156b3c48d423f04397b7 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 5 Sep 2022 16:54:24 +0200 Subject: [PATCH 01/11] Common search improvements --- .../src/components/Search/List.vue | 2 +- .../web-app-files/src/search/sdk/preview.ts | 5 +- .../web-app-search/src/portals/SearchBar.vue | 70 +++++++++++++------ 3 files changed, 53 insertions(+), 24 deletions(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index 3807536222c..fef1a959a34 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -102,7 +102,7 @@ export default defineComponent({ return this.searchResult.range }, rangeItems() { - return this.searchResult.range?.split('/')[1] + return parseInt(this.searchResult.range?.split('/')[1] || 0) }, searchResultExceedsLimit() { return !this.rangeSupported || (this.rangeItems && this.rangeItems > searchLimit) diff --git a/packages/web-app-files/src/search/sdk/preview.ts b/packages/web-app-files/src/search/sdk/preview.ts index 37f7b732d96..d32b1d7f0cc 100644 --- a/packages/web-app-files/src/search/sdk/preview.ts +++ b/packages/web-app-files/src/search/sdk/preview.ts @@ -9,6 +9,8 @@ import VueRouter from 'vue-router' import { DavProperties } from 'web-pkg/src/constants' import { Store } from 'vuex' +export const previewSearchLimit = 5 + export default class Preview implements SearchPreview { public readonly component: Component private readonly cache: Cache @@ -42,7 +44,7 @@ export default class Preview implements SearchPreview { const areHiddenFilesShown = this.store.state.Files?.areHiddenFilesShown const { range, results } = await clientService.owncloudSdk.files.search( term, - 5, // todo: add configuration option, other places need that too... needs consolidation + previewSearchLimit, // todo: add configuration option, other places need that too... needs consolidation DavProperties.Default ) const resources = results.reduce((acc, plainResource) => { @@ -59,7 +61,6 @@ export default class Preview implements SearchPreview { return acc }, []) - return this.cache.set(term, { range, values: resources }) } diff --git a/packages/web-app-search/src/portals/SearchBar.vue b/packages/web-app-search/src/portals/SearchBar.vue index b37053186ed..ccc7d64288e 100644 --- a/packages/web-app-search/src/portals/SearchBar.vue +++ b/packages/web-app-search/src/portals/SearchBar.vue @@ -49,6 +49,12 @@ :search-result="searchResultValue" /> +
  • +
  • {{ moreText }}
  • @@ -78,6 +84,29 @@ export default { }, computed: { + rangeSupported() { + return this.searchResult.range + }, + + rangeItems() { + return parseInt(this.searchResult.range?.split('/')[1]) + }, + + hasMore() { + return this.rangeSupported && this.rangeItems > this.searchResult.values.length + }, + + moreText() { + const moreCount = this.rangeItems - this.searchResult.values.length + return this.$gettextInterpolate(this.$gettext('%{moreCount} more items'), { + moreCount + }) + }, + + showNoMatches() { + return this.searchResult?.values?.length === 0 + }, + availableProviders() { return this.providerStore.availableProviders }, @@ -88,27 +117,26 @@ export default { }, watch: { - $route() { - if (this.activeProvider && !this.activeProvider.available) { - this.activeProvider = undefined - } - } - }, - - mounted() { - if (!this.availableProviders.length) { - return - } - - const input = this.$el.getElementsByTagName('input')[0] - const routeTerm = get(this, '$route.query.term') - - if (!input || !routeTerm) { - return + $route: { + handler(r, o) { + if (!!o && this.activeProvider && !this.activeProvider.available) { + this.activeProvider = undefined + } + this.$nextTick(() => { + if (!this.availableProviders.length) { + return + } + const routeTerm = get(r, 'query.term') + const input = this.$el.getElementsByTagName('input')[0] + if (!input || !routeTerm) { + return + } + this.term = routeTerm + input.value = routeTerm + }) + }, + immediate: true } - - this.term = routeTerm - input.value = routeTerm }, asyncComputed: { @@ -153,6 +181,7 @@ export default { resetProvider() { this.optionsVisible = false this.availableProviders.forEach((provider) => provider.reset()) + this.$router.go(-1) }, activateProvider(provider) { this.optionsVisible = false @@ -301,7 +330,6 @@ export default { li { padding: 15px 10px; - cursor: pointer; position: relative; font-size: var(--oc-font-size-small); From 53f31f93f6e7aacbaefeb3fdd86485b8ba2ced30 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 5 Sep 2022 16:56:13 +0200 Subject: [PATCH 02/11] Improve --- packages/web-app-search/src/portals/SearchBar.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/web-app-search/src/portals/SearchBar.vue b/packages/web-app-search/src/portals/SearchBar.vue index ccc7d64288e..9a300f99ee2 100644 --- a/packages/web-app-search/src/portals/SearchBar.vue +++ b/packages/web-app-search/src/portals/SearchBar.vue @@ -49,11 +49,7 @@ :search-result="searchResultValue" /> -
  • +
  • No matches
  • {{ moreText }}
  • @@ -89,7 +85,7 @@ export default { }, rangeItems() { - return parseInt(this.searchResult.range?.split('/')[1]) + return parseInt(this.searchResult.range?.split('/')[1] || 0) }, hasMore() { From 2b27787c02ccf77efabccf7d84678bcb77db7ab7 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 5 Sep 2022 17:00:57 +0200 Subject: [PATCH 03/11] Fix --- packages/web-app-search/src/portals/SearchBar.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/web-app-search/src/portals/SearchBar.vue b/packages/web-app-search/src/portals/SearchBar.vue index 9a300f99ee2..2cb2d9ccdc1 100644 --- a/packages/web-app-search/src/portals/SearchBar.vue +++ b/packages/web-app-search/src/portals/SearchBar.vue @@ -49,7 +49,11 @@ :search-result="searchResultValue" /> -
  • No matches
  • +
  • {{ moreText }}
  • From 7a172a826d2966d2c930dbcb2453b0345f04dd8c Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 5 Sep 2022 17:54:18 +0200 Subject: [PATCH 04/11] Fix scrolling --- .../src/components/Search/List.vue | 99 ++++++++++--------- packages/web-app-search/src/views/List.vue | 8 +- 2 files changed, 56 insertions(+), 51 deletions(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index fef1a959a34..8f200b0e1a2 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -1,47 +1,49 @@ @@ -65,11 +67,20 @@ import MixinFilesListScrolling from '../../mixins/filesListScrolling' import { searchLimit } from '../../search/sdk/list' import { Resource } from 'web-client' import { useStore } from 'web-pkg/src/composables' +import FilesViewWrapper from '../FilesViewWrapper.vue' const visibilityObserver = new VisibilityObserver() export default defineComponent({ - components: { AppBar, ContextActions, ListInfo, Pagination, NoContentMessage, ResourceTable }, + components: { + AppBar, + ContextActions, + ListInfo, + Pagination, + NoContentMessage, + ResourceTable, + FilesViewWrapper + }, mixins: [MixinFileActions, MixinFilesListFilter, MixinFilesListScrolling], props: { searchResult: { diff --git a/packages/web-app-search/src/views/List.vue b/packages/web-app-search/src/views/List.vue index 11ff374c811..daf33e0b8ca 100644 --- a/packages/web-app-search/src/views/List.vue +++ b/packages/web-app-search/src/views/List.vue @@ -1,5 +1,5 @@