Add editing group title
This commit is contained in:
parent
35f8c983ad
commit
b66a5d2934
|
@ -72,6 +72,23 @@ defmodule FrenzyWeb.GroupController do
|
|||
end
|
||||
end
|
||||
|
||||
def edit(conn, _params) do
|
||||
group = conn.assigns[:group]
|
||||
edit_changeset = Group.changeset(group, %{})
|
||||
|
||||
render(conn, "edit.html", %{
|
||||
group: group,
|
||||
changeset: edit_changeset
|
||||
})
|
||||
end
|
||||
|
||||
def update(conn, %{"group" => group_params}) do
|
||||
group = conn.assigns[:group]
|
||||
changeset = Group.changeset(group, group_params)
|
||||
{:ok, group} = Repo.update(changeset)
|
||||
redirect(conn, to: Routes.group_path(Endpoint, :show, group.id))
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
group = conn.assigns[:group]
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ defmodule FrenzyWeb.Router do
|
|||
post "/account/export", AccountController, :export
|
||||
|
||||
get "/", GroupController, :index
|
||||
resources "/groups", GroupController, except: [:edit, :update]
|
||||
resources "/groups", GroupController
|
||||
|
||||
resources "/feeds", FeedController, except: [:index, :new]
|
||||
post "/feeds/:id/refresh", FeedController, :refresh
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<h1>Edit Group</h1>
|
||||
|
||||
<%= form_for @changeset, Routes.group_path(@conn, :update, @group.id), fn f -> %>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label" for="title">Title</label>
|
||||
<div class="col-sm-10">
|
||||
<%= text_input f, :title, class: "form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<%= submit "Update Group", class: "btn btn-primary" %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,10 +1,11 @@
|
|||
<h1><%= @group.title %></h1>
|
||||
|
||||
<%= form_tag Routes.group_path(@conn, :delete, @group.id), method: :delete do %>
|
||||
<a href="<%= Routes.group_path(@conn, :edit, @group.id) %>" class="btn btn-primary">Edit Group</a>
|
||||
<%= form_tag Routes.group_path(@conn, :delete, @group.id), method: :delete, class: "d-inline" do %>
|
||||
<%= submit "Delete Group", class: "btn btn-danger" %>
|
||||
<% end %>
|
||||
|
||||
<%= form_for @create_feed_changeset, Routes.feed_path(@conn, :create), fn form -> %>
|
||||
<%= form_for @create_feed_changeset, Routes.feed_path(@conn, :create), [class: "mt-2 mb-2"], fn form -> %>
|
||||
<%= hidden_input form, :group_id %>
|
||||
<div class="row">
|
||||
<%= label form, :feed_url, "Feed URL", class: "col-sm-2 col-form-label" %>
|
||||
|
@ -17,6 +18,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<a href="#" class="btn btn-secondary">Read Articles</a>
|
||||
|
||||
<h3 class="mt-4">Feeds</h3>
|
||||
|
||||
|
|
Loading…
Reference in New Issue