raysuelzer / ngx-angular-query-builder

A version of angular2-query-builder to work with Angular 12+ (Need maintainers)
Other
30 stars 38 forks source link

Search in queryField select #17

Closed LorenzoBellani closed 8 months ago

LorenzoBellani commented 10 months ago

HI, for one of my angular projects with material I used this library and in the customization I included the possibility of doing the search in the queryField select.

Unfortunately this creates a bug because by filtering the array of available fields all the selects are filtered because I assume that the library uses the same instances of options for multiple elements.

Are you thinking of implementing the research or do you have any advice on how to do it custom?

raysuelzer commented 10 months ago

I don't know if I understand the problem fully. But, you will probably want to make your own custom field input and then copy the options on the init or someplace. That being said, I don't really do anything with the library until it's needed for work, the only reason I made it because the old one was abandoned and we needed to upgrade angular.

export class ContactAttemptQueryFieldInputComponent
  extends WithDisposableSubject() implements ControlValueAccessor {
  /** Field configuration */
  @Input() field: Field;
  @Input() options: Option[] = [];

   // Set this someplace and use it in your template
   visibleOptions = [];

   filterOptions(keyword: string) {
      this.visibleOptions = this.options.filter(v => v.value.includes(keyword))
   }