Skip to content

Commit

Permalink
description of wasm handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Nelson committed Mar 2, 2024
1 parent 8ee4339 commit 6d477de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions lib/launch_cart/forms/wasm_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule LaunchCart.Forms.WasmHandler do
@foreign_key_type :binary_id
schema "wasm_handlers" do
field :wasm, Wasm.Type
field :description, :string
belongs_to :form, Form

timestamps()
Expand All @@ -19,8 +20,8 @@ defmodule LaunchCart.Forms.WasmHandler do
@doc false
def changeset(wasm_handler, attrs) do
wasm_handler
|> cast(attrs, [:form_id])
|> cast(attrs, [:form_id, :description])
|> cast_attachments(attrs, [:wasm], allow_paths: true)
|> validate_required([:form_id])
|> validate_required([:form_id, :description])
end
end
9 changes: 1 addition & 8 deletions lib/launch_cart_web/live/form_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@
<%= live_redirect "View reponses", to: Routes.form_form_responses_path(@socket, :index, @form) %>
</p>

<p>Form responses will be sent to these end points:</p>

<.web_hooks id="web-hooks" web-hooks={@form.web_hooks}></.web_hooks>

<p>Form responses will be sent to these email addresses:</p>

<.form_emails id="form-emails" form-emails={@form.form_emails}></.form_emails>

<.link patch={~p"/forms/#{@form.id}/wasm_handlers"}>WASM Form Handlers</.link>

<h2 class="u-push__top--xl">Usage:</h2>
<p>Using your Launch Form is easy! </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defmodule LaunchCartWeb.WasmHandlerLive.FormComponent do
phx-submit="save"
>
<.input type="hidden" field={@form[:form_id]} value={@form_id} />
<.input type="text" field={@form[:description]} label="Description" />
<.live_file_input upload={@uploads.wasm}/>
<:actions>
Expand Down
4 changes: 2 additions & 2 deletions lib/launch_cart_web/live/wasm_handler_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Listing Wasm handlers
<:actions>
<.link patch={~p"/forms/#{@form_id}/wasm_handlers/new"}>
<.button>New Wasm handler</.button>
New WASM Handler
</.link>
</:actions>
</.header>
Expand All @@ -12,7 +12,7 @@
rows={@streams.wasm_handlers}
row_click={fn {_id, wasm_handler} -> JS.navigate(~p"/forms/#{@form_id}/wasm_handlers/#{wasm_handler}") end}
>
<:col :let={{_id, wasm_handler}} label="Wasm">Filename goes here</:col>
<:col :let={{_id, wasm_handler}} label="Description"><%= wasm_handler.description %></:col>
<:action :let={{_id, wasm_handler}}>
<div class="sr-only">
<.link navigate={~p"/wasm_handlers/#{wasm_handler}"}>Show</.link>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule LaunchCart.Repo.Migrations.AddDescriptionToWasmHandlers do
use Ecto.Migration

def change do
alter table(:wasm_handlers) do
add :description, :string
end
end
end

0 comments on commit 6d477de

Please sign in to comment.