Skip to content

Commit

Permalink
refactor: Removed some things to clean up example
Browse files Browse the repository at this point in the history
  • Loading branch information
theycallmehero committed Nov 6, 2021
1 parent e5e486e commit 4f822f2
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lib/moon_web/pages/tutorials/add_data_using_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ defmodule MoonWeb.Pages.Tutorials.AddDataUsingForm do
alias Moon.Components.Heading
alias Moon.Components.Link
alias Moon.Components.Select
alias Moon.Components.Switch
alias Moon.Components.TextInput
alias Moon.Components.Toast.Message
alias Moon.Components.ToastStack
Expand Down Expand Up @@ -55,12 +54,9 @@ defmodule MoonWeb.Pages.Tutorials.AddDataUsingForm do
|> assign(
theme_name: params["theme_name"] || "sportsbet-dark",
active_page: __MODULE__,
user_map: @default_user_map,
user_changeset: user_changeset,
gender_options: gender_options,
lock_fields: false,
uploaded_files: [],
enable_validations: false
uploaded_files: []
)
|> allow_upload(:file, accept: ~w(.jpg .jpeg .png .pdf), max_entries: 1)

Expand Down Expand Up @@ -128,7 +124,6 @@ defmodule MoonWeb.Pages.Tutorials.AddDataUsingForm do
~F"""
@user_changeset = {inspect(@user_changeset, pretty: true)}
@gender_options = {inspect(@gender_options, pretty: true)}
@lock_fields = {@lock_fields}
@uploads.file.entries = {inspect(@uploads.file.entries, pretty: true)}
"""
end
Expand Down Expand Up @@ -162,17 +157,13 @@ defmodule MoonWeb.Pages.Tutorials.AddDataUsingForm do

def handle_event("clear_changeset_form", _, socket) do
user_changeset = User.changeset(%User{}, @default_user_map)
{:noreply, assign(socket, user_changeset: user_changeset, lock_fields: false)}
{:noreply, assign(socket, user_changeset: user_changeset)}
end

def handle_event("clear_simple_form", _, socket) do
{:noreply, assign(socket, user_map: @default_user_map)}
end

def handle_event("lock_form_fields", _, socket) do
{:noreply, assign(socket, lock_fields: !socket.assigns.lock_fields)}
end

def handle_info({:hide_toast, toast_id}, socket) do
ToastStack.hide_toast(toast_id, "toasts")
{:noreply, socket}
Expand Down

0 comments on commit 4f822f2

Please sign in to comment.