Skip to content
Snippets Groups Projects
Commit 5658b44f authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #21462 TIME 2:45 WIP: add sender and recipient to quick search

parent 95f77215
No related branches found
No related tags found
No related merge requests found
<div class="bg-head-title-tool">
<form *ngIf="hideSearchBar()" (ngSubmit)="goTo()" #criteriaFormUp="ngForm">
<div class="bg-head-title-tool" style="margin-right: 40px;">
<form *ngIf="hideSearchBar()" (ngSubmit)="goTo()" #criteriaFormUp="ngForm" style="margin-right: 10px; width: 100%">
<mat-form-field floatLabel="never" class="basket-search">
<button mat-icon-button style="margin-right: 10px;" type="submit" matSuffix [title]="'lang.quickSearchTarget' | translate">
<mat-icon class="fas fa-search"></mat-icon>
</button>
<input class="metaSearch" type="text" matInput
[placeholder]="'lang.searchMails' | translate" name="searchTarget" [(ngModel)]="searchTarget">
<button mat-icon-button type="submit" matPrefix [title]="'lang.quickSearchTarget' | translate">
<mat-icon class="fas fa-search"></mat-icon>
<button type="button" mat-icon-button matPrefix [matMenuTriggerFor]="target" *ngIf="!appService.getViewMode()" [title]="'lang.quickSearchTargets' | translate">
<mat-icon class="fa fa-chevron-down" style="font-size: 15px; margin-bottom: 2px;"></mat-icon>
</button>
<mat-menu #target="matMenu" class="headerMaarchShortcut">
<ng-container *ngFor="let target of quickSearchTargets">
<button type="button" (click)="selectedQuickSearchTarget = target.id" style="white-space:inherit;height: 100px;line-height:20px;"
class="col-md-4 col-xs-6" [class.isSelected]="target.id === selectedQuickSearchTarget" mat-button color="primary">
<mat-icon [class]="target.icon" style="margin-bottom: 5px;"></mat-icon>
<br />{{target.label | translate}}
</button>
</ng-container>
</mat-menu>
</mat-form-field>
</form>
......
......@@ -65,4 +65,8 @@
font-size: 25px;
position: absolute;
cursor: pointer;
}
.isSelected {
color: var(--maarch-color-secondary-dark);
}
\ No newline at end of file
......@@ -30,6 +30,26 @@ export class HeaderRightComponent implements OnInit {
@ViewChild('searchInput', { static: false }) searchInput: MatInput;
quickSearchTargets: any[] = [
{
id: 'default',
label: this.translate.instant('lang.defaultQuickSearch'),
icon: 'fas fa-inbox fa-2x',
},
{
id: 'recipients',
label: this.translate.instant('lang.recipient'),
icon: 'fas fa-user fa-2x',
},
{
id: 'senders',
label: this.translate.instant('lang.sender'),
icon: 'fas fa-address-book fa-2x',
}
];
selectedQuickSearchTarget: string = 'default';
constructor(
public translate: TranslateService,
public http: HttpClient,
......@@ -89,7 +109,7 @@ export class HeaderRightComponent implements OnInit {
}
goTo() {
this.router.navigate(['/search'], { queryParams: { value: this.searchTarget } });
this.router.navigate(['/search'], { queryParams: { target: this.selectedQuickSearchTarget, value: this.searchTarget } });
}
openAboutModal() {
......
import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output, Input, QueryList, ViewChildren } from '@angular/core';
import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output, Input, QueryList, ViewChildren, OnDestroy } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { AppService } from '@service/app.service';
......@@ -32,7 +32,7 @@ import { HeaderService } from '@service/header.service';
})
export class CriteriaToolComponent implements OnInit {
@Input() searchTerm: string = 'Foo';
@Input() searchTerm: string = '';
@Input() defaultCriteria: any = [];
@Input() adminMode: boolean = false;
@Input() openedPanel: boolean = true;
......@@ -65,6 +65,8 @@ export class CriteriaToolComponent implements OnInit {
searchTermControl = new FormControl();
searchCriteria = new FormControl();
currentParam: any = null;
infoFields: any = [
{
id: 1,
......@@ -112,7 +114,13 @@ export class CriteriaToolComponent implements OnInit {
) {
_activatedRoute.queryParams.subscribe(
params => {
this.searchTerm = params.value;
if (params.target === 'default') {
this.searchTerm = params.value;
} else {
this.currentParam = params;
this.searchTerm = '';
this.searchTermControl.setValue(this.searchTerm);
}
}
);
}
......@@ -120,7 +128,6 @@ export class CriteriaToolComponent implements OnInit {
async ngOnInit(): Promise<void> {
this.searchTermControl.setValue(this.searchTerm);
this.listProperties = this.criteriaSearchService.initListsProperties(this.headerService.user.id);
this.criteria = await this.indexingFields.getAllSearchFields();
this.criteria.forEach((element: any) => {
......@@ -153,6 +160,15 @@ export class CriteriaToolComponent implements OnInit {
if (!this.adminMode) {
this.getSearchTemplates();
}
if (['senders', 'recipients'].indexOf(this.currentParam?.target)) {
console.log(this.currentParam);
if (this.currentParam.target === 'senders') {
this.listProperties.criteria = {senders: {type: 'autocomplete', values: [this.currentParam.value]}};
} else {
this.listProperties.criteria = {recipients: {type: 'contact', values: [this.currentParam.value]}};
}
this.updateFilters();
}
}
isCurrentCriteriaById(criteriaIds: string[]) {
......@@ -720,7 +736,7 @@ export class CriteriaToolComponent implements OnInit {
if ((['recipients', 'senders'].indexOf(element.identifier) > -1 || element.type === 'contact') && typeof searchTemplate.query[index].values[0] === 'string') {
const val = searchTemplate.query[index].values[0];
setTimeout(() => {
this.appContactAutocomplete.toArray().filter((component: any) => component.id === element.identifier)[0].setInputValue(val);
this.appContactAutocomplete.toArray().filter((component: any) => component.id === element.identifier)[0]?.setInputValue(val);
}, 0);
}
......@@ -742,6 +758,8 @@ export class CriteriaToolComponent implements OnInit {
updateFilters() {
this.listProperties.page = 0;
this.criteriaSearchService.updateListsProperties(this.listProperties);
console.log(this.listProperties);
this.refreshDaoResult.emit(this.listProperties);
}
......
......@@ -165,13 +165,15 @@ export class SearchResultListComponent implements OnInit, OnDestroy {
_activatedRoute.queryParams.subscribe(
params => {
if (!this.functions.empty(params.value)) {
this.searchTerm = params.value;
this.initSearch = true;
this.criteria = {
meta: {
values: this.searchTerm
}
};
if (params.target === 'default') {
this.searchTerm = params.value;
this.initSearch = true;
this.criteria = {
meta: {
values: this.searchTerm
}
};
}
}
}
);
......
......@@ -13,9 +13,13 @@
</div>
</div>
<div class="bg-head-content" [class.fullContainer]="appService.getViewMode()">
<app-criteria-tool #appCriteriaTool [isLoadingResult]="loadingResult" [data]="data" (searchUrlGenerated)="appSearchResultList.launchSearch($event, true);"
style="width:100%;padding-bottom: 10px;"
(loaded)="initSearch()" (afterGetSearchTemplates)="setLaunchWithSearchTemplate($event)" (refreshDaoResult)="appSearchResultList.listProperties = $event; appSearchResultList.refreshDao();"></app-criteria-tool>
<app-criteria-tool #appCriteriaTool
style="width:100%;padding-bottom: 10px;"
[isLoadingResult]="loadingResult" [data]="data"
(searchUrlGenerated)="appSearchResultList.launchSearch($event, true);"
(loaded)="initSearch()" (afterGetSearchTemplates)="setLaunchWithSearchTemplate($event)"
(refreshDaoResult)="appSearchResultList.listProperties = $event; appSearchResultList.refreshDao();">
</app-criteria-tool>
<div id="toolTemplate" style="width: 100%;"></div>
</div>
</div>
......
......@@ -31,7 +31,7 @@ export class SearchComponent implements OnInit {
@ViewChild('adminMenuTemplate', { static: true }) adminMenuTemplate: TemplateRef<any>;
@ViewChild('appSearchResultList', { static: false }) appSearchResultList: SearchResultListComponent;
@ViewChild('appCriteriaTool', { static: true }) appCriteriaTool: CriteriaToolComponent;
@ViewChild('appCriteriaTool', { static: false }) appCriteriaTool: CriteriaToolComponent;
constructor(
_activatedRoute: ActivatedRoute,
......@@ -50,7 +50,9 @@ export class SearchComponent implements OnInit {
this.searchTemplateId = params.searchTemplateId;
window.history.replaceState({}, document.title, window.location.pathname + window.location.hash.split('?')[0]);
} else if (!this.functions.empty(params.value)) {
this.searchTerm = params.value;
if (params.target === 'default') {
this.searchTerm = params.value;
}
}
}
);
......
......@@ -2599,5 +2599,7 @@
"showInformationsBlock": "Afficher le bloc d'informations",
"hideInformationsBlock": "Masquer le bloc d'informations",
"hasLinkedRes": "Au moins un courrier enregistré dans les {{nbDays}} derniers jour(s) est affecté au même contact.",
"seeMore": "Voir !"
"seeMore": "Voir !",
"quickSearchTargets": "Cible de la recherche rapide",
"defaultQuickSearch": "Sujet, Code à barre, Numéro GED"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment