merged/app/views/merged/cards/index.haml

62 lines
2.8 KiB
Plaintext
Raw Normal View History

2023-01-09 14:44:00 +02:00
.mx-20.flex.h-16.items-center.gap-16
= render "merged/sections/sections_pagination" , section: @section
.text-xl.text-gray-900
Cards for Section #{@section.index} -
= link_to @section.header , merged.section_path( @section.id) , class: "underline"
= link_to( "New Card" , merged.new_section_card_path(@section.id) , class: "p-2 border border-gray-200 bg-cyan-100 font-bold rounded-lg hover:bg-sky-100")
2022-11-30 11:22:45 +02:00
- template = find_template(@section)
= render( template , section: @section)
2022-12-02 23:22:43 +02:00
2022-12-13 19:52:09 +02:00
- @section.cards.each_with_index do |card , index|
2023-01-10 21:06:11 +02:00
.flex.gap-10.px-20.pt-4.pb-2.mb-2.border.border-2.bg-neutral-50.border-slate-400{ id: "card_#{card.id}"}
.basis-60
2023-01-09 14:44:00 +02:00
%h3.mt-4.text-lg.font-bold Card #{index + 1}:#{card.header}
.flex.flex-wrap
= blue_button( "Up" , merged.card_move_path(card.id , dir: :up) )
= blue_button( "Down" , merged.card_move_path(card.id , dir: :down) )
.mt-6
2022-12-26 20:58:34 +02:00
.basis-full.mt-3
Updated at:
= distance_of_time_in_words_to_now(card.updated_at)
.basis-full.mb-3
Updated by:
= card.updated_by
2023-01-10 21:06:11 +02:00
.basis-full.mb-3
= form_tag( merged.card_path(card.id) , {method: :delete } ) do
=submit_button( "Delete Card" , true)
2022-12-02 15:04:53 +02:00
2023-01-09 00:22:47 +02:00
.basis-80
2022-12-30 22:25:32 +02:00
= link_to(merged.images_path(card_id: card.id)) do
-if card.image
%h3.mt-4.text-lg.font-bold Image #{card.image.name}
.flex.align-center.justify-between.mb-4
.text-lg.font-bold.mt-2.mx-2
= card.image.size.to_s + "k"
2023-01-10 21:06:11 +02:00
%strong.inline-block.rounded.bg-slate-200.px-3.py-1.text-md.font-medium
2022-12-30 22:25:32 +02:00
= card.image.aspect_ratio
2023-01-10 21:06:11 +02:00
= image_for( card , "mb-4")
= green_button("Change Image" , merged.images_path(card_id: card.id) )
= red_button("Remove image", merged.card_set_image_path( card.id , image: "") )
2022-12-30 22:25:32 +02:00
-else
2023-01-10 21:06:11 +02:00
%h3.text-lg.font-bold No image
2022-12-13 19:52:09 +02:00
.basis-72.grow
2023-01-10 21:06:11 +02:00
= form_tag( merged.card_path(card.id) , {method: :patch , class: "mx-auto mb-0 max-w space-y-4" } ) do
2022-12-02 15:04:53 +02:00
%label.block
2022-12-13 19:52:09 +02:00
.text-lg.font-bold Header
2022-12-02 15:04:53 +02:00
= 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
2022-12-13 19:52:09 +02:00
.mt-4.text-lg.font-bold Text
2022-12-02 15:04:53 +02:00
= text_area_tag( :text , card.text, rows: 5 , class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" )
2023-01-10 21:06:11 +02:00
=submit_button( "Update Texts")
2022-12-13 19:52:09 +02:00
.basis-72.grow
2023-01-10 21:06:11 +02:00
= form_tag( merged.card_path(card.id) , {method: :patch , class: "mx-auto mb-0 max-w space-y-4" }) do
2022-12-05 18:14:56 +02:00
- card.option_definitions.each do |option|
2023-01-09 00:22:47 +02:00
.grid.grid-cols-3
=render "merged/sections/option_form_#{option.type}" , section: card , option: option
2022-12-05 18:14:56 +02:00
-if card.option_definitions.empty?
%p No options
-else
2023-01-10 21:06:11 +02:00
= submit_button("Update Options")