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

lizmap-features-table - Improve the logic of the feature detail opening #5194

Merged

Conversation

mdouchin
Copy link
Collaborator

@mdouchin mdouchin commented Jan 14, 2025

Improve the way the web component <lizmap-features-table> displays the popup of a feature when the user clicks on its title.

This adds a new way to load the component with a highlighted feature at startup,
by adding a new optional attribute data-active-item-feature-id.

If this attribute is set to a valid feature ID, the table will be hidden and the corresponding feature popup visible.

image

For example:

  • By setting the attribute in the HTML element definition:

    <lizmap-features-table
      sortingorder="asc" sortingfield="libsquart" 
      withgeometry="1" 
      expressionfilter="quartmno = 'MC'" 
      uniquefield="id" 
      data-center-to-highlighted-feature-geometry="true" 
      data-show-highlighted-feature-geometry="true" 
      layerid="sousquartiers_24ceec66_e7fe_46a2_b57a_af5c50389649" 
      layertitle="child sub-districts" 
      data-active-item-feature-id="18"
    >
    <lizmap-features-table>
  • By setting the attribute in Javascript:

    // Get the element (the selector must probably be more specific.)
    const elt = document.querySelector('lizmap-features-table')
    // Change its attribute data-active-item-feature-id which will display the feature details
    elt.setAttribute('data-active-item-feature-id', 18);
    // Note here that you can also use the dataset shortcut
    elt.dataset.activeItemFeatureId = 23;
    
    // Move back to the list of features
    // Note here that you can also use the dataset shortcut
    elt.dataset.activeItemFeatureId = null

Ticket : #5146

Funded by 3liz

@github-actions github-actions bot added this to the 3.10.0 milestone Jan 14, 2025
@mdouchin mdouchin requested a review from nboisteault January 14, 2025 15:53
@mdouchin mdouchin self-assigned this Jan 14, 2025
@mdouchin mdouchin added javascript Pull requests that update Javascript code backport release_3_8 backport release_3_9 run end2end If the PR must run end2end tests or not labels Jan 14, 2025
@mdouchin mdouchin requested a review from rldhont January 14, 2025 16:03
@mdouchin mdouchin mentioned this pull request Jan 14, 2025
5 tasks
@mdouchin mdouchin force-pushed the lizmap-features-table-popup-improvement branch 2 times, most recently from 38f6849 to 3187e71 Compare January 15, 2025 09:42
@mdouchin mdouchin added run end2end If the PR must run end2end tests or not and removed run end2end If the PR must run end2end tests or not labels Jan 15, 2025
@mdouchin mdouchin force-pushed the lizmap-features-table-popup-improvement branch from 3187e71 to 9eb2197 Compare January 15, 2025 09:53
Copy link
Collaborator

@rldhont rldhont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes

assets/src/components/FeaturesTable.js Outdated Show resolved Hide resolved
assets/src/components/FeaturesTable.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_8 backport release_3_9 javascript Pull requests that update Javascript code run end2end If the PR must run end2end tests or not
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants