@@ -165,7 +165,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
165165
166166 def pageview_fields ( assigns ) do
167167 ~H"""
168- < div id = "pageviews-form " class = "py-2 " { @ rest } >
168+ < div id = "pageviews-form " class = "py-2 " x-data = " { addCustomProperty: false } " { @ rest } >
169169 < div class = "text-sm pb-6 text-gray-500 dark:text-gray-400 text-justify rounded-md " >
170170 Pageview goals allow you to measure how many people visit a specific page or section of your site. Learn more in < . styled_link
171171 href = "https://plausible.io/docs/pageview-goals "
@@ -204,6 +204,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
204204 x-data = "{ firstFocus: true } "
205205 x-on:focus = "if (firstFocus) { $el.select(); firstFocus = false; } "
206206 />
207+
208+ < . custom_property_section suffix = { @ suffix } />
207209 </ div >
208210 """
209211 end
@@ -222,6 +224,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
222224 scrollThreshold: '90',
223225 pagePath: '',
224226 displayName: '',
227+ addCustomProperty: false,
225228 updateDisplayName() {
226229 if (this.scrollThreshold && this.pagePath) {
227230 this.displayName = `Scroll ${this.scrollThreshold}% on ${this.pagePath}`
@@ -235,6 +238,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
235238 scrollThreshold: '#{ assigns . goal . scroll_threshold } ',
236239 pagePath: '#{ assigns . goal . page_path } ',
237240 displayName: '#{ assigns . goal . display_name } ',
241+ addCustomProperty: false,
238242 updateDisplayName() {}
239243 }
240244 """
@@ -299,6 +303,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
299303 x-data = "{ firstFocus: true } "
300304 x-on:focus = "if (firstFocus) { $el.select(); firstFocus = false; } "
301305 />
306+
307+ < . custom_property_section suffix = { @ suffix } />
302308 </ div >
303309 """
304310 end
@@ -317,7 +323,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
317323
318324 def custom_event_fields ( assigns ) do
319325 ~H"""
320- < div id = "custom-events-form " class = "py-2 " { @ rest } >
326+ < div id = "custom-events-form " class = "py-2 " x-data = " { addCustomProperty: false } " { @ rest } >
321327 < div id = "event-fields " >
322328 < div class = "text-sm pb-6 text-gray-500 dark:text-gray-400 text-justify rounded-md " >
323329 Custom Events are not tracked by default - you have to configure them on your site to be sent to Plausible. See examples and learn more in < . styled_link
@@ -364,6 +370,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
364370 />
365371 </ div >
366372
373+ < . custom_property_section suffix = { @ suffix } />
374+
367375 <%= if ee? ( ) and Plausible.Sites . regular? ( @ site ) and not editing_non_revenue_goal? ( assigns ) do %>
368376 < . revenue_goal_settings
369377 f = { @ f }
@@ -382,6 +390,43 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
382390 """
383391 end
384392
393+ attr ( :suffix , :string , required: true )
394+
395+ def custom_property_section ( assigns ) do
396+ ~H"""
397+ < div class = "mt-6 mb-2 flex items-center justify-between " >
398+ < span class = "text-sm/6 font-medium text-gray-900 dark:text-gray-100 " >
399+ Add custom property
400+ </ span >
401+ < . toggle_switch
402+ id = "add-custom-property "
403+ id_suffix = { @ suffix }
404+ js_active_var = "addCustomProperty "
405+ />
406+ </ div >
407+
408+ < div x-show = "addCustomProperty " class = "flex items-center gap-3 " >
409+ < . live_component
410+ id = { "property_input_#{ @ suffix } " }
411+ submit_name = "goal[property] "
412+ placeholder = "Select property "
413+ module = { ComboBox }
414+ suggest_fun = { fn _input , _options -> [ ] end }
415+ creatable
416+ />
417+ < span class = "text-sm/6 font-medium text-gray-900 dark:text-gray-100 " > is</ span >
418+ < . live_component
419+ id = { "value_input_#{ @ suffix } " }
420+ submit_name = "goal[value] "
421+ placeholder = "Select value "
422+ module = { ComboBox }
423+ suggest_fun = { fn _input , _options -> [ ] end }
424+ creatable
425+ />
426+ </ div >
427+ """
428+ end
429+
385430 def revenue_goal_settings ( assigns ) do
386431 js_data =
387432 Jason . encode! ( % {
@@ -394,7 +439,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
394439 ~H"""
395440 < div x-data = { @ js_data } data-test-id = "revenue-goal-settings " >
396441 <%= if is_nil ( @ goal ) do %>
397- < div class = "mt-6 mb-3 " >
442+ < div class = "mt-6 mb-2 " >
398443 < . revenue_toggle { assigns } />
399444 </ div >
400445 <% else %>
@@ -515,22 +560,22 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
515560 /> .
516561 </ div >
517562 </: tooltip_content >
518- < div class = "flex itemx-center mb-3 " >
519- < PlausibleWeb.Components.Generic . toggle_switch
520- id = "enable-revenue-tracking "
521- id_suffix = { @ suffix }
522- js_active_var = "active "
523- disabled = { not @ has_access_to_revenue_goals? }
524- />
563+ < div class = "flex items-center justify-between " >
525564 < span class = { [
526- "ml-3 text-sm font-medium" ,
565+ "text-sm/6 font-medium" ,
527566 if ( @ has_access_to_revenue_goals? ,
528567 do: "text-gray-900 dark:text-gray-100" ,
529568 else: "text-gray-500 dark:text-gray-400"
530569 )
531570 ] } >
532571 Enable revenue tracking
533572 </ span >
573+ < PlausibleWeb.Components.Generic . toggle_switch
574+ id = "enable-revenue-tracking "
575+ id_suffix = { @ suffix }
576+ js_active_var = "active "
577+ disabled = { not @ has_access_to_revenue_goals? }
578+ />
534579 </ div >
535580 </ . tooltip >
536581 """
0 commit comments