Fix no responding when trying to access front end page

This commit is contained in:
chris 2013-01-09 11:23:18 +08:00
parent fac4faad6c
commit 1d80b39dcb
3 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,5 @@
class Admin::PagesController < Admin::ItemsController
helper Admin::PagePartsHelper
def show
@item = Page.find(params[:id])
respond_to do |format|

View File

@ -9,14 +9,19 @@ module Admin::PagePartsHelper
end
end
def widget_field_options(i)
def widget_field_options(i,local_item=nil)
local_item = @part if local_item.nil?
options = @module_app.widget_fields.collect{|widget_field| [I18n.t(widget_field[1]), widget_field[0]]}
options_for_select(options, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
end
def widget_fiield_type_options(i)
def widget_fiield_type_options(i,local_item=nil)
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
options_for_select(options, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
local_item = @part if local_item.nil?
options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
end
end

View File

@ -3,8 +3,8 @@
<%= label_tag('frontend_field & frontend_field_type') %>
<% @module_app.widget_fields.each_with_index do |frontend_field, i| %>
<%= i+1 %>
<%= select_tag "page[frontend_field][]", options_for_select(@module_app.widget_fields.collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][0] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %>
<%= select_tag "page[frontend_field_type][]", options_for_select(LIST[:widget_field_type].collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][1] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %> <br />
<%= select_tag "page[frontend_field][]",widget_field_options(i,@item) , :include_blank => true %>
<%= select_tag "page[frontend_field_type][]", widget_fiield_type_options(i,@item), :include_blank => true %> <br />
<% end %>
<% end %>