search modified

This commit is contained in:
Lucio Lelii 2023-03-21 16:21:39 +01:00
parent 4f87f755b3
commit c740663394
7 changed files with 41 additions and 23 deletions

View File

@ -20,12 +20,18 @@
</ion-back-button> </ion-back-button>
</ion-buttons> </ion-buttons>
<ion-title> {{ title }} </ion-title> <ion-title> {{ title }} </ion-title>
<ion-buttons *ngIf="parentItem" slot="end"> <ion-buttons slot="end">
<ion-button (click)="createFolder()"><mat-icon>create_new_folder</mat-icon></ion-button> <ion-button *ngIf="enableCreateOperations" (click)="createFolder()"><mat-icon>create_new_folder</mat-icon></ion-button>
<ion-button (click)="addFile()"><mat-icon>upload_file</mat-icon></ion-button> <ion-button *ngIf="enableCreateOperations" (click)="addFile()"><mat-icon>upload_file</mat-icon></ion-button>
<ion-button (click)="changeSearchEnabled()">
<mat-icon>manage_search</mat-icon>
</ion-button>
</ion-buttons> </ion-buttons>
<ion-progress-bar *ngIf="!filtereBySearchItems" type="indeterminate"></ion-progress-bar> <ion-progress-bar *ngIf="!filtereBySearchItems" type="indeterminate"></ion-progress-bar>
</ion-toolbar> </ion-toolbar>
<ion-searchbar *ngIf="searchenabled"
[disabled]="!filtereBySearchItems || (filtereBySearchItems.length == 0 && currentSearch.length==0)" [debounce]="500"
(ionClear)="searchCleared()" (ionChange)="searchItems($event)"></ion-searchbar>
<div> <div>
<ion-buttons slot="start"> <ion-buttons slot="start">
<ion-item> <ion-item>
@ -38,10 +44,6 @@
</ion-item> </ion-item>
<ion-button (click)="changeSortType()"><mat-icon>{{ currentSortType }}</mat-icon></ion-button> <ion-button (click)="changeSortType()"><mat-icon>{{ currentSortType }}</mat-icon></ion-button>
</ion-buttons> </ion-buttons>
<ion-buttons slot="end">
<ion-searchbar [disabled]="!filtereBySearchItems || (filtereBySearchItems.length == 0 && currentSearch.length==0)"
[debounce]="500" (ionClear)="searchCleared()" (ionChange)="searchItems($event)"></ion-searchbar>
</ion-buttons>
</div> </div>
<input hidden type="file" #filepicker (change)="fileSelected($event)" /> <input hidden type="file" #filepicker (change)="fileSelected($event)" />
<app-items-list [items]="filtereBySearchItems" [underUploadItem]="underUpload" <app-items-list [items]="filtereBySearchItems" [underUploadItem]="underUpload"

View File

@ -52,7 +52,9 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() root: boolean = false; @Input() root: boolean = false;
@Input() enableCreateOperations = false;
searchenabled = false;
selectedSegment = "all"; selectedSegment = "all";
@ -64,7 +66,7 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
currentSearch: string = ""; currentSearch: string = "";
@ViewChild('filepicker') uploader!: ElementRef; @ViewChild('filepicker') uploader!: ElementRef;
customSortAlertOptions = { customSortAlertOptions = {
header: 'Sort by', header: 'Sort by',
translucent: true, translucent: true,
@ -99,7 +101,7 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
this.backButtonSubscription = this.event.BackButtonEvent.subscribe(() => this.onbackButtonPressed()); this.backButtonSubscription = this.event.BackButtonEvent.subscribe(() => this.onbackButtonPressed());
} }
ngOnDestroy(): void { ngOnDestroy(): void {
var p: IonBackButtonDelegate var p: IonBackButtonDelegate
@ -123,7 +125,7 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
res.forEach(i => { res.forEach(i => {
var localItem = new WSItem(i); var localItem = new WSItem(i);
tmpItems$.push(localItem); tmpItems$.push(localItem);
if (segmentFilterFunction(localItem)){ if (segmentFilterFunction(localItem)) {
tmpFilteredBySegment$.push(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() { onbackButtonPressed() {
if (!this.root) { if (!this.root) {
console.log("back clicked (not root)"); console.log("back clicked (not root)");
@ -166,15 +174,15 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
filterBy(value: string) { filterBy(value: string) {
if (value == this.selectedSegment) return; if (value == this.selectedSegment) return;
this.filtereBySearchItems = undefined; this.filtereBySearchItems = undefined;
this.selectedSegment = value; this.selectedSegment = value;
if (this.selectedSegment == "all") if (this.selectedSegment == "all")
this.filtereBySearchItems = this._items; this.filteredBySegmentItems = this._items;
else else
this.filteredBySegmentItems = this._items?.filter(this.getSegmentFilterFunction()); this.filteredBySegmentItems = this._items?.filter(this.getSegmentFilterFunction());
if (this.currentSearch.length != 0) if (this.currentSearch.length != 0)
this.filtereBySearchItems = this.filteredBySegmentItems?.filter(d => d.getTitle().toLowerCase().indexOf(this.currentSearch) > -1); this.filtereBySearchItems = this.filteredBySegmentItems?.filter(d => d.getTitle().toLowerCase().indexOf(this.currentSearch) > -1);
else this.filtereBySearchItems = this.filteredBySegmentItems; else this.filtereBySearchItems = this.filteredBySegmentItems;
@ -197,13 +205,13 @@ export class ShowFolderComponent implements OnInit, OnDestroy, AfterViewInit {
updateSort() { updateSort() {
this._items = this._items?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType)); this._items = this._items?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
if (this.selectedSegment == "all") if (this.selectedSegment == "all")
this.filteredBySegmentItems = this._items; this.filteredBySegmentItems = this._items;
else else
this.filteredBySegmentItems = this.filteredBySegmentItems?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType)); 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)); this.filtereBySearchItems = this.filtereBySearchItems?.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
else this.filtereBySearchItems = this.filteredBySegmentItems; 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); this.filtereBySearchItems = this.filteredBySegmentItems?.filter(d => d.getTitle().toLowerCase().indexOf(query) > -1);
} }
searchCleared(){ searchCleared() {
this.currentSearch = ""; this.currentSearch = "";
this.filtereBySearchItems = this.filteredBySegmentItems this.filtereBySearchItems = this.filteredBySegmentItems
} }
itemClicked(item: WSItem) { itemClicked(item: WSItem) {

View File

@ -1,4 +1,4 @@
<ion-content [fullscreen]="true"> <ion-content [fullscreen]="true">
<show-folder title="Trash" [root]="true" [parentItem]="getCurrentItem()" [items]="getValues()"></show-folder> <show-folder title="Trash" [root]="true" [parentItem]="getCurrentItem()" [items]="getValues()"></show-folder>
</ion-content> </ion-content>

View File

@ -1,3 +1,3 @@
<ion-content [fullscreen]="true"> <ion-content [fullscreen]="true">
<show-folder [root]="root" [title]="getTitle()" [parentItem]="getCurrentItem()" [items]="getValues()" (folderClickedEvent)="openFolder($event)"></show-folder> <show-folder [root]="root" [title]="getTitle()" [parentItem]="getCurrentItem()" [items]="getValues()" [enableCreateOperations]="enableCreateOperations()" (folderClickedEvent)="openFolder($event)"></show-folder>
</ion-content> </ion-content>

View File

@ -27,6 +27,10 @@ export class VresPage implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private alertCtrl: AlertController) { } private alertCtrl: AlertController) { }
enableCreateOperations() : boolean {
return this.getCurrentItem() != undefined;
}
ngOnInit() { ngOnInit() {
var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined; var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined;

View File

@ -1,3 +1,3 @@
<ion-content [fullscreen]="true"> <ion-content [fullscreen]="true">
<show-folder [title]="getTitle()" [root]="root" [parentItem]="getCurrentItem()" [items]="getValues()" (folderClickedEvent)="openFolder($event)"></show-folder> <show-folder [title]="getTitle()" [root]="root" [parentItem]="getCurrentItem()" [items]="getValues()" [enableCreateOperations]="enableCreateOperations()" (folderClickedEvent)="openFolder($event)"></show-folder>
</ion-content> </ion-content>

View File

@ -92,4 +92,8 @@ export class WsPage implements OnInit {
return this.root ? "My Workspace" : this.item?.getTitle() return this.root ? "My Workspace" : this.item?.getTitle()
} }
enableCreateOperations() : boolean {
return this.getCurrentItem() != undefined;
}
} }