From 0dabd5b95f6eb85f4a04484a2c0e6b6341b4e2b4 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Mon, 25 Feb 2013 12:49:06 +0800 Subject: [PATCH] fix widget field reload --- app/assets/javascripts/page_edit.js.erb | 2 +- .../admin/page_parts_controller.rb | 1 + app/controllers/admin/pages_controller.rb | 8 ++++ .../admin/pages/_data_count_field.html.erb | 6 +++ .../admin/pages/reload_widget_field.js.erb | 1 + config/routes.rb | 1 + .../helper/default_widget_tag_helper.rb | 12 ++++++ lib/orbit_app/module/registration.rb | 2 +- lib/tasks/migrate.rake | 38 +++++++++---------- 9 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 app/views/admin/pages/_data_count_field.html.erb create mode 100644 app/views/admin/pages/reload_widget_field.js.erb create mode 100644 lib/orbit_app/helper/default_widget_tag_helper.rb diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index 2585961a9..09326600b 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -43,7 +43,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')); + $.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()); }); $('.part_kind').live('click', function() { diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 825f5e597..fea1bf3f5 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -108,6 +108,7 @@ class Admin::PagePartsController < ApplicationController @part = PagePart.find params[:id] @choosen_field = params[:widget_field_value] @module_app = @part.module_app + @module_app = ModuleApp.find params[:module_app_id] if @module_app.nil? end def reload_widgets diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index c15c9d22b..a5cba320a 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -180,4 +180,12 @@ helper Admin::PagePartsHelper end end + def reload_widget_field + @index = params[:field_seri].to_i + @page = Page.find params[:id] + @choosen_field = params[:widget_field_value] + @module_app = @page.module_app + @module_app = ModuleApp.find params[:module_app_id] if @module_app.nil? + end + end diff --git a/app/views/admin/pages/_data_count_field.html.erb b/app/views/admin/pages/_data_count_field.html.erb new file mode 100644 index 000000000..48f355f06 --- /dev/null +++ b/app/views/admin/pages/_data_count_field.html.erb @@ -0,0 +1,6 @@ + +
+ <%= select_tag(field_name,options_for_select(@module_app.get_registration.get_data_count,field_value )) %> +
\ No newline at end of file diff --git a/app/views/admin/pages/reload_widget_field.js.erb b/app/views/admin/pages/reload_widget_field.js.erb new file mode 100644 index 000000000..0f6bd1f7b --- /dev/null +++ b/app/views/admin/pages/reload_widget_field.js.erb @@ -0,0 +1 @@ +$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page','frontend_field',nil,@choosen_field) %>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index cc272ffca..8ceb71c99 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,6 +90,7 @@ Orbit::Application.routes.draw 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 end diff --git a/lib/orbit_app/helper/default_widget_tag_helper.rb b/lib/orbit_app/helper/default_widget_tag_helper.rb new file mode 100644 index 000000000..52160398b --- /dev/null +++ b/lib/orbit_app/helper/default_widget_tag_helper.rb @@ -0,0 +1,12 @@ +module DefaultWidgetTagHelper + include Renderer + include AdminHelper + + def link_to_more_tag(req,params) + @request = req + @params =params + content_tag :div,:class=> 'more' do + link_to I18n.t(@more_link[:label_i18n]),eval(@more_link[:path_method]) + end + end +end \ No newline at end of file diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb index 9a300a0f4..5dbc36054 100644 --- a/lib/orbit_app/module/registration.rb +++ b/lib/orbit_app/module/registration.rb @@ -36,7 +36,7 @@ module OrbitApp @side_bar = nil @front_end_app_pages = nil @module_label = 'rulingcom.errors.init.module_app_noname' - @data_count = 1..3 # as default + @data_count = 1..15 # as default block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? setup_module_app end diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 52f0ae888..fe331c6cd 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -190,6 +190,25 @@ namespace :migrate do end end + task :convert_cate_tag_type => :environment do + [Page,PagePart].each do |obj| + obj.all.each do |pp| + if pp.category.blank? + pp.category = [] + else + pp.category = [pp.category] + end + + if pp.tag.blank? + pp.tag = [] + else + pp.tag = [pp.tag] + end + pp.save + end + end + end + task :clean_parts => :environment do PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})} PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})} @@ -214,23 +233,4 @@ namespace :migrate do end end - task :convert_cate_tag_type => :environment do - [Page,PagePart].each do |obj| - obj.all.each do |pp| - if pp.category.blank? - pp.category = [] - else - pp.category = [pp.category] - end - - if pp.tag.blank? - pp.tag = [] - else - pp.tag = [pp.tag] - end - pp.save - end - end - end - end