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

New Lizmap web component lizmap-features-table to display a compact list of features #4502

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

mdouchin
Copy link
Collaborator

@mdouchin mdouchin commented Jun 6, 2024

This lizmap-features-table web component allows to display a compact list of vector layer features labels:

  • The QGIS "Display name" is used as the feature label: an expression can be used to tweak its content, configured in the Tooltip tab of the QGIS vector layer properties. For example:
    CONCAT(
        "quartiers_libquart", ' - ', "libsquart", ' (', to_int(area(@geometry)/10000), ' ha)'
    )
    will produce a text like MONTPELLIER CENTRE - Les Aubes (85 ha)
  • If the popup is configured for the given layer, a click on a feature label display its popup under the list of features

Peek 31-07-2024 09-37

It will be used in future in several contexts:

  • To display the child elements of a popup object
  • To display the child elements in an editing form
  • To display a compact list of features anywhere else needed (for example in the expression based HTML popup)

As any HTML web component, it can be used by writing an HTML element with attributes allowing to configure its source data and behaviour, for example:

<lizmap-features-table
    layertitle="child sub-districts"
    layerid="sousquartiers_24ceec66_e7fe_46a2_b57a_af5c50389649"
    uniquefield="id"
    expressionfilter="quartmno = 'MC'"
    withgeometry
    sortingfield="libsquart"
    sortingorder="asc"
    draggable="yes"
/>

The following attributes allow configuring the table:

  • layertitle : the title to use at the top of the table
  • layerid: The QGIS vector layer internal ID. It can be found in QGIS vector layer properties dialogue, tab Variables
  • uniquefield: the unique identifier of the layer features. Use the primary key if possible.
  • expressionfilter: a QGIS expression allowing to filter the displayed features. If no filter is set, all the features will be shown. Beware of bad performances for heavy datasets.
  • withgeometry: If this attribute exists (with or without a value), the geometries will also be used and downloaded. Use it at present if the feature display expression depends on the geometry, for example if it contains a calculation made from the geometry, e.g. area(@geometry). In the future, this will also be used to draw the geometry on the map.
  • sortingfield and sortingorder: allow defining in which order the features must be displayed. Default is the alphabetical order of the display expression values. asc means ascending order, and desc means descending order.
  • draggable: if set with the value yes, the user will be able to change the position of an item in the table by dragging and dropping it.

Events will be fired

  • features.table.rendered When the table has been successfully displayed. The event carries the lizmap-features-table HTML element ID
  • features.table.item.dragged when the user has dropped an item in a new position. The event carries 3 properties:
    • itemFeatureId: the vector feature ID
    • itemOldLineId: the original line ID before dropping the item
    • itemNewLineId: the new line ID after dropping the item in a new position

Funded by Ville d'Avignon https://cartes.mairie-avignon.com/

@github-actions github-actions bot added this to the 3.8.0 milestone Jun 6, 2024
@mdouchin mdouchin self-assigned this Jun 6, 2024
@mdouchin mdouchin added enhancement user interface new feature javascript Pull requests that update Javascript code labels Jun 6, 2024
@mdouchin mdouchin requested review from nboisteault and Gustry June 6, 2024 09:42
@Gustry Gustry added the sponsored development This development has been funded label Jun 6, 2024
@Gustry Gustry modified the milestones: 3.8.0, 3.9.0 Jun 7, 2024
@mdouchin mdouchin force-pushed the lizmap-features-table branch 2 times, most recently from eb07c0f to 4bead37 Compare June 20, 2024 08:23
@mdouchin mdouchin force-pushed the lizmap-features-table branch 2 times, most recently from bdb42b3 to d31f7f3 Compare July 29, 2024 15:43
@mdouchin mdouchin added the run end2end If the PR must run end2end tests or not label Jul 30, 2024
@mdouchin mdouchin modified the milestones: 3.9.0, 3.8.0 Jul 30, 2024
@mdouchin mdouchin force-pushed the lizmap-features-table branch from d31f7f3 to 70cbde6 Compare July 30, 2024 16:01
@github-actions github-actions bot modified the milestones: 3.8.0, 3.9.0 Jul 30, 2024
@mdouchin mdouchin requested review from nboisteault and rldhont July 30, 2024 16:02
@mdouchin mdouchin marked this pull request as ready for review July 30, 2024 16:05
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.

Use the new API.

assets/src/components/FeaturesTable.js Outdated Show resolved Hide resolved
assets/src/components/FeaturesTable.js Outdated Show resolved Hide resolved
assets/src/components/FeaturesTable.js Outdated Show resolved Hide resolved
assets/src/modules/FeaturesTable.js Outdated Show resolved Hide resolved
assets/src/modules/FeaturesTable.js Outdated Show resolved Hide resolved
@mdouchin mdouchin force-pushed the lizmap-features-table branch from 70cbde6 to c91f887 Compare July 31, 2024 07:38
…ist of features

<lizmap-features-table
    layertitle="child sub-districts"
    layerid="sousquartiers_24ceec66_e7fe_46a2_b57a_af5c50389649"
    uniquefield="id"
    expressionfilter="quartmno = 'MC'"
    withgeometry="1"
    sortingfield="libsquart"
    sortingorder="asc"
    draggable="yes"
></lizmap-features-table>
@Gustry
Copy link
Member

Gustry commented Aug 1, 2024

I just noticed this while translating on Transifex new strings.
This PR uses item/items :

image

For consistency with QGIS and other parts of Lizmap, shouldn't we use feature ?
I'm just trying to be consistent across the application.

@erw-1
Copy link
Contributor

erw-1 commented Nov 29, 2024

When a feature table item is selected, other items are automatically hidden, as expected. However, if there is another feature table in the selected feature, new items are also hidden before they can be picked, because they share the same CSS selector.

You could introduce a hierarchy level into the selector to differentiate between parent and child feature tables.

Video example (FRA): https://youtu.be/zZafmypUBVs

@rldhont
Copy link
Collaborator

rldhont commented Nov 29, 2024

Hi @erw-1 if you find an issue, please open one.

@rldhont
Copy link
Collaborator

rldhont commented Nov 29, 2024

@erw-1 you can also provide a Pull Request if you have a solution to fix it.

@erw-1
Copy link
Contributor

erw-1 commented Nov 29, 2024

Here, this is my first contribution/ pull request ever! Hopefully I did things right.
I'm a GIS student, learning dev stuff recreationally at the moment.

#5037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_8 doc-needed enhancement javascript Pull requests that update Javascript code new feature run end2end If the PR must run end2end tests or not sponsored development This development has been funded user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants