diff --git a/app/models/merged/card.rb b/app/models/merged/card.rb index 65872fb..4bc4b94 100644 --- a/app/models/merged/card.rb +++ b/app/models/merged/card.rb @@ -7,19 +7,19 @@ module Merged fields :id , :index , :section_id fields :text , :header, :image_name - def move_up - swap_index_with(next_card) - end - def change_name pagename = section ? section.page.name : section_id.to_s "#{pagename}:#{header}" end - def move_down + def move_up swap_index_with(previous_card) end + def move_down + swap_index_with(next_card) + end + def previous_card section.cards.where(index: index - 1).first end diff --git a/app/models/merged/section.rb b/app/models/merged/section.rb index 94df5fe..6f45e49 100644 --- a/app/models/merged/section.rb +++ b/app/models/merged/section.rb @@ -42,11 +42,11 @@ module Merged end def move_up - swap_index_with(next_section) + swap_index_with(previous_section) end def move_down - swap_index_with(previous_section) + swap_index_with(next_section) end def previous_section diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index 64ab313..d3771fd 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -3,7 +3,8 @@ .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") + = link_to( merged.new_section_card_path(@section.id) ) do + %button.button.change New Card .xl:mx-auto{class: "max-w-[1920px]"} = render_section( @section ) @@ -16,11 +17,11 @@ .p-2 =link_to(merged.card_move_path(card.id , dir: :down)) do %svg.w-6.h-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} - %path{:d => "M8.25 6.75L12 3m0 0l3.75 3.75M12 3v18", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + %path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"} .p-2 =link_to(merged.card_move_path(card.id , dir: :up)) do %svg.w-6.h-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} - %path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + %path{:d => "M8.25 6.75L12 3m0 0l3.75 3.75M12 3v18", "stroke-linecap" => "round", "stroke-linejoin" => "round"} .mt-6 .basis-full.mt-3 @@ -35,7 +36,10 @@ = simple_form_for( card , method: :patch ) do |f| = f.input :section_id , label: "move to section (on this page)" , include_blank: false , collection: card_section_select(card) - %button.button.change.mt-4{type: :submit} Move + .flex.justify-between.mt-4 + %button.button.change{type: :submit} Move + = link_to( merged.new_section_card_path(@section.id) ) do + .button.change New Card .basis-80 -if card.image diff --git a/app/views/merged/sections/index.haml b/app/views/merged/sections/index.haml index 11f9521..8d8a799 100644 --- a/app/views/merged/sections/index.haml +++ b/app/views/merged/sections/index.haml @@ -19,11 +19,11 @@ .p-2 =link_to(merged.section_move_path(section.id , dir: :down)) do %svg.w-6.h-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} - %path{:d => "M8.25 6.75L12 3m0 0l3.75 3.75M12 3v18", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + %path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"} .p-2 =link_to(merged.section_move_path(section.id , dir: :up)) do %svg.w-6.h-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} - %path{:d => "M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + %path{:d => "M8.25 6.75L12 3m0 0l3.75 3.75M12 3v18", "stroke-linecap" => "round", "stroke-linejoin" => "round"} .basis-full.mt-3 Updated at: = distance_of_time_in_words_to_now(section.updated_at)