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 << "
+ <%= f.submit t('update') %> <%= link_back %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 4afc26e7..208a92f3 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -16,13 +16,13 @@<%= t('admin.design_name') %> - <%= f.select :design_id, @designs.collect { |d| [d.title, d.id] }, :selected => @default_design.id %> + <%#= f.select :design_id, @designs.collect { |d| [d.title, d.id] }, :selected => @default_design.id %> + <%= f.select :design_id, @designs.collect { |d| [d.title, d.id] } %>
- <%= @item.design.inspect %> <%= t('admin.theme') %> - <%= f.select :theme_id, @default_design.themes.collect { |t| [t.name, t.id] }, :selected => @default_design.themes.detect {|t| t.file_filename.to_s == 'default.css' }.id %> - <%#= f.collection_select :design, @designs, :id, :title %> + <%#= f.select :theme_id, @default_design.themes.collect { |t| [t.name, t.id] }, :selected => @default_design.themes.detect {|t| t.file_filename.to_s == 'default.css' }.id %> + <%= f.select :theme_id, @design.themes.collect { |t| [t.name, t.id] }%>
diff --git a/app/views/admin/pages/edit.html.erb b/app/views/admin/pages/edit.html.erb new file mode 100644 index 00000000..23676c93 --- /dev/null +++ b/app/views/admin/pages/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :sidebar do %> + <%= render 'admin/items/site_map_left_bar' %> +<% end -%> + +<%= render 'edit' %> \ No newline at end of file diff --git a/app/views/admin/pages/edit.js.erb b/app/views/admin/pages/edit.js.erb new file mode 100644 index 00000000..67d528b5 --- /dev/null +++ b/app/views/admin/pages/edit.js.erb @@ -0,0 +1 @@ +$('#panel_main').html("<%= escape_javascript(render 'edit') %>"); \ No newline at end of file diff --git a/app/views/admin/pages/update.js.erb b/app/views/admin/pages/update.js.erb new file mode 100644 index 00000000..4fdd4357 --- /dev/null +++ b/app/views/admin/pages/update.js.erb @@ -0,0 +1,2 @@ +$('#panel_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); +history.pushState(null, document.title, "<%= escape_javascript(admin_page_url(@item)) %>"); \ No newline at end of file diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 2f2118e6..caba0fa6 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -114,7 +114,7 @@ namespace :dev do design_1.save - home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design.id, :name => 'home', :is_published => true ) + home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id ) home.page_parts.create!( :name => 'header_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id ) end