Commit a62f50c5 authored by Exbrayat Cédric's avatar Exbrayat Cédric
Browse files

fix: do not deactivate large aggregations with a single option

parent b537ffe3
......@@ -11,25 +11,16 @@
<small class="text-muted ml-1">({{ aggregation.buckets.length | number }})</small>
</h3>
<!-- multiple values as pills and a typeahead to add them -->
<div *ngIf="aggregation.buckets.length > 1; else singleValue">
<div class="mb-2">
<!-- values as pills and a typeahead to add them -->
<div class="mb-2">
<span class="badge badge-pill badge-secondary mr-1" *ngFor="let key of selectedKeys" tabindex="0"
(keydown.backspace)="removeKey(key)">
<rare-document-count [name]="key" [count]="documentCountForKey(key)" [muted]="false"></rare-document-count>
<button tabindex="-1" type="button" class="btn btn-link" (click)="removeKey(key)">&times;</button>
</span>
</div>
<input id="typeahead-basic" type="text" class="form-control" [formControl]="criterion" [ngbTypeahead]="search"
(selectItem)="selectKey($event)" [resultTemplate]="resultTemplate"/>
</div>
<!-- single value as a pill not removable -->
<ng-template #singleValue>
<span class="badge badge-pill badge-light">
<rare-document-count [name]="aggregation.buckets[0].key" [count]="aggregation.buckets[0].documentCount"
[muted]="false"></rare-document-count>
</span>
</ng-template>
<input class="form-control" [formControl]="criterion" [ngbTypeahead]="search"
(selectItem)="selectKey($event)" [resultTemplate]="resultTemplate"/>
</div>
</div>
......
......@@ -122,25 +122,6 @@ describe('LargeAggregationComponent', () => {
expect(tester.pills[1].button('button')).not.toBeNull();
});
it('should disable the unique criterion and display it as a pill', () => {
// given an aggregation with a bucket and a unique value
const tester = new LargeAggregationComponentTester();
const component = tester.componentInstance;
component.aggregation = toAggregation('coo', ['France']);
// when displaying the component
tester.detectChanges();
// then it should have no input
expect(tester.inputField).toBeNull();
expect(tester.typeahead).toBeNull();
// and France should be displayed a pill
expect(tester.pills.length).toBe(1);
expect(tester.pills[0]).toContainText('France[10]');
// but not a removable one
expect(tester.pills[0].button('button')).toBeNull();
});
it('should find one results containing the term entered', () => {
// given an aggregation with a bucket
const component = new LargeAggregationComponent();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment