search bug fixes and documentation updates (#3256)

* bug fixes for search

* test fixes

* bug fixes for search
This commit is contained in:
Denys Vuika
2018-05-03 10:28:20 +01:00
committed by Eugenio Romano
parent a9ab0af640
commit 856c4fd7f5
19 changed files with 423 additions and 78 deletions

View File

@@ -23,6 +23,7 @@ import { SearchQueryBuilderService } from '../../search-query-builder.service';
@Component({
selector: 'adf-search-text',
templateUrl: './search-text.component.html',
styleUrls: ['./search-text.component.scss'],
encapsulation: ViewEncapsulation.None,
host: { class: 'adf-search-text' }
})
@@ -36,7 +37,7 @@ export class SearchTextComponent implements SearchWidget, OnInit {
context: SearchQueryBuilderService;
ngOnInit() {
if (this.context && this.settings) {
if (this.context && this.settings && this.settings.pattern) {
const pattern = new RegExp(this.settings.pattern, 'g');
const match = pattern.exec(this.context.queryFragments[this.id] || '');
@@ -46,10 +47,19 @@ export class SearchTextComponent implements SearchWidget, OnInit {
}
}
reset() {
this.value = '';
this.updateQuery(null);
}
onChangedHandler(event) {
this.value = event.target.value;
if (this.value) {
this.context.queryFragments[this.id] = `${this.settings.field}:'${this.value}'`;
this.updateQuery(this.value);
}
private updateQuery(value: string) {
if (this.context && this.settings && this.settings.field) {
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${value}'` : '';
this.context.update();
}
}