From c740663394459866b45be0d7d2825aac8a7dd6f4 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Tue, 21 Mar 2023 16:21:39 +0100 Subject: [PATCH] search modified --- .../show-folder/show-folder.component.html | 16 +++++---- src/app/show-folder/show-folder.component.ts | 34 ++++++++++++------- src/app/trash/trash.page.html | 2 +- src/app/vres/vres.page.html | 2 +- src/app/vres/vres.page.ts | 4 +++ src/app/ws/ws.page.html | 2 +- src/app/ws/ws.page.ts | 4 +++ 7 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/app/show-folder/show-folder.component.html b/src/app/show-folder/show-folder.component.html index 4e2b8f0..dfb8af2 100644 --- a/src/app/show-folder/show-folder.component.html +++ b/src/app/show-folder/show-folder.component.html @@ -20,12 +20,18 @@ {{ title }} - - create_new_folder - upload_file + + create_new_folder + upload_file + + manage_search + +
@@ -38,10 +44,6 @@ {{ currentSortType }} - - -
this.onbackButtonPressed()); } - + ngOnDestroy(): void { var p: IonBackButtonDelegate @@ -123,7 +125,7 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit { res.forEach(i => { var localItem = new WSItem(i); tmpItems$.push(localItem); - if (segmentFilterFunction(localItem)){ + if (segmentFilterFunction(localItem)) { tmpFilteredBySegment$.push(localItem); } }); @@ -138,6 +140,12 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit { } } + changeSearchEnabled() { + this.searchenabled = !this.searchenabled; + if (!this.searchenabled) + this.searchCleared() + } + onbackButtonPressed() { if (!this.root) { console.log("back clicked (not root)"); @@ -166,15 +174,15 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit { filterBy(value: string) { if (value == this.selectedSegment) return; - + this.filtereBySearchItems = undefined; this.selectedSegment = value; - + if (this.selectedSegment == "all") - this.filtereBySearchItems = this._items; - else + this.filteredBySegmentItems = this._items; + else this.filteredBySegmentItems = this._items?.filter(this.getSegmentFilterFunction()); - + if (this.currentSearch.length != 0) this.filtereBySearchItems = this.filteredBySegmentItems?.filter(d => d.getTitle().toLowerCase().indexOf(this.currentSearch) > -1); else this.filtereBySearchItems = this.filteredBySegmentItems; @@ -197,13 +205,13 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit { updateSort() { this._items = this._items?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType)); - + if (this.selectedSegment == "all") this.filteredBySegmentItems = this._items; else this.filteredBySegmentItems = this.filteredBySegmentItems?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType)); - - if (this.currentSearch.length!=0 ) + + if (this.currentSearch.length != 0) this.filtereBySearchItems = this.filtereBySearchItems?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType)); else this.filtereBySearchItems = this.filteredBySegmentItems; } @@ -214,9 +222,9 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit { this.filtereBySearchItems = this.filteredBySegmentItems?.filter(d => d.getTitle().toLowerCase().indexOf(query) > -1); } - searchCleared(){ + searchCleared() { this.currentSearch = ""; - this.filtereBySearchItems = this.filteredBySegmentItems + this.filtereBySearchItems = this.filteredBySegmentItems } itemClicked(item: WSItem) { diff --git a/src/app/trash/trash.page.html b/src/app/trash/trash.page.html index ce7f7c0..dfca5a2 100644 --- a/src/app/trash/trash.page.html +++ b/src/app/trash/trash.page.html @@ -1,4 +1,4 @@ - + diff --git a/src/app/vres/vres.page.html b/src/app/vres/vres.page.html index f3817f7..cb6a3fc 100644 --- a/src/app/vres/vres.page.html +++ b/src/app/vres/vres.page.html @@ -1,3 +1,3 @@ - + diff --git a/src/app/vres/vres.page.ts b/src/app/vres/vres.page.ts index c4c674e..b9563af 100644 --- a/src/app/vres/vres.page.ts +++ b/src/app/vres/vres.page.ts @@ -27,6 +27,10 @@ export class VresPage implements OnInit { private route: ActivatedRoute, private alertCtrl: AlertController) { } + + enableCreateOperations() : boolean { + return this.getCurrentItem() != undefined; + } ngOnInit() { var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined; diff --git a/src/app/ws/ws.page.html b/src/app/ws/ws.page.html index cae9aa5..7e5d0be 100644 --- a/src/app/ws/ws.page.html +++ b/src/app/ws/ws.page.html @@ -1,3 +1,3 @@ - + diff --git a/src/app/ws/ws.page.ts b/src/app/ws/ws.page.ts index 639c8c9..a1a3d57 100644 --- a/src/app/ws/ws.page.ts +++ b/src/app/ws/ws.page.ts @@ -92,4 +92,8 @@ export class WsPage implements OnInit { return this.root ? "My Workspace" : this.item?.getTitle() } + enableCreateOperations() : boolean { + return this.getCurrentItem() != undefined; + } + }