Sha256: 0fb458d0104757b0c42059c5a4bead0f808e5655b223e31de126eea57a3adff6

Contents?: true

Size: 964 Bytes

Versions: 33

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Templates
    module Admin
      # Updates the questionnaire template given form data.
      class UpdateTemplate < Rectify::Command
        # Initializes the command.
        #
        # template - The Template to update.
        # form        - The form object containing the data to update.
        # user        - The user that updates the template.
        def initialize(template, form, user)
          @template = template
          @form = form
          @user = user
        end

        def call
          return broadcast(:invalid) unless @form.valid?
          return broadcast(:invalid) unless @user.organization == @template.organization

          @template = Decidim.traceability.update!(
            @template,
            @user,
            name: @form.name,
            description: @form.description
          )

          broadcast(:ok, @template)
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-templates-0.26.10 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.9 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.8 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.7 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.5 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.4 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.3 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.2 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.1 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.0 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.0.rc2 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.26.0.rc1 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.2 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.1 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.0 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.0.rc4 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.0.rc3 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.0.rc2 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.25.0.rc1 app/commands/decidim/templates/admin/update_template.rb
decidim-templates-0.24.3 app/commands/decidim/templates/admin/update_template.rb