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

How to handle ToggleVisibility for table/columns #239

Closed
dhartford opened this issue Oct 9, 2023 · 8 comments · Fixed by #251
Closed

How to handle ToggleVisibility for table/columns #239

dhartford opened this issue Oct 9, 2023 · 8 comments · Fixed by #251
Assignees
Labels
card format/adaptivecard Adaptive Card support documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@dhartford
Copy link

dhartford commented Oct 9, 2023

Hi everyone,
I'm curious if there is a way to handle the chevron-style expand/collapse as shown here:

https://adaptivecards.io/samples/ExpenseReport.html

If there isn't a good way, is there a way to take the raw JSON (template) and raw JSON data and send it through this library?

TIA!!!

@atc0005
Copy link
Owner

atc0005 commented Oct 9, 2023

Hi @dhartford,

While I'm not familiar enough with Microsoft Teams to know the answer for sure, this library is mostly (at present) focused on submitting messages (formatted or not) through a webhook connector.

This is a one-way data submission and I'm not sure that there would be enough feedback for the client using this library to use in making a decision based on toggling the UI element.

@dhartford
Copy link
Author

thanks for the quick response!!!

Not looking for feedback/decisions, just 'hide' and 'show' with the toggle feature only (the visual side only)

@atc0005
Copy link
Owner

atc0005 commented Oct 10, 2023

@dhartford So are you asking whether you can embed JavaScript in the payload to make the delivered message in Microsoft Teams behave the way that the https://adaptivecards.io/samples/ExpenseReport.html demo does?

@dhartford
Copy link
Author

I mis-spoke - JSON template and JSON dataset (edited original ask), I was thinking javascript notation but only wrote javascript - sorry for the confusion!!!!

The example uses some special syntax as well as 'order' for the toggle visibility to work on certain containers that I can't quite seem to get with the API, which is why I was wondering if could do a 'raw' approach first until iterate it into the API in a meaningful (versus rushed) way.

` "type": "Container",

      "id": "cardContent${$index}",

      "isVisible": false,

      "items": [

        {

          "type": "Container",

          "items": [

            {

              "$data": "${custom_fields}",

              "type": "TextBlock",

              "text": "* ${value}",

              "isSubtle": true,

              "wrap": true

            },`

and

`
"type": "Column",

          "spacing": "small",
          
          "selectAction": {

            "type": "Action.ToggleVisibility",

            "title": "expand",

            "targetElements": [
              "cardContent${$index}",
              "chevronDown${$index}",
              "chevronUp${$index}"
            ]
          },
          "verticalContentAlignment": "center",
          "items": [
            {
              "type": "Image",
              "id": "chevronDown${$index}",
              "url": "https://adaptivecards.io/content/down.png",
              "width": "20px",
              "altText": "${description} $${total} collapsed"
            },

            {
              "type": "Image",
              "id": "chevronUp${$index}",
              "url": "https://adaptivecards.io/content/up.png",
              "width": "20px",
              "altText": "${description} $${total} expanded",
              "isVisible": false
            }
            `

@atc0005
Copy link
Owner

atc0005 commented Oct 11, 2023

@dhartford Thanks for the additional details/clarification.

I appreciate the desire to prototype before implementing library changes.

When I'm prototyping changes to this library or a client tool I maintain I often fallback to using the approach noted here:

If you can craft a JSON file that you're able to successfully deliver to a Microsoft Teams webhook (e.g., via curl) then it's very likely that this library could grow the feature to do the same, either in a raw manner as you've indicated or in another form.

Please give that approach a try and let me know what results you get.

@atc0005
Copy link
Owner

atc0005 commented Nov 20, 2023

@dhartford see also this recent request:

@atc0005 atc0005 self-assigned this Dec 6, 2023
@atc0005 atc0005 added documentation Improvements or additions to documentation enhancement New feature or request card format/adaptivecard Adaptive Card support labels Dec 6, 2023
atc0005 added a commit that referenced this issue Dec 7, 2023
- 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
@atc0005
Copy link
Owner

atc0005 commented Dec 7, 2023

@dhartford The initial prototype support can be found in the v2.9.0-alpha.1 release here:

Examples are included.

Feedback is welcome.

@atc0005 atc0005 added this to the v2.9.0 milestone Dec 7, 2023
@atc0005
Copy link
Owner

atc0005 commented Dec 14, 2023

Hi @dhartford ,

Just checking to make sure you saw my last note.

atc0005 added a commit that referenced this issue Jan 25, 2024
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
card format/adaptivecard Adaptive Card support documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants