From 27d47215e9e57f2cb44a1e80663547a17a336400 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Wed, 24 Aug 2011 02:34:24 +0800 Subject: [PATCH] Modify edit page. Still need to handle "form" with drop down lists --- app/controllers/admin/pages_controller.rb | 17 +++++++++++++++++ app/helpers/admin/item_helper.rb | 1 + app/models/design/theme.rb | 2 -- app/models/page.rb | 2 +- app/views/admin/pages/_edit.html.erb | 10 ++++++++++ app/views/admin/pages/_form.html.erb | 8 ++++---- app/views/admin/pages/edit.html.erb | 5 +++++ app/views/admin/pages/edit.js.erb | 1 + app/views/admin/pages/update.js.erb | 2 ++ lib/tasks/dev.rake | 2 +- 10 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 app/views/admin/pages/_edit.html.erb create mode 100644 app/views/admin/pages/edit.html.erb create mode 100644 app/views/admin/pages/edit.js.erb create mode 100644 app/views/admin/pages/update.js.erb diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index a0f4231e..1fcc7bde 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -26,6 +26,11 @@ class Admin::PagesController < ApplicationController end def edit + @item = Page.find(params[:id]) + @i18n_variable = @item.i18n_variable + @designs = Design.all.entries + @design = @item.design + @default_design = @design.themes.detect {|t| t.id == @item.theme_id } end def create @@ -48,6 +53,18 @@ class Admin::PagesController < ApplicationController end def update + @item = Page.find(params[:id]) + if @item.update_attributes(params[:item]) + flash[:notice] = t('admin.update_success_page') + respond_to do |format| + format.html { + redirect_to admin_page_url(@item) + } + format.js {} + end + else + render :action => "edit" + end end def destroy diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index e91265fc..c28c9b8f 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -12,6 +12,7 @@ module Admin::ItemHelper ret << "