merged/app/views/merged/cards/index.haml
2022-12-19 09:53:25 +02:00

54 lines
2.3 KiB
Plaintext

- content_for( :merged_menu ) do
= render "merged/sections/sections_pagination" , section: @section
.text-xl.text-gray-900
Cards for Section #{@section.index} -
= link_to @section.header , section_url( @section.id) , class: "underline"
= link_to( "New Card" , new_section_card_url(@section.id) , class: "p-2 border border-gray-200 font-bold rounded-lg hover:bg-sky-100")
= render "layouts/merged_header"
- template = find_template(@section)
= render( template , section: @section)
- @section.cards.each_with_index do |card , index|
.flex.gap-10.px-20.py-10{class: (card.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' , id: "card_#{card.id}"}
.basis-96
.p-4
%h3.mt-4.text-lg.font-bold Card #{index + 1}:#{card.header}
.flex.flex-wrap
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
= form_tag( card_url(card.id) , {method: :delete } ) do
=submit_button( "Delete" , true)
.p-4
%h3.mt-4.text-lg.font-bold Image
= 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? )
%p No image
-else
= image_for( card, "p-3")
.basis-72.grow
%h3.mt-4.text-lg.font-bold Fields
= form_tag( card_url(card.id) , {method: :patch , class: "mx-auto mt-8 mb-0 max-w space-y-4" } ) do
%label.block
.text-lg.font-bold Header
= text_field_tag( :header , card.header, class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%label.block
.mt-4.text-lg.font-bold Text
= text_area_tag( :text , card.text, rows: 5 , class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" )
=submit_button( "Update")
.basis-72.grow
.mt-4.text-lg.font-bold Options
= form_tag( card_url(card.id) , {method: :patch , class: "mx-auto mt-8 mb-0 max-w space-y-4" }) do
- card.option_definitions.each do |option|
=render "merged/sections/option_form_#{option.type}" , section: card , option: option
-if card.option_definitions.empty?
%p No options
-else
= submit_button("Update")