From 1036d11e98a043a49863b582ca6a9f9f9664bada Mon Sep 17 00:00:00 2001 From: Torsten Date: Fri, 20 Jan 2023 20:14:23 +0200 Subject: [PATCH] fix set template with/without cards mismatch --- app/controllers/merged/sections_controller.rb | 9 +++++++++ app/views/merged/cards/index.haml | 6 +++--- app/views/merged/sections/_sections_pagination.haml | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/merged/sections_controller.rb b/app/controllers/merged/sections_controller.rb index 2812fa7..929d9d6 100644 --- a/app/controllers/merged/sections_controller.rb +++ b/app/controllers/merged/sections_controller.rb @@ -41,6 +41,15 @@ module Merged def set_template template = params[:template] raise "no template given" if template.blank? + style = SectionStyle.where(template: template).first + raise "no such template #{template}" unless style + if(! style.has_cards?) + if( @section.cards.length > 0 ) + redirect_to section_url(@section.id) , alert: "Must delete cards first" + return + end + @section.card_style = "" + end @section.set_template( template ) @section.edit_save(current_member.email) redirect_to section_url(@section.id) diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index 74293f1..0502db4 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -1,8 +1,8 @@ .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" + .text-3xl.font-bold.text-gray-900 + = @section.cards.length + Cards = 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") = render_section( @section ) diff --git a/app/views/merged/sections/_sections_pagination.haml b/app/views/merged/sections/_sections_pagination.haml index bb7cc14..275a3f5 100644 --- a/app/views/merged/sections/_sections_pagination.haml +++ b/app/views/merged/sections/_sections_pagination.haml @@ -7,7 +7,7 @@ Section \: = link_to section.header, section_path(section), class: "underline text-3xl ml-3" -.link + .inline-flex.items-center.justify-center.gap-3 - if section.previous_section =link_to merged.section_path(section.previous_section.id) , class: "inline-flex h-8 w-8 items-center justify-center rounded border border-gray-100 hover:bg-sky-100" do