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

feature: show search results in infowindow #1751

Merged
merged 10 commits into from
Sep 22, 2023
Merged

Conversation

jokd
Copy link
Contributor

@jokd jokd commented Apr 25, 2023

Fixes #1413
Replaces #1436
Adds a infowindow-component which can be used to create a floating infowindow or aligned to the left.
Search control is configured ike this:

{
"name": "search",
"options": {
...
"searchlistOptions":{
  "placement": "floating", //can be search, left or floating, activated by hitting enter (defaults to nothing)
  "export": true,
  "exportUrl": "origo-server-url/excelcreator",
  "exportButtontext": "Exportera lista",
  "exportFilename": "export.xlsx"
},
"autocompletePlacement": "search", //can be search, left or floating (defaults to search)
}
}

@jokd jokd mentioned this pull request Apr 26, 2023
@tonnyandersson
Copy link
Collaborator

@jokd Umm, yeah... If you could just resolve the current conflicts, that'd be great.

@jokd
Copy link
Contributor Author

jokd commented Jun 21, 2023

I fixed the conflicts. But testing it I have a couple of comments myself so I will try to:
Make the export button a real button, and
Put it in a footer so you don't have to scroll down to the bottom to make an export

@jokd
Copy link
Contributor Author

jokd commented Jun 21, 2023

Now the export buttons should lok similar to the infowindow export buttons:

  "placement": "left", 
  "roundButton": false

image

  "placement": "floating",
  "roundButton": true

image

Example config:

 {
 "name": "search",
 "options": {
  "url": "//origoserver/search",
  "searchAttribute": "NAMN",
  "layerNameAttribute": "TYPE",
  "idAttribute": "GID",
  "geometryAttribute": "GEOM",
  "hintText": "Sök adress eller platser...",
  "includeSearchableLayers": true,
  "autocompletePlacement": "left" //can be search, left or floating (defaults to search),
  "searchlistOptions":{
    "placement": "left", //can be left or floating, activated by hitting enter (defaults to nothing)
    "export": true, // default is false
    "exportUrl": "//origoserver/excelcreator",
    "exportButtonText": "Exportera lista", // default is "Export"
    "exportFilename": "export.xlsx", // default is export.xlsx
    "roundButton": false, // default is false,
    "title": "Sökresultat" // Title for the searchlist, defaults to 'Sökresultat för "{{value}}"', {{value}} will be replaced with the search input
  }
 }
}

@jokd
Copy link
Contributor Author

jokd commented Jun 22, 2023

I will also add an option to make a selection of the search result for a layer.

@filleg
Copy link
Contributor

filleg commented Jun 22, 2023

Nice additions. Not really a bug, but found something that can be a bit confusing for the user. If you activate the searchlist-component after doing a search you can still access the previous search in the searchbar which won't work.

Probably outside the scope of this PR but if you use the regular search for autocomplePlacement your hits will be with the regular popup. While the searchlist will use infowindow. Would be more coherent to be able to set the regular search to infowindow as well. Covered here I guess #1228

@jokd
Copy link
Contributor Author

jokd commented Jun 22, 2023

Added these options:

      "exportExcludedFields": ["GEOM", "label", "value"], // exclude properties you don't wanna export
      "makeSelectionButton": true, //default is false
      "makeSelectionButtonText": "Använd som urval"

Which will turn a search result into a selection.

@jokd
Copy link
Contributor Author

jokd commented Jun 22, 2023

Nice additions. Not really a bug, but found something that can be a bit confusing for the user. If you activate the searchlist-component after doing a search you can still access the previous search in the searchbar which won't work.

Probably outside the scope of this PR but if you use the regular search for autocomplePlacement your hits will be with the regular popup. While the searchlist will use infowindow. Would be more coherent to be able to set the regular search to infowindow as well. Covered here I guess #1228

Thats the way it has always been right?

@jokd
Copy link
Contributor Author

jokd commented Jun 29, 2023

I think I'm done with this, anyone wanna have a look?

@jokd
Copy link
Contributor Author

jokd commented Aug 22, 2023

@tonnyandersson Wanna have another look on this? Would be nice to merge in case it's OK.

@tonnyandersson
Copy link
Collaborator

@jokd Never had a look at this in the first place. My earlier comment was just about the conflicts.

I don't have a lot of configs including the Search control set up, so it might take some time for me to configure a decent test case. If anyone else has got something ready to roll. please feel free to take this beauty out for a ride around the block.

@jokd
Copy link
Contributor Author

jokd commented Aug 22, 2023

Nice additions. Not really a bug, but found something that can be a bit confusing for the user. If you activate the searchlist-component after doing a search you can still access the previous search in the searchbar which won't work.

@filleg I addressed this issue in #1817, hopefully it will work well along with this PR (I haven't tested it)

@filleg
Copy link
Contributor

filleg commented Aug 29, 2023

I tried the changes and seems to work fine. Can't confirm all parts since it is not fully compatible with QGIS server. But that is more related to getfeature.js and #1139
Might be good if a geoserver user tests as well.

@steff-o
Copy link
Contributor

steff-o commented Aug 30, 2023

Tested using GeoServer. Most stuff seems to work and no errors are given in the console. However, I have some comments:

  1. If the placement parameter is missing, no searchList is displayed. Maybe intentional but must be documented
  2. The relation between autocompletePlacement and placement is not obvious. Maybe a really good documentation will clearify that. In the end it is apparently possible to configure search to use the searchList as one and only display of results or use the old awesomeplete as usual and searchList when hitting enter.
  3. It only works for Option 1 and 2 in the search documentation, which means that idAttribute and geometryAttribute must be specified and also layerName or layerNameAttribute. Possibly intentional, but it is possible to make the searchList work without idAttribute, but when clicking a feature or pressing the select button all features in the layer are selected.
  4. I don't see the point with the export button when infowindow has better export possibilities. But it's there and seems to work (haven't actually tested getting a response, as I don't have a report server) so it might as well stay.
  5. If you have typed more than minimum characters and has a result and backspaces to fewer than the minimum search characters the searchlist remains at the last search. The awesomplete is emptied as expected.
  6. The showFeatureInfo method in featureinfo.js has no documentation for new newly added argument opts. Not the end of the world, but since it is an api function and the other argument is documented opts should also be documented.
  7. After pressing enter the search input field is emptied. Clicking the field to type something new, the old search result appears in the awesomplete list. Clicking one of the old results throws an error. Most likely this is the same error as when manually emptying the search input and clicking it.

Other than that there are some other issues already mentioned by others or outside the scope of this PR:

  1. getFeature has issues with Qgis server which affects zoom to.
  2. Clicking a search result in the awesomeplete list does not obey the infoWindow setting and always displays the result in overlay. searchList on the other hand obeys infoWindow setting which makes the mixed mode with both awesomplete and searchList a bit confusing.

src/utils.js Outdated Show resolved Hide resolved
@jokd
Copy link
Contributor Author

jokd commented Aug 31, 2023

Tested using GeoServer. Most stuff seems to work and no errors are given in the console. However, I have some comments:

  1. If the placement parameter is missing, no searchList is displayed. Maybe intentional but must be documented

We could use searchList: true as an option to activate the list, would that be better?

  1. The relation between autocompletePlacement and placement is not obvious. Maybe a really good documentation will clearify that. In the end it is apparently possible to configure search to use the searchList as one and only display of results or use the old awesomeplete as usual and searchList when hitting enter.

placement is a searchlistOptions-option while autocompletePlacement is a search-option. Will make it clear in the documentation

  1. It only works for Option 1 and 2 in the search documentation, which means that idAttribute and geometryAttribute must be specified and also layerName or layerNameAttribute. Possibly intentional, but it is possible to make the searchList work without idAttribute, but when clicking a feature or pressing the select button all features in the layer are selected.

This can be looked into when issue #1420 is solved

  1. I don't see the point with the export button when infowindow has better export possibilities. But it's there and seems to work (haven't actually tested getting a response, as I don't have a report server) so it might as well stay.

They do export different stuff and I think that export all of the search results can be useful instead of making a selection and export it layer by layer

  1. If you have typed more than minimum characters and has a result and backspaces to fewer than the minimum search characters the searchlist remains at the last search. The awesomplete is emptied as expected.

Will push a fix for this

  1. The showFeatureInfo method in featureinfo.js has no documentation for new newly added argument opts. Not the end of the world, but since it is an api function and the other argument is documented opts should also be documented.

Will push a fix for this

  1. After pressing enter the search input field is emptied. Clicking the field to type something new, the old search result appears in the awesomplete list. Clicking one of the old results throws an error. Most likely this is the same error as when manually emptying the search input and clicking it.

This is addressed in #1816

@steff-o
Copy link
Contributor

steff-o commented Sep 20, 2023

LGTM.

@jokd jokd merged commit aa9fc5a into master Sep 22, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

Improve how the search results are presented
4 participants