Skip to content

Commit 3643a2e

Browse files
pbartuschmkr
authored andcommitted
Add som more on hover info when quotes appear in search input. Warn for unmatched quotes.
1 parent 8a5a47f commit 3643a2e

File tree

3 files changed

+83
-33
lines changed

3 files changed

+83
-33
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import com.typesafe.sbt.GitBranchPrompt
22

33
name := "search-management-ui"
4-
version := "4.1.0"
4+
version := "4.1.1"
55
maintainer := "Contact productful.io <hello@productful.io>"
66

77
scalaVersion := "2.12.17"

frontend/src/app/components/details/rule-management/rule-management.component.html

+46-22
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@
4444
disabled="disabled"
4545
/>
4646
</ng-container>
47-
<div class="input-group-append" *ngIf="warnSearchinputExact()">
47+
<div class="input-group-append" *ngIf="shouldWarnSearchinputExact()">
4848
<span class="input-group-text smui-clean-input-group-append">
4949
<span class="badge badge-warning">
50-
<i class="fa fa-info-circle">&nbsp;</i>
51-
{{ warnSearchinputExact() }}
50+
<i class="fa fa-info-circle" title="{{warnSearchinputExact()![1]}}">&nbsp;</i>
51+
{{ warnSearchinputExact()![0] }}
5252
</span>
5353
</span>
5454
</div>
55-
55+
5656
<div *ngIf="detailSearchInput && showPreviewLinks()">
5757
<app-smui-preview-link
5858
[previewSections]="previewLinks(detailSearchInput.term)"
5959
>
6060
</app-smui-preview-link>
6161
</div>
62-
62+
6363
</div>
64-
64+
6565
</td>
6666
<td
6767
[style.display]="showTags ? 'table-cell' : 'none'"
@@ -364,14 +364,25 @@
364364
<td
365365
ng-style="{'width' : (featureToggleService.getSyncToggleUiConceptAllRulesWithSolrFields()) ? '35%' : '55%'}"
366366
>
367-
<input
368-
type="text"
369-
class="form-control"
370-
id="inputUpDownTerm"
371-
placeholder="Edit UP/DOWN Rule Term ..."
372-
[(ngModel)]="upDownRule.term"
373-
(keyup.enter)="saveSearchInputDetails()"
374-
/>
367+
<div class="input-group">
368+
<input
369+
type="text"
370+
class="form-control"
371+
id="inputUpDownTerm"
372+
placeholder="Edit UP/DOWN Rule Term ..."
373+
[(ngModel)]="upDownRule.term"
374+
(keyup.enter)="saveSearchInputDetails()"
375+
/>
376+
<div class="input-group-append" *ngIf="shouldWarnForUnescapedQuotesInTerm(upDownRule.term)">
377+
<span class="input-group-text smui-clean-input-group-append">
378+
<span class="badge badge-warning">
379+
<i class="fa fa-info-circle"
380+
title="Solr/Lucene query syntax requires matching starting and closing quotes, escape them with \ if you want to match the quote character">&nbsp;</i>
381+
Unmatched quotes!
382+
</span>
383+
</span>
384+
</div>
385+
</div>
375386
</td>
376387
<td style="width:5%">
377388
<button
@@ -426,14 +437,27 @@
426437
<td
427438
ng-style="{'width' : (featureToggleService.getSyncToggleUiConceptAllRulesWithSolrFields()) ? '55%' : '75%'}"
428439
>
429-
<input
430-
type="text"
431-
class="form-control"
432-
id="inputFilterTerm"
433-
placeholder="Edit FILTER Rule Term ..."
434-
[(ngModel)]="filterRule.term"
435-
(keyup.enter)="saveSearchInputDetails()"
436-
/>
440+
441+
<div class="input-group">
442+
<input
443+
type="text"
444+
class="form-control"
445+
id="inputFilterTerm"
446+
placeholder="Edit FILTER Rule Term ..."
447+
[(ngModel)]="filterRule.term"
448+
(keyup.enter)="saveSearchInputDetails()"
449+
/>
450+
451+
<div class="input-group-append" *ngIf="shouldWarnForUnescapedQuotesInTerm(filterRule.term)">
452+
<span class="input-group-text smui-clean-input-group-append">
453+
<span class="badge badge-warning">
454+
<i class="fa fa-info-circle"
455+
title="Solr/Lucene query syntax requires matching starting and closing quotes, escape them with \ if you want to match the quote character">&nbsp;</i>
456+
Unmatched quotes!
457+
</span>
458+
</span>
459+
</div>
460+
</div>
437461
</td>
438462
<td style="width:5%">
439463
<button

frontend/src/app/components/details/rule-management/rule-management.component.ts

+36-10
Original file line numberDiff line numberDiff line change
@@ -636,33 +636,59 @@ export class RuleManagementComponent implements OnChanges, OnInit, AfterContentC
636636
);
637637
}
638638

639-
warnSearchinputExact(): (string | undefined) {
639+
warnSearchinputExact(): ([string, string] | null) {
640640
if(!this.detailSearchInput) {
641-
return undefined
641+
return null
642642
} else {
643643
if( SearchInput.isTermExact(this.detailSearchInput.term) ) {
644-
return "exact match"
644+
return ["exact match", "Matches only when a user enters the exact same query"]
645645
} else {
646646
if( SearchInput.isTermLeftExact(this.detailSearchInput.term) ) {
647-
return "left exact"
647+
return ["left exact", "Matches only queries starting with this input"]
648648
}
649649
else if( SearchInput.isTermRightExact(this.detailSearchInput.term) ) {
650-
return "right exact"
650+
return ["right exact", "Matches only queries ending with this input"]
651651
} else {
652-
return undefined
652+
return null
653653
}
654654
}
655655
}
656656
}
657657

658-
warnForExactMatchingSyntax(inSynonymTerm: string): boolean {
658+
shouldWarnSearchinputExact(): boolean {
659+
return this.detailSearchInput != undefined && this.warnForExactMatchingSyntax(this.detailSearchInput.term);
660+
}
661+
662+
warnForExactMatchingSyntax(term: string): boolean {
659663
return (
660-
SearchInput.isTermExact(inSynonymTerm)
661-
|| SearchInput.isTermLeftExact(inSynonymTerm)
662-
|| SearchInput.isTermRightExact(inSynonymTerm)
664+
SearchInput.isTermExact(term)
665+
|| SearchInput.isTermLeftExact(term)
666+
|| SearchInput.isTermRightExact(term)
663667
)
664668
}
665669

670+
shouldWarnForUnescapedQuotesInTerm(term: string): boolean {
671+
// if this is a term value used as a (Lucene) filter we should warn when there are unescaped quotes
672+
const isSolrTarget = this.featureToggleService.getSyncToggleUiConceptAllRulesWithSolrFields();
673+
if (isSolrTarget) {
674+
let withinQuotes = false;
675+
let escapeNext = false;
676+
for (let i = 0; i < term.length; i++) {
677+
const char = term[i];
678+
if (escapeNext) {
679+
escapeNext = false;
680+
} else if (char === '\\') {
681+
escapeNext = true;
682+
} else if (char === '"') {
683+
withinQuotes = !withinQuotes;
684+
}
685+
}
686+
return withinQuotes;
687+
} else {
688+
return false;
689+
}
690+
}
691+
666692
showPreviewLinks(): boolean {
667693
return this.previewLinkService.previewLinksAvailable()
668694
}

0 commit comments

Comments
 (0)