Angular-QueryBuilder icon indicating copy to clipboard operation
Angular-QueryBuilder copied to clipboard

nullable: true is not clearing the old value

Open iKrishnaSahu opened this issue 3 years ago • 2 comments

If any property in config has nullable: true, then after entering something in the input box and changing the operator to is null is not clearing the old value.

school: { name: 'School', type: 'string', nullable: true },

image

iKrishnaSahu avatar Jul 16 '21 05:07 iKrishnaSahu

Have you found the solution for your above query?

Shah-ali avatar Jun 10 '23 19:06 Shah-ali

@Shah-ali I have written a custom logic for this issue. Whenever there is a change in query builder model (ngModelChange), I am calling below method to clear those values.

  public removeValueForNullAndEmptyOperator(query: RuleSet) {
    query.rules.forEach((rule: Rule | RuleSet) => {
      if ((rule as RuleSet).rules) {
        return this.removeValueForNullAndEmptyOperator(rule as RuleSet);
      }
      const ruleWithNull = ['is null', 'is not null', 'is empty', 'is not empty'].includes((rule as Rule).operator ?? '');
      if (ruleWithNull) {
        delete (rule as Rule).value;
      }
    });
  }

iKrishnaSahu avatar Jun 15 '23 04:06 iKrishnaSahu