diff --git a/app/controllers/portlet/link_contents_controller.rb b/app/controllers/portlet/link_contents_controller.rb index df07756..725bd83 100644 --- a/app/controllers/portlet/link_contents_controller.rb +++ b/app/controllers/portlet/link_contents_controller.rb @@ -6,11 +6,6 @@ class Portlet::LinkContentsController < ApplicationController @link_content = LinkContent.new - - params[:link_content_cible_type] = "CibleUrl" if !params[:link_content_cible_type] - - @cible = params[:link_content_cible_type].constantize.new() - @link_content.cible = @cible respond_to do |format| format.html { @@ -25,15 +20,11 @@ class Portlet::LinkContentsController < ApplicationController def create - params_cible = params[:link_content].delete(:cible_attributes) - cible_type = params[:link_content][:cible_type] + @link_content = LinkContent.new(params[:link_content]) - - cible = cible_type.constantize.new(params_cible) - - @link_content.cible = cible + respond_to do |format| if @link_content.save @@ -77,19 +68,7 @@ class Portlet::LinkContentsController < ApplicationController @link_content = LinkContent.find(params[:id]) @portlet = @link_content.portlet - - - params_cible = params[:link_content].delete(:cible_attributes) - cible_type = params[:link_content][:cible_type] - - if !(params[:link_content][:cible_id] and params[:link_content][:cible_id] != "") - cible = cible_type.constantize.new(params_cible) - @link_content.cible = cible - end - - - diff --git a/app/views/portlet/link_contents/_alias_form_line.html.haml b/app/views/portlet/link_contents/_alias_form_line.html.haml deleted file mode 100644 index 2998bfd..0000000 --- a/app/views/portlet/link_contents/_alias_form_line.html.haml +++ /dev/null @@ -1,7 +0,0 @@ --menu_item.ancestors.size.times do -    -=f.radio_button :menu_item_id, menu_item.id, :disabled => ("disabled" if menu_item.menu_content_type =="MenuAlias") -%label{:for => params[:resource].to_s+"_cible_attributes_menu_item_id_"+menu_item.id.to_s}=menu_item.name -%br --menu_item.children.find(:all, :order => :position).each do |m| - =render :partial => "portlet/link_contents/alias_form_line", :locals => {:f => f, :menu_item => m} diff --git a/app/views/portlet/link_contents/_cible_alias.html.haml b/app/views/portlet/link_contents/_cible_alias.html.haml deleted file mode 100644 index bb63453..0000000 --- a/app/views/portlet/link_contents/_cible_alias.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -Lien vers l'élément de menu -=cible.menu_item.name if cible.menu_item \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_alias_form.html.haml b/app/views/portlet/link_contents/_cible_alias_form.html.haml deleted file mode 100644 index 6cb465f..0000000 --- a/app/views/portlet/link_contents/_cible_alias_form.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -=form.semantic_fields_for :cible do |cible| - = cible.inputs do - - -MenuItem.find(:all, :conditions => {:parent_id => nil}, :order => :position).each do |m| - =render :partial => "portlet/link_contents/alias_form_line", :locals => {:f => cible, :menu_item => m} \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_article.html.haml b/app/views/portlet/link_contents/_cible_article.html.haml deleted file mode 100644 index 5a462d7..0000000 --- a/app/views/portlet/link_contents/_cible_article.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -Lien vers l'article -=cible.article.title if cible.article \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_article_form.html.haml b/app/views/portlet/link_contents/_cible_article_form.html.haml deleted file mode 100644 index a749532..0000000 --- a/app/views/portlet/link_contents/_cible_article_form.html.haml +++ /dev/null @@ -1,13 +0,0 @@ - -=form.semantic_fields_for :cible do |cible| - = cible.inputs do - -Folder.all.each do |folder| - - %h4=folder.title - - -folder.articles.each do |article| - %p - =cible.radio_button :article_id, article.id - %label{:for => "link_content_cible_attributes_article_id_"+article.id.to_s}=article.title - %br - %br \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_folder.html.haml b/app/views/portlet/link_contents/_cible_folder.html.haml deleted file mode 100644 index bcb10e2..0000000 --- a/app/views/portlet/link_contents/_cible_folder.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -Lien vers le dossier -=cible.folder.title if cible.folder \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_folder_form.html.haml b/app/views/portlet/link_contents/_cible_folder_form.html.haml deleted file mode 100644 index 901c1ae..0000000 --- a/app/views/portlet/link_contents/_cible_folder_form.html.haml +++ /dev/null @@ -1,8 +0,0 @@ - -=form.semantic_fields_for :cible do |cible| - = cible.inputs do - -Folder.all.each do |folder| - %p - =cible.radio_button :folder_id, folder.id - %label{:for => "link_content_cible_attributes_folder_id_"+folder.id.to_s}=folder.title - \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_url.html.haml b/app/views/portlet/link_contents/_cible_url.html.haml deleted file mode 100644 index 4b653f1..0000000 --- a/app/views/portlet/link_contents/_cible_url.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -Lien vers l'url -=cible.url \ No newline at end of file diff --git a/app/views/portlet/link_contents/_cible_url_form.html.haml b/app/views/portlet/link_contents/_cible_url_form.html.haml deleted file mode 100644 index 8458283..0000000 --- a/app/views/portlet/link_contents/_cible_url_form.html.haml +++ /dev/null @@ -1,6 +0,0 @@ - - - -=form.semantic_fields_for :cible do |cible| - = cible.inputs do - = cible.input :url, :as => :string, :label => "Url :" diff --git a/app/views/portlet/link_contents/_form.html.haml b/app/views/portlet/link_contents/_form.html.haml index 38c0b88..0eb74a1 100644 --- a/app/views/portlet/link_contents/_form.html.haml +++ b/app/views/portlet/link_contents/_form.html.haml @@ -6,22 +6,9 @@ =# form.input :title, :label => "Title :" = form.input :popup,:as => :boolean , :label => "Ouvrir dans une nouvelle fenêtre ?" - - - - #select_cible_type_bar.bar.dark_blue - -CibleType.all.each do |cible_type| - =link_to cible_type.name, new_portlet_link_content_path(:link_content_cible_type => cible_type.slug ), :onclick => "$('#link_content_cible_form').load($(this).attr('href')+' #link_content_cible_form_content');$('#select_cible_type_bar .active').removeClass('active');$(this).addClass('active');return false;",:class => ("active" if cible_type.slug == @link_content.cible_type).to_s - - - - #link_content_cible_form.form2 - #link_content_cible_form_content - = form.inputs do - = form.input :cible_type,:as => :hidden - = form.input :cible_id,:as => :hidden - =render :partial => "portlet/link_contents/"+@link_content.cible_type.tableize.singularize.to_s+"_form", :locals => {:form => form} - + = form.input :cible, :label => "Cible :" , :as => :qi_cible_select + + = form.buttons do = form.commit_button "Sauvegarder" diff --git a/app/views/portlet/link_contents/_link_content.html.haml b/app/views/portlet/link_contents/_link_content.html.haml index 9fd0808..20387b2 100644 --- a/app/views/portlet/link_contents/_link_content.html.haml +++ b/app/views/portlet/link_contents/_link_content.html.haml @@ -4,4 +4,7 @@ Texte affiché : %br ="s'ouvre dans une nouvelle page" if link_content.popup -=render :partial => "portlet/link_contents/"+link_content.cible_type.tableize.singularize, :locals => {:cible => link_content.cible} \ No newline at end of file +- if link_content.cible + %strong + Liens vers + = link_content.cible.cible_name \ No newline at end of file diff --git a/app/views/portlet/link_contents/new.html.haml b/app/views/portlet/link_contents/new.html.haml deleted file mode 100644 index 038bb12..0000000 --- a/app/views/portlet/link_contents/new.html.haml +++ /dev/null @@ -1 +0,0 @@ -=render :partial => "form" \ No newline at end of file diff --git a/app/views/portlets/render_public/_linkcontent.html.haml b/app/views/portlets/render_public/_linkcontent.html.haml index 36b7941..6cf9229 100644 --- a/app/views/portlets/render_public/_linkcontent.html.haml +++ b/app/views/portlets/render_public/_linkcontent.html.haml @@ -1,3 +1,6 @@ .portlet.link_content - - =link_to input.name.to_s, input.url.to_s, :class => "external_link", :target => ("_blank" if input.popup).to_s \ No newline at end of file + - if input.cible + -url = input.cible.cible_url + -else + -url = "" + =link_to input.name.to_s, url.to_s, :class => "external_link", :target => ("_blank" if input.popup).to_s \ No newline at end of file