Skip to content

Commit

Permalink
✨ Start to implement autofilter parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Oct 22, 2024
1 parent d709702 commit 8a4d0d0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/SearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@
</div>

</div>
<!-- @since 3.11.0 -->
<input
id = "g3w-search-filter"
class = "magic-checkbox"
v-model = "state.autofilter"
type = "checkbox"/>
<label for = "g3w-search-filter">Autofilter</label>

<!-- SEARCH BUTTON -->
<div class = "form-group">
Expand Down
4 changes: 3 additions & 1 deletion src/components/g3w-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function SearchPanel(opts = {}, show = false) {
/** keep a reference to initial search options (you shouldn't mutate them..) */
options: d.input.options,
})),
autofilter: false, //@since v3.11.0. Used to set already feature layers filtered https://github.com/g3w-suite/g3w-client/issues/676
};

// create search form structure
Expand Down Expand Up @@ -175,7 +176,8 @@ async function doSearch({
queryUrl,
formatter: 1,
feature_count,
raw: false // in order to get a raw response
raw: false, // in order to get a raw response
autofilter: state.autofilter //Boolean autofilter by server
},
outputs: show && { title: state.title }
});
Expand Down
6 changes: 5 additions & 1 deletion src/map/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,7 @@ class Layer extends G3WObject {
* @param options.unique
* @param options.queryUrl
* @param options.ordering
* @param options.autofilter //@since 3.11.0
* @param { Object } params - OWS search params
*
* @returns { Promise }
Expand Down Expand Up @@ -1798,6 +1799,7 @@ class Layer extends G3WObject {
suggest: options.suggest,
/** @since 3.9.0 */
formatter: undefined !== options.formatter ? options.formatter : 1,
autofilter: options.autofilter,
})
);
} catch(e) {
Expand Down Expand Up @@ -1834,6 +1836,7 @@ class Layer extends G3WObject {
formatter = 1,
queryUrl,
ordering,
autofilter, //@since 3.11.0
} = {}) {
const provider = this.getProvider('data');
provider._projections = provider._projections || { map: null, layer: null };
Expand All @@ -1845,7 +1848,8 @@ class Layer extends G3WObject {
unique,
fformatter,
ffield,
filtertoken: ApplicationState.tokens.filtertoken
filtertoken: ApplicationState.tokens.filtertoken,
autofilter,
};
try {
const url = queryUrl ? queryUrl : provider._layer.getUrl('data');
Expand Down
2 changes: 2 additions & 0 deletions src/services/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export default {
* @param options.feature_count
* @param options.formatter
* @param options.ordering
* @param options.autofilter //@since 3.11.0
*
* @returns { Promise<{ data: [], query: { type: 'search', search: * }, type: 'api' | 'ows' }> }
*/
Expand All @@ -243,6 +244,7 @@ export default {
feature_count,
formatter: 1,
ordering,
autofilter: false,
}) {
const { layer, ...params } = options;
params.filter = [].concat(params.filter); // check if filter is array
Expand Down

0 comments on commit 8a4d0d0

Please sign in to comment.