From c1eef311d377ef029bc6df42c55be52b13e50491 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 29 Jan 2020 10:56:07 +0100 Subject: [PATCH] FEAT #12869 TIME 0:35 add var lang + search adv --- .../criteria-tool.component.html | 34 +++++++++++-------- .../criteria-tool.component.scss | 2 +- .../criteria-tool/criteria-tool.component.ts | 22 +++++++----- .../list/search-adv-list.component.html | 4 +-- .../link-resource-modal.component.html | 2 +- src/frontend/lang/lang-en.ts | 6 ++++ src/frontend/lang/lang-fr.ts | 6 ++++ src/frontend/lang/lang-nl.ts | 6 ++++ 8 files changed, 55 insertions(+), 27 deletions(-) diff --git a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.html b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.html index fc8654a6a0e..d569f5f1199 100644 --- a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.html +++ b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.html @@ -2,7 +2,7 @@ <mat-expansion-panel expanded #criteriaTool> <mat-expansion-panel-header> <mat-panel-title> - Critères de recherche + {{lang.criteriaSearch}} </mat-panel-title> </mat-expansion-panel-header> @@ -12,7 +12,7 @@ [formControl]="searchCriteria" [matAutocomplete]="autoGroup"> <mat-autocomplete #autoGroup="matAutocomplete" (optionSelected)="addCriteria($event.option.value)"> <ng-container *ngFor="let keyVal of criteria | keyvalue"> - <mat-optgroup [label]="keyVal.key" *ngIf="(filteredCriteria[keyVal.key] | async)?.length > 0"> + <mat-optgroup [label]="lang[keyVal.key]" *ngIf="(filteredCriteria[keyVal.key] | async)?.length > 0"> <mat-option *ngFor="let crit of filteredCriteria[keyVal.key] | async | sortBy : 'label'" [value]="crit" [disabled]="isCurrentCriteria(crit.id)"> {{crit.label}} @@ -22,19 +22,23 @@ </mat-autocomplete> </mat-form-field> </div> - <div class="col-md-6" *ngFor="let criteria of currentCriteria;let i=index"> - <mat-form-field appearance="outline" class="criteriaField"> - <mat-label>{{criteria.label}}</mat-label> - <input matInput placeholder="First name" [formControl]="criteria.control"> - <button mat-icon-button matSuffix color="primary" (click)="$event.stopPropagation();removeCriteria(i)"> - <mat-icon color="warn" class="fa fa-trash"></mat-icon> + <form (ngSubmit)="getSearchUrl()" #criteriaFormUp="ngForm"> + <div class="col-md-6" *ngFor="let criteria of currentCriteria;let i=index"> + <mat-form-field appearance="outline" class="criteriaField"> + <mat-label>{{criteria.label}}</mat-label> + <input matInput [formControl]="criteria.control"> + <button mat-icon-button type="button" matSuffix color="primary" + (click)="$event.stopPropagation();removeCriteria(i)"> + <mat-icon color="warn" class="fa fa-trash"></mat-icon> + </button> + <mat-hint>{{criteria.desc}}</mat-hint> + </mat-form-field> + </div> + <div class="col-md-12"> + <button mat-raised-button matSuffix color="primary" type="submit"> + {{lang.searchMails}} </button> - </mat-form-field> - </div> - <div class="col-md-12"> - <button mat-raised-button matSuffix color="primary" (click)="getSearchUrl()"> - {{lang.searchMails}} - </button> - </div> + </div> + </form> </mat-expansion-panel> </mat-accordion> \ No newline at end of file diff --git a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.scss b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.scss index 37666ddb35a..d6332eb7e57 100644 --- a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.scss +++ b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.scss @@ -1,7 +1,7 @@ @import '../../../css/vars.scss'; .addCriteriaField { - font: 10px; + font-size: 10px; } .criteriaField { diff --git a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.ts b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.ts index 914cdac0c77..50d4ec1e368 100644 --- a/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.ts +++ b/src/frontend/app/adv-search/criteria-tool/criteria-tool.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output, Input } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { LANG } from '../../translate.component'; import { AppService } from '../../../service/app.service'; @@ -20,20 +20,20 @@ export class CriteriaToolComponent implements OnInit { lang: any = LANG; criteria: any = { - resource: [ + mailInformations: [ { id : 'resourceField', - label: 'Recherche par sujet / numéro chrono', + label: this.lang.criteriaResourceField, + desc: this.lang.criteriaResourceFieldDesc, control : new FormControl() }, { id : 'contactField', - label: 'Recherche par contact', + label: this.lang.criteriaContactField, + desc: this.lang.criteriaContactFieldDesc, control : new FormControl() }, - ], - attachment: [], - contact: [] + ] } currentCriteria: any = []; @@ -42,6 +42,8 @@ export class CriteriaToolComponent implements OnInit { searchCriteria = new FormControl(); + @Input() defaultCriteria: any = []; + @Output() searchUrlGenerated = new EventEmitter<string>(); @ViewChild('criteriaTool', { static: false }) criteriaTool: MatExpansionPanel; @@ -54,9 +56,13 @@ export class CriteriaToolComponent implements OnInit { private latinisePipe: LatinisePipe) { } ngOnInit(): void { - this.currentCriteria.push(this.criteria.resource[0]); Object.keys(this.criteria).forEach(keyVal => { + this.criteria[keyVal].forEach((element: any) => { + if (this.defaultCriteria.indexOf(element.id) > -1) { + this.currentCriteria.push(element); + } + }); this.filteredCriteria[keyVal] = {}; this.filteredCriteria[keyVal] = new Observable<string[]>(); this.filteredCriteria[keyVal] = this.searchCriteria.valueChanges diff --git a/src/frontend/app/adv-search/list/search-adv-list.component.html b/src/frontend/app/adv-search/list/search-adv-list.component.html index f291d87b732..a4fe8c885a7 100644 --- a/src/frontend/app/adv-search/list/search-adv-list.component.html +++ b/src/frontend/app/adv-search/list/search-adv-list.component.html @@ -3,8 +3,8 @@ </div> <div style="display: flex;"> <div style="display: flex;align-items: center;"> - {{allResInSearch.length}} - {{lang.records | ucfirst}} <small *ngIf="selectedRes.length > 0">- {{selectedRes.length}} + <b>{{allResInSearch.length}} + {{lang.records | ucfirst}}</b> <small *ngIf="selectedRes.length > 0" style="color: #029BB6;">- {{selectedRes.length}} {{lang.selected}}</small> </div> <div style="flex:1;"> diff --git a/src/frontend/app/linkedResource/linkResourceModal/link-resource-modal.component.html b/src/frontend/app/linkedResource/linkResourceModal/link-resource-modal.component.html index 87c7e553002..a5ff523f429 100644 --- a/src/frontend/app/linkedResource/linkResourceModal/link-resource-modal.component.html +++ b/src/frontend/app/linkedResource/linkResourceModal/link-resource-modal.component.html @@ -6,7 +6,7 @@ <mat-icon class="fa fa-times"></mat-icon> </button></h1> <mat-dialog-content class="modal-container"> - <app-criteria-tool (searchUrlGenerated)="launchSearch($event)"></app-criteria-tool> + <app-criteria-tool (searchUrlGenerated)="launchSearch($event)" [defaultCriteria]="['resourceField','contactField']"></app-criteria-tool> <search-adv-list #appSearchAdvList></search-adv-list> </mat-dialog-content> <div mat-dialog-actions class="actions"> diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index a70c5ac3ff1..13963934dfc 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1456,4 +1456,10 @@ export const LANG_EN = { "linkSelectedResources": "Link selected resources", "resourceUnlinked": "Resource unlinked", "resourcesLinked": "Resources linked", + "criteriaSearch": "Criteria search", + "criteriaResourceField": "Subjec / Chrono number", + "criteriaResourceFieldDesc": "Search a subject / chrono or a part of these elements", + "criteriaContactField": "Recipient / Sender", + "criteriaContactFieldDesc": "Search the company, the name, the firstname or a part of these elements", + "mailInformations": "Mail informations", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index e8ba8d77630..18fd0d026d9 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1496,4 +1496,10 @@ export const LANG_FR = { "linkSelectedResources": "Lier les courriers sélectionnés", "resourceUnlinked": "Liaison supprimée", "resourcesLinked": "Liaison(s) ajoutée(s)", + "criteriaSearch": "Critères de recherche", + "criteriaResourceField": "Sujet / numéro chrono", + "criteriaResourceFieldDesc": "Recherche un sujet / chrono ou une partie des ces élements", + "criteriaContactField": "Expéditeur / Destinataire", + "criteriaContactFieldDesc": "Recherche sur la structure, le nom, le prénom ou une partie des ces élements", + "mailInformations": "Informations du courrier", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index ad23db49dd3..1e893b6f827 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1481,4 +1481,10 @@ export const LANG_NL = { "linkSelectedResources": "Link selected resources", //_TO_TRANSLATE "resourceUnlinked": "Resource unlinked", //_TO_TRANSLATE "resourcesLinked": "Resources linked", //_TO_TRANSLATE + "criteriaSearch": "Criteria search", //_TO_TRANSLATE + "criteriaResourceField": "Subjec / Chrono number", //_TO_TRANSLATE + "criteriaResourceFieldDesc": "Search a subject / chrono or a part of these elements", //_TO_TRANSLATE + "criteriaContactField": "Recipient / Sender", //_TO_TRANSLATE + "criteriaContactFieldDesc": "Search the company, the name, the firstname or a part of these elements", //_TO_TRANSLATE + "mailInformations": "Mail informations", //_TO_TRANSLATE }; -- GitLab