Sha256: 3c3f51bef1ec8e1778726e7c40a3b5f6039f873bcf7526a67944707eb615c004

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

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

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

          transaction do
            update_timeline_entry
          end

          broadcast(:ok)
        end

        private

        attr_reader :timeline_entry, :form

        def update_timeline_entry
          timeline_entry.update_attributes!(
            entry_date: @form.entry_date,
            description: @form.description
          )
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
decidim-accountability-0.9.3 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.9.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.9.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.9.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.8.4 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.8.3 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.8.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.8.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.8.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.7.4 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.7.3 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.7.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.7.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.7.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.1.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.1.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.1.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb