-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds a link to see more or less results on the facet. * Closes #87 Co-Authored-by: Bertrand Zuchuat <[email protected]> Co-Authored-by: Johnny Mariéthoz <[email protected]>
- Loading branch information
1 parent
af90732
commit 7e86c5f
Showing
14 changed files
with
269 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ui/src/app/records/search/aggregation/aggregation.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<section class="mb-2" *ngIf="aggregation.buckets.length"> | ||
<a class="text-muted" [ngClass]="{'collapsed': !isOpen(aggregation.title)}" | ||
data-toggle="collapse" href="#{{'agg_'+aggregation.title }}" | ||
aria-expanded="false" aria-controls="libraryData"> | ||
<h6 class="mb-0 d-inline border-bottom pb-1 font-weight-bold"><i class="fa fa-caret-down" aria-hidden="true"></i> {{ aggregation.name | translate }}</h6> | ||
</a> | ||
<div class="collapse" [ngClass]="{'show': isOpen(aggregation.title)}" id="{{'agg_'+aggregation.title }}"> | ||
<ul class="list-unstyled mb-0"> | ||
<li class="form-check" *ngFor="let bucket of aggregation.buckets|slice:0:sizeOfBucket()"> | ||
<input class="form-check-input" type="checkbox" [checked]="isFiltered(aggregation.title, bucket.key)" (click)="aggFilter(aggregation.title, bucket.key) "> | ||
<label class="form-check-label"> | ||
<span *ngIf="bucket.name">{{ bucket.name | translate }}</span> | ||
<span *ngIf="!bucket.name">{{ bucket.key | translate }}</span> ({{ bucket.doc_count }}) | ||
</label> | ||
</li> | ||
</ul> | ||
<div *ngIf="displayMoreAndLessLink()"> | ||
<a | ||
*ngIf="moreMode" | ||
href="#" | ||
data-toggle="collapse" | ||
(click)="setMoreMode(false)" | ||
translate | ||
>more…</a> | ||
<a | ||
*ngIf="!moreMode" | ||
href="#" | ||
data-toggle="collapse" | ||
(click)="setMoreMode(true)" | ||
translate | ||
>less…</a> | ||
</div> | ||
</div> | ||
</section> |
Empty file.
25 changes: 25 additions & 0 deletions
25
ui/src/app/records/search/aggregation/aggregation.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AggregationComponent } from './aggregation.component'; | ||
|
||
describe('AggregationComponent', () => { | ||
let component: AggregationComponent; | ||
let fixture: ComponentFixture<AggregationComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AggregationComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AggregationComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
61 changes: 61 additions & 0 deletions
61
ui/src/app/records/search/aggregation/aggregation.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component, Input, Output, EventEmitter } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-aggregation', | ||
templateUrl: './aggregation.component.html', | ||
styleUrls: ['./aggregation.component.scss'] | ||
}) | ||
export class AggregationComponent { | ||
|
||
@Input() aggFilters = null; | ||
@Input() aggsSettings = null; | ||
@Input() aggregation = null; | ||
|
||
@Output() addAggFilter = new EventEmitter<{term: string, value: string}>(); | ||
@Output() removeAggFilter = new EventEmitter<{term: string, value: string}>(); | ||
|
||
private moreMode = true; | ||
|
||
isFiltered(term: any, value?: any) { | ||
if (value) { | ||
const filterValue = `${term}=${value}`; | ||
return this.aggFilters.some((val: any) => filterValue === val); | ||
} else { | ||
return this.aggFilters.some((val: any) => term === val.split('=')[0]); | ||
} | ||
} | ||
|
||
aggFilter(term: string, value: string) { | ||
if (this.isFiltered(term, value)) { | ||
this.removeAggFilter.emit({term: term, value: value}); | ||
} else { | ||
this.addAggFilter.emit({term: term, value: value}); | ||
} | ||
} | ||
|
||
isOpen(title: string) { | ||
if (this.isFiltered(title)) { | ||
return true; | ||
} | ||
if (this.aggsSettings.expand.some((value: any) => value === title)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
sizeOfBucket() { | ||
if (this.moreMode) { | ||
return this.aggsSettings.initialBucketSize; | ||
} else { | ||
return this.aggregation.buckets.length; | ||
} | ||
} | ||
|
||
displayMoreAndLessLink() { | ||
return this.aggregation.buckets.length > this.aggsSettings.initialBucketSize; | ||
} | ||
|
||
setMoreMode(state: boolean) { | ||
this.moreMode = state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.