Changes for empty file and link in create and edit for news and announcement + partially fix tinymce

This commit is contained in:
Matt 2012-09-11 00:41:52 +08:00
parent b110b22daa
commit 71021b8c69
3 changed files with 29 additions and 1 deletions

View File

@ -40,7 +40,11 @@ function load_tinymce() {
template_replace_values : { template_replace_values : {
username : "Some User", username : "Some User",
staffid : "991234" staffid : "991234"
} },
// Valide HTML elements
valid_elements : '*[*]',
valid_children : '*[*]'
}); });
} }
function myFileBrowser(field_name, url, type, win) { function myFileBrowser(field_name, url, type, win) {

View File

@ -8,6 +8,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
controller.get_categorys('BulletinCategory') controller.get_categorys('BulletinCategory')
end end
before_filter :clean_values, :only => [:create, :update]
# before_filter :for_admin_only,:only => [:] # before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,] # before_filter :for_app_manager,:only => [:index,:show,]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
@ -363,4 +364,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue [] @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end 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 end

View File

@ -9,6 +9,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
controller.get_categorys('NewsBulletinCategory') controller.get_categorys('NewsBulletinCategory')
controller.get_unit_list controller.get_unit_list
end end
before_filter :clean_values, :only => [:create, :update]
def preview 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") #@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 [] @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end 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 end