From 8aa676e0b7d7839a5bbbd3fac83179afc402f5f5 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Tue, 27 Oct 2020 11:14:09 +0100
Subject: [PATCH] FEAT #13271 TIME 0:15 remove global seach restriction

---
 .../criteria-tool.component.html              |  4 ++--
 .../criteria-tool/criteria-tool.component.ts  |  4 ----
 .../search-result-list.component.ts           | 22 +++----------------
 .../service/criteriaSearch.service.ts         |  4 ----
 4 files changed, 5 insertions(+), 29 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 605f92d2f5f..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 [disabled]="isLoadingResult || !hasCriteria()">
+        <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" [disabled]="isLoadingResult || !hasCriteria()">
+                <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 d1424356c5d..4371313f579 100644
--- a/src/frontend/app/search/criteria-tool/criteria-tool.component.ts
+++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.ts
@@ -706,8 +706,4 @@ export class CriteriaToolComponent implements OnInit {
             this.searchTermControl.setValue(searchTemplate.query[index].values);
         }
     }
-
-    hasCriteria() {
-        return this.currentCriteria.filter((item: any) => !this.functions.empty(item.control.value)).length > 0 || !this.functions.empty(this.searchTermControl.value);
-    }
 }
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 769c60536d9..d54b0aec1bb 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
@@ -265,18 +265,13 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
             this.dataFilters = {};
         }
         this.criteria = JSON.parse(JSON.stringify(criteria));
-        if (!this.initSearch && Object.keys(criteria).length > 0) {
-            console.log('initSearch');
+        if (!this.initSearch) {
             this.initResultList();
             this.initSearch = true;
-            this.appCriteriaTool.toggleTool(false);
-        } else if (Object.keys(criteria).length > 0) {
-            this.refreshDao();
-            this.appCriteriaTool.toggleTool(false);
         } else {
-            this.resetDao();
-            this.appCriteriaTool.toggleTool(true);
+            this.refreshDao();
         }
+        this.appCriteriaTool.toggleTool(false);
     }
 
     initResultList() {
@@ -420,17 +415,6 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
         this.toggleAllRes(e);
     }
 
-    resetDao() {
-        this.data = [];
-        this.criteriaSearchService.resetCriteria();
-        this.dataFilters = [];
-        this.resultsLength = 0;
-        this.paginatorLength = 0;
-        this.allResInBasket = [];
-        this.selectedRes = [];
-        this.sidenavRight.close();
-    }
-
     viewThumbnail(row: any) {
         if (row.hasDocument) {
             this.thumbnailUrl = '../rest/resources/' + row.resId + '/thumbnail';
diff --git a/src/frontend/service/criteriaSearch.service.ts b/src/frontend/service/criteriaSearch.service.ts
index 8eabf23a4f3..988b10090a7 100644
--- a/src/frontend/service/criteriaSearch.service.ts
+++ b/src/frontend/service/criteriaSearch.service.ts
@@ -79,10 +79,6 @@ export class CriteriaSearchService {
         sessionStorage.setItem('criteriaSearch_' + this.headerService.user.id, JSON.stringify(this.listsProperties));
     }
 
-    resetCriteria() {
-        sessionStorage.removeItem('criteriaSearch_' + this.headerService.user.id);
-    }
-
     getCriteria() {
         return this.listsProperties.criteria;
     }
-- 
GitLab