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|
|
||||
data = i.attributes.dup
|
||||
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] = i.created_at.to_i
|
||||
data[:aspect_ratio] = i.aspect_ratio.join("/")
|
||||
@ -16,6 +16,10 @@ module Merged
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
@image = Image.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
new_image = Image.create_new(params['filename'] , params['image_file'])
|
||||
redirect = :images
|
||||
@ -26,6 +30,13 @@ module Merged
|
||||
redirect_to redirect
|
||||
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
|
||||
|
@ -7,10 +7,6 @@ module Merged
|
||||
@page = Page.find(params[:page_id])
|
||||
end
|
||||
|
||||
def select_image
|
||||
@images = Image.all
|
||||
end
|
||||
|
||||
def select_template
|
||||
@sections = SectionStyle.all
|
||||
end
|
||||
@ -37,9 +33,9 @@ module Merged
|
||||
end
|
||||
|
||||
def set_image
|
||||
@section.image = params[:image]
|
||||
@section.image_id = params[:image_id]
|
||||
@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
|
||||
|
||||
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
|
||||
.text-xl.font-bold.text-gray-900
|
||||
All Images
|
||||
= text_for_index
|
||||
|
||||
= render "layouts/merged_header"
|
||||
- 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
|
||||
-else
|
||||
= 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: ""))
|
||||
|
||||
.basis-80.grow
|
||||
|
Loading…
Reference in New Issue
Block a user