section image select and basic image show
This commit is contained in:
parent
0aca94cba2
commit
5654bb0743
@ -7,7 +7,7 @@ module Merged
|
|||||||
@image_data = @images.collect{|i|
|
@image_data = @images.collect{|i|
|
||||||
data = i.attributes.dup
|
data = i.attributes.dup
|
||||||
data[:url] = view_context.asset_path(i.asset_name)
|
data[:url] = view_context.asset_path(i.asset_name)
|
||||||
data[:link] = view_context.image_url(i.id)
|
data[:link] = build_link_for(i)
|
||||||
data[:created_at] = i.created_at.to_date
|
data[:created_at] = i.created_at.to_date
|
||||||
data[:created] = i.created_at.to_i
|
data[:created] = i.created_at.to_i
|
||||||
data[:aspect_ratio] = i.aspect_ratio.join("/")
|
data[:aspect_ratio] = i.aspect_ratio.join("/")
|
||||||
@ -16,6 +16,10 @@ module Merged
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@image = Image.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
new_image = Image.create_new(params['filename'] , params['image_file'])
|
new_image = Image.create_new(params['filename'] , params['image_file'])
|
||||||
redirect = :images
|
redirect = :images
|
||||||
@ -26,6 +30,13 @@ module Merged
|
|||||||
redirect_to redirect
|
redirect_to redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def build_link_for(image)
|
||||||
|
if(params[:section_id])
|
||||||
|
return view_context.section_set_image_url(params[:section_id] , image_id: image.id)
|
||||||
|
end
|
||||||
|
view_context.image_url(image.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -7,10 +7,6 @@ module Merged
|
|||||||
@page = Page.find(params[:page_id])
|
@page = Page.find(params[:page_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_image
|
|
||||||
@images = Image.all
|
|
||||||
end
|
|
||||||
|
|
||||||
def select_template
|
def select_template
|
||||||
@sections = SectionStyle.all
|
@sections = SectionStyle.all
|
||||||
end
|
end
|
||||||
@ -37,9 +33,9 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_image
|
def set_image
|
||||||
@section.image = params[:image]
|
@section.image_id = params[:image_id]
|
||||||
@section.save
|
@section.save
|
||||||
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image}"
|
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_template
|
def set_template
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
module Merged
|
|
||||||
|
|
||||||
module ImageHelper
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
26
app/helpers/merged/images_helper.rb
Normal file
26
app/helpers/merged/images_helper.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
module Merged
|
||||||
|
|
||||||
|
module ImagesHelper
|
||||||
|
|
||||||
|
def text_for_index
|
||||||
|
return section_text if(section_id)
|
||||||
|
return card_text if(card_id)
|
||||||
|
"All Images"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
def section_id
|
||||||
|
params[:section_id]
|
||||||
|
end
|
||||||
|
def card_id
|
||||||
|
params[:card_id]
|
||||||
|
end
|
||||||
|
def section_text
|
||||||
|
section = Section.find(section_id)
|
||||||
|
"Select image for Section #{section.index} : #{section.header}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -1,6 +1,6 @@
|
|||||||
- content_for( :merged_menu ) do
|
- content_for( :merged_menu ) do
|
||||||
.text-xl.font-bold.text-gray-900
|
.text-xl.font-bold.text-gray-900
|
||||||
All Images
|
= text_for_index
|
||||||
|
|
||||||
= render "layouts/merged_header"
|
= render "layouts/merged_header"
|
||||||
- if Rails.env.development?
|
- if Rails.env.development?
|
||||||
|
7
app/views/merged/images/show.haml
Normal file
7
app/views/merged/images/show.haml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- content_for( :merged_menu ) do
|
||||||
|
.text-xl.font-bold.text-gray-900
|
||||||
|
Image #{@image.name}
|
||||||
|
|
||||||
|
= render "layouts/merged_header"
|
||||||
|
|
||||||
|
= image_tag(@image.asset_name)
|
@ -19,7 +19,7 @@
|
|||||||
%p No image
|
%p No image
|
||||||
-else
|
-else
|
||||||
= image_for( @section , "my-3")
|
= image_for( @section , "my-3")
|
||||||
= yellow_button("Change Image", section_select_image_url(@section.id))
|
= yellow_button("Change Image", images_url(section_id: @section.id))
|
||||||
= red_button( "Remove image", section_set_image_path( @section.id , image: ""))
|
= red_button( "Remove image", section_set_image_path( @section.id , image: ""))
|
||||||
|
|
||||||
.basis-80.grow
|
.basis-80.grow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user