fix for both part and page part settings
Conflicts: app/helpers/admin/page_parts_helper.rb app/views/admin/pages/reload_front_end_setting.js.erb app/views/admin/pages/reload_frontend_pages.js.erb
This commit is contained in:
parent
f6b600df59
commit
0f6f5aafce
|
@ -2,12 +2,6 @@ function get_part_id(){
|
|||
return $(".edit_page_part,.edit_page").attr("action").split('/').pop();
|
||||
}
|
||||
|
||||
function get_object_path(){
|
||||
a = window.location.href.split('/');
|
||||
a.pop();
|
||||
return a.join('/');
|
||||
}
|
||||
|
||||
$("div.editable").live("mouseenter mouseleave", function (event) {
|
||||
$(this).children('.edit_link').toggle();
|
||||
});
|
||||
|
@ -31,11 +25,11 @@ $("#page_design").live('change', function() {
|
|||
// });
|
||||
|
||||
$("#module_app_list select").live('change', function() {
|
||||
$.getScript(get_object_path() + '/reload_after_module_changed?module_app_id='+$(this).val()); //?part_id=' + get_part_id());
|
||||
$.getScript($(this).attr('rel') + '?module_app_id='+$(this).val()); //?part_id=' + get_part_id());
|
||||
});
|
||||
|
||||
$("#widget_list select,#frontend_list select").live('change', function() {
|
||||
$.getScript(get_object_path() +'/reload_after_list_changed?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() );//+ '&part_id=' + get_part_id());
|
||||
$.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() );//+ '&part_id=' + get_part_id());
|
||||
});
|
||||
|
||||
$("#tag_list select").live('change', function() {
|
||||
|
@ -43,7 +37,7 @@ $("#tag_list select").live('change', function() {
|
|||
});
|
||||
|
||||
$("select.widget_field_select").live('change', function() {
|
||||
$.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val());
|
||||
$.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val());
|
||||
});
|
||||
|
||||
$('.part_kind').live('click', function() {
|
||||
|
|
|
@ -56,10 +56,9 @@ class Admin::PagePartsController < OrbitBackendController
|
|||
def update
|
||||
|
||||
@part = PagePart.find(params[:id])
|
||||
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type],params[:page_part][:widget_field_is_link] ) if params[:page_part][:widget_field]
|
||||
|
||||
params[:page_part][:widget_field_type] = nil
|
||||
params[:page_part][:widget_field_is_link] = nil
|
||||
|
||||
# params[:page_part][:widget_field_type] = nil
|
||||
# params[:page_part][:widget_field_is_link] = nil
|
||||
|
||||
if params[:page_part][:module_app].blank?
|
||||
params[:page_part][:module_app] = nil
|
||||
|
@ -73,8 +72,7 @@ class Admin::PagePartsController < OrbitBackendController
|
|||
params[:page_part][:category] = []
|
||||
end
|
||||
|
||||
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page_part][:widget_field].blank?
|
||||
|
||||
# params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page_part][:widget_field].blank?
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
flash.now[:notice] = t('update.success.content')
|
||||
|
|
|
@ -14,6 +14,7 @@ helper Admin::PagePartsHelper
|
|||
@item = Page.new
|
||||
@item.parent = Item.find(params[:parent_id]) rescue nil
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
end
|
||||
|
@ -76,8 +77,10 @@ helper Admin::PagePartsHelper
|
|||
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
||||
end
|
||||
|
||||
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field]
|
||||
params[:page][:frontend_field_type] = nil
|
||||
# params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type], params[:page][:frontend_field_is_link] ) if params[:page][:frontend_field]
|
||||
|
||||
# params[:page][:frontend_field_type] = nil
|
||||
# params[:page][:frontend_field_is_link] = nil
|
||||
|
||||
if params[:page][:tag].nil? || params[:page][:tag].include?("nil")
|
||||
params[:page][:tag] = []
|
||||
|
@ -87,6 +90,9 @@ helper Admin::PagePartsHelper
|
|||
params[:page][:category] = []
|
||||
end
|
||||
|
||||
# params[:page][:frontend_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page][:frontend_field].blank?
|
||||
|
||||
|
||||
if @item.update_attributes(params[:page])
|
||||
flash[:notice] = t('update.success.page')
|
||||
respond_to do |format|
|
||||
|
@ -127,6 +133,9 @@ helper Admin::PagePartsHelper
|
|||
|
||||
@app_frontend_urls = @module_app.nil? ? nil : @module_app.app_pages.each{|name,data| [I18n.t(data["i18n"]),name]}
|
||||
@frontend_styles = @module_app.app_pages[params["frontend"]]["style"] rescue nil
|
||||
# =======
|
||||
# @chosen_frontend = @user_choose = params[:frontend]
|
||||
# >>>>>>> Stashed changes
|
||||
end
|
||||
|
||||
def get_categories_and_tags
|
||||
|
@ -172,7 +181,7 @@ helper Admin::PagePartsHelper
|
|||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@item = Page.find params[:id]
|
||||
@item = params.has_key?(:id) ? Page.find(params[:id] ) : Page.new
|
||||
@choosen_field = params[:widget_field_value]
|
||||
@module_app = @page.module_app
|
||||
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
|
|
|
@ -12,43 +12,42 @@ module Admin::PagePartsHelper
|
|||
def get_widget_field_rel(local_item=nil)
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @item if local_item.nil? && @item
|
||||
|
||||
case local_item
|
||||
when Page
|
||||
admin_pages_path
|
||||
reload_after_list_changed_admin_pages_path
|
||||
when PagePart
|
||||
admin_page_parts_path
|
||||
reload_after_list_changed_admin_page_part_path
|
||||
end
|
||||
end
|
||||
|
||||
def link_to_field_switch(i,object_name,field_name,local_item=nil,prefill_value=nil) #link_to_field is for showing
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @item if local_item.nil? && @item
|
||||
res = ''
|
||||
choosen_value = prefill_value || (local_item[field_name][i][0] rescue nil)
|
||||
|
||||
if choosen_value
|
||||
choosen_field_is_link = (@module_app.widget_fields.select{|t| t[0].to_s==choosen_value}.first)[2]==:link
|
||||
else
|
||||
choosen_field_is_link = false
|
||||
end
|
||||
def link_to_field_switch( i ,object_name,field_name,local_item=nil,assign_field_name_value=nil) #link_to_field is for showing
|
||||
field_is_checked = nil
|
||||
local_item = case
|
||||
when local_item.nil? && @part
|
||||
@part
|
||||
when local_item.nil? && @item
|
||||
@item
|
||||
end
|
||||
|
||||
field_is_checked = local_item.default_widget_field_sat_to_link?(i)
|
||||
res = hidden_field_tag "#{object_name}[#{field_name}][][sat_to_link]", 'false'
|
||||
|
||||
if choosen_field_is_link
|
||||
value = case local_item
|
||||
when Page
|
||||
local_item[:frontend_field][i][2] rescue false
|
||||
when PagePart
|
||||
local_item[:widget_field][i][2] rescue false
|
||||
end
|
||||
unless field_is_checked.nil? and assign_field_name_value.nil?
|
||||
origin_field = nil
|
||||
|
||||
res = label_tag '' do
|
||||
check_box_tag("#{object_name}[#{field_name}_is_link][]", "true", value) + I18n.t("default_widget.field_is_link")
|
||||
end
|
||||
else # choosen_field_not_link
|
||||
res = hidden_field_tag "#{object_name}[#{field_name}_is_link][]", 'false'
|
||||
end # of if choosen_field_is_link
|
||||
origin_field = @module_app.widget_fields.select{|t| t.first.to_s==(assign_field_name_value || local_item.default_widget_field_name[i])}.first
|
||||
|
||||
if origin_field and origin_field[2]==:link #choosen_field_is_link
|
||||
|
||||
res = label_tag '' do
|
||||
check_box_tag("#{object_name}[#{field_name}][][sat_to_link]", "true", field_is_checked) + I18n.t("default_widget.field_is_link")
|
||||
end
|
||||
else # choosen_field_not_link
|
||||
return res
|
||||
end # of if choosen_field_is_link
|
||||
else
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
||||
def widget_field_options(i,local_item=nil)
|
||||
|
@ -59,25 +58,24 @@ module Admin::PagePartsHelper
|
|||
label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}")
|
||||
[label, widget_field[0]]
|
||||
end
|
||||
|
||||
case local_item
|
||||
when Page
|
||||
options_for_select(options, (local_item[:frontend_field][i][0] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
|
||||
options_for_select(options, (local_item.frontend_field_name[i] if(local_item) ))
|
||||
when PagePart
|
||||
options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
options_for_select(options, (local_item.widget_field_name[i] if(local_item) ))
|
||||
end
|
||||
end
|
||||
|
||||
def widget_fiield_type_options(i,local_item=nil)
|
||||
def widget_fiield_class_options(i,local_item=nil)
|
||||
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @item if local_item.nil? && @item
|
||||
|
||||
case local_item
|
||||
when Page
|
||||
options_for_select(options, (local_item[:frontend_field][i][1] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
|
||||
options_for_select(options, (local_item.frontend_class[i] if (local_item) ))
|
||||
when PagePart
|
||||
options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
|
||||
options_for_select(options, (local_item.widget_class[i] if (local_item) ))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,12 @@ class Page < Item
|
|||
field :page_title, localize: true
|
||||
|
||||
field :frontend_style
|
||||
field :frontend_field , :type => Array
|
||||
field :frontend_field , :type => Array,:default => []
|
||||
|
||||
field :frontend_field_name , :type => Array,:default => []
|
||||
field :frontend_class , :type => Array,:default => []
|
||||
field :frontend_sat_to_link , :type => Array,:default => []
|
||||
|
||||
field :frontend_data_count
|
||||
|
||||
belongs_to :design
|
||||
|
@ -32,6 +37,29 @@ class Page < Item
|
|||
self.save
|
||||
end
|
||||
|
||||
def default_widget_field_sat_to_link?(i)
|
||||
case frontend_sat_to_link[i]
|
||||
when 'true'
|
||||
true
|
||||
when 'false'
|
||||
false
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def default_widget_field_name
|
||||
return frontend_field_name
|
||||
end
|
||||
|
||||
def frontend_field=(settings)
|
||||
settings.each_with_index do |setting,index|
|
||||
self.frontend_field_name[index] = setting["field_name"]
|
||||
self.frontend_class[index] = setting["class"]
|
||||
self.frontend_sat_to_link[index] = setting["sat_to_link"]
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def create_parts
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class PagePart
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
|
@ -15,7 +14,12 @@ class PagePart
|
|||
field :tag, type: Array,:default => []
|
||||
|
||||
field :widget_style
|
||||
field :widget_field , :type => Array
|
||||
field :widget_field , :type => Array,:default => []
|
||||
|
||||
field :widget_field_name , :type => Array,:default => []
|
||||
field :widget_class , :type => Array,:default => []
|
||||
field :widget_sat_to_link , :type => Array,:default => []
|
||||
|
||||
field :widget_options ,:type=>Hash
|
||||
field :widget_data_count
|
||||
|
||||
|
@ -25,15 +29,28 @@ class PagePart
|
|||
before_save :delete_empty_widget_field
|
||||
after_save :update_parent
|
||||
|
||||
# def module_app
|
||||
# if self[:module_app]
|
||||
# self[:module_app]
|
||||
# elsif self[:kind] == 'module_widget'
|
||||
# self.page.module_app
|
||||
# else
|
||||
# nil
|
||||
# end
|
||||
# end
|
||||
def default_widget_field_sat_to_link?(i)
|
||||
case widget_sat_to_link[i]
|
||||
when 'true'
|
||||
true
|
||||
when 'false'
|
||||
false
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def default_widget_field_name
|
||||
return widget_field_name
|
||||
end
|
||||
|
||||
def widget_field=(settings)
|
||||
settings.each_with_index do |setting,index|
|
||||
self.widget_field_name[index] = setting["field_name"]
|
||||
self.widget_class[index] = setting["class"]
|
||||
self.widget_sat_to_link[index] = setting["sat_to_link"]
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
<% when PagePart %>
|
||||
<% object_name = 'page_part' %>
|
||||
<% field_name = 'widget_field' %>
|
||||
<% reload_rel = reload_after_widget_field_changed_admin_page_part_path %>
|
||||
<% when Page %>
|
||||
<% object_name = 'page' %>
|
||||
<% field_name = 'frontend_field' %>
|
||||
<% reload_rel = reload_after_widget_field_changed_admin_pages_path %>
|
||||
<% end %>
|
||||
|
||||
<div class="style_switch control-group">
|
||||
|
@ -29,10 +31,10 @@
|
|||
<div class="rows clear">
|
||||
<span class="span4">
|
||||
<%= i+1 %>
|
||||
<%= select_tag "#{object_name}[#{field_name}][]", widget_field_options(i), :include_blank => true ,:class=>'widget_field_select',:field_seri => i ,:id=>"#{object_name}_#{field_name}_#{i}"%>
|
||||
<%= select_tag "#{object_name}[#{field_name}][][field_name]", widget_field_options(i), :include_blank => true ,:class=>'widget_field_select',:field_seri => i ,:id=>"#{object_name}_#{field_name}_#{i}",:rel=>reload_rel%>
|
||||
</span>
|
||||
<span class="span3">
|
||||
<%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
|
||||
<%= select_tag "#{object_name}[#{field_name}][][class]", widget_fiield_class_options(i), :include_blank => true %> <br />
|
||||
</span>
|
||||
<span class="span5 link_switch_holder">
|
||||
<%= link_to_field_switch(i,object_name,field_name) %>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<%= t "default_widget.select_module_app" %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :module_name, :selected => (@module_app.id rescue nil)), {:include_blank => true }, {:rel => admin_page_parts_path,:id=>"page_module_app_id"} %>
|
||||
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :module_name, :selected => (@module_app.id rescue nil)), {:include_blank => true }, {:rel => reload_after_module_changed_admin_page_part_path,:id=>"page_module_app_id"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<%= f.select :module_app_id, @apps.collect { |t| [t.module_name, t.id] }, {:include_blank => true} ,{:rel => admin_pages_path } %>
|
|
@ -27,7 +27,7 @@
|
|||
<div class="control-group">
|
||||
<%= f.label :name, t(:template_name), :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %>
|
||||
<%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => reload_themes_admin_pages_path} %>
|
||||
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,14 +42,14 @@
|
|||
<div class="control-group" id="module_app_list">
|
||||
<%= f.label '',t("default_widget.select_module_app"), :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= render :partial => "app_selector", :locals => { :f => f } %>
|
||||
<%= f.select :module_app_id, options_from_collection_for_select(@module_apps, :id, :module_name, :selected => (@module_app.id rescue nil)), {:include_blank => true }, {:rel => reload_after_module_changed_admin_pages_path,:id=>"page_module_app_id"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" id="frontend_list">
|
||||
<%= f.label '', t("front_page.select_app_url"), :class => 'control-label' %>
|
||||
<div class="controls" id="app_page_url">
|
||||
<%= select('page','app_frontend_url', @app_frontend_urls || [], :selected => @item.app_frontend_url ) rescue ''%>
|
||||
<%= select('page','app_frontend_url', @app_frontend_urls || [],{}, {:selected => (@item.app_frontend_url || 'default_widget'),:rel => reload_after_list_changed_admin_pages_path}) rescue ''%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<% @module_app.widget_fields.each_with_index do |frontend_field, i| %>
|
||||
<%= i+1 %>
|
||||
<%= 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 />
|
||||
<%= select_tag "page[frontend_field_type][]", widget_fiield_class_options(i,@item), :include_blank => true %> <br />
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% form_for :page, :url => admin_page_path(@page), :html => { :method => :delete } do |f| %>
|
||||
<% form_for :page, :url => admin_page_path(@item), :html => { :method => :delete } do |f| %>
|
||||
<h2><%= t('sure?') %></h2>
|
||||
<p>
|
||||
<%= submit_tag t(:delete_) %>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<% if show_default_widget_setting_panel %>
|
||||
// $('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
|
||||
|
||||
$('#frontend_setting').html("<%= j render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:object=>@page} %>");
|
||||
$('#frontend_setting').append("<%= j render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>@page} %>");
|
||||
$('#frontend_setting').html("<%= j render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:object=>@item} %>");
|
||||
$('#frontend_setting').append("<%= j render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>@item} %>");
|
||||
<% else %>
|
||||
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
|
||||
<% end %>
|
|
@ -1,12 +1,12 @@
|
|||
<% if @module_app %>
|
||||
$('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>");
|
||||
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
|
||||
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>(@page.frontend_data_count rescue nil)} %>");
|
||||
$('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@item}%>");
|
||||
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@item} %>");
|
||||
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>(@item.frontend_data_count rescue nil)} %>");
|
||||
|
||||
<% if !@module_app.app_pages.blank? %>
|
||||
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>");
|
||||
<%else %>
|
||||
$('#app_page_url').html("<%= t('default_widget.no_support_setting')%>");
|
||||
<% if !@module_app.app_pages.blank? or @module_app.has_default_widget? %>
|
||||
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, (@item.app_frontend_url || 'default_widget')),{},{:rel => reload_after_list_changed_admin_pages_path}) %>");
|
||||
<% else %>
|
||||
$('#app_page_url').html("<div class='well'><%= t('default_widget.no_support_setting')%></div>");
|
||||
<% end %>
|
||||
|
||||
<% if @app_frontend_urls.first =='default_widget' %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defaults: &defaults
|
||||
host: localhost
|
||||
host: 192.168.1.105
|
||||
# slaves:
|
||||
# - host: slave1.local
|
||||
port: 27017
|
||||
|
|
|
@ -82,15 +82,13 @@ Orbit::Application.routes.draw do
|
|||
|
||||
resources :pages do
|
||||
collection do
|
||||
get 'reload_themes'
|
||||
get 'reload_after_module_changed', :action=>'reload_frontend_pages'
|
||||
get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
|
||||
get 'reload_after_widget_field_changed',:action=> 'reload_widget_field'
|
||||
end
|
||||
member do
|
||||
get 'delete'
|
||||
get 'reload_themes'
|
||||
get 'reload_after_module_changed',:action=>'reload_frontend_pages'
|
||||
get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
|
||||
get 'reload_after_widget_field_changed',:action=> 'reload_widget_field'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -246,4 +246,60 @@ namespace :migrate do
|
|||
end
|
||||
end
|
||||
|
||||
task :backup_page_frontend_setting => :environment do
|
||||
Page.all.each do |page|
|
||||
if page.frontend_field and page.frontend_field.collect{|t| t.class}.include?(Array)
|
||||
page["temp_frontend_setting"] = page.frontend_field
|
||||
end
|
||||
page.save
|
||||
end
|
||||
end
|
||||
|
||||
# task :correct_page_frontend_setting => :environment do
|
||||
# Page.all.each do |page|
|
||||
# page.frontend_field = {}
|
||||
# if page["temp_frontend_setting"] and page["temp_frontend_setting"].collect{|t| t.class}.include?(Array)
|
||||
# page["temp_frontend_setting"].each_with_index do |old_frontend_setting,index|
|
||||
# for_a_field={
|
||||
# :field_name=>old_frontend_setting[0],
|
||||
# :field_type=> old_frontend_setting[1],
|
||||
# :set_to_link=>old_frontend_setting[2]
|
||||
# }
|
||||
# page.frontend_field << for_a_field
|
||||
# end #of each_with_index
|
||||
# end # of if Array
|
||||
# binding.pry unless page.frontend_field.blank?
|
||||
# page.save
|
||||
# end #of each page
|
||||
# end #of task
|
||||
|
||||
task :migrate_from_one_frontend_field_to_three_fields => :environment do
|
||||
Page.all.each do |page|
|
||||
page.frontend_field_name = []
|
||||
page.frontend_class = []
|
||||
page.frontend_sat_to_link = []
|
||||
if page.frontend_field and page.frontend_field.collect{|t| t.class}.include?(Array)
|
||||
page.frontend_field.each_with_index do |old_frontend_setting,index|
|
||||
page.frontend_field_name << old_frontend_setting[0]
|
||||
page.frontend_class << old_frontend_setting[1]
|
||||
page.frontend_sat_to_link << old_frontend_setting[2]
|
||||
end
|
||||
end
|
||||
page.save
|
||||
end
|
||||
end
|
||||
|
||||
task :clean_page_frontend_setting => :environment do
|
||||
Page.all.each do |page|
|
||||
if page.frontend_field and page.frontend_field.collect{|t| t.class}.include?(Array)
|
||||
|
||||
else
|
||||
page.frontend_field = []
|
||||
end
|
||||
|
||||
page.unset :temp_frontend_setting
|
||||
page.unset :frontend_field_is_link
|
||||
page.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue