From 71021b8c69fbb0e27e32dbabd996b2601f78fb6d Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 11 Sep 2012 00:41:52 +0800 Subject: [PATCH] Changes for empty file and link in create and edit for news and announcement + partially fix tinymce --- app/assets/javascripts/tinymce_orbit.js.erb | 6 +++++- .../announcement/back_end/bulletins_controller.rb | 12 ++++++++++++ .../panel/news/back_end/news_bulletins_controller.rb | 12 ++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index aa954973..3a71f77c 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -40,7 +40,11 @@ function load_tinymce() { template_replace_values : { username : "Some User", staffid : "991234" - } + }, + + // Valide HTML elements + valid_elements : '*[*]', + valid_children : '*[*]' }); } function myFileBrowser(field_name, url, type, win) { diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 1b4ee879..ecffb3e1 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -8,6 +8,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| controller.get_categorys('BulletinCategory') end + before_filter :clean_values, :only => [:create, :update] # before_filter :for_admin_only,:only => [:] # before_filter :for_app_manager,:only => [:index,:show,] before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] @@ -362,5 +363,16 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue [] end + + def clean_values + if params[:bulletin] + params[:bulletin][:bulletin_links_attributes].each_with_index do |link, index| + params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank? + end rescue nil + params[:bulletin][:bulletin_files_attributes].each_with_index do |link, index| + params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank? + end rescue nil + end + end end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb index 2e8038e3..f7471d1f 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb @@ -9,6 +9,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController controller.get_categorys('NewsBulletinCategory') controller.get_unit_list end + before_filter :clean_values, :only => [:create, :update] def preview #@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin") @@ -389,4 +390,15 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue [] end + def clean_values + if params[:news_bulletin] + params[:news_bulletin][:news_bulletin_links_attributes].each_with_index do |link, index| + params[:news_bulletin][:news_bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank? + end rescue nil + params[:news_bulletin][:news_bulletin_files_attributes].each_with_index do |link, index| + params[:news_bulletin][:news_bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank? + end rescue nil + end + end + end