mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ACS-7363] Search - Advanced Filters - visual bugs in Logic and Properties filters (#9914)
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
placeholder="{{ placeholder | translate }}"
|
placeholder="{{ placeholder | translate }}"
|
||||||
aria-controls="adf-search-chip-autocomplete"
|
aria-controls="adf-search-chip-autocomplete"
|
||||||
#optionInput
|
#optionInput
|
||||||
|
#autocompleteTrigger="matAutocompleteTrigger"
|
||||||
[formControl]="formCtrl"
|
[formControl]="formCtrl"
|
||||||
[matAutocomplete]="auto"
|
[matAutocomplete]="auto"
|
||||||
[matChipInputFor]="chipList"
|
[matChipInputFor]="chipList"
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
[attr.aria-label]="placeholder | translate"
|
[attr.aria-label]="placeholder | translate"
|
||||||
class="adf-search-properties-file-input"
|
class="adf-search-properties-file-input"
|
||||||
(matChipInputTokenEnd)="add($event)"
|
(matChipInputTokenEnd)="add($event)"
|
||||||
(blur)="activeAnyOption = false"
|
(blur)="activeAnyOption = false; autocompleteTrigger.closePanel()"
|
||||||
data-automation-id="adf-search-chip-autocomplete-input">
|
data-automation-id="adf-search-chip-autocomplete-input">
|
||||||
</mat-chip-grid>
|
</mat-chip-grid>
|
||||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"
|
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
[(ngModel)]="searchCondition[LogicalSearchFields[field]]"
|
[(ngModel)]="searchCondition[LogicalSearchFields[field]]"
|
||||||
placeholder="{{ ('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate }}"
|
placeholder="{{ ('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate }}"
|
||||||
[attr.aria-label]="('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate"
|
[attr.aria-label]="('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate"/>
|
||||||
(change)="onInputChange()"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -99,13 +99,14 @@ describe('SearchLogicalFilterComponent', () => {
|
|||||||
expect(component.hasValidValue()).toBeTrue();
|
expect(component.hasValidValue()).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update display value after phrases changes', () => {
|
it('should update display value after phrases changes and user user clicks submit', () => {
|
||||||
spyOn(component.displayValue$, 'next');
|
spyOn(component.displayValue$, 'next');
|
||||||
enterNewPhrase('test2', 0);
|
enterNewPhrase('test2', 0);
|
||||||
|
component.submitValues();
|
||||||
expect(component.displayValue$.next).toHaveBeenCalledOnceWith(` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[0]}: test2`);
|
expect(component.displayValue$.next).toHaveBeenCalledOnceWith(` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[0]}: test2`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have correct display value after each field has at least one phrase', () => {
|
it('should have correct display value after each field has at least one phrase and user clicks submit', () => {
|
||||||
spyOn(component.displayValue$, 'next');
|
spyOn(component.displayValue$, 'next');
|
||||||
enterNewPhrase('test1', 0);
|
enterNewPhrase('test1', 0);
|
||||||
enterNewPhrase('test2', 1);
|
enterNewPhrase('test2', 1);
|
||||||
@@ -115,6 +116,7 @@ describe('SearchLogicalFilterComponent', () => {
|
|||||||
const displayVal2 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[1]}: test2`;
|
const displayVal2 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[1]}: test2`;
|
||||||
const displayVal3 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[2]}: test3`;
|
const displayVal3 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[2]}: test3`;
|
||||||
const displayVal4 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[3]}: test4`;
|
const displayVal4 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[3]}: test4`;
|
||||||
|
component.submitValues();
|
||||||
expect(component.displayValue$.next).toHaveBeenCalledWith(displayVal1 + displayVal2 + displayVal4 + displayVal3);
|
expect(component.displayValue$.next).toHaveBeenCalledWith(displayVal1 + displayVal2 + displayVal4 + displayVal3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ export enum LogicalSearchFields {
|
|||||||
MATCH_EXACT = 'matchExact'
|
MATCH_EXACT = 'matchExact'
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LogicalSearchConditionEnumValuedKeys = { [T in LogicalSearchFields]: string; };
|
export type LogicalSearchConditionEnumValuedKeys = { [T in LogicalSearchFields]: string };
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
export interface LogicalSearchCondition extends LogicalSearchConditionEnumValuedKeys {}
|
export interface LogicalSearchCondition extends LogicalSearchConditionEnumValuedKeys {}
|
||||||
|
|
||||||
@@ -55,14 +55,10 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
|||||||
this.clearSearchInputs();
|
this.clearSearchInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
onInputChange() {
|
|
||||||
this.updateDisplayValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
submitValues() {
|
submitValues() {
|
||||||
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
|
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
|
||||||
this.updateDisplayValue();
|
this.updateDisplayValue();
|
||||||
const fields = this.settings.field.split(',').map((field) => field += ':');
|
const fields = this.settings.field.split(',').map((field) => (field += ':'));
|
||||||
let query = '';
|
let query = '';
|
||||||
Object.keys(this.searchCondition).forEach((key) => {
|
Object.keys(this.searchCondition).forEach((key) => {
|
||||||
if (this.searchCondition[key] !== '') {
|
if (this.searchCondition[key] !== '') {
|
||||||
@@ -88,11 +84,15 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
|||||||
if (key === LogicalSearchFields.MATCH_EXACT) {
|
if (key === LogicalSearchFields.MATCH_EXACT) {
|
||||||
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
|
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
|
||||||
} else {
|
} else {
|
||||||
this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => {
|
this.searchCondition[key]
|
||||||
|
.split(' ')
|
||||||
|
.filter((condition: string) => condition !== '')
|
||||||
|
.forEach((phrase: string) => {
|
||||||
const refinedPhrase = '"' + phrase + '"';
|
const refinedPhrase = '"' + phrase + '"';
|
||||||
fieldQuery += fieldQuery === '(' ?
|
fieldQuery +=
|
||||||
`${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` :
|
fieldQuery === '('
|
||||||
` ${connector} ${field}${refinedPhrase}`;
|
? `${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}`
|
||||||
|
: ` ${connector} ${field}${refinedPhrase}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
subQuery += `${fieldQuery})`;
|
subQuery += `${fieldQuery})`;
|
||||||
@@ -103,6 +103,8 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
|||||||
});
|
});
|
||||||
this.context.queryFragments[this.id] = query;
|
this.context.queryFragments[this.id] = query;
|
||||||
this.context.update();
|
this.context.update();
|
||||||
|
} else {
|
||||||
|
this.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user