From a8523d474ecc41a2dd5f8b955fb7ba8a3e77ae5b Mon Sep 17 00:00:00 2001 From: Torsten Date: Mon, 9 Jan 2023 00:22:47 +0200 Subject: [PATCH] better option display --- app/views/merged/cards/index.haml | 10 +++++----- app/views/merged/sections/_option_form_date.haml | 2 +- app/views/merged/sections/_option_form_select.haml | 2 +- app/views/merged/sections/_option_form_text.haml | 2 +- app/views/merged/sections/index.haml | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index 9693898..332730a 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -12,7 +12,7 @@ - @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 + .basis-80 .p-4 %h3.mt-4.text-lg.font-bold Card #{index + 1}:#{card.header} .flex.flex-wrap @@ -21,17 +21,16 @@ = form_tag( merged.card_path(card.id) , {method: :delete } ) do =submit_button( "Delete" , true) .p-4 - %h3.mt-4.text-lg.font-bold.image_button Image = yellow_button("Change Image" , merged.images_path(card_id: card.id) ) - = red_button("Remove image", merged.card_set_image_path( card.id , image: "") ) .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 + = red_button("Remove image", merged.card_set_image_path( card.id , image: "") ) - .basis-96 + .basis-80 = link_to(merged.images_path(card_id: card.id)) do -if card.image %h3.mt-4.text-lg.font-bold Image #{card.image.name} @@ -58,7 +57,8 @@ .mt-4.text-lg.font-bold Options = form_tag( merged.card_path(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 + .grid.grid-cols-3 + =render "merged/sections/option_form_#{option.type}" , section: card , option: option -if card.option_definitions.empty? %p No options -else diff --git a/app/views/merged/sections/_option_form_date.haml b/app/views/merged/sections/_option_form_date.haml index 30d8ca2..e662327 100644 --- a/app/views/merged/sections/_option_form_date.haml +++ b/app/views/merged/sections/_option_form_date.haml @@ -1,4 +1,4 @@ %label.block .mt-4.text-lg.font-bold = option.name.camelcase - = select_date section.option(option.name) , :prefix => "option[#{option.name}]" +.col-span-2= select_date section.option(option.name) , :prefix => "option[#{option.name}]" diff --git a/app/views/merged/sections/_option_form_select.haml b/app/views/merged/sections/_option_form_select.haml index 6b1da57..c84cb3c 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 .mt-4.text-lg.font-bold = option.name.camelcase - = 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") +.col-span-2= 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 43b505f..97b1010 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 .mt-4.text-lg.font-bold = option.name.camelcase - = 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") +.col-span-2= 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.haml b/app/views/merged/sections/index.haml index 0cda01a..a85099e 100644 --- a/app/views/merged/sections/index.haml +++ b/app/views/merged/sections/index.haml @@ -72,8 +72,9 @@ %h3.mt-4.text-lg.font-bold Options .grid.grid-cols-2.gap-3.mx-10 - section.options.each do|name , value| - .font-bold.mt-1= name.camelcase - .font-xl= value + -unless value.blank? + .font-bold.mt-1= name.camelcase + .font-xl= value .grid.grid-cols-2.gap-2.m-8 .relative.block %p