<commit_before>import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { FormControl } from '@angular/forms';

@Component({
  selector: 'pnx-select-search',
  templateUrl: './select-search.component.html',
  styleUrls: ['./select-search.component.scss']
})
export class SelectSearchComponent implements OnInit {
  public currentValue = null;
  public selectedItems = [];
  public searchControl = new FormControl();
  @Input() parentFormControl: FormControl;
  // value of the options
  @Input() values: Array<any>;
  // key of the array of options
  @Input() key: string;
  @Input() multiselect: boolean;
  @Input() disabled: boolean;
  @Input() label: any;
  @Input() debounceTime: number;
  @Output() onSearch = new EventEmitter();
  @Output() onChange = new EventEmitter<any>();
  @Output() onDelete = new EventEmitter<any>();
  constructor() {}

  ngOnInit() {
    this.debounceTime = this.debounceTime || 100;
    this.disabled = this.disabled || false;

    this.searchControl.valueChanges
      .debounceTime(this.debounceTime)
      .distinctUntilChanged()
      .subscribe(value => {
        this.onSearch.emit(value);
      });
  }

  setCurrentValue(val) {
    this.currentValue = val[this.key];
    this.searchControl.reset();
    this.parentFormControl.patchValue(val);
  }

  addItem(item) {
    // remove element from the items list
    this.values = this.values.filter(curItem => {
      return curItem[this.key] !== item[this.key];
    });<commit_msg>Select search: rafrachi l'affichage des données à la MAJ du formControl<commit_after>import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { FormControl } from '@angular/forms';

@Component({
  selector: 'pnx-select-search',
  templateUrl: './select-search.component.html',
  styleUrls: ['./select-search.component.scss']
})
export class SelectSearchComponent implements OnInit {
  public currentValue = null;
  public selectedItems = [];
  public searchControl = new FormControl();
  @Input() parentFormControl: FormControl;
  // value of the options
  @Input() values: Array<any>;
  // key of the array of options
  @Input() key: string;
  @Input() multiselect: boolean;
  @Input() disabled: boolean;
  @Input() label: any;
  @Input() debounceTime: number;
  @Output() onSearch = new EventEmitter();
  @Output() onChange = new EventEmitter<any>();
  @Output() onDelete = new EventEmitter<any>();
  constructor() {}

  ngOnInit() {
    this.debounceTime = this.debounceTime || 100;
    this.disabled = this.disabled || false;

    this.searchControl.valueChanges
      .debounceTime(this.debounceTime)
      .distinctUntilChanged()
      .subscribe(value => {
        this.onSearch.emit(value);
      });

    this.parentFormControl.valueChanges.filter(value => value === null).subscribe(value => {
      if (this.multiselect) {
        this.selectedItems = [];
      } else {
        this.currentValue = null;
      }
    });
  }

  setCurrentValue(val) {
    this.currentValue = val[this.key];
    this.searchControl.reset();
    this.parentFormControl.patchValue(val);
  }

  addItem(item) {
    // remove element from the items list
    this.values = this.values.filter(curItem => {
      return curItem[this.key] !== item[this.key];
    });
{'fraction_non_alphanumeric': 0.14246491763270286, 'fraction_numerical': 0.0018303843807199512, 'mean_word_length': 3.6709401709401708, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3319087', 'n_tokens_mistral': 1001, 'n_tokens_neox': 990, 'n_words': 231}