From 8dbdf377f02c683f6bc91b658173a57751305429 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 13 Dec 2022 19:52:09 +0200 Subject: [PATCH] flexing card edit page too --- app/helpers/merged/cards_helper.rb | 1 + app/views/merged/cards/index.haml | 19 ++++++++++--------- .../sections/{_form.html.haml => _form.haml} | 0 .../merged/sections/_option_form_select.haml | 2 +- .../merged/sections/_option_form_text.haml | 2 +- .../sections/{index.html.haml => index.haml} | 0 .../sections/{new.html.haml => new.haml} | 0 .../sections/{show.html.haml => show.haml} | 0 8 files changed, 13 insertions(+), 11 deletions(-) rename app/views/merged/sections/{_form.html.haml => _form.haml} (100%) rename app/views/merged/sections/{index.html.haml => index.haml} (100%) rename app/views/merged/sections/{new.html.haml => new.haml} (100%) rename app/views/merged/sections/{show.html.haml => show.haml} (100%) diff --git a/app/helpers/merged/cards_helper.rb b/app/helpers/merged/cards_helper.rb index ea6c452..f466b3a 100644 --- a/app/helpers/merged/cards_helper.rb +++ b/app/helpers/merged/cards_helper.rb @@ -1,4 +1,5 @@ module Merged module CardsHelper + include ViewHelper #for previews end end diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index 54b83ce..cdbc6e0 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -10,9 +10,9 @@ - template = find_template(@section) = render( template , section: @section) -.grid.grid-cols-4.gap-2.m-8 - - @section.cards.each_with_index do |card , index| - .relative.block.border.border-gray-100 +- @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} = blue_button( "Up" , card_move_url(card.id , dir: :up) ) @@ -25,24 +25,25 @@ = red_button("Remove image", card_set_image_path( card.id , image: "") ) - .relative.block.border.border-gray-100 + .basis-96 %h3.mt-4.text-lg.font-bold Image -if( card.image.blank? ) %p No image -else = image_tag( "cms/" + card.image , class: "p-3") - .relative.block.border.border-gray-100 + .basis-72.grow + %h3.mt-4.text-lg.font-bold Fields = form_tag( card_url(card.id) , {method: :patch } ) do %label.block - %h4.text-lg.font-bold Header + .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 - %h4.mt-4.text-lg.font-bold Text + .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") - .relative.block.border.border-gray-100 - %h3.mt-4.text-lg.font-bold Options + .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 diff --git a/app/views/merged/sections/_form.html.haml b/app/views/merged/sections/_form.haml similarity index 100% rename from app/views/merged/sections/_form.html.haml rename to app/views/merged/sections/_form.haml diff --git a/app/views/merged/sections/_option_form_select.haml b/app/views/merged/sections/_option_form_select.haml index 6e728c7..4a78741 100644 --- a/app/views/merged/sections/_option_form_select.haml +++ b/app/views/merged/sections/_option_form_select.haml @@ -1,4 +1,4 @@ %label.block - %h4.text-lg.font-bold + .mt-4.text-lg.font-bold = option.name.capitalize = select_tag( "option[#{option.name}]" , options_for_select(option.values, section.option(option.name)), class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") diff --git a/app/views/merged/sections/_option_form_text.haml b/app/views/merged/sections/_option_form_text.haml index d8c8ad3..97e1fd5 100644 --- a/app/views/merged/sections/_option_form_text.haml +++ b/app/views/merged/sections/_option_form_text.haml @@ -1,4 +1,4 @@ %label.block - %h4.text-lg.font-bold + .mt-4.text-lg.font-bold = option.name = text_field_tag( "option[#{option.name}]" , section.option(option.name), class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") diff --git a/app/views/merged/sections/index.html.haml b/app/views/merged/sections/index.haml similarity index 100% rename from app/views/merged/sections/index.html.haml rename to app/views/merged/sections/index.haml diff --git a/app/views/merged/sections/new.html.haml b/app/views/merged/sections/new.haml similarity index 100% rename from app/views/merged/sections/new.html.haml rename to app/views/merged/sections/new.haml diff --git a/app/views/merged/sections/show.html.haml b/app/views/merged/sections/show.haml similarity index 100% rename from app/views/merged/sections/show.html.haml rename to app/views/merged/sections/show.haml