From 9bcd43215b943543cd3dc6fcdefc363c975f0a52 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 3 Jan 2023 19:37:31 +0200 Subject: [PATCH] fixing demo errors, rename template to style --- app/controllers/merged/cards_controller.rb | 2 +- app/controllers/merged/pages_controller.rb | 2 +- app/controllers/merged/sections_controller.rb | 2 +- app/helpers/merged/view_helper.rb | 3 ++- app/models/merged/change_set.rb | 1 + app/views/merged/sections/index.haml | 4 ++-- app/views/merged/sections/select_card_template.haml | 2 +- app/views/merged/sections/select_template.haml | 2 +- app/views/merged/sections/show.haml | 8 ++++---- app/views/merged/view/_section_half_image.haml | 3 --- config/merged/section_styles.yml | 1 - 11 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/controllers/merged/cards_controller.rb b/app/controllers/merged/cards_controller.rb index 17641ac..93bd36b 100644 --- a/app/controllers/merged/cards_controller.rb +++ b/app/controllers/merged/cards_controller.rb @@ -45,7 +45,7 @@ module Merged @card.option_definitions.each do |option| @card.set_option(option.name, options[option.name]) end if options - @card.save(current_member.email) + @card.edit_save(current_member.email) redirect_to section_cards_url(@card.section.id) , notice: "Updated #{@card.header}" end diff --git a/app/controllers/merged/pages_controller.rb b/app/controllers/merged/pages_controller.rb index 441d2ac..e0d7134 100644 --- a/app/controllers/merged/pages_controller.rb +++ b/app/controllers/merged/pages_controller.rb @@ -53,7 +53,7 @@ module Merged end def destroy - @page.delete() + @page.delete_save! redirect_to pages_url, notice: "Page #{@page.name} was removed." end diff --git a/app/controllers/merged/sections_controller.rb b/app/controllers/merged/sections_controller.rb index 4d8422f..eeb024f 100644 --- a/app/controllers/merged/sections_controller.rb +++ b/app/controllers/merged/sections_controller.rb @@ -27,7 +27,7 @@ module Merged end def destroy - @section.delete + @section.delete_save! redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed" end diff --git a/app/helpers/merged/view_helper.rb b/app/helpers/merged/view_helper.rb index 0117ea5..6d3ec60 100644 --- a/app/helpers/merged/view_helper.rb +++ b/app/helpers/merged/view_helper.rb @@ -5,7 +5,8 @@ module Merged def rows( text ) return 5 if text.blank? text = text.text unless text.is_a?(String) - rows = (text.length / 60).to_i + return 5 if text.blank? + rows = (text.length / 50).to_i return 5 if rows < 5 rows end diff --git a/app/models/merged/change_set.rb b/app/models/merged/change_set.rb index a4dfe1d..288bb15 100644 --- a/app/models/merged/change_set.rb +++ b/app/models/merged/change_set.rb @@ -12,6 +12,7 @@ module Merged end def zero + [Page, Section, Card].each { |m| m.reload(true) } @adds = [] @edits = [] @deletes = [] diff --git a/app/views/merged/sections/index.haml b/app/views/merged/sections/index.haml index d558411..91fd9fa 100644 --- a/app/views/merged/sections/index.haml +++ b/app/views/merged/sections/index.haml @@ -41,9 +41,9 @@ =submit_button( "Delete" , true) .basis-72 - %h3.mt-4.text-lg.font-bold Template + %h3.mt-4.text-lg.font-bold Style = link_to(merged.section_select_template_path(section.id)) do - %p= section.template + %p= section.template_style.header = section_preview(section , class: "object-contain") .basis-52.grow %h3.mt-4.text-lg.font-bold Header diff --git a/app/views/merged/sections/select_card_template.haml b/app/views/merged/sections/select_card_template.haml index 8a88266..3c04d4a 100644 --- a/app/views/merged/sections/select_card_template.haml +++ b/app/views/merged/sections/select_card_template.haml @@ -2,7 +2,7 @@ .text-xl.font-bold.text-gray-900 Page #{link_to @section.page.name, merged.page_sections_path(@section.page.id), class: "underline"} .text-xl.text-gray-900 - Select Card Template for Section #{@section.index} - #{@section.header} + Select Card Style for Section #{@section.index} - #{@section.header} = render "layouts/merged_header" .grid.grid-cols-4.gap-6.m-8 diff --git a/app/views/merged/sections/select_template.haml b/app/views/merged/sections/select_template.haml index 9b1c6bc..0a93b2a 100644 --- a/app/views/merged/sections/select_template.haml +++ b/app/views/merged/sections/select_template.haml @@ -2,7 +2,7 @@ .text-xl.font-bold.text-gray-900 Page #{link_to @section.page.name, merged.page_sections_path(@section.page.id), class: "underline"} .text-xl.text-gray-900 - Select Template for Section #{@section.index} - #{@section.header} + Select Style for Section #{@section.index} - #{@section.header} = render "layouts/merged_header" diff --git a/app/views/merged/sections/show.haml b/app/views/merged/sections/show.haml index 76ef71a..d848569 100644 --- a/app/views/merged/sections/show.haml +++ b/app/views/merged/sections/show.haml @@ -8,9 +8,9 @@ .flex.gap-4.m-8.flex-wrap .basis-96 - %h3.mt-4.text-lg.font-bold Template #{@section.template} + %h3.mt-4.text-lg.font-bold= @section.template_style.header = section_preview(@section , class: "w-full object-contain my-4") - = yellow_button( "Change Template" , merged.section_select_template_path(@section.id)) + = yellow_button( "Change Style" , merged.section_select_template_path(@section.id)) = green_button( "New Section" , merged.new_page_section_path(@section.page.id , template: @section.template) ) .basis-full.mt-3 Updated at: @@ -48,10 +48,10 @@ - if( @section.has_cards? ) .basis-full.h-0 .basis-96 - .mx-3.text-lg.font-bold Card Template #{@section.card_template} + .mx-3.text-lg.font-bold Card Style #{@section.card_template} =card_preview(@section , class: "my-3") %p.py-3 - =yellow_button("Change Card Template", merged.section_select_card_template_path(@section.id)) + =yellow_button("Change Card Style", merged.section_select_card_template_path(@section.id)) .basis-96.grow %h3.mt-4.text-lg.font-bold #{@section.cards.length} Cards diff --git a/app/views/merged/view/_section_half_image.haml b/app/views/merged/view/_section_half_image.haml index 8aaa171..0e8220d 100644 --- a/app/views/merged/view/_section_half_image.haml +++ b/app/views/merged/view/_section_half_image.haml @@ -10,9 +10,6 @@ = section.option("subheader") %p.prose.mt-8.md:block = markdown(section) - -if section.has_option?("text") - %p.prose.mt-8.md:block - = markdown section.option("text") -if section.has_option?("button_text") .mt-8.md:mt-8 = render 'merged/view/elements/button' , section: section diff --git a/config/merged/section_styles.yml b/config/merged/section_styles.yml index dbfbb33..eca4506 100644 --- a/config/merged/section_styles.yml +++ b/config/merged/section_styles.yml @@ -51,7 +51,6 @@ - background - color - subheader - - text - text_align - button_link - button_text