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

Field Template Bug #1019

Merged
merged 2 commits into from
Dec 4, 2023
Merged

Field Template Bug #1019

merged 2 commits into from
Dec 4, 2023

Conversation

simon-leech
Copy link
Contributor

@simon-leech simon-leech commented Nov 29, 2023

This PR addresses a bug on two layer formats: mvt and wkt.
Previously if you provided a workspace.template for the thematic field, the workspace.template name was not assigned as the field name, meaning the thematic would be drawn as all 0 or null.

So in the example below, the mvt and wkt layer formats would return
select case when field >0 then field*10 else field end
which would mean that there was no field for the thematic.
This PR adds the following code, ensuring the field key is used as the field name.

const fields = _.fields?.split(',')
    .map(field => `${_.workspace.templates[field]?.template || field} AS ${field}`)
    .filter(field => !!field)

Example:

"templates": { 
"field_template": {
"template": "case when field > 10 then field*10 else field end"
}
}
"themes": {
      "test": {
        "title": "Test",
        "type": "graduated",
        "field": "field_template",
        "cat_arr": [
          {
            "value": 0,
            "label": "Under £75",
            "style": {
              "fillColor": "#edf8fb",
              "fillOpacity": 0.5
            }
          },
        {
            "value": 75,
            "label": "£75 - £150",
            "style": {
              "fillColor": "#edf8fb",
              "fillOpacity": 0.5
            }
          }
       ] 
   } 
}

@simon-leech simon-leech marked this pull request as ready for review November 29, 2023 11:16
@simon-leech simon-leech added the Bug A genuine bug. There must be some form of error exception to work with. label Nov 29, 2023
Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

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

The labels should also be escaped if they come from a template.

Copy link

sonarcloud bot commented Nov 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

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

lgtm

@RobAndrewHurst RobAndrewHurst merged commit 89bd992 into GEOLYTIX:main Dec 4, 2023
6 checks passed
@simon-leech simon-leech deleted the field-template-fix branch February 9, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug. There must be some form of error exception to work with.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants