Sha256: a8d8eb01ad89489df35ca8357859f676e3d06b88012339e41d107c8a57b24358
Contents?: true
Size: 1.39 KB
Versions: 16
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module Decidim module Plans module Admin # This command is executed when the user modifies sections from # the admin panel. class UpdateSections < Rectify::Command include NestedUpdater # Initializes a UpdateSections Command. # # form - The form from which to get the data. # sections - The current set of the sections to be updated. def initialize(form, sections) @form = form @sections = sections end # Updates the sections if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if @form.invalid? Decidim::Plans::Section.transaction do update_sections end broadcast(:ok) end private def update_sections @form.sections.each do |form_section| update_nested_model( form_section, { body: form_section.body, help: form_section.help, mandatory: form_section.mandatory, answer_length: form_section.answer_length, position: form_section.position, section_type: form_section.section_type }, @sections ) end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems