move cards

This commit is contained in:
Torsten 2023-01-20 19:54:20 +02:00
parent e752c46d96
commit 321f1909c5
8 changed files with 29 additions and 9 deletions

View File

@ -1570,6 +1570,10 @@ select {
margin-top: 5rem;
}
.ml-3 {
margin-left: 0.75rem;
}
.block {
display: block;
}

View File

@ -39,7 +39,7 @@ module Merged
@card.update(params[:card])
@card.update_options( params[:options])
@card.edit_save(current_member.email)
redirect_to section_cards_url(@card.section.id) , notice: "Updated #{@card.header}"
redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}"
end
private

View File

@ -1,5 +1,9 @@
module Merged
module CardsHelper
include ViewHelper #for previews
def card_section_select
Section.where.not(card_template: "").collect{|s| ["#{s.page.name}: #{s.header}" , s.id]}
end
end
end

View File

@ -38,6 +38,10 @@ module Merged
CardStyle.find_by_template( self.template )
end
def allowed_fields
super + [:section_id]
end
def delete_and_reset_index(editor)
delete_save!(editor)
section.reset_index

View File

@ -61,12 +61,15 @@ module Merged
def update(hash)
return unless hash
hash.each do |key , value|
raise "unsuported field #{key} for #{template}:#{allowed_fields}" unless allowed_fields.include?(key.to_sym)
value = value.to_i if key.to_s.include?("_id")
key = key.to_sym
raise "unsuported field #{key} for #{template}:#{allowed_fields}" unless allowed_fields.include?(key)
if(! attributes[key].nil? ) # first setting ok, types not (yet?) specified
if( @attributes[key].class != value.class )
raise "Type mismatch #{key} #{key.class}!=#{value.class}"
raise "Type mismatch #{key} #{@attributes[key].class}!=#{value.class}"
end
end
puts "setting #{key}=#{value}"
attributes[key] = value
end
end

View File

@ -31,9 +31,9 @@
.basis-full.mb-3
= form_for( card , {method: :delete } ) do
=submit_button( "Delete Card" , true)
= simple_form_for( card , method: :post ) do |f|
= simple_form_for( card , method: :patch ) do |f|
= f.input :section_id , label: "move to section" , include_blank: false ,
collection: Merged::Page.all.collect{|p| [p.name , p.id]}
collection: card_section_select
=submit_button( "Move")
.basis-80

View File

@ -1,9 +1,14 @@
.text-xl.font-bold.text-gray-900
= section.page.type.capitalize
=link_to section.page.name, merged.page_sections_path(section.page.id), class: "underline"
\:
= link_to section.page.name, merged.page_sections_path(section.page.id), class: "underline text-3xl ml-3"
.text-xl.font-bold.text-gray-900
%span
Section
\:
= link_to section.header, section_path(section), class: "underline text-3xl ml-3"
.link
.inline-flex.items-center.justify-center.gap-3
.text-xl.font-bold.text-gray-900
Section #{section.header}
- 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
%span.sr-only Next Section

View File

@ -1,4 +1,4 @@
.mx-20.flex.h-16.items-center.gap-16
.mx-20.flex.h-16.items-center.gap-16.w-full
= render "sections_pagination" , section: @section
= link_to( "New Section" , merged.new_page_section_path(@section.page.id) , class: button_classes + " bg-cyan-100")