import * as _ from "lodash" ; import BaseResultProcessing from "./BaseResultProcessing" ; import { Option } from "./GridDataAutoCompleteHandler" ; export default class SimpleResultProcessing extends BaseResultProcessing { constructor ( protected options ? ) { super ( ) ; } tryToGetFieldCategory ( fieldOrLabel ) { var found = _ . find ( this . options , f => f . columnText == fieldOrLabel ) ; return found ? found . columnField : fieldOrLabel ; } filter ( row , fieldOrLabel , operator , value ) { var field = this . tryToGetFieldCategory ( fieldOrLabel ) ; switch ( operator ) { case "==" : return row [ field ] == value ; case "!=" : return row [ field ] != value ; case "contains" : return row [ field ] . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) ) >= 0 ; case "!contains" : return row [ field ] . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) ) < 0 ; } return false ; } }