Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryPanel: allow automatic wildcard attachment for LIKE Comparison Filters #191

Open
justb4 opened this issue May 27, 2013 · 1 comment

Comments

@justb4
Copy link
Contributor

justb4 commented May 27, 2013

The QueryPanel/QueryFilter allows to attach explicit wildcard symbols (*) in the attribute query condition forms (for LIKE Comparison Filters with Strings). It would be handy to have a config property like 'autoWildCardAttach' that, when set to true, automatically wraps the string values of LIKE Comparison Filters with a wildcard. Together with caseInsensitiveMatch (see #189) this will provide a more modern form interaction.

This is similar to GeoExt.form (https://github.com/geoext/geoext/blob/master/lib/GeoExt/widgets/form.js), although with QueryPanel we may not need finegrained wildcard attachment control with STARTS_WITH, ENDS_WITH, CONTAINS, though this may be added later. For now CONTAINS-mode (prepend and append the wildcard) may be sufficient.

See an example here: http://lib.heron-mc.org/heron/latest/examples/querybuilder/
(try STATE_NAME like 'al').

This affects QueryBuilder.js and FilterBuilder.js (I don't think FilterField.js). I have a patch and can issue a pull.

justb4 added a commit to justb4/gxp that referenced this issue May 27, 2013
justb4 added a commit to justb4/gxp that referenced this issue Jul 22, 2013
justb4 added a commit to justb4/gxp that referenced this issue Jul 22, 2013
ahocevar added a commit that referenced this issue Jul 22, 2013
fix for gxp #191 - allow automatic wildcard attachment in LIKE Filters
@justb4
Copy link
Contributor Author

justb4 commented May 23, 2014

There appeared an issue with multiple conditions in wrapWildCards when filter.filters was undefined.
The fix is as follows (!typeof filter.filters === "undefined" line):

wrapWildCards: function (filter) {

    if (filter instanceof OpenLayers.Filter.Logical) {
        // JvdB: fix for Heron issue: 377
        // https://code.google.com/p/geoext-viewer/issues/detail?id=377
        // Fegyi's hack: check first if filter.filters is defined
        if (!typeof filter.filters === "undefined") {
            // Go recursively through composite filter
            for (var i = 0; i < filter.filters.length; i++) {
                filter = this.wrapWildCards(filter.filters[i]);
            }
        }
    } else if (filter.type === OpenLayers.Filter.Comparison.LIKE) {
        // Wrap the value in Wildcard strings.
        filter.value = this.wildCardString + filter.value + this.wildCardString;
    }

    return filter;
 },

I can make a patch and PR.

justb4 added a commit to justb4/gxp that referenced this issue May 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant