Skip to content

Commit

Permalink
Initial support for toggling visibility
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
atc0005 committed Jan 25, 2024
1 parent 64c5cd4 commit 7ef6d52
Show file tree
Hide file tree
Showing 6 changed files with 1,068 additions and 25 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ A package to send messages to a Microsoft Teams channel.
- [Tables](#tables)
- [Set custom user agent](#set-custom-user-agent)
- [Add an Action](#add-an-action)
- [Toggle visibility](#toggle-visibility)
- [Disable webhook URL prefix validation](#disable-webhook-url-prefix-validation)
- [Enable custom patterns' validation](#enable-custom-patterns-validation)
- [Used by](#used-by)
Expand Down Expand Up @@ -242,6 +243,17 @@ this action triggers opening a URL in a separate browser or application.
- `MessageCard`
- File: [actions](./examples/messagecard/actions/main.go)

#### Toggle visibility

These examples illustrates using
[`ToggleVisibility`][adaptivecard-ref-actions] Actions to control the
visibility of various Elements of an `Adaptive Card` message.

- File: [toggle-visibility-single-button](./examples/adaptivecard/toggle-visibility-single-button/main.go)
- File: [toggle-visibility-multiple-buttons](./examples/adaptivecard/toggle-visibility-multiple-buttons/main.go)
- File: [toggle-visibility-column-action](./examples/adaptivecard/toggle-visibility-column-action/main.go)
- File: [toggle-visibility-container-action](./examples/adaptivecard/toggle-visibility-container-action/main.go)

#### Disable webhook URL prefix validation

This example disables the validation webhook URLs, including the validation of
Expand Down
Loading

0 comments on commit 7ef6d52

Please sign in to comment.