use simple_form and hash updates

This commit is contained in:
Torsten 2023-01-20 16:49:11 +02:00
parent cb734f9de7
commit fba9f3d2fb
3 changed files with 10 additions and 13 deletions

View File

@ -36,15 +36,8 @@ module Merged
end
def update
@card.allowed_fields.each do |key|
if( params.has_key?(key) )
@card.update(key, params[key])
end
end
options = params[:option]
@card.option_definitions.each do |option|
@card.set_option(option.name, options[option.name])
end if options
@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}"
end

View File

@ -66,10 +66,7 @@ module Merged
def update
@section.update(params[:section])
options = params[:option]
@section.option_definitions.each do |option|
@section.set_option(option.name, options[option.name])
end if options
@section.update_options( params[:options])
@section.edit_save(current_member.email)
redirect_to :section , notice: "Update ok"
end

View File

@ -59,6 +59,7 @@ module Merged
end
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)
if(! attributes[key].nil? ) # first setting ok, types not (yet?) specified
@ -70,6 +71,12 @@ module Merged
end
end
def update_options( options )
return unless options
option_definitions.each do |option|
set_option(option.name, options[option.name])
end
end
#other may be nil
def swap_index_with(other)
return unless other