Unverified Commit eaed9f80 authored by Dan MacFarlane's avatar Dan MacFarlane Committed by GitHub
Browse files

Merge pull request #89 from kobvel/disable-search-bug

fix disable search to be a part of config
parents 06d1bcfd 5470898c
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,10 @@ export interface Mentions {
  // option to disable sorting
  // option to disable sorting
  disableSort?:boolean;
  disableSort?:boolean;


  // option to diable internal filtering. can be used to show the full list returned
  // from an async operation (or allows a custom filter function to be used - in future)
  disableSearch?:boolean;

  // display menu above text instead of below
  // display menu above text instead of below
  dropUp?:boolean;
  dropUp?:boolean;
  
  
+1 −5
Original line number Original line Diff line number Diff line
@@ -59,10 +59,6 @@ export class MentionDirective implements OnChanges {
  // event emitted whenever the search term changes
  // event emitted whenever the search term changes
  @Output() searchTerm = new EventEmitter();
  @Output() searchTerm = new EventEmitter();


  // option to diable internal filtering. can be used to show the full list returned
  // from an async operation (or allows a custom filter function to be used - in future)
  private disableSearch:boolean = false;

  private triggerChars:{[key:string]:MentionConfig} = {};
  private triggerChars:{[key:string]:MentionConfig} = {};


  private searchString: string;
  private searchString: string;
@@ -279,7 +275,7 @@ export class MentionDirective implements OnChanges {
    if (this.activeConfig && this.activeConfig.items) {
    if (this.activeConfig && this.activeConfig.items) {
      let objects = this.activeConfig.items;
      let objects = this.activeConfig.items;
      // disabling the search relies on the async operation to do the filtering
      // disabling the search relies on the async operation to do the filtering
      if (!this.disableSearch && this.searchString) {
      if (!this.activeConfig.disableSearch && this.searchString) {
        let searchStringLowerCase = this.searchString.toLowerCase();
        let searchStringLowerCase = this.searchString.toLowerCase();
        objects = objects.filter(e => e[this.activeConfig.labelKey].toLowerCase().startsWith(searchStringLowerCase));
        objects = objects.filter(e => e[this.activeConfig.labelKey].toLowerCase().startsWith(searchStringLowerCase));
      }
      }