import {AnalyticalScope, ComboBox, ComboBoxModel, Filter, FilterComponent, FilterUtil} from "@webbpm/base-package";

@AnalyticalScope(ComboBox)
export class ComboboxFilterComponent extends FilterComponent {

  public isBusinessId: boolean;

  getFilter(): Filter {
    let combobox = this.getScript(ComboBox) as ComboBox;
    let model = combobox.getValueAsModel();

    if (model) {
        let value = this.isBusinessId ? model.businessId : model.id;
        return FilterUtil.singleValueFilter(this.getObjectId(), value, this.operation);
    }
    else {
        return null;
    }
  }
}