Skip to content

skip validating empty rules#428

Closed
Ruud-cb wants to merge 1 commit intomistic100:devfrom
Ruud-cb:dev
Closed

skip validating empty rules#428
Ruud-cb wants to merge 1 commit intomistic100:devfrom
Ruud-cb:dev

Conversation

@Ruud-cb
Copy link
Contributor

@Ruud-cb Ruud-cb commented Feb 1, 2017

Related to #426

This adds an option for getRules() to skip empty rules.

When clicking add rule, getting the rules would be impossible, it will always return an empty object (or an invalid one when using allow_invalid).
All other rules are now validated, the rule that is empty (did not select an filter or operator) will be removed from the result list and no warning will appear.

Merge request checklist

  • I read the guidelines for contributing
  • I created my branch from dev and I am issuing the PR to dev
  • Unit tests are OK
  • If it's a new feature, I added the necessary unit tests
  • If it's a new language, I filled the __locale and __author fields

I've tried to use QUnit, but it gave me errors out of the box, related to language files. So I'm not able to test a created test. (Not that experienced as well).

In my best attempt, here is the unit test:

   /**
     * Test skip_empty option
     */
    QUnit.test('skip_empty', function(assert) {
        $b.queryBuilder({
            filters: basic_filters
        });

        $b.queryBuilder('setRules', {
            condition: 'XOR',
            rules: [{
                id: 'name',
                operator: 'unkown_ope',
                value: 'Mistic'
            },{
               empty : true
            }]
        });

        assert.rulesMatch(
            $b.queryBuilder('getRules', {
                skip_empty: true
            }),
            {
                condition: 'AND',
                rules: [{
                    id: 'name',
                    operator: 'equal',
                    value: 'Mistic'
                }]
            },
            'Should skip empty rules for getRules'
        );
    });
	

Seems like the example is conflicting, not necessary to keep my version so just rebase it with whatever you have.

@mistic100
Copy link
Owner

62f6f44
it fixes indentation (you used tabs) and manage empty groups too

@mistic100 mistic100 closed this Feb 1, 2017
@mistic100 mistic100 added this to the 2.4.1 milestone Feb 1, 2017
@mistic100 mistic100 added the feature New feature label Feb 1, 2017
@Ruud-cb
Copy link
Contributor Author

Ruud-cb commented Feb 6, 2017

Thanks for the 'merge'!

@mistic100 mistic100 modified the milestones: 2.4.2, 2.4.1 Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants