From 7f54f6ce0687c0ad7209253d2e9b8fea6ec61e5b Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Tue, 13 Oct 2020 15:13:56 +0200 Subject: [PATCH] FEAT #13271 TIME 0:40 fix some issues --- .../criteria-tool.component.html | 4 +-- .../criteria-tool/criteria-tool.component.ts | 1 + .../search-result-list.component.html | 8 ++--- .../search-result-list.component.ts | 33 +++++++++++-------- src/frontend/app/search/search.component.html | 4 +-- src/frontend/app/search/search.component.ts | 1 + 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/frontend/app/search/criteria-tool/criteria-tool.component.html b/src/frontend/app/search/criteria-tool/criteria-tool.component.html index 532a5388c6f..698fd27cc05 100644 --- a/src/frontend/app/search/criteria-tool/criteria-tool.component.html +++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.html @@ -2,7 +2,7 @@ <mat-form-field *ngIf="!adminMode" floatLabel="never" class="basket-search"> <input class="metaSearch" type="text" matInput [formControl]="searchTermControl" [placeholder]="'lang.quickSearchTarget' |Â translate"> - <button mat-icon-button matPrefix> + <button mat-icon-button matPrefix [disabled]="isLoadingResult"> <mat-icon class="fas fa-search"></mat-icon> </button> </mat-form-field> @@ -238,7 +238,7 @@ <mat-spinner class="loader"></mat-spinner> </ng-template> <div *ngIf="!adminMode" class="col-md-12" style="text-align: center;"> - <button mat-raised-button matSuffix color="primary" type="submit"> + <button mat-raised-button matSuffix color="primary" type="submit" [disabled]="isLoadingResult"> <mat-icon class="fa fa-search" style="height: auto;font-size: 24px;"></mat-icon> {{'lang.searchMails' | translate}} </button> </div> diff --git a/src/frontend/app/search/criteria-tool/criteria-tool.component.ts b/src/frontend/app/search/criteria-tool/criteria-tool.component.ts index bd688077acd..fad842abc8b 100644 --- a/src/frontend/app/search/criteria-tool/criteria-tool.component.ts +++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.ts @@ -60,6 +60,7 @@ export class CriteriaToolComponent implements OnInit { @Input() defaultCriteria: any = []; @Input() adminMode: boolean = false; @Input() openedPanel: boolean = false; + @Input() isLoadingResult: boolean = false; @Input() class: 'main' | 'secondary' = 'main'; @Output() searchUrlGenerated = new EventEmitter<any>(); diff --git a/src/frontend/app/search/result-list/search-result-list.component.html b/src/frontend/app/search/result-list/search-result-list.component.html index a0c6085b11d..1901e408519 100644 --- a/src/frontend/app/search/result-list/search-result-list.component.html +++ b/src/frontend/app/search/result-list/search-result-list.component.html @@ -2,15 +2,15 @@ <img style="max-height: 100vh;" *ngIf="thumbnailUrl !== ''" [src]="thumbnailUrl | secureUrl | async" /> </mat-card> <ng-template #filterTemplate> - <app-filter-tool-adv-search #appFilterToolAdvSearch [filters]="dataFilters" (filterChanged)="launchSearch()" *ngIf="!hideFilter"></app-filter-tool-adv-search> + <app-filter-tool-adv-search #appFilterToolAdvSearch [filters]="dataFilters" (filterChanged)="launchSearch()" *ngIf="!hideFilter && !isLoadingResults"></app-filter-tool-adv-search> </ng-template> <ng-template #toolTemplate> - <div *ngIf="initSearch" class="filtersContent"> + <div *ngIf="data.length > 0" class="filtersContent"> <div style="flex: 1"></div> <div class="orderTool"> <mat-form-field class="basket-order"> <mat-icon matPrefix class="fa fa-list"></mat-icon> - <mat-select [(ngModel)]="this.listProperties.order" (selectionChange)="updateFilters()"> + <mat-select [(ngModel)]="this.listProperties.order" (selectionChange)="updateFilters()" [disabled]="isLoadingResults"> <mat-option [value]="column.id" *ngFor="let column of displayColsOrder"> {{'lang.' + column.id | translate}} </mat-option> @@ -18,7 +18,7 @@ </mat-form-field> </div> <div class="ascDescTool"> - <button [disabled]="this.listProperties.order == ''" + <button [disabled]="this.listProperties.order == '' || isLoadingResults" [style.opacity]="this.listProperties.order == '' ? '0.2' : '1'" mat-fab [title]="this.listProperties.orderDir == 'DESC' ? this.translate.instant('lang.descOrder') : this.translate.instant('lang.ascOrder')" style="color: rgba(0,0,0,0.38);" (click)="changeOrderDir();"> diff --git a/src/frontend/app/search/result-list/search-result-list.component.ts b/src/frontend/app/search/result-list/search-result-list.component.ts index 603bc6c9711..365ea26d89e 100644 --- a/src/frontend/app/search/result-list/search-result-list.component.ts +++ b/src/frontend/app/search/result-list/search-result-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, EventEmitter, ViewContainerRef, OnDestroy, TemplateRef, Input } from '@angular/core'; +import { Component, OnInit, ViewChild, EventEmitter, ViewContainerRef, OnDestroy, TemplateRef, Input, Output } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { TranslateService } from '@ngx-translate/core'; import { NotificationService } from '@service/notification/notification.service'; @@ -43,6 +43,8 @@ export class SearchResultListComponent implements OnInit, OnDestroy { @Input() appCriteriaTool: CriteriaToolComponent; @Input() sidenavRight: MatSidenav; + @Output() loadingResult = new EventEmitter<boolean>(); + loading: boolean = true; initSearch: boolean = false; docUrl: string = ''; @@ -82,7 +84,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { resultListDatabase: ResultListHttpDao | null; data: any = []; resultsLength = 0; - isLoadingResults = true; + isLoadingResults = false; dataFilters: any = {}; listProperties: any = {}; currentChrono: string = ''; @@ -283,6 +285,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { if (!this.isLoadingResults) { this.sidenavRight.close(); this.isLoadingResults = true; + this.loadingResult.emit(true); return this.resultListDatabase!.getRepoIssues( this.sort.active, this.sort.direction, this.paginator.pageIndex, this.searchUrl, this.listProperties, this.paginator.pageSize, this.criteria, this.dataFilters); } @@ -291,6 +294,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { this.selectedRes = []; // Flip flag to show that loading has finished. this.isLoadingResults = false; + this.loadingResult.emit(false); data = this.processPostData(data); this.templateColumns = data.templateColumns; this.dataFilters = data.filters; @@ -307,6 +311,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { this.dataFilters = {}; this.allResInBasket = []; this.isLoadingResults = false; + this.loadingResult.emit(false); this.initSearch = false; return of(false); }) @@ -688,20 +693,22 @@ export class SearchResultListComponent implements OnInit, OnDestroy { } removeCriteria(identifier: string, value: any = null) { - if (identifier !== '_ALL') { - const tmpArrCrit = []; - if (value === null || this.criteria[identifier].values.length === 1) { - this.criteria[identifier].values = []; + if (!this.isLoadingResults)Â { + if (identifier !== '_ALL') { + const tmpArrCrit = []; + if (value === null || this.criteria[identifier].values.length === 1) { + this.criteria[identifier].values = []; + } else { + const indexArr = this.criteria[identifier].values.indexOf(value); + this.criteria[identifier].values.splice(indexArr, 1); + } } else { - const indexArr = this.criteria[identifier].values.indexOf(value); - this.criteria[identifier].values.splice(indexArr, 1); + Object.keys(this.criteria).forEach(key => { + this.criteria[key].values = []; + }); } - } else { - Object.keys(this.criteria).forEach(key => { - this.criteria[key].values = []; - }); + this.appCriteriaTool.refreshCriteria(this.criteria); } - this.appCriteriaTool.refreshCriteria(this.criteria); } updateFilters() { diff --git a/src/frontend/app/search/search.component.html b/src/frontend/app/search/search.component.html index 56710b47bea..6fdfc00ea6c 100644 --- a/src/frontend/app/search/search.component.html +++ b/src/frontend/app/search/search.component.html @@ -13,14 +13,14 @@ </div> </div> <div class="bg-head-content" [class.fullContainer]="appService.getViewMode()"> - <app-criteria-tool #appCriteriaTool (searchUrlGenerated)="appSearchResultList.launchSearch($event, true);" + <app-criteria-tool #appCriteriaTool [isLoadingResult]="loadingResult" (searchUrlGenerated)="appSearchResultList.launchSearch($event, true);" style="width:100%;padding-bottom: 10px;" (loaded)="appSearchResultList.initSavedCriteria()"></app-criteria-tool> <div id="toolTemplate" style="width: 100%;"></div> </div> </div> <div class="container" [class.fullContainer]="appService.getViewMode()"> <div class="container-content"> - <app-search-result-list #appSearchResultList [searchTerm]="searchTerm" [appCriteriaTool]="appCriteriaTool" [sidenavRight]="sidenavRight"></app-search-result-list> + <app-search-result-list #appSearchResultList [searchTerm]="searchTerm" [appCriteriaTool]="appCriteriaTool" [sidenavRight]="sidenavRight" (loadingResult)="loadingResult=$event"></app-search-result-list> </div> </div> </mat-sidenav-content> diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts index c2238f9226a..f538791b715 100644 --- a/src/frontend/app/search/search.component.ts +++ b/src/frontend/app/search/search.component.ts @@ -21,6 +21,7 @@ export class SearchComponent implements OnInit { filtersChange = new EventEmitter(); dialogRef: MatDialogRef<any>; + loadingResult: boolean = false; @ViewChild('snav2', { static: true }) sidenavRight: MatSidenav; -- GitLab