AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

[Feature Request] support template bool for rtl and other boolean properties.

Open licanhua opened this issue 3 years ago • 8 comments

Problem Statement

$ is not a valid usage in JSON, so it has problem to convert the template data to bool directly.

"rtl": ${bool($rtl)}

Proposed solution

Data binding works as expected as requested in this feature request. To see the correct usage, see 4350. Designer needs to be updated so that a serialization doesn't happen before template expansion because templates are stripped off if the expected type are not string.

Alternatives or Workarounds

No response

licanhua avatar Oct 25 '21 16:10 licanhua

Ditto for int() to be used with value, min, and max for number fields.

aarongustafson avatar Mar 02 '22 23:03 aarongustafson

Another way of thinking about this, if the parsing is too much of a challenge: Could you adjust the API of these fields that require boolean, integers, etc. to allow for equivalents as well. So, 3 == "3" or true == 'true' or even true == 1. Making the API more liberal in what it accepts (with guardrails of course) would make for a more robust solution overall and eliminate the need for this sort of value coercion in a template to begin with.

aarongustafson avatar Mar 08 '22 17:03 aarongustafson

Is this a regression? I'm not sure if this is a new feature request or a bug since this PR seems to address it: https://github.com/microsoft/AdaptiveCards/pull/4351

JeanRoca avatar Aug 10 '22 19:08 JeanRoca

See https://github.com/microsoft/AdaptiveCards/issues/4350 as well

JeanRoca avatar Aug 10 '22 19:08 JeanRoca

@JeanRoca Given the dates, I’m guessing it’s a regression. Not sure if it is extended to int(), but if it isn’t it should be.

aarongustafson avatar Aug 10 '22 20:08 aarongustafson

I think this might be just Designer issue. let me try that. There will be a lot more issues filed if this doesn't work.

jwoo-msft avatar Aug 11 '22 21:08 jwoo-msft

I verify that it does work in code.

jwoo-msft avatar Aug 11 '22 23:08 jwoo-msft

I've updated the feature request with a proposed solution.

jwoo-msft avatar Aug 11 '22 23:08 jwoo-msft

This also happens when trying to set image height and width using the data payload. You can only see the image change size when you hit preview mode. Is this expected behavior?

Card JSON

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5",
    "body": [
        {
            "type": "TextBlock",
            "text": "Image test:",
            "wrap": true
        },
        {
            "type": "Image",
            "url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
            "width": "${imageSize}",
            "height": "${imageSize}"
        }
    ]
}

Data JSON

{
    "imageSize": "100px"
}

JeanRoca avatar Aug 16 '22 22:08 JeanRoca