import { ICellRendererParams } from "ag-grid-community";
import { KebabCase } from "../../utils/kebab-case";
import { ButtonsColDefAction } from "../../vm/list-view-buttons-coldef";
import BaseRenderer from "./base-renderer";

export default class SelectionCellRenderer extends BaseRenderer {

  protected buttons: ButtonsColDefAction<any>[];

  public init(params: ICellRendererParams & { buttons: ButtonsColDefAction<any>[] }) {
    this.buttons = params.buttons;
    super.init(params);
    super.setupGui();
  }

  public setupContentGui(): string {
    this.eGui.style.display = 'flex';
    this.eGui.style.alignItems = 'center';
    this.eGui.style.justifyContent = 'center';
    let html = `<ui-checkbox if.bind="params.colDef.headerComponentParams.VM.isSelectable(params.data)"`
      + ` change.capture="params.colDef.headerComponentParams.VM.isSelectedChanged(params.data)"`
      + ` checked.two-way="params.data.isSelected"></ui-checkbox>`
    return html;
  }
}