import { BaseFilterBase } from './base-filter-base';
import { IFloatingFilterComp, FilterChangedEvent, IFloatingFilterParams, IAfterGuiAttachedParams } from "ag-grid-community";

export default abstract class BaseFloatingFilter extends BaseFilterBase implements IFloatingFilterComp {
  protected body: HTMLElement;

  public init(params: IFloatingFilterParams): void {
    super.init(params);
    this.body = document.body;
  }

  public async setupGui() {
    await super.setupGui(true, true);
  }

  private async onOpenCloseDropDown() {
    if (this.firstTime) {
      await this.onOpenDropDown();
      this.firstTime = false;
    }
  }

  public async onOpenDropDown() {
    //empty
  }

  public destroy() {
    if (this.view) this.view.unbind();
    if (this.viewSlot) this.viewSlot.detached();
    this.dispose();
  }

  public afterGuiAttached?(params?: IAfterGuiAttachedParams): void;

  public abstract onParentModelChanged(parentModel: any, filterChangedEvent?: FilterChangedEvent): void;

  public abstract getModelAsString(): string;
}
