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

group + rule is not work #111

Open
njuptlzf opened this issue Feb 10, 2025 · 2 comments
Open

group + rule is not work #111

njuptlzf opened this issue Feb 10, 2025 · 2 comments

Comments

@njuptlzf
Copy link

njuptlzf commented Feb 10, 2025

jsonform

value.json

{
  "size": 1,
  "container1": {
    "name": "Initial Name for Container 1",
    "image": "https://example.com/image.png"
  },
  "container2": {
    "name": "Initial Name for Container 2",
    "url": "https://example.com"
  }
}

schema.json

{
  "type": "object",
  "properties": {
    "size": {
      "type": "integer",
      "title": "Size",
      "enum": [1, 2],
      "default": 1
    },
    "container1": {
      "type": "object",
      "title": "Container 1",
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "image": {
          "type": "string",
          "title": "Image URL"
        }
      }
    },
    "container2": {
      "type": "object",
      "title": "Container 2",
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "url": {
          "type": "string",
          "title": "URL"
        }
      }
    }
  }
}

ui-schema.json

{
  "type": "VerticalLayout",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/size",
      "label": "Size",
      "options": {
        "format": "radio"
      }
    },
    {
      "type": "Group",
      "label": "Container 1",
      "elements": [
        {
          "type": "Control",
          "scope": "#/properties/container1/properties/name",
          "label": "Name"
        },
        {
          "type": "Control",
          "scope": "#/properties/container1/properties/image",
          "label": "Image URL"
        }
      ],
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/size",
          "schema": {
            "const": 1
          }
        }
      }
    },
    {
      "type": "Group",
      "label": "Container 2",
      "elements": [
        {
          "type": "Control",
          "scope": "#/properties/container2/properties/name",
          "label": "Name"
        },
        {
          "type": "Control",
          "scope": "#/properties/container2/properties/url",
          "label": "URL"
        }
      ],
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/size",
          "schema": {
            "const": 2
          }
        }
      }
    }
  ]
}

result

Image

other info

If it is a simple string, then it is fine.

@DrewHoo
Copy link
Contributor

DrewHoo commented Feb 11, 2025

Nice find! It looks like we're not using the visible property correctly in the group renderer: https://github.com/great-expectations/jsonforms-antd-renderers/blob/main/src/layouts/GroupLayout.tsx

It should probably return null if visible is false.

Do you want to try opening a PR with your example as a test?

@njuptlzf
Copy link
Author

njuptlzf commented Feb 13, 2025

Nice find! It looks like we're not using the visible property correctly in the group renderer: https://github.com/great-expectations/jsonforms-antd-renderers/blob/main/src/layouts/GroupLayout.tsx

It should probably return null if visible is false.

Do you want to try opening a PR with your example as a test?

Hi, @DrewHoo, I am very keen on building open source projects, but I am sorry that I am not good at typescript and antd. I generated the jsonforms-antd-renderers rendering project based on ai. :(

I am willing to fix this issue in parallel with everyone. If it is not fixed in a few days (or weeks), I will try to submit this PR when I have time. :)

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

No branches or pull requests

2 participants