analytics/lib/plausible_web/live/goal_settings/form.ex

375 lines
12 KiB
Elixir
Raw Normal View History

Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
defmodule PlausibleWeb.Live.GoalSettings.Form do
@moduledoc """
Live view for the goal creation form
"""
use Phoenix.LiveComponent, global_prefixes: ~w(x-)
use Plausible
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
import PlausibleWeb.Live.Components.Form
alias PlausibleWeb.Live.Components.ComboBox
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
alias Plausible.Repo
def update(assigns, socket) do
site = Repo.preload(assigns.site, [:owner])
owner = Plausible.Users.with_subscription(site.owner)
site = %{site | owner: owner}
has_access_to_revenue_goals? =
Plausible.Billing.Feature.RevenueGoals.check_availability(owner) == :ok
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
form =
%Plausible.Goal{}
|> Plausible.Goal.changeset()
|> to_form()
socket =
socket
|> assign(
id: assigns.id,
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
context_unique_id: assigns.context_unique_id,
form: form,
event_name_options_count: length(assigns.event_name_options),
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
event_name_options: Enum.map(assigns.event_name_options, &{&1, &1}),
current_user: assigns.current_user,
domain: assigns.domain,
selected_tab: "custom_events",
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
tab_sequence_id: 0,
site: site,
has_access_to_revenue_goals?: has_access_to_revenue_goals?,
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
existing_goals: assigns.existing_goals,
on_save_goal: assigns.on_save_goal,
on_autoconfigure: assigns.on_autoconfigure
)
{:ok, socket}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
end
def render(assigns) do
~H"""
<div id={@id}>
<.form
:let={f}
x-data="{ tabSelectionInProgress: false }"
for={@form}
phx-submit="save-goal"
phx-target={@myself}
>
<PlausibleWeb.Components.Generic.spinner
class="spinner block absolute right-9 top-8"
x-show="tabSelectionInProgress"
/>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<h2 class="text-xl font-black dark:text-gray-100">Add Goal for <%= @domain %></h2>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<.tabs selected_tab={@selected_tab} myself={@myself} />
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<.custom_event_fields
:if={@selected_tab == "custom_events"}
x-show="!tabSelectionInProgress"
f={f}
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
suffix={suffix(@context_unique_id, @tab_sequence_id)}
current_user={@current_user}
site={@site}
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
existing_goals={@existing_goals}
goal_options={@event_name_options}
has_access_to_revenue_goals?={@has_access_to_revenue_goals?}
x-init="tabSelectionInProgress = false"
/>
<.pageview_fields
:if={@selected_tab == "pageviews"}
x-show="!tabSelectionInProgress"
f={f}
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
suffix={suffix(@context_unique_id, @tab_sequence_id)}
site={@site}
x-init="tabSelectionInProgress = false"
/>
<div class="py-4" x-show="!tabSelectionInProgress">
<PlausibleWeb.Components.Generic.button type="submit" class="w-full">
Add Goal
</PlausibleWeb.Components.Generic.button>
</div>
<button
:if={@selected_tab == "custom_events" && @event_name_options_count > 0}
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
x-show="!tabSelectionInProgress"
class="mt-2 text-sm hover:underline text-indigo-600 dark:text-indigo-400 text-left"
phx-click="autoconfigure"
phx-target={@myself}
>
<span :if={@event_name_options_count > 1}>
Already sending custom events? We've found <%= @event_name_options_count %> custom events from the last 6 months that are not yet configured as goals. Click here to add them.
</span>
<span :if={@event_name_options_count == 1}>
Already sending custom events? We've found 1 custom event from the last 6 months that is not yet configured as a goal. Click here to add it.
</span>
</button>
</.form>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</div>
"""
end
attr(:f, Phoenix.HTML.Form)
attr(:site, Plausible.Site)
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
attr(:suffix, :string)
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
attr(:rest, :global)
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
def pageview_fields(assigns) do
~H"""
<div id="pageviews-form" class="py-2" {@rest}>
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
<.label for={"page_path_input_#{@suffix}"}>
Page Path
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</.label>
<.live_component
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
id={"page_path_input_#{@suffix}"}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
submit_name="goal[page_path]"
class={[
"py-2"
]}
module={ComboBox}
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
suggest_fun={fn input, _options -> suggest_page_paths(input, @site) end}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
creatable
/>
<.error :for={{msg, opts} <- @f[:page_path].errors}>
<%= Enum.reduce(opts, msg, fn {key, value}, acc ->
String.replace(acc, "%{#{key}}", fn _ -> to_string(value) end)
end) %>
</.error>
</div>
"""
end
attr(:f, Phoenix.HTML.Form)
attr(:site, Plausible.Site)
attr(:current_user, Plausible.Auth.User)
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
attr(:suffix, :string)
attr(:existing_goals, :list)
attr(:goal_options, :list)
attr(:has_access_to_revenue_goals?, :boolean)
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
attr(:rest, :global)
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
def custom_event_fields(assigns) do
~H"""
<div id="custom-events-form" class="my-6" {@rest}>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<div id="event-fields">
<div class="pb-6 text-xs text-gray-700 dark:text-gray-200 text-justify rounded-md">
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 <a
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
class="text-indigo-500 hover:underline"
target="_blank"
rel="noreferrer"
href="https://plausible.io/docs/custom-event-goals"
> our docs</a>.
</div>
<div>
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
<.label for={"event_name_input_#{@suffix}"}>
Event Name
</.label>
<.live_component
id={"event_name_input_#{@suffix}"}
submit_name="goal[event_name]"
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
placeholder="e.g. Signup"
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
class={[
"py-2"
]}
module={ComboBox}
suggest_fun={fn input, _options -> suggest_event_names(input, @site, @existing_goals) end}
options={@goal_options}
creatable
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
/>
</div>
<div
:if={ee?()}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
class="mt-6 space-y-3"
x-data={
Jason.encode!(%{
active: !!@f[:currency].value and @f[:currency].value != "",
currency: @f[:currency].value
})
}
>
<PlausibleWeb.Components.Billing.Notice.premium_feature
billable_user={@site.owner}
current_user={@current_user}
feature_mod={Plausible.Billing.Feature.RevenueGoals}
size={:xs}
class="rounded-b-md"
/>
<button
class={[
"flex items-center w-max mb-3",
if @has_access_to_revenue_goals? do
"cursor-pointer"
else
"cursor-not-allowed"
end
]}
aria-labelledby="enable-revenue-tracking"
role="switch"
type="button"
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
x-on:click="active = !active; currency = ''"
x-bind:aria-checked="active"
disabled={not @has_access_to_revenue_goals?}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
>
<span
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
class="relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2"
x-bind:class="active ? 'bg-indigo-600' : 'dark:bg-gray-700 bg-gray-200'"
>
<span
aria-hidden="true"
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
x-bind:class="active ? 'dark:bg-gray-800 translate-x-5' : 'dark:bg-gray-800 translate-x-0'"
/>
</span>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<span
class={[
"ml-3 font-medium",
if(assigns.has_access_to_revenue_goals?,
do: "text-gray-900 dark:text-gray-100",
else: "text-gray-500 dark:text-gray-300"
)
]}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
id="enable-revenue-tracking"
>
Enable Revenue Tracking
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</span>
</button>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<div x-show="active">
<.live_component
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
id={"currency_input_#{@suffix}"}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
submit_name={@f[:currency].name}
module={ComboBox}
suggest_fun={
on_ee do
fn
"", [] ->
Plausible.Goal.Revenue.currency_options()
input, options ->
ComboBox.StaticSearch.suggest(input, options, weight_threshold: 0.8)
end
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
end
}
/>
</div>
</div>
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
<.error :for={{msg, opts} <- @f[:event_name].errors}>
<%= Enum.reduce(opts, msg, fn {key, value}, acc ->
String.replace(acc, "%{#{key}}", fn _ -> to_string(value) end)
end) %>
</.error>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</div>
</div>
"""
end
def tabs(assigns) do
~H"""
<div class="mt-6 font-medium dark:text-gray-100">Goal Trigger</div>
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
<div class="my-3 w-full flex rounded border border-gray-300 dark:border-gray-500">
<.custom_events_tab selected?={@selected_tab == "custom_events"} myself={@myself} />
<.pageviews_tab selected?={@selected_tab == "pageviews"} myself={@myself} />
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</div>
"""
end
defp custom_events_tab(assigns) do
~H"""
<a
class={[
"w-1/2 text-center py-2 border-r dark:border-gray-500",
"cursor-pointer",
@selected? && "shadow-inner font-bold bg-indigo-600 text-white",
!@selected? && "dark:text-gray-100 text-gray-800"
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
]}
id="event-tab"
x-on:click={!@selected? && "tabSelectionInProgress = true"}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
phx-click="switch-tab"
phx-value-tab="custom_events"
phx-target={@myself}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
>
Custom Event
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
</a>
"""
end
def pageviews_tab(assigns) do
~H"""
<a
class={[
"w-1/2 text-center py-2 cursor-pointer",
@selected? && "shadow-inner font-bold bg-indigo-600 text-white",
!@selected? && "dark:text-gray-100 text-gray-800"
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
]}
id="pageview-tab"
x-on:click={!@selected? && "tabSelectionInProgress = true"}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
phx-click="switch-tab"
phx-value-tab="pageviews"
phx-target={@myself}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
>
Pageview
</a>
"""
end
def handle_event("switch-tab", %{"tab" => tab}, socket) do
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
socket =
socket
|> assign(:selected_tab, tab)
|> update(:tab_sequence_id, &(&1 + 1))
{:noreply, socket}
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
end
def handle_event("save-goal", %{"goal" => goal}, socket) do
case Plausible.Goals.create(socket.assigns.site, goal) do
{:ok, goal} ->
socket =
goal
|> Map.put(:funnels, [])
|> socket.assigns.on_save_goal.(socket)
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
{:noreply, socket}
{:error, %Ecto.Changeset{} = changeset} ->
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
{:noreply, assign(socket, form: to_form(changeset))}
end
end
def handle_event("autoconfigure", _params, socket) do
{:noreply, socket.assigns.on_autoconfigure.(socket)}
end
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
def suggest_page_paths(input, site) do
query = Plausible.Stats.Query.from(site, %{"with_imported" => "true", "period" => "all"})
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
site
|> Plausible.Stats.filter_suggestions(query, "page", input)
|> Enum.map(fn %{label: label, value: value} -> {label, value} end)
end
Implement custom events suggestions (#4092) * Start suggesting event names in goal settings form * Fix tests * Bump phoenix_live_view to 0.20.12 * Implement a criminal hack to track removal of modal's child live components * Revert "Implement a criminal hack to track removal of modal's child live components" This reverts commit f34ceb78f17dbdc531e7be90b7039231cd919c46. * Remove redundant closing brace from currency combo input * Hide batch goal add button when tab selection is in progress * Implement unique modal ID regenerated on every modal close/open cycle * Use unique modal ID as ID suffix to live components in goal settings form * Reset suffix on tab selection to reset live components state on switch * Revert "Bump phoenix_live_view to 0.20.12" This reverts commit 1b1c80198128efe4b9021791c0f279a097fd70f9. * Make unique IDs more predictable * Fix tests for `GoalSettings.Form` * Use unique modal ID in country rule modal * Use unique modal ID in hostname rule modal * Use unique modal ID in page rule form modal * Don't limit detected goals when fetching them for autoconfigure * Escape interpolated Alpine state function argument * Exclude goals with whitespace on either end or consisting only of whitespace * Ensure event name suggestions update after goal deletion * Avoid showing loading spinner when closing modal * Don't enable spinner when new combobox selection is identical * Revert "Don't enable spinner when new combobox selection is identical" This reverts commit a041ba8542432827a48185282aefb4396f69b48f.
2024-06-11 09:28:25 +03:00
def suggest_event_names(input, site, existing_goals) do
existing_names =
existing_goals
|> Enum.reject(&is_nil(&1.event_name))
|> Enum.map(& &1.event_name)
site
|> Plausible.Stats.GoalSuggestions.suggest_event_names(input, exclude: existing_names)
|> Enum.map(fn name -> {name, name} end)
end
defp suffix(context_unique_id, tab_sequence_id) do
"#{context_unique_id}-tabseq#{tab_sequence_id}"
end
Improve goal settings UX (#3293) * Add Heroicons dependency * Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector * Update changelog * Make goal deletion possible with only goal id * Remove stale goal controllers * Improve ComboBox component - make sure the list options are always of the parent input width - allow passing a suggestion function instead of a module * Stale fixup * Update routes * Use the new goals route in funnel settings * Use a function in the funnel combo * Use function in the props combo * Remove old goals form * Implement new goal settings * Update moduledoc * Fix revenue switch in dark mode * Connect live socket on goal settings page * Fixup * Use Heroicons.trash icon * Tweak goals search input * Remove unused alias * Fix search/button alignment * Fix backspace icon alignment * Delegate :superadmin check to get_for_user/3 I'll do props settings separately, it's work in progress in a branch on top of this one already. cc @ukutaht * Rename socket assigns * Fixup to 5c9f58e * Fixup * Render ComboBox suggestions asynchronously This commit: - prevents redundant work by checking the socket connection - allows passing no options to the ComboBox component, so that when combined with the `async` option, the options are asynchronously initialized post-render - allows updating the suggestions asynchronously with the `async` option set to `true` - helpful in case of DB queries used for suggestions * Update tests * Throttle comboboxes * Update tests * Dim the search input * Use debounce=200 in ComboBox component * Move creatable option to the top * Ensure there's always a leading slash for goals * Test pageview goals with leading / missing * Make the modal scrollable on small viewports
2023-09-04 14:44:22 +03:00
end