From e752c46d9670e13cac455508d7375872a943c299 Mon Sep 17 00:00:00 2001 From: Torsten Date: Fri, 20 Jan 2023 16:49:22 +0200 Subject: [PATCH] change forms for simple_form --- app/views/merged/cards/index.haml | 22 ++++++++++--------- .../merged/sections/_option_form_date.haml | 2 +- .../merged/sections/_option_form_select.haml | 2 +- .../merged/sections/_option_form_text.haml | 2 +- app/views/merged/sections/show.haml | 21 ++++++++---------- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index 7ad0b31..f5d555f 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -29,8 +29,12 @@ Updated by: = card.updated_by .basis-full.mb-3 - = form_tag( merged.card_path(card.id) , {method: :delete } ) do + = form_for( card , {method: :delete } ) do =submit_button( "Delete Card" , true) + = simple_form_for( card , method: :post ) do |f| + = f.input :section_id , label: "move to section" , include_blank: false , + collection: Merged::Page.all.collect{|p| [p.name , p.id]} + =submit_button( "Move") .basis-80 = link_to(merged.images_path(card_id: card.id)) do @@ -49,17 +53,15 @@ %h3.mt-4.text-lg.font-bold No image %button.my-3.bg-cyan-200{class: button_classes} Add Image .basis-72.grow - = form_tag( merged.card_path(card.id) , {method: :patch , class: "mx-auto mb-0 max-w space-y-4" } ) do - %label.block - .text-lg.font-bold Header - = text_field_tag( :header , card.header, class: "mt-2 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: "mt-2 w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" ) - =submit_button( "Update Texts") + %label.block + %h4.text-lg.font-bold Texts + = simple_form_for( card , method: :patch) do |f| + = f.input :header + = f.input :text , as: :text , input_html: {rows: rows(card)} + .mt-4= submit_button("Update Texts") .basis-72.grow - = form_tag( merged.card_path(card.id) , {method: :patch , class: "mx-auto mb-0 max-w space-y-4" }) do + = form_for( card , {method: :patch }) do - card.option_definitions.each do |option| .grid.grid-cols-3 =render "merged/sections/option_form_#{option.type}" , section: card , option: option diff --git a/app/views/merged/sections/_option_form_date.haml b/app/views/merged/sections/_option_form_date.haml index e662327..4c07c0f 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 -.col-span-2= select_date section.option(option.name) , :prefix => "option[#{option.name}]" +.col-span-2= select_date section.option(option.name) , :prefix => "options[#{option.name}]" diff --git a/app/views/merged/sections/_option_form_select.haml b/app/views/merged/sections/_option_form_select.haml index c84cb3c..6bc7a18 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 -.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") +.col-span-2= select_tag( "options[#{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 97b1010..dd8eac1 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 -.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") +.col-span-2= text_field_tag( "options[#{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/show.haml b/app/views/merged/sections/show.haml index 28ab2c1..8b9959e 100644 --- a/app/views/merged/sections/show.haml +++ b/app/views/merged/sections/show.haml @@ -16,10 +16,9 @@ .basis-full.mb-3 Updated by: = @section.updated_by - = simple_form_for( @section , method: :patch , class: "mx-auto mb-2 max-w space-y-4") do |f| - = f.input :page_id , label: "move to page" , include_blank: false , - collection: Merged::Page.all.collect{|p| [p.name , p.id]} , - class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" + = simple_form_for( @section , method: :patch ) do |f| + = f.input :page_id , label: "move to page" , include_blank: false , + collection: Merged::Page.all.collect{|p| [p.name , p.id]} =submit_button( "Move") .basis-80.image @@ -40,13 +39,11 @@ .mt-3= red_button( "Remove image", merged.section_set_image_path( @section.id , image: "")) if( @section.image ) .basis-80.grow.content_update - = form_tag( merged.section_path( @section.id) , method: :patch , class: "mx-auto mb-2 max-w space-y-4") do - %label.block - %h4.text-lg.font-bold Header - = text_field_tag( :header , @section.header, class: "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 - = text_area_tag( :text , @section.text, rows: rows(@section) ,class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") + %label.block + %h4.text-lg.font-bold Texts + = simple_form_for( @section , method: :patch) do |f| + = f.input :header + = f.input :text , as: :text , input_html: {rows: rows(@section)} .mt-4= submit_button("Update Texts") - if( @section.has_cards? ) @@ -67,7 +64,7 @@ = blue_button( "New Card" , merged.new_section_card_path(@section.id) ) .basis-80.grow - = form_tag( merged.section_path( @section.id) , method: :patch , class: "mx-auto mb-0 max-w space-y-4") do + = simple_form_for( @section , method: :patch , class: "mx-auto mb-0 max-w space-y-4") do - @section.option_definitions.each do |option| .grid.grid-cols-3 =render "option_form_#{option.type}" , section: @section , option: option