@@ -13,14 +13,8 @@ defmodule PeekAppSDK.UI.Odyssey.OdysseyActivityPicker do
1313 use Phoenix.LiveComponent
1414 use Phoenix.Component
1515
16- @ required_assigns ~w( field install_id) a
17-
1816 @ impl true
1917 def mount ( socket ) do
20- socket =
21- socket
22- |> assign ( selection: nil )
23-
2418 { :ok , socket }
2519 end
2620
@@ -59,7 +53,7 @@ defmodule PeekAppSDK.UI.Odyssey.OdysseyActivityPicker do
5953 ~H"""
6054 < div phx-hook = "OdysseyActivityPicker " id = { "#{ @ id } _hook" } >
6155 <!-- Hidden input for form value -->
62- < input type = "hidden " name = { @ field . name } value = { @ selection } />
56+ < input type = "hidden " name = { @ field . name } value = { process_ids_for_multi_select ( @ field . value ) } />
6357
6458 <!-- Odyssey product picker will be rendered here -->
6559 < div >
@@ -68,7 +62,8 @@ defmodule PeekAppSDK.UI.Odyssey.OdysseyActivityPicker do
6862 phx-update = "ignore "
6963 title = "Activity Picker "
7064 phx-target = { @ myself }
71- ids = { @ selection }
65+ multiple = { if ( @ multiple , do: "true" , else: "false" ) }
66+ ids = { process_ids_for_multi_select ( @ field . value ) }
7267 products = { Jason . encode! ( @ products ) }
7368 >
7469 </ odyssey-product-picker >
@@ -77,6 +72,10 @@ defmodule PeekAppSDK.UI.Odyssey.OdysseyActivityPicker do
7772 """
7873 end
7974
75+ defp process_ids_for_multi_select ( ids ) do
76+ ids |> List . wrap ( ) |> Enum . join ( "," )
77+ end
78+
8079 @ doc """
8180 Renders an activity picker component.
8281
@@ -85,6 +84,7 @@ defmodule PeekAppSDK.UI.Odyssey.OdysseyActivityPicker do
8584 """
8685 attr ( :field , :any , required: true , doc: "a Phoenix.HTML.FormField struct" )
8786 attr ( :id , :string , doc: "component id, defaults to form_field_activity_picker" )
87+ attr ( :multiple , :boolean , default: false , doc: "whether to allow multiple selections" )
8888 attr ( :install_id , :string , required: true , doc: "the install id for the current partner" )
8989
9090 def odyssey_activity_picker ( assigns ) do
0 commit comments