From 5f832a17d497258b310692d0bc818a58c7847bd1 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 +- app/controllers/admin/page_parts_controller.rb | 1 + app/controllers/admin/pages_controller.rb | 8 ++++++++ app/views/admin/pages/_data_count_field.html.erb | 6 ++++++ app/views/admin/pages/reload_widget_field.js.erb | 1 + config/routes.rb | 1 + lib/orbit_app/helper/default_widget_tag_helper.rb | 12 ++++++++++++ lib/orbit_app/module/registration.rb | 2 +- lib/tasks/migrate.rake | 2 +- 9 files changed, 32 insertions(+), 3 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 b77716922..f989628a5 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 8d106ebc6..aeb76562f 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 c448eed74..0a5ca9b26 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -208,6 +208,7 @@ namespace :migrate do 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})} @@ -231,7 +232,6 @@ namespace :migrate do Page.all.each do |page| page.save end - end end