changement des cibles sur la page d'accueil
This commit is contained in:
parent
d2bf1e6e9d
commit
141f191cb4
@ -14,27 +14,7 @@ class Admin::HomeBlocksController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@home_block = HomeBlock.find(params[:id])
|
@home_block = HomeBlock.find(params[:id])
|
||||||
params[:resource => "home_block"]
|
|
||||||
|
|
||||||
params_content = params[:home_block].delete(:cible_attributes)
|
|
||||||
content_type = params[:home_block][:cible_type]
|
|
||||||
|
|
||||||
cible_id = params[:home_block][:cible_id].to_i if params[:home_block][:cible_id].to_i != 0
|
|
||||||
|
|
||||||
puts cible_id.to_i
|
|
||||||
|
|
||||||
if !cible_id
|
|
||||||
content = content_type.constantize.new(params_content)
|
|
||||||
else
|
|
||||||
content = content_type.constantize.find(cible_id)
|
|
||||||
|
|
||||||
content.attributes = params_content
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@home_block.cible = content
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if @home_block.update_attributes(params[:home_block])
|
if @home_block.update_attributes(params[:home_block])
|
||||||
|
@ -13,7 +13,6 @@ class Admin::SlidesController < ApplicationController
|
|||||||
|
|
||||||
@slide = Slide.new(:slider_id => params[:slider_id])
|
@slide = Slide.new(:slider_id => params[:slider_id])
|
||||||
|
|
||||||
@slide.cible = CibleArticle.new()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -22,33 +21,10 @@ class Admin::SlidesController < ApplicationController
|
|||||||
@slides = Slide.order(:position)
|
@slides = Slide.order(:position)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
params[:resource => "slide"]
|
|
||||||
|
|
||||||
params_content = params[:slide].delete(:cible_attributes)
|
|
||||||
content_type = params[:slide][:cible_type]
|
|
||||||
|
|
||||||
cible_id = params[:slide][:cible_id].to_i if params[:slide][:cible_id].to_i != 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if !cible_id
|
|
||||||
content = content_type.constantize.new(params_content)
|
|
||||||
else
|
|
||||||
content = content_type.constantize.find(cible_id)
|
|
||||||
|
|
||||||
content.attributes = params_content
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
@slide = Slide.new(params[:slide])
|
@slide = Slide.new(params[:slide])
|
||||||
@slide.cible = content
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -78,29 +54,6 @@ class Admin::SlidesController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
params[:resource => "slide"]
|
|
||||||
|
|
||||||
params_content = params[:slide].delete(:cible_attributes)
|
|
||||||
content_type = params[:slide][:cible_type]
|
|
||||||
|
|
||||||
cible_id = params[:slide][:cible_id].to_i if params[:slide][:cible_id].to_i != 0
|
|
||||||
|
|
||||||
puts cible_id.to_i
|
|
||||||
|
|
||||||
if !cible_id
|
|
||||||
content = content_type.constantize.new(params_content)
|
|
||||||
else
|
|
||||||
content = content_type.constantize.find(cible_id)
|
|
||||||
|
|
||||||
content.attributes = params_content
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@slide.cible = content
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if @slide.update_attributes(params[:slide])
|
if @slide.update_attributes(params[:slide])
|
||||||
|
@ -8,6 +8,13 @@ class CibleAlias < ActiveRecord::Base
|
|||||||
#has_one :link_content, :as => :cible
|
#has_one :link_content, :as => :cible
|
||||||
has_one :cibleable, :as => :cible
|
has_one :cibleable, :as => :cible
|
||||||
|
|
||||||
|
def cible_name
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cible_url
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
if self.menu_item
|
if self.menu_item
|
||||||
|
@ -3,6 +3,13 @@ class CibleArticle < ActiveRecord::Base
|
|||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
belongs_to :article
|
belongs_to :article
|
||||||
|
|
||||||
|
def cible_name
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cible_url
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
if self.article and self.article.folder
|
if self.article and self.article.folder
|
||||||
|
@ -3,6 +3,13 @@ class CibleFolder < ActiveRecord::Base
|
|||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
belongs_to :folder
|
belongs_to :folder
|
||||||
|
|
||||||
|
def cible_name
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cible_url
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
if self.folder
|
if self.folder
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class CibleUrl < ActiveRecord::Base
|
class CibleUrl < ActiveRecord::Base
|
||||||
validates :url, :presence => true
|
validates :url, :presence => true
|
||||||
|
def cible_name
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cible_url
|
||||||
|
"A changer"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ class Slide < ActiveRecord::Base
|
|||||||
validates :title, :presence => true
|
validates :title, :presence => true
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
slides = Slide.where(:slider_id => self.slider_id).order(:position.desc)
|
slides = Slide.where(:slider_id => self.slider_id).order("position desc")
|
||||||
slides[0] ? position = slides[0].position.to_i + 1 : position = 1
|
slides[0] ? position = slides[0].position.to_i + 1 : position = 1
|
||||||
|
|
||||||
self.position = position
|
self.position = position
|
||||||
|
@ -1,25 +1,10 @@
|
|||||||
= semantic_form_for [:admin, @home_block], :remote => true do |form|
|
= semantic_form_for [:admin, @home_block], :remote => true do |form|
|
||||||
|
|
||||||
.form1
|
|
||||||
= form.inputs do
|
|
||||||
= form.input :title, :label => "Title :"
|
|
||||||
= form.input :description,:as => :text , :label => "Description :"
|
|
||||||
|
|
||||||
|
= form.inputs do
|
||||||
|
= form.input :title, :label => "Title :"
|
||||||
|
= form.input :description,:as => :text , :label => "Description :"
|
||||||
#select_cible_type_bar.bar.dark_blue
|
= form.input :cible, :label => "Cible :" , :as => :qi_cible_select
|
||||||
-CibleType.all.each do |cible_type|
|
|
||||||
=link_to cible_type.name, new_admin_cible_path(:cible_type => cible_type.slug, :resource_type => "HomeBlock" ), :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 == @home_block.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/"+@home_block.cible_type.tableize.singularize.to_s+"_form", :locals => {:form => form} if @home_block.cible
|
|
||||||
|
|
||||||
= form.buttons do
|
= form.buttons do
|
||||||
= form.commit_button "Sauvegarder"
|
= form.commit_button "Sauvegarder"
|
||||||
|
@ -5,4 +5,6 @@
|
|||||||
|
|
||||||
|
|
||||||
-if home_block.cible
|
-if home_block.cible
|
||||||
=render :partial => "portlet/link_contents/"+home_block.cible_type.tableize.singularize, :locals => {:cible => home_block.cible}
|
%strong
|
||||||
|
Liens vers
|
||||||
|
= home_block.cible.cible_name
|
@ -6,40 +6,11 @@
|
|||||||
|
|
||||||
|
|
||||||
= form.input :description, :label => "Description courte :", :as => :text, :class => "text_editor"
|
= form.input :description, :label => "Description courte :", :as => :text, :class => "text_editor"
|
||||||
|
= form.input :image_file_id, :label => "Image :" , :as => :qi_image_select
|
||||||
|
|
||||||
|
|
||||||
%li.string.optional
|
|
||||||
%label
|
|
||||||
Image :
|
|
||||||
%fieldset
|
|
||||||
-r = rand(1000000000000000000000000000)
|
|
||||||
=link_to "Modifier cette image", "#", :onclick => "select_image_from_manager('"+r.to_s+"');return false;"
|
|
||||||
%br
|
|
||||||
|
|
||||||
-if form.object.image_file
|
|
||||||
=image_tag form.object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s
|
|
||||||
-else
|
|
||||||
=image_tag "", :id => "img_"+r.to_s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=form.hidden_field :image_file_id, :class => "inputText", :id => "input_"+r.to_s
|
|
||||||
|
|
||||||
#select_cible_type_bar.bar.dark_blue
|
|
||||||
-CibleType.all.each do |cible_type|
|
|
||||||
=link_to cible_type.name, new_admin_cible_path(:cible_type => cible_type.slug, :resource_type => "Slide" ), :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 == @slide.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/"+@slide.cible_type.tableize.singularize.to_s+"_form", :locals => {:form => form} if @slide.cible
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
= form.input :cible, :label => "Cible :" , :as => :qi_cible_select
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,11 @@
|
|||||||
|
|
||||||
|
|
||||||
-if slide.cible
|
-if slide.cible
|
||||||
.cible=render :partial => "portlet/link_contents/"+slide.cible_type.tableize.singularize, :locals => {:cible => slide.cible}
|
.cible
|
||||||
|
%strong
|
||||||
|
Liens vers
|
||||||
|
= slide.cible.cible_name
|
||||||
|
|
||||||
.clear
|
.clear
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
%li#slide.slide{:id => slide.id, :style => "width:960px;height:309px;"}
|
%li#slide.slide{:id => slide.id, :style => "width:960px;height:309px;"}
|
||||||
|
|
||||||
|
- if slide.cible
|
||||||
|
-url = slide.cible.cible_url
|
||||||
|
-else
|
||||||
|
-url = ""
|
||||||
|
|
||||||
|
|
||||||
.title
|
.title
|
||||||
=link_to slide.title, (slide.cible ? slide.cible.url : "") if slide.image_file
|
=link_to slide.title, url if slide.image_file
|
||||||
|
|
||||||
.description
|
.description
|
||||||
=link_to simple_format(slide.description), (slide.cible ? slide.cible.url : "") if slide.image_file
|
=link_to simple_format(slide.description), url
|
||||||
|
|
||||||
|
|
||||||
.image_file=link_to image_tag( slide.image_file.file.large.medium.url), (slide.cible ? slide.cible.url : "") if slide.image_file
|
.image_file=link_to image_tag( slide.image_file.file.large.medium.url), url
|
||||||
.cible= link_to image_tag('front/en-savoir-plus-gris.png'), (slide.cible ? slide.cible.url : "")
|
.cible= link_to image_tag('front/en-savoir-plus-gris.png'), url
|
||||||
|
@ -29,21 +29,31 @@
|
|||||||
=render :partial => "public/shared/contact_block"
|
=render :partial => "public/shared/contact_block"
|
||||||
.column_2.column
|
.column_2.column
|
||||||
-block = @home.home_blocks.find_by_slug("left_block")
|
-block = @home.home_blocks.find_by_slug("left_block")
|
||||||
.title=link_to block.title, (block.cible ? block.cible.url : "")
|
|
||||||
.desc=link_to simple_format(block.description), (block.cible ? block.cible.url : "")
|
- if block.cible
|
||||||
|
-url = block.cible.cible_url
|
||||||
|
-else
|
||||||
|
-url = ""
|
||||||
|
|
||||||
|
.title=link_to block.title, url
|
||||||
|
.desc=link_to simple_format(block.description), url
|
||||||
|
|
||||||
.cible
|
.cible
|
||||||
=link_to image_tag('front/en-savoir-plus-marron.png'), (block.cible ? block.cible.url : "")
|
=link_to image_tag('front/en-savoir-plus-marron.png'), url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.column_3.column
|
.column_3.column
|
||||||
-block = @home.home_blocks.find_by_slug("right_block")
|
-block = @home.home_blocks.find_by_slug("right_block")
|
||||||
.title=link_to block.title, (block.cible ? block.cible.url : "")
|
- if block.cible
|
||||||
.desc=link_to simple_format(block.description), (block.cible ? block.cible.url : "")
|
-url = block.cible.cible_url
|
||||||
|
-else
|
||||||
|
-url = ""
|
||||||
|
.title=link_to block.title, url
|
||||||
|
.desc=link_to simple_format(block.description), url
|
||||||
|
|
||||||
.cible
|
.cible
|
||||||
=link_to image_tag('front/en-savoir-plus-marron.png'), (block.cible ? block.cible.url : "")
|
=link_to image_tag('front/en-savoir-plus-marron.png'), url
|
||||||
|
|
||||||
.clear
|
.clear
|
||||||
#home_promotions
|
#home_promotions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user