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

Retrieve spatialDataColumn in TableWidget for its future usage #900

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

jmgaya
Copy link
Contributor

@jmgaya jmgaya commented Sep 6, 2024

Description

Shortcut: https://app.shortcut.com/cartoteam/story/438209/add-support-for-geocolumn-spatialdatacolumn-when-retrieving-table-widget-information?cf_workflow=500091853&ct_workflow=all&vc_group_by=day

Sending this to the API should give us back the information about the spatialDataColumn, which we'll use afterward for zooming into the coordinate

zoomtopoint

Type of change

  • Feature


```
yarn build && ./copy-packages.sh ~/workspace/repositories/cloud-native/workspace-www/node_modules/@carto
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zbigg I've added this, as we both sometimes copy&paste content for the seek of pragmatism when developing things on Carto4React and testing them on cloud-native 😄

queryParams.spatialDataType = spatialDataType;
if (spatialFilters) queryParams.spatialFilters = JSON.stringify(spatialFilters);
if (spatialDataType) queryParams.spatialDataType = spatialDataType;
if (spatialDataColumn) queryParams.spatialDataColumn = spatialDataColumn;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only specifies which is the spatialDataColumn and shouldn't affect other Widgets, but it's used from the Backend perspective for determining which column they should "transform", for more info see: https://github.com/CartoDB/cloud-native/pull/17146

@@ -121,6 +122,7 @@ function TableWidget({
height={height}
dense={dense}
isLoading={isLoading}
onRowClick={onRowClick}
Copy link
Contributor Author

@jmgaya jmgaya Sep 6, 2024

Choose a reason for hiding this comment

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

I've added support for the onRowClick event Handler to the TableWidget, because it needs support for this initiative 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

ok but add a new comment in the parm section please

Copy link

github-actions bot commented Sep 6, 2024

Pull Request Test Coverage Report for Build 10770948415

Details

  • 19 of 22 (86.36%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 70.964%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-api/src/api/model.js 19 22 86.36%
Totals Coverage Status
Change from base Build 10722808249: 0.007%
Covered Lines: 2839
Relevant Lines: 3682

💛 - Coveralls

Copy link

github-actions bot commented Sep 6, 2024

Visit the preview URL for this PR (updated for commit 9d90a71):

https://cartodb-fb-storybook-react-dev--pr900-feature-438209-s-tkhjm3e2.web.app

(expires Mon, 16 Sep 2024 10:06:45 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 517cc4d31d7e09cf277774e034094b67c301cd4c

if (props.model === 'table') {
queryParams.params = JSON.stringify({
...params,
column: [...params.column, spatialDataColumn]
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor.
I would prefer special parameter that either hides (hiddenColumns) some column or fetches extra column (invisiableColumns) than magic that just adds geo column to fetched set.

App will have power to use whatever "extra" column it needs - even if current use case is to add exactly same column as spatialDataColumn

Copy link
Contributor Author

@jmgaya jmgaya Sep 6, 2024

Choose a reason for hiding this comment

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

I like it 🤔

The only "problem" I see is that we'll have to expose or move somewhere the extraction of the spatialDataColumn, because it's the one we need to pass down as "hiddenColumns` or whatever name we decide to use, WDYT?

I've tried to keep the number of changes as minimal as possible because of being Carto4React, but I'm happy to make more obvious the retrieval of such columns, rather than hiding magic in the "core utility"

Copy link
Member

Choose a reason for hiding this comment

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

Will share more details in Slack, but we are also working on adding the ability for the server to return a unique ID for all layers, by hashing the geometry. When a unique ID is available, perhaps fetching the entire geometry into the table widget is not necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @donmccurdy but it's something that we need to check in the server-side click initiative. Also, I'm worried if PS uses this widget and suddenly they will start receiving geometries. @jmgaya It would be possible to request the geometries as an optional parameter of the table widget?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this if is going to be difficult to adapt when we integrate carto-api-client. The TableWidget has a columns parameter that you could use to add the spatialDataColumn and you would need an extra property to hide this column. I know that it requires more changes but I think that would be cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When a unique ID is available, perhaps fetching the entire geometry into the table widget is not necessary?

Yup, I think this makes total sense! However, it's not ready yet, but we should probably re-visit this once we merge this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this if is going to be difficult to adapt when we integrate carto-api-client

Absolutely agree! I've tried to keep this as minimal as possible, but in terms of reusability, we can handle this in a different way, let me propose something else 👍

@@ -121,6 +122,7 @@ function TableWidget({
height={height}
dense={dense}
isLoading={isLoading}
onRowClick={onRowClick}
Copy link
Contributor

Choose a reason for hiding this comment

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

ok but add a new comment in the parm section please

if (props.model === 'table') {
queryParams.params = JSON.stringify({
...params,
column: [...params.column, spatialDataColumn]
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @donmccurdy but it's something that we need to check in the server-side click initiative. Also, I'm worried if PS uses this widget and suddenly they will start receiving geometries. @jmgaya It would be possible to request the geometries as an optional parameter of the table widget?

if (props.model === 'table') {
queryParams.params = JSON.stringify({
...params,
column: [...params.column, spatialDataColumn]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this if is going to be difficult to adapt when we integrate carto-api-client. The TableWidget has a columns parameter that you could use to add the spatialDataColumn and you would need an extra property to hide this column. I know that it requires more changes but I think that would be cleaner.

@jmgaya jmgaya requested review from zbigg and padawannn September 9, 2024 09:58
@jmgaya jmgaya marked this pull request as ready for review September 9, 2024 09:58
@jmgaya jmgaya merged commit 04b9491 into master Sep 10, 2024
2 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.

4 participants