card image selection

This commit is contained in:
Torsten 2022-12-19 09:53:25 +02:00
parent 5654bb0743
commit 5d4da2c032
5 changed files with 11 additions and 9 deletions

View File

@ -6,14 +6,10 @@ module Merged
@section = Section.find(params[:section_id])
end
def select_image
@images = Image.all
end
def set_image
@card.image = params[:image]
@card.image_id = params[:image_id]
@card.save
redirect_to section_cards_url(@card.section.id) , notice: "Image selected: #{@card.image}"
redirect_to section_cards_url(@card.section.id) , notice: "Image selected: #{@card.image.name}"
end
def move

View File

@ -35,6 +35,9 @@ module Merged
if(params[:section_id])
return view_context.section_set_image_url(params[:section_id] , image_id: image.id)
end
if(params[:card_id])
return view_context.card_set_image_url(params[:card_id] , image_id: image.id)
end
view_context.image_url(image.id)
end
end

View File

@ -20,6 +20,10 @@ module Merged
section = Section.find(section_id)
"Select image for Section #{section.index} : #{section.header}"
end
def card_text
card = Card.find(card_id)
"Select image for Card #{card.index} : #{card.header}"
end
end

View File

@ -22,10 +22,9 @@
=submit_button( "Delete" , true)
.p-4
%h3.mt-4.text-lg.font-bold Image
= yellow_button("Change Image" , card_select_image_url(card.id) )
= yellow_button("Change Image" , images_url(card_id: card.id) )
= red_button("Remove image", card_set_image_path( card.id , image: "") )
.basis-96
%h3.mt-4.text-lg.font-bold Image
-if( card.image.blank? )

View File

@ -11,7 +11,7 @@ module Merged
expect(first.class).to be Image
end
it "has name" do
expect(first.name).to eq "common_spaces"
expect(first.name).to eq "Common spaces"
end
it "has height and width" do
expect(first.height).to eq 300