Autogen registration UI.
This commit is contained in:
62
lib/runosaari_web/controllers/performer_controller.ex
Normal file
62
lib/runosaari_web/controllers/performer_controller.ex
Normal file
@@ -0,0 +1,62 @@
|
||||
defmodule RunosaariWeb.PerformerController do
|
||||
use RunosaariWeb, :controller
|
||||
|
||||
alias Runosaari.Registration
|
||||
alias Runosaari.Registration.Performer
|
||||
|
||||
def index(conn, _params) do
|
||||
performers = Registration.list_performers()
|
||||
render(conn, "index.html", performers: performers)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = Registration.change_performer(%Performer{})
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
def create(conn, %{"performer" => performer_params}) do
|
||||
case Registration.create_performer(performer_params) do
|
||||
{:ok, performer} ->
|
||||
conn
|
||||
|> put_flash(:info, "Performer created successfully.")
|
||||
|> redirect(to: Routes.performer_path(conn, :show, performer))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
performer = Registration.get_performer!(id)
|
||||
render(conn, "show.html", performer: performer)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
performer = Registration.get_performer!(id)
|
||||
changeset = Registration.change_performer(performer)
|
||||
render(conn, "edit.html", performer: performer, changeset: changeset)
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "performer" => performer_params}) do
|
||||
performer = Registration.get_performer!(id)
|
||||
|
||||
case Registration.update_performer(performer, performer_params) do
|
||||
{:ok, performer} ->
|
||||
conn
|
||||
|> put_flash(:info, "Performer updated successfully.")
|
||||
|> redirect(to: Routes.performer_path(conn, :show, performer))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "edit.html", performer: performer, changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
performer = Registration.get_performer!(id)
|
||||
{:ok, _performer} = Registration.delete_performer(performer)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Performer deleted successfully.")
|
||||
|> redirect(to: Routes.performer_path(conn, :index))
|
||||
end
|
||||
end
|
||||
@@ -17,6 +17,7 @@ defmodule RunosaariWeb.Router do
|
||||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :index
|
||||
resources "/performers", PerformerController
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
|
||||
5
lib/runosaari_web/templates/performer/edit.html.eex
Normal file
5
lib/runosaari_web/templates/performer/edit.html.eex
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>Edit Performer</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.performer_path(@conn, :update, @performer)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.performer_path(@conn, :index) %></span>
|
||||
39
lib/runosaari_web/templates/performer/form.html.eex
Normal file
39
lib/runosaari_web/templates/performer/form.html.eex
Normal file
@@ -0,0 +1,39 @@
|
||||
<%= form_for @changeset, @action, fn f -> %>
|
||||
<%= if @changeset.action do %>
|
||||
<div class="alert alert-danger">
|
||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= label f, :performerId %>
|
||||
<%= number_input f, :performerId %>
|
||||
<%= error_tag f, :performerId %>
|
||||
|
||||
<%= label f, :fname %>
|
||||
<%= text_input f, :fname %>
|
||||
<%= error_tag f, :fname %>
|
||||
|
||||
<%= label f, :lname %>
|
||||
<%= text_input f, :lname %>
|
||||
<%= error_tag f, :lname %>
|
||||
|
||||
<%= label f, :email %>
|
||||
<%= text_input f, :email %>
|
||||
<%= error_tag f, :email %>
|
||||
|
||||
<%= label f, :tel %>
|
||||
<%= text_input f, :tel %>
|
||||
<%= error_tag f, :tel %>
|
||||
|
||||
<%= label f, :confirmed %>
|
||||
<%= checkbox f, :confirmed %>
|
||||
<%= error_tag f, :confirmed %>
|
||||
|
||||
<%= label f, :notes %>
|
||||
<%= text_input f, :notes %>
|
||||
<%= error_tag f, :notes %>
|
||||
|
||||
<div>
|
||||
<%= submit "Save" %>
|
||||
</div>
|
||||
<% end %>
|
||||
38
lib/runosaari_web/templates/performer/index.html.eex
Normal file
38
lib/runosaari_web/templates/performer/index.html.eex
Normal file
@@ -0,0 +1,38 @@
|
||||
<h1>Listing Performers</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Performerid</th>
|
||||
<th>Fname</th>
|
||||
<th>Lname</th>
|
||||
<th>Email</th>
|
||||
<th>Tel</th>
|
||||
<th>Confirmed</th>
|
||||
<th>Notes</th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for performer <- @performers do %>
|
||||
<tr>
|
||||
<td><%= performer.performerId %></td>
|
||||
<td><%= performer.fname %></td>
|
||||
<td><%= performer.lname %></td>
|
||||
<td><%= performer.email %></td>
|
||||
<td><%= performer.tel %></td>
|
||||
<td><%= performer.confirmed %></td>
|
||||
<td><%= performer.notes %></td>
|
||||
|
||||
<td>
|
||||
<span><%= link "Show", to: Routes.performer_path(@conn, :show, performer) %></span>
|
||||
<span><%= link "Edit", to: Routes.performer_path(@conn, :edit, performer) %></span>
|
||||
<span><%= link "Delete", to: Routes.performer_path(@conn, :delete, performer), method: :delete, data: [confirm: "Are you sure?"] %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<span><%= link "New Performer", to: Routes.performer_path(@conn, :new) %></span>
|
||||
5
lib/runosaari_web/templates/performer/new.html.eex
Normal file
5
lib/runosaari_web/templates/performer/new.html.eex
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New Performer</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.performer_path(@conn, :create)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.performer_path(@conn, :index) %></span>
|
||||
43
lib/runosaari_web/templates/performer/show.html.eex
Normal file
43
lib/runosaari_web/templates/performer/show.html.eex
Normal file
@@ -0,0 +1,43 @@
|
||||
<h1>Show Performer</h1>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<strong>Performerid:</strong>
|
||||
<%= @performer.performerId %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Fname:</strong>
|
||||
<%= @performer.fname %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Lname:</strong>
|
||||
<%= @performer.lname %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Email:</strong>
|
||||
<%= @performer.email %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Tel:</strong>
|
||||
<%= @performer.tel %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Confirmed:</strong>
|
||||
<%= @performer.confirmed %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Notes:</strong>
|
||||
<%= @performer.notes %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<span><%= link "Edit", to: Routes.performer_path(@conn, :edit, @performer) %></span>
|
||||
<span><%= link "Back", to: Routes.performer_path(@conn, :index) %></span>
|
||||
3
lib/runosaari_web/views/performer_view.ex
Normal file
3
lib/runosaari_web/views/performer_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule RunosaariWeb.PerformerView do
|
||||
use RunosaariWeb, :view
|
||||
end
|
||||
Reference in New Issue
Block a user