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 698fd27cc05897de31827b7116dc936a5652b067..4f0cbdab0b3a16aee2ef8966f7575fcfe8d1e82e 100644 --- a/src/frontend/app/search/criteria-tool/criteria-tool.component.html +++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.html @@ -6,41 +6,13 @@ <mat-icon class="fas fa-search"></mat-icon> </button> </mat-form-field> - <mat-accordion [class.criteria-container]="class==='main'" [class.criteria-container-secondary]="class==='secondary'"> + <mat-accordion [class.criteria-container]="class==='main'" + [class.criteria-container-secondary]="class==='secondary'"> <mat-expansion-panel #criteriaTool [expanded]="openedPanel" togglePosition="before"> <mat-expansion-panel-header> <mat-panel-title> <span> {{'lang.criteriaSearch' | translate}} - <button type="button" mat-icon-button [matMenuTriggerFor]="menu" (menuOpened)="focusFilter()" - (click)="$event.stopPropagation()" [title]="'lang.displayCriteria' | translate"> - <mat-icon class="fa fa-plus"></mat-icon> - </button> - <mat-menu #menu="matMenu" class="searchTemplateMenu"> - <div class="menuTitle" - style="position: sticky;top: 0px;background: white;z-index: 1;display: flex;justify-content: center;"> - <span> - {{'lang.criteria' | translate}} - </span> - <mat-form-field floatLabel="never" appearance="outline" class="smallInput" - (click)="$event.stopPropagation();" - style="width: 220px !important; padding-top: 10px;"> - <input matInput id="searchTerm" #searchCriteriaInput - [formControl]="getFilterControl()" placeholder="{{'lang.filterBy' | translate}}" - autocomplete="off" (click)="$event.stopPropagation();" - (keydown)="$event.stopPropagation()"> - </mat-form-field> - </div> - <button mat-menu-item *ngIf="(getFilteredCriterias() | async)?.length===0" - disabled>{{'lang.noResult' | translate}}</button> - <button mat-menu-item - *ngFor="let item of getFilteredCriterias() | async |Â sortBy : 'label'" - (click)="addCriteria(item);$event.stopPropagation()" - [disabled]="isCurrentCriteriaById(item.identifier)"> - <i class="fa {{item.icon}}" color="primary" - style="font-size:14px;width:50px;text-align:center;"></i> {{item.label}} - </button> - </mat-menu> </span> <span style="background: white;height: 1px;flex: 1;margin-left: 10px;"></span> </mat-panel-title> @@ -77,7 +49,8 @@ </ng-container> <div class="saveSearchTemplate"> <mat-divider></mat-divider> - <button mat-menu-item (click)="saveSearchTemplate()" style="display: flex;align-items: center;" + <button mat-menu-item (click)="saveSearchTemplate()" + style="display: flex;align-items: center;" [disabled]="functions.empty(currentCriteria) && functions.empty(searchTermControl.value)"> <mat-icon class="fa fa-copy" color="primary" style="line-height: 21px;"></mat-icon> <div style="flex:1;"> @@ -88,8 +61,35 @@ </mat-menu> </mat-panel-description> </mat-expansion-panel-header> + <button type="button" mat-stroked-button [matMenuTriggerFor]="menu" (menuOpened)="focusFilter()" + (click)="$event.stopPropagation()" [title]="'lang.displayCriteria' | translate" class="addCriteriaButton"> + <mat-icon class="fa fa-plus" style="height:auto;"></mat-icon> {{'lang.addCriteria' | translate}} + </button> + <mat-menu #menu="matMenu" class="searchTemplateMenu"> + <div class="menuTitle" + style="position: sticky;top: 0px;background: white;z-index: 1;display: flex;justify-content: center;"> + <span> + {{'lang.criteria' | translate}} + </span> + <mat-form-field floatLabel="never" appearance="outline" class="smallInput" + (click)="$event.stopPropagation();" style="width: 220px !important; padding-top: 10px;"> + <input matInput id="searchTerm" #searchCriteriaInput [formControl]="getFilterControl()" + placeholder="{{'lang.filterBy' | translate}}" autocomplete="off" + (click)="$event.stopPropagation();" (keydown)="$event.stopPropagation()"> + </mat-form-field> + </div> + <button mat-menu-item *ngIf="(getFilteredCriterias() | async)?.length===0" + disabled>{{'lang.noResult' | translate}}</button> + <button mat-menu-item *ngFor="let item of getFilteredCriterias() | async |Â sortBy : 'label'" + (click)="addCriteria(item);$event.stopPropagation()" + [disabled]="isCurrentCriteriaById(item.identifier)"> + <i class="fa {{item.icon}}" color="primary" + style="font-size:14px;width:50px;text-align:center;"></i> {{item.label}} + </button> + </mat-menu> <ng-container *ngIf="!loading; else loadingTemplate"> - <div [class.criteria-content]="!appService.getViewMode()" [class.criteria-content-mobile]="appService.getViewMode()"> + <div [class.criteria-content]="!appService.getViewMode()" + [class.criteria-content-mobile]="appService.getViewMode()"> <div style="display: grid;align-items: baseline;grid-template-columns: 35% 60% 5%;padding:5px;" *ngFor="let field of currentCriteria;let i=index"> <ng-container *ngIf="field.type === 'string'"> @@ -147,10 +147,10 @@ </ng-container> : </span> <plugin-select-autocomplete-search #pluginSelectAutocompleteSearch [id]="field.identifier" - [showResetOption]="true" - [placeholderLabel]="'lang.chooseValue' | translate" [formControlSelect]="field.control" - [datas]="field.values" [routeDatas]="field.routeDatas" [extraModel]="['type']" - [multiple]="true" [returnValue]="field.returnValue" style="width:100%;"> + [showResetOption]="true" [placeholderLabel]="'lang.chooseValue' | translate" + [formControlSelect]="field.control" [datas]="field.values" + [routeDatas]="field.routeDatas" [extraModel]="['type']" [multiple]="true" + [returnValue]="field.returnValue" style="width:100%;"> </plugin-select-autocomplete-search> </ng-container> <ng-container *ngIf="field.type === 'date'"> @@ -239,7 +239,8 @@ </ng-template> <div *ngIf="!adminMode" class="col-md-12" style="text-align: center;"> <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}} + <mat-icon class="fa fa-search" style="height: auto;font-size: 24px;"></mat-icon> + {{'lang.searchMails' | translate}} </button> </div> </mat-expansion-panel> diff --git a/src/frontend/app/search/criteria-tool/criteria-tool.component.scss b/src/frontend/app/search/criteria-tool/criteria-tool.component.scss index 4854062c883dcd667174a76b209a7e95804ea73c..51201aee1c5d42110d587dc28b49a0e97f7254b1 100644 --- a/src/frontend/app/search/criteria-tool/criteria-tool.component.scss +++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.scss @@ -213,4 +213,10 @@ position: sticky; bottom: 0px; background-color: white; +} + +.addCriteriaButton { + border-radius: 20px; + border-color: #135F7F; + color: #135F7F; } \ No newline at end of file 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 7a074dbf8bd55aca0a5ba145086b6ebfec81c0a5..c862809fceb09ffb19d560f9f929061acd61f739 100644 --- a/src/frontend/app/search/criteria-tool/criteria-tool.component.ts +++ b/src/frontend/app/search/criteria-tool/criteria-tool.component.ts @@ -218,7 +218,7 @@ export class CriteriaToolComponent implements OnInit { if (field.type === 'date' || field.type === 'integer') { if (!this.functions.empty(field.control.value.start) || !this.functions.empty(field.control.value.end)) { objCriteria[field.identifier] = { - type : field.type, + type: field.type, values: { start: !this.functions.empty(field.control.value.start) ? field.control.value.start : null, end: !this.functions.empty(field.control.value.end) ? field.control.value.end : null @@ -228,14 +228,14 @@ export class CriteriaToolComponent implements OnInit { } else { if (!this.functions.empty(field.control.value)) { objCriteria[field.identifier] = { - type : field.type, + type: field.type, values: field.control.value }; } else { if (['recipients', 'senders'].indexOf(field.identifier) > -1 || field.type === 'contact') { if (!this.functions.empty(this.appContactAutocomplete.toArray().filter((component: any) => component.id === field.identifier)[0].getInputValue())) { objCriteria[field.identifier] = { - type : field.type, + type: field.type, values: [this.appContactAutocomplete.toArray().filter((component: any) => component.id === field.identifier)[0].getInputValue()] }; } @@ -298,28 +298,40 @@ export class CriteriaToolComponent implements OnInit { } } - refreshCriteria(criteria: any) { + resetAllCriteria() { this.currentCriteria.forEach((field: any, index: number) => { - if (criteria[field.identifier] !== undefined) { - if (this.currentCriteria[index].type === 'date' && this.functions.empty(criteria[field.identifier].values)) { - field.control.setValue({ + this.resetCriteria(field.identifier, false); + }); + + this.resetCriteria('meta', false); + + this.getCurrentCriteriaValues(); + } + + resetCriteria(criteriaId: string, refresh: boolean = true) { + if (criteriaId !== 'meta') { + const criteria = this.currentCriteria.filter((item: any) => item.identifier === criteriaId)[0]; + + if (criteria !== undefined) { + if (criteria.type === 'date' && this.functions.empty(criteria.values)) { + criteria.control.setValue({ start: null, end: null }); } else { - field.control.setValue(criteria[field.identifier].values); + criteria.control.setValue([]); } - } - if ((['recipients', 'senders'].indexOf(field.identifier) > -1 || field.type === 'contact') && this.functions.empty(criteria[field.identifier].values)) { - this.appContactAutocomplete.toArray().filter((component: any) => component.id === field.identifier)[0].resetInputValue(); + if ((['recipients', 'senders'].indexOf(criteria.identifier) > -1 || criteria.type === 'contact') && this.functions.empty(criteria.values)) { + this.appContactAutocomplete.toArray().filter((component: any) => component.id === criteria.identifier)[0].resetInputValue(); + } } - }); - - if (Object.keys(criteria)[0] === 'meta') { - this.searchTermControl.setValue(criteria['meta'].values); + } else { + this.searchTermControl.setValue(''); + } + if (refresh) { + this.getCurrentCriteriaValues(); } - this.getCurrentCriteriaValues(); } searchInAttachments(identifier: string) { 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 f73e783063b698529810bb0baca26e10ba6c4e74..43cf78d942d1d6591490966e6db378bb95b56918 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 @@ -711,8 +711,6 @@ export class SearchResultListComponent implements OnInit, OnDestroy { removeCriteria(identifier: string, value: any = null) { if (!this.isLoadingResults) { - console.log('removeCrit'); - this.appCriteriaTool.toggleTool(true); if (identifier !== '_ALL') { const tmpArrCrit = []; @@ -722,12 +720,13 @@ export class SearchResultListComponent implements OnInit, OnDestroy { const indexArr = this.criteria[identifier].values.indexOf(value); this.criteria[identifier].values.splice(indexArr, 1); } + this.appCriteriaTool.resetCriteria(identifier); } else { Object.keys(this.criteria).forEach(key => { this.criteria[key].values = []; }); + this.appCriteriaTool.resetAllCriteria(); } - this.appCriteriaTool.refreshCriteria(this.criteria); } }