chat_sdk-teams 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chat_sdk/teams/adaptive_card_renderer.rb +41 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dd8b4de05c46835a9f07d65dd88446c9b76bc3caef20447fbf2e660d6244e32
|
|
4
|
+
data.tar.gz: ffd479d4c04b616d7f18559871f999f7b02d81ef627fd5a0da1eca3a2021d44e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 180473cb244ebb81bbbfc2c6027525dead9def447370eab1a22a4332b81cbe116a7391bc64dfb9ece492c40106d2984a705c6529fb0506755650370630cd6f34
|
|
7
|
+
data.tar.gz: 225fa926d125f21ff5cb9c970015aa9da7e7d5415caf0fbceac7d9cd73ee11223ebe74b18a3e75fb5078fd1dd3efdab50eceb293286f7d6a5ef2e35cd00404fe
|
|
@@ -37,16 +37,18 @@ module ChatSDK
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
wrap_card(body)
|
|
40
|
+
wrap_card(body, width: node.attributes[:width])
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
def wrap_card(body)
|
|
44
|
-
{
|
|
43
|
+
def wrap_card(body, width: nil)
|
|
44
|
+
card = {
|
|
45
45
|
"type" => "AdaptiveCard",
|
|
46
46
|
"$schema" => "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
47
|
-
"version" => "1.
|
|
47
|
+
"version" => "1.5",
|
|
48
48
|
"body" => body
|
|
49
49
|
}
|
|
50
|
+
card["msteams"] = {"width" => "full"} if width.to_s == "full"
|
|
51
|
+
card
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
def render_node(node)
|
|
@@ -60,6 +62,8 @@ module ChatSDK
|
|
|
60
62
|
when :button then render_action_submit(node)
|
|
61
63
|
when :link_button then render_action_open_url(node)
|
|
62
64
|
when :select then render_select(node)
|
|
65
|
+
when :table then render_table(node)
|
|
66
|
+
when :chart then render_chart(node)
|
|
63
67
|
end
|
|
64
68
|
end
|
|
65
69
|
|
|
@@ -141,6 +145,7 @@ module ChatSDK
|
|
|
141
145
|
"data" => {"action" => node.attributes[:id]}
|
|
142
146
|
}
|
|
143
147
|
action["data"]["value"] = node.attributes[:value] if node.attributes[:value]
|
|
148
|
+
action["tooltip"] = node.attributes[:tooltip] if node.attributes[:tooltip]
|
|
144
149
|
if node.attributes[:style] == :primary
|
|
145
150
|
action["style"] = "positive"
|
|
146
151
|
elsif node.attributes[:style] == :danger
|
|
@@ -150,11 +155,14 @@ module ChatSDK
|
|
|
150
155
|
end
|
|
151
156
|
|
|
152
157
|
def render_action_open_url(node)
|
|
153
|
-
{
|
|
158
|
+
action = {
|
|
154
159
|
"type" => "Action.OpenUrl",
|
|
155
160
|
"title" => node.attributes[:text],
|
|
156
161
|
"url" => node.attributes[:url]
|
|
157
162
|
}
|
|
163
|
+
action["id"] = node.attributes[:id] if node.attributes[:id]
|
|
164
|
+
action["tooltip"] = node.attributes[:tooltip] if node.attributes[:tooltip]
|
|
165
|
+
action
|
|
158
166
|
end
|
|
159
167
|
|
|
160
168
|
def render_select(node)
|
|
@@ -171,6 +179,34 @@ module ChatSDK
|
|
|
171
179
|
input["placeholder"] = node.attributes[:placeholder] if node.attributes[:placeholder]
|
|
172
180
|
input
|
|
173
181
|
end
|
|
182
|
+
|
|
183
|
+
def render_table(node)
|
|
184
|
+
rows = [Array(node.attributes[:headers]), *Array(node.attributes[:rows])]
|
|
185
|
+
{
|
|
186
|
+
"type" => "Container",
|
|
187
|
+
"items" => rows.each_with_index.map do |row, index|
|
|
188
|
+
{
|
|
189
|
+
"type" => "ColumnSet",
|
|
190
|
+
"columns" => Array(row).map do |cell|
|
|
191
|
+
{
|
|
192
|
+
"type" => "Column",
|
|
193
|
+
"width" => "stretch",
|
|
194
|
+
"items" => [{"type" => "TextBlock", "text" => cell.to_s, "weight" => ("bolder" if index.zero?), "wrap" => true}.compact]
|
|
195
|
+
}
|
|
196
|
+
end
|
|
197
|
+
}
|
|
198
|
+
end
|
|
199
|
+
}
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def render_chart(node)
|
|
203
|
+
{
|
|
204
|
+
"type" => "TextBlock",
|
|
205
|
+
"text" => node.fallback_text,
|
|
206
|
+
"wrap" => true,
|
|
207
|
+
"fontType" => "Monospace"
|
|
208
|
+
}
|
|
209
|
+
end
|
|
174
210
|
end
|
|
175
211
|
end
|
|
176
212
|
end
|