forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
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
[Doumentation] Verify extensibility of Search plugin services configuration #438
Merged
allyoucanmap
merged 2 commits into
GeoNode:master
from
luorlandini:420_verify_extensibility_doc
Aug 19, 2021
Merged
[Doumentation] Verify extensibility of Search plugin services configuration #438
allyoucanmap
merged 2 commits into
GeoNode:master
from
luorlandini:420_verify_extensibility_doc
Aug 19, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allyoucanmap
requested changes
Aug 19, 2021
README.md
Outdated
} | ||
} | ||
|
||
return localConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal:
- Please don't remove the previous example but we could add a list of snippet examples where this should be
update plugin configuration
- Add also the example for
enable plugin
(copy from here https://github.com/GeoNode/geonode-mapstore-client/tree/3.3.x#customization-via-configurationstemplates)
Below a refactor to include the logic in a function
- update plugin configuration
{% extends 'geonode-mapstore-client/_geonode_config.html' %}
{% block override_local_config %}
<script>
window.__GEONODE_CONFIG__.overrideLocalConfig = function(localConfig, _) {
/**
* this is an example of function used to merge new plugin configuration in the default localConfig
* if match the plugin name for the GeoNode section, extend or override it
* if the plugin is new, add it to localConfig
* Note: you can create your on function or manipulate the localConfig to get your expected final configuration
* @param {object} config localConfig to update
* @param {string[]} options.pages array of page keys to target
* @param {string} options.name name of plugin
* @param {object} options.cfg new cfg to apply
*/
function mergePluginConfig(config, options) {
var pages = options.pages;
var pluginName = options.name;
var pluginCfg = options.cfg;
for (var j = 0; j < pages.length; j++ ) {
var page = pages[j];
var plugins = config.plugins[page];
var merged = false;
for (var i = 0; i < config.plugins[page].length; i++ ) {
var plugin = plugins[i];
if (plugin.name === pluginName) {
plugin.cfg = _.merge(plugin.cfg, pluginCfg);
merged = true;
break;
}
}
if (!merged) {
plugins.push({
name: pluginName,
cfg: pluginCfg
})
}
}
}
mergePluginConfig(localConfig, {
pages: [ 'map_edit', 'map_view' ],
name: 'Search',
cfg: {
"searchOptions": {
"services": [
// { "type": "nominatim", "priority": 5 }, // default service
{
"type": "wfs",
"priority": 3,
"displayName": "${properties.propToDisplay}",
"subTitle": " (a subtitle for the results coming from this service [ can contain expressions like ${properties.propForSubtitle}])",
"options": {
"url": "{state('settings') && state('settings').geoserverUrl ? state('settings').geoserverUrl + '/wfs' : '/geoserver/wfs'}",
"typeName": "workspace:layer",
"queriableAttributes": [
"attribute_to_query"
],
"sortBy": "id",
"srsName": "EPSG:4326",
"maxFeatures": 20,
"blacklist": [
"... an array of strings to exclude from the final search filter "
]
}
}
]
}
}
});
return localConfig;
};
</script>
{% endblock %}
allyoucanmap
approved these changes
Aug 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in PR: