Sha256: 76f26661fd2b208311035413be5ca4a84a40f5b3ac7611fd30b88c566fda7993

Contents?: true

Size: 932 Bytes

Versions: 65

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Pages
    module Admin
      # This command is executed when the user changes a Page from the admin
      # panel.
      class UpdatePage < Rectify::Command
        # Initializes a UpdatePage Command.
        #
        # form - The form from which to get the data.
        # page - The current instance of the page to be updated.
        def initialize(form, page)
          @form = form
          @page = page
        end

        # Updates the page if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if @form.invalid?

          update_page
          broadcast(:ok)
        end

        private

        def update_page
          Decidim.traceability.update!(
            @page,
            @form.current_user,
            body: @form.body
          )
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
decidim-pages-0.17.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.18.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.17.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.16.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.17.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.16.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.15.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.15.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.15.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.14.4 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.14.3 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.14.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.14.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.13.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.12.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.13.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.12.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.13.0.pre1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.12.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.11.2 app/commands/decidim/pages/admin/update_page.rb