import {FormField} from "./FormField";
import {AnalyticalScope, GridV2, GridV2Column, NotNull, ObjectRef} from "@webbpm/base-package";

@AnalyticalScope(GridV2)
export class GridFormField extends FormField {

  @NotNull()
  @ObjectRef()
  public column: GridV2Column;

  public getValue(): any[] {
    let grid: GridV2 = this.getScript(GridV2);
    return grid.getAllRows().map(rowData => rowData[this.column.getField()]);
  }
}
