-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in feature/SHIBUI-297 (pull request #28)
SHIBUI-297: Implemented modal search Approved-by: Ryan Mathis <rmathis@unicon.net>
- Loading branch information
Showing
17 changed files
with
196 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface QueryParams { | ||
term: string; | ||
limit?: number; | ||
offset?: number; | ||
} |
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
35 changes: 30 additions & 5 deletions
35
ui/src/app/metadata-filter/component/search-dialog.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 |
---|---|---|
@@ -1,16 +1,41 @@ | ||
<div class="modal-header"> | ||
<h4 class="modal-title">Heading</h4> | ||
<h4 class="modal-title"> | ||
<ng-container i18n="@@label--search-entity-id">Search Entity Id ({{ source }})</ng-container> | ||
|
||
</h4> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="activeModal.dismiss()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
Body | ||
<form [formGroup]="form"> | ||
<div class="form-row"> | ||
<div class="form-group col-9"> | ||
<input type="text" | ||
formControlName="search" | ||
class="form-control" | ||
/> | ||
</div> | ||
<div class="form-group col-3"> | ||
<button class="btn btn-primary btn-block"> | ||
<i class="fa fa-search"></i> | ||
<ng-container i18n="@@action--search">Search</ng-container> | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
<div class="list-group list-group-flush scrolled my-2" id="list-tab" role="tablist"> | ||
<a href="" | ||
*ngFor="let item of matches$ | async" | ||
class="list-group-item list-group-item-action p-1" | ||
[class.active]="item === selected" | ||
(click)="select($event, item)">{{ item }}</a> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="activeModal.close('https://account.example.com/sso')"> | ||
<button type="button" class="btn btn-primary" (click)="activeModal.close(selected)"> | ||
<i class="fa fa-save"></i> | ||
Select ID | ||
<ng-container i18n="@@action--select-id">Select ID</ng-container> | ||
</button> | ||
<button type="button" class="btn btn-secondary" (click)="activeModal.dismiss()" i18n="@@action--cancel">Cancel</button> | ||
</div> | ||
</div> |
6 changes: 6 additions & 0 deletions
6
ui/src/app/metadata-filter/component/search-dialog.component.scss
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,6 @@ | ||
:host { | ||
.scrolled { | ||
max-height: 400px; | ||
overflow: scroll; | ||
} | ||
} |
50 changes: 43 additions & 7 deletions
50
ui/src/app/metadata-filter/component/search-dialog.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 |
---|---|---|
@@ -1,27 +1,63 @@ | ||
import { Component, OnChanges, OnInit } from '@angular/core'; | ||
import { Component, AfterViewInit, Input, OnInit, SimpleChange, SimpleChanges } from '@angular/core'; | ||
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
import * as fromFilter from '../reducer'; | ||
import { QueryEntityIds } from '../action/filter.action'; | ||
import { FormBuilder, FormGroup } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'search-dialog', | ||
templateUrl: './search-dialog.component.html' | ||
templateUrl: './search-dialog.component.html', | ||
styleUrls: ['./search-dialog.component.scss'] | ||
}) | ||
export class SearchDialogComponent implements OnInit, OnChanges { | ||
export class SearchDialogComponent implements OnInit, AfterViewInit { | ||
|
||
@Input() term: string; | ||
@Input() source = 'InCommon'; | ||
|
||
matches$: Observable<string[]>; | ||
|
||
selected: string; | ||
|
||
limit = 100; | ||
dbounce = 500; | ||
|
||
form: FormGroup = this.fb.group({ | ||
search: [''], | ||
entityId: [''] | ||
}); | ||
|
||
constructor( | ||
public activeModal: NgbActiveModal, | ||
private store: Store<fromFilter.State> | ||
private store: Store<fromFilter.State>, | ||
private fb: FormBuilder | ||
) { | ||
// console.log(activeModal); | ||
// this.query$ = this.store.select(fromFilter.getQuery); | ||
this.matches$ = this.store.select(fromFilter.getEntityCollection); | ||
} | ||
|
||
ngOnChanges(): void { | ||
ngOnInit(): void { | ||
let search = this.form.get('search'); | ||
search.setValue(this.term); | ||
|
||
search.valueChanges | ||
.debounceTime(this.dbounce) | ||
.subscribe(val => | ||
this.store.dispatch( | ||
new QueryEntityIds({ term: val, limit: this.limit }) | ||
) | ||
); | ||
} | ||
|
||
ngOnInit(): void { | ||
ngAfterViewInit(): void { | ||
const { term, limit } = this; | ||
this.store.dispatch(new QueryEntityIds({ term, limit })); | ||
} | ||
|
||
select($event: MouseEvent, id: string): void { | ||
$event.preventDefault(); | ||
this.selected = id; | ||
} | ||
} /* istanbul ignore next */ |
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
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.