diff --git a/lib/shift73k_web/live/live_helpers.ex b/lib/shift73k_web/live/live_helpers.ex index ff98ac8d..36c33170 100644 --- a/lib/shift73k_web/live/live_helpers.ex +++ b/lib/shift73k_web/live/live_helpers.ex @@ -1,6 +1,5 @@ defmodule Shift73kWeb.LiveHelpers do import Phoenix.LiveView - import Phoenix.LiveView.Helpers alias Shift73k.Accounts alias Shift73k.Accounts.User @@ -19,27 +18,6 @@ defmodule Shift73kWeb.LiveHelpers do """ def live_okreply(socket), do: {:ok, socket} - @doc """ - Renders a component inside the `Shift73kWeb.ModalComponent` component. - - The rendered modal receives a `:return_to` option to properly update - the URL when the modal is closed. - - ## Examples - - <%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent, - id: @property.id || :new, - action: @live_action, - property: @property, - return_to: Routes.property_index_path(@socket, :index) %> - """ - def live_modal(socket, component, opts) do - modal_opts = [id: :modal, component: component, opts: opts] - # dirty little workaround for elixir complaining about socket being unused - _socket = socket - live_component(socket, Shift73kWeb.ModalComponent, modal_opts) - end - @doc """ Loads default assigns for liveviews """ diff --git a/lib/shift73k_web/live/shift_assign_live/index.html.heex b/lib/shift73k_web/live/shift_assign_live/index.html.heex index ce1d37a4..ce656afe 100644 --- a/lib/shift73k_web/live/shift_assign_live/index.html.heex +++ b/lib/shift73k_web/live/shift_assign_live/index.html.heex @@ -1,10 +1,15 @@ <%= if @delete_days_shifts do %> - <%= live_modal @socket, Shift73kWeb.ShiftAssignLive.DeleteComponent, + <.live_component + module={Shift73kWeb.ModalComponent} + id="modal" + component={Shift73kWeb.ShiftAssignLive.DeleteComponent} + opts={[ id: "delete-days-shifts-#{@current_user.id}", title: "Delete Shifts From Selected Days", delete_days_shifts: @delete_days_shifts, current_user: @current_user - %> + ]} + /> <% end %> diff --git a/lib/shift73k_web/live/shift_live/index.html.heex b/lib/shift73k_web/live/shift_live/index.html.heex index bc9cdf08..b599bd8e 100644 --- a/lib/shift73k_web/live/shift_live/index.html.heex +++ b/lib/shift73k_web/live/shift_live/index.html.heex @@ -1,8 +1,14 @@ <%= if @delete_shift do %> - <%= live_modal @socket, Shift73kWeb.ShiftLive.DeleteComponent, + <.live_component + module={Shift73kWeb.ModalComponent} + id="modal" + component={Shift73kWeb.ShiftLive.DeleteComponent} + opts={[ id: @delete_shift.id, title: "Delete Shift Template", - delete_shift: @delete_shift %> + delete_shift: @delete_shift + ]} + /> <% end %> diff --git a/lib/shift73k_web/live/shift_template_live/index.html.heex b/lib/shift73k_web/live/shift_template_live/index.html.heex index 45faa445..62abcdec 100644 --- a/lib/shift73k_web/live/shift_template_live/index.html.heex +++ b/lib/shift73k_web/live/shift_template_live/index.html.heex @@ -1,17 +1,29 @@ <%= if @live_action in [:new, :edit, :clone] do %> - <%= live_modal @socket, Shift73kWeb.ShiftTemplateLive.FormComponent, - id: @shift_template.id || :new, - title: @page_title, - action: @live_action, - shift_template: @shift_template, - current_user: @current_user %> + <.live_component + module={Shift73kWeb.ModalComponent} + id="modal" + component={Shift73kWeb.ShiftTemplateLive.FormComponent} + opts={[ + id: @shift_template.id || :new, + title: @page_title, + action: @live_action, + shift_template: @shift_template, + current_user: @current_user + ]} + /> <% end %> <%= if @delete_shift_template do %> - <%= live_modal @socket, Shift73kWeb.ShiftTemplateLive.DeleteComponent, + <.live_component + module={Shift73kWeb.ModalComponent} + id="modal" + component={Shift73kWeb.ShiftTemplateLive.DeleteComponent} + opts={[ id: @delete_shift_template.id, title: "Delete Shift Template", - delete_shift_template: @delete_shift_template %> + delete_shift_template: @delete_shift_template + ]} + /> <% end %> diff --git a/lib/shift73k_web/live/user/settings.html.heex b/lib/shift73k_web/live/user/settings.html.heex index 40e08afe..e769ec43 100644 --- a/lib/shift73k_web/live/user/settings.html.heex +++ b/lib/shift73k_web/live/user/settings.html.heex @@ -6,10 +6,10 @@