Skip to content

Commit

Permalink
Added Admin::PagesController logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiokr committed Aug 23, 2011
1 parent 702b4cd commit 4c6f599
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
15 changes: 15 additions & 0 deletions app/controllers/admin/pages_controller.rb
@@ -1,11 +1,26 @@
class Admin::PagesController < Admin::ApplicationController
def index
@pages = pages.order('key ASC, locale ASC')
end

def edit
@page = pages.find(params[:id])
end

def update
@page = pages.find(params[:id])

if @page.update_attributes(params[:manageable_content_page])
redirect_to admin_pages_path
else
render :edit
end
end

protected

def pages
ManageableContent::Manager.pages
end

end
23 changes: 22 additions & 1 deletion app/views/admin/pages/edit.html.erb
@@ -1,2 +1,23 @@
<h1>Admin::Pages#edit</h1>
<p>Find me in app/views/admin/pages/edit.html.erb</p>
<%= form_for @page, :url => admin_page_path(@page), :method => :put do |form| %>
<p>
<%= form.label :key %>
<%= form.text_field :key, :disabled => true %>
</p>
<p>
<%= form.label :locale %>
<%= form.text_field :locale, :disabled => true %>
</p>

<% unless form.object.page_contents.empty? %>
<% eligible_contents = ManageableContent::Manager.eligible_contents(form.object.key) %>
<%= form.fields_for :page_contents do |content_form| %>
<% if eligible_contents.include?(content_form.object.key.to_sym) %>
<%= content_form.label :content, content_form.object.key %>
<%= content_form.text_area :content %>
<% end %>
<% end %>
<% end %>
<%= form.submit 'Save' %>
<% end %>
15 changes: 14 additions & 1 deletion app/views/admin/pages/index.html.erb
@@ -1,2 +1,15 @@
<h1>Admin::Pages#index</h1>
<p>Find me in app/views/admin/pages/index.html.erb</p>
<table>
<thead>
<th>Page</th>
<th></th>
<thead>
<tbody>
<% @pages.each do |page| %>
<tr>
<td><%= page.key.titleize %></td>
<td><%= link_to 'edit', edit_admin_page_path(page) %></td>
</tr>
<% end %>
</tbody>
</table>
2 changes: 0 additions & 2 deletions app/views/admin/pages/update.html.erb

This file was deleted.

0 comments on commit 4c6f599

Please sign in to comment.