-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support for ToggleVisibility #243
Comments
Hi @arluko Thank you for the detailed GH issue. No promises on implementation time, but a quick review suggests this should be doable. I will try to share a curl snippet and JSON file to test functionality in the near future so you can test delivering to your Teams instance. This will help confirm that the generated JSON payload will work as expected. |
Place this within a text file (e.g., {
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "Something has failed",
"wrap": true,
"style": "heading"
},
{
"id": "details",
"type": "TextBlock",
"text": "Lorem ipsum dolor sit amet ...",
"wrap": true,
"isVisible": false
},
{
"type": "Container",
"selectAction": {
"type": "Action.ToggleVisibility",
"targetElements": [
"details",
"showDetails",
"hideDetails"
]
},
"items": [
{
"type": "TextBlock",
"id": "showDetails",
"color": "Accent",
"text": "Show details"
},
{
"type": "TextBlock",
"id": "hideDetails",
"color": "Accent",
"text": "Hide details",
"isVisible": false
}
]
}
]
}
}
]
} and use this snippet to deliver it (substituting the example webhook URL for your own): webhook_url="https://example.webhook.office.com/webhookb2/a1269812-6d10-44b1-abc5-b84f93580ba0@9e7b80c7-d1eb-4b52-8582-76f921e416d9/IncomingWebhook/3fdd6767bae44ac58e5995547d66a4e4/f332c8d9-3397-4ac5-957b-b8e3fc465a8c"
curl \
-X POST \
-H "Content-type: application/json" \
-d @/path/to/gh-243-test-payload1.json \
"${webhook_url}" |
@atc0005 I have tested your sample with curl and it works on my teams instance. |
Thank you for testing and confirming the results. |
I've been working on this, but it will take some time to work out the changes. I'll post again when there is something ready for testing/feedback. |
- add Element.Visible field - to control visibility of Elements - if not specified, this value defaults to true by omitting the field from the generated JSON payload - add TargetElement type - add Action.TargetElement field - to specify collection of TargetElement values - used to specify target Element values whose visibility state should be controlled by the Element whose Action the TargetElement field is associated with - add ISelectAction.TargetElements field - same purpose as Action.TargetElement field - add missing validation for Element.SelectAction field for Element of ColumnSet type - add missing validation for Element.SelectAction field for Element of Container type - add Column.AddSelectAction method - accepts Action or ISelectAction value - update ISelectAction.Validate method - add missing validation for ISelectAction.Fallback field - add validation for ISelectAction.TargetElements field for Action.ToggleVisibility type - update Action.Validate method - convert validation logic to use validator package - add Action.AddTargetElement method - accepts multiple Element values - allows explicitly setting target Element visibility - add Action.AddVisibleTargetElement method - convienence method to explicitly enable visibility for target Element values - add Action.AddHiddenTargetElement method - convienence method to explicitly disable visibility for target Element values - add Action.AddTargetElementID method - accepts multiple Element ID values - allows explicitly setting target Element visibility - add new helper "constructor" functions - NewHiddenerContainer - NewColumn - NewColumnSet - NewHiddenTextBlock - NewActionToggleVisibility - update Container.AddAction - add note to doc comments directing reader to Container.AddSelectAction for adding an Action to be used when the Container is tapped or selected - add Container.AddSelectAction method - accepts Action or ISelectAction value - add examples - add toggle-visibility-column-action - add toggle-visibility-container-action - add toggle-visibility-multiple-buttons - add toggle-visibility-single-button refs GH-243 refs GH-239
@arluko The initial prototype support can be found in the v2.9.0-alpha.1 release here: Examples are included. Feedback is welcome. |
@atc0005 I have tested the |
Hi @arluko , Thanks for testing and providing feedback. As I worked on these changes I ran into several places in the code that I would have liked to change to make integrating the new support easier, to make the steps feel more natural, but that would require an API change and thus a version bump to v3. I would like to avoid that here if possible; I would like to wait a bit longer and gather additional feedback before including this code as part of the next stable release. While this initial implementation is subject to change (to fix any discovered problems), the tag I shared will remain in case you wish to move forward with the existing behavior in your application(s) while we wait on others to respond. |
@atc0005 I have restructured my card (for now) to work without the toggle visibility feature, so I am not really dependent on a immediate release with this feature. If there is a release sometime in the future with this functionality, I will integrate it, but in the meantime I have a working solution. |
- add Element.Visible field - to control visibility of Elements - if not specified, this value defaults to true by omitting the field from the generated JSON payload - add TargetElement type - add Action.TargetElement field - to specify collection of TargetElement values - used to specify target Element values whose visibility state should be controlled by the Element whose Action the TargetElement field is associated with - add ISelectAction.TargetElements field - same purpose as Action.TargetElement field - add missing validation for Element.SelectAction field for Element of ColumnSet type - add missing validation for Element.SelectAction field for Element of Container type - add Column.AddSelectAction method - accepts Action or ISelectAction value - update ISelectAction.Validate method - add missing validation for ISelectAction.Fallback field - add validation for ISelectAction.TargetElements field for Action.ToggleVisibility type - update Action.Validate method - convert validation logic to use validator package - add Action.AddTargetElement method - accepts multiple Element values - allows explicitly setting target Element visibility - add Action.AddVisibleTargetElement method - convienence method to explicitly enable visibility for target Element values - add Action.AddHiddenTargetElement method - convienence method to explicitly disable visibility for target Element values - add Action.AddTargetElementID method - accepts multiple Element ID values - allows explicitly setting target Element visibility - add new helper "constructor" functions - NewHiddenerContainer - NewColumn - NewColumnSet - NewHiddenTextBlock - NewActionToggleVisibility - update Container.AddAction - add note to doc comments directing reader to Container.AddSelectAction for adding an Action to be used when the Container is tapped or selected - add Container.AddSelectAction method - accepts Action or ISelectAction value - add examples - add toggle-visibility-column-action - add toggle-visibility-container-action - add toggle-visibility-multiple-buttons - add toggle-visibility-single-button refs GH-243 refs GH-239
First, thank a lot for this library. It made my job a lot easier but a little but crucial piece for my use-case is missing.
I would like to build an AdaptiveCard to achieve the following:
I have built an example which you can try out in the
Preview mode
of the designer:The following pieces are currently missing:
targetElements
can not be set on theAction.ToggleVisibility
(see schema)isVisible
can not be set on anContainer
(see schema)Note:
isVisible
can not only be set onContainer
but a lot more element but for my use-case a container should be enough.Can you add support for these two properties?
The text was updated successfully, but these errors were encountered: