@@ -132,6 +132,15 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
132132 site = { @ site }
133133 x-init = "tabSelectionInProgress = false "
134134 />
135+ < . scroll_fields
136+ :if = { @ selected_tab == "scroll" }
137+ x-show = "!tabSelectionInProgress "
138+ f = { f }
139+ suffix = { suffix ( @ context_unique_id , @ tab_sequence_id ) }
140+ current_user = { @ current_user }
141+ site = { @ site }
142+ x-init = "tabSelectionInProgress = false "
143+ />
135144
136145 < div x-show = "!tabSelectionInProgress " >
137146 < . button type = "submit " class = "w-full " >
@@ -196,17 +205,63 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
196205 x-data = "{ firstFocus: true } "
197206 x-on:focus = "if (firstFocus) { $el.select(); firstFocus = false; } "
198207 />
208+ </ div >
209+ """
210+ end
211+
212+ attr ( :f , Phoenix.HTML.Form )
213+ attr ( :current_user , Plausible.Auth.User )
214+ attr ( :site , Plausible.Site )
215+ attr ( :suffix , :string )
216+ attr ( :goal , Plausible.Goal , default: nil )
217+ attr ( :rest , :global )
218+
219+ def scroll_fields ( assigns ) do
220+ ~H"""
221+ < div id = "scroll-form " class = "py-2 " { @ rest } >
222+ < . label for = { "scroll_threshold_input_#{ @ suffix } " } >
223+ Scroll Threshold
224+ </ . label >
199225
200226 < . input
201- :if = { Plausible.Stats.ScrollDepth . feature_visible? ( @ site , @ current_user ) }
202- label = "Scroll Depth Threshold (optional) "
227+ id = { "scroll_threshold_input_#{ @ suffix } " }
203228 field = { @ f [ :scroll_threshold ] }
204229 type = "number "
205230 value = { if @ goal && @ goal . scroll_threshold > - 1 , do: @ goal . scroll_threshold , else: nil }
206231 min = "0 "
207232 max = "100 "
208233 step = "1 "
209234 />
235+
236+ < . label for = { "page_path_input_#{ @ suffix } " } class = "mt-3 " >
237+ Page Path
238+ </ . label >
239+
240+ < . live_component
241+ id = { "page_path_input_#{ @ suffix } " }
242+ submit_name = "goal[page_path] "
243+ class = { [
244+ "py-2"
245+ ] }
246+ module = { ComboBox }
247+ suggest_fun = { fn input , _options -> suggest_page_paths ( input , @ site ) end }
248+ selected = { if @ goal && @ goal . page_path , do: @ goal . page_path }
249+ creatable
250+ x-on-selection-change = "document.getElementById('pageview_display_name_input').setAttribute('value', 'Visit ' + $event.detail.value.displayValue) "
251+ />
252+
253+ < . error :for = { msg <- Enum . map ( @ f [ :page_path ] . errors , & translate_error / 1 ) } >
254+ { msg }
255+ </ . error >
256+
257+ < . input
258+ label = "Display Name "
259+ id = "pageview_display_name_input "
260+ field = { @ f [ :display_name ] }
261+ type = "text "
262+ x-data = "{ firstFocus: true } "
263+ x-on:focus = "if (firstFocus) { $el.select(); firstFocus = false; } "
264+ />
210265 </ div >
211266 """
212267 end
@@ -375,6 +430,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
375430 < div class = "my-2 text-sm w-full flex rounded border border-gray-300 dark:border-gray-500 " >
376431 < . custom_events_tab selected? = { @ selected_tab == "custom_events" } myself = { @ myself } />
377432 < . pageviews_tab selected? = { @ selected_tab == "pageviews" } myself = { @ myself } />
433+ < . scroll_tab selected? = { @ selected_tab == "scroll" } myself = { @ myself } />
378434 </ div >
379435 """
380436 end
@@ -383,7 +439,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
383439 ~H"""
384440 < a
385441 class = { [
386- "w-1/2 text-center py-2.5 border-r dark:border-gray-500" ,
442+ "w-1/3 text-center py-2.5 border-r dark:border-gray-500" ,
387443 "cursor-pointer" ,
388444 @ selected? && "shadow-inner font-medium bg-indigo-600 text-white" ,
389445 ! @ selected? && "dark:text-gray-100 text-gray-800"
@@ -403,7 +459,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
403459 ~H"""
404460 < a
405461 class = { [
406- "w-1/2 text-center py-2.5 cursor-pointer" ,
462+ "w-1/3 text-center py-2.5 cursor-pointer" ,
407463 @ selected? && "shadow-inner font-medium bg-indigo-600 text-white" ,
408464 ! @ selected? && "dark:text-gray-100 text-gray-800"
409465 ] }
@@ -418,6 +474,25 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
418474 """
419475 end
420476
477+ def scroll_tab ( assigns ) do
478+ ~H"""
479+ < a
480+ class = { [
481+ "w-1/3 text-center py-2.5 cursor-pointer" ,
482+ @ selected? && "shadow-inner font-medium bg-indigo-600 text-white" ,
483+ ! @ selected? && "dark:text-gray-100 text-gray-800"
484+ ] }
485+ id = "pageview-tab "
486+ x-on:click = { ! @ selected? && "tabSelectionInProgress = true" }
487+ phx-click = "switch-tab "
488+ phx-value-tab = "scroll "
489+ phx-target = { @ myself }
490+ >
491+ Scroll
492+ </ a >
493+ """
494+ end
495+
421496 def handle_event ( "switch-tab" , % { "tab" => tab } , socket ) do
422497 socket =
423498 socket
0 commit comments