diff --git a/app/assets/stylesheets/merged/merged.css b/app/assets/stylesheets/merged/merged.css index 95079e4..a91ab19 100644 --- a/app/assets/stylesheets/merged/merged.css +++ b/app/assets/stylesheets/merged/merged.css @@ -1570,6 +1570,10 @@ select { margin-top: 5rem; } +.ml-3 { + margin-left: 0.75rem; +} + .block { display: block; } diff --git a/app/controllers/merged/cards_controller.rb b/app/controllers/merged/cards_controller.rb index 5580095..7912f40 100644 --- a/app/controllers/merged/cards_controller.rb +++ b/app/controllers/merged/cards_controller.rb @@ -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 diff --git a/app/helpers/merged/cards_helper.rb b/app/helpers/merged/cards_helper.rb index f466b3a..d576ffc 100644 --- a/app/helpers/merged/cards_helper.rb +++ b/app/helpers/merged/cards_helper.rb @@ -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 diff --git a/app/models/merged/card.rb b/app/models/merged/card.rb index d436bfc..65872fb 100644 --- a/app/models/merged/card.rb +++ b/app/models/merged/card.rb @@ -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 diff --git a/app/models/merged/view_base.rb b/app/models/merged/view_base.rb index 610eca7..79b4d91 100644 --- a/app/models/merged/view_base.rb +++ b/app/models/merged/view_base.rb @@ -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 diff --git a/app/views/merged/cards/index.haml b/app/views/merged/cards/index.haml index f5d555f..74293f1 100644 --- a/app/views/merged/cards/index.haml +++ b/app/views/merged/cards/index.haml @@ -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 diff --git a/app/views/merged/sections/_sections_pagination.haml b/app/views/merged/sections/_sections_pagination.haml index 7a30549..bb7cc14 100644 --- a/app/views/merged/sections/_sections_pagination.haml +++ b/app/views/merged/sections/_sections_pagination.haml @@ -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 diff --git a/app/views/merged/sections/show.haml b/app/views/merged/sections/show.haml index 8b9959e..32513c4 100644 --- a/app/views/merged/sections/show.haml +++ b/app/views/merged/sections/show.haml @@ -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")