import { Injectable } from '@angular/core' ; @ Injectable ( { providedIn : 'root' , } ) export class HsFiltersService { add ( kind , append , collection ) { let filter ; switch ( kind ) { case 'AND' : filter = [ '&&' , [ '==' , '<attribute>' , '<value>' ] ] ; break ; case 'OR' : filter = [ '||' , [ '==' , '<attribute>' , '<value>' ] ] ; break ; case 'COMPARE' : filter = [ '==' , '<attribute>' , '<value>' ] ; break ; default : } if ( append ) { collection . push ( filter ) ; } else { collection . length = 0 ; collection . push ( ... filter ) ; } } humanReadableLogOp ( logOp ) { return { '&&' : 'AND' , '||' : 'OR' , '!' : 'NOT' } [ logOp ] ; } isLogOp ( filters ) { return filters ?. length > 0 && [ '&&' , '||' ] . includes ( filters [ 0 ] ) ; } }