Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
add cacheSearchTerm option and index.ts file for easy npm install fro…
Browse files Browse the repository at this point in the history
…m github repo
  • Loading branch information
user authored and crystalline committed Jun 13, 2017
1 parent 222891a commit d085691
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export {Ng2CompleterModule} from "./src/ng2-completer.module";

export {CompleterCmp} from "./src/components/completer-cmp";
export {CompleterListItemCmp} from "./src/components/completer-list-item-cmp";
export {CompleterService} from "./src/services/completer-service";
export {CompleterData} from "./src/services/completer-data";
export {localDataFactory, LocalDataFactoryProvider, remoteDataFactory, RemoteDataFactoryProvider} from "./src/services/completer-data-factory";
export {CompleterItem} from "./src/components/completer-item";
export {LocalData} from "./src/services/local-data";
export {RemoteData} from "./src/services/remote-data";
export {CompleterBaseData} from "./src/services/completer-base-data";
export {CtrCompleter} from "./src/directives/ctr-completer";
export {CtrDropdown} from "./src/directives/ctr-dropdown";
export {CtrInput} from "./src/directives/ctr-input";
export {CtrList} from "./src/directives/ctr-list";
export {CtrRow} from "./src/directives/ctr-row";
2 changes: 2 additions & 0 deletions src/components/completer-cmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const COMPLETER_CONTROL_VALUE_ACCESSOR = {
<div class="completer-dropdown-holder"
*ctrList="dataService;
minSearchLength: minSearchLength;
cacheSearchTerm: cacheSearchTerm;
pause: pause;
autoMatch: autoMatch;
initialValue: initialValue;
Expand Down Expand Up @@ -136,6 +137,7 @@ export class CompleterCmp implements OnInit, ControlValueAccessor, AfterViewChec
@Input() public openOnFocus = false;
@Input() public initialValue: any;
@Input() public autoHighlight = false;
@Input() public cacheSearchTerm = true;

@Output() public selected = new EventEmitter<CompleterItem>();
@Output() public highlighted = new EventEmitter<CompleterItem>();
Expand Down
6 changes: 4 additions & 2 deletions src/directives/ctr-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class CtrList implements OnInit, CompleterList {
@Input() public ctrListAutoMatch = false;
@Input() public ctrListAutoHighlight = false;
@Input() public ctrListDisplaySearching = true;
@Input() public ctrListCacheSearchTerm = true;

private _dataService: CompleterData;
// private results: CompleterItem[] = [];
Expand Down Expand Up @@ -100,7 +101,8 @@ export class CtrList implements OnInit, CompleterList {
}

public search(term: string) {
if (!isNil(term) && term.length >= this.ctrListMinSearchLength && this.term !== term) {
if (!isNil(term) && term.length >= this.ctrListMinSearchLength &&
(!this.ctrListCacheSearchTerm || (this.term !== term))) {
if (this.searchTimer) {
this.searchTimer.unsubscribe();
this.searchTimer = null;
Expand Down Expand Up @@ -135,7 +137,7 @@ export class CtrList implements OnInit, CompleterList {
}

public open() {
if (!this.ctx.searchInitialized) {
if (!this.ctrListCacheSearchTerm || !this.ctx.searchInitialized) {
this.search("");
}
this.refreshTemplate();
Expand Down

0 comments on commit d085691

Please sign in to comment.