From 4c6f599b9c9ec8b973e57cfd13638d8915f703d4 Mon Sep 17 00:00:00 2001 From: Fabio Kreusch Date: Tue, 23 Aug 2011 11:49:43 -0700 Subject: [PATCH] Added Admin::PagesController logic --- app/controllers/admin/pages_controller.rb | 15 +++++++++++++++ app/views/admin/pages/edit.html.erb | 23 ++++++++++++++++++++++- app/views/admin/pages/index.html.erb | 15 ++++++++++++++- app/views/admin/pages/update.html.erb | 2 -- 4 files changed, 51 insertions(+), 4 deletions(-) delete mode 100644 app/views/admin/pages/update.html.erb diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index bcfa21e..a5da1b8 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/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 diff --git a/app/views/admin/pages/edit.html.erb b/app/views/admin/pages/edit.html.erb index 3ce4694..aa6daea 100644 --- a/app/views/admin/pages/edit.html.erb +++ b/app/views/admin/pages/edit.html.erb @@ -1,2 +1,23 @@

Admin::Pages#edit

-

Find me in app/views/admin/pages/edit.html.erb

+<%= form_for @page, :url => admin_page_path(@page), :method => :put do |form| %> +

+ <%= form.label :key %> + <%= form.text_field :key, :disabled => true %> +

+

+ <%= form.label :locale %> + <%= form.text_field :locale, :disabled => true %> +

+ + <% 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 %> \ No newline at end of file diff --git a/app/views/admin/pages/index.html.erb b/app/views/admin/pages/index.html.erb index 3df134e..eaf3878 100644 --- a/app/views/admin/pages/index.html.erb +++ b/app/views/admin/pages/index.html.erb @@ -1,2 +1,15 @@

Admin::Pages#index

-

Find me in app/views/admin/pages/index.html.erb

+ + + + + + + <% @pages.each do |page| %> + + + + + <% end %> + +
Page
<%= page.key.titleize %><%= link_to 'edit', edit_admin_page_path(page) %>
diff --git a/app/views/admin/pages/update.html.erb b/app/views/admin/pages/update.html.erb deleted file mode 100644 index c6e2717..0000000 --- a/app/views/admin/pages/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Admin::Pages#update

-

Find me in app/views/admin/pages/update.html.erb