Sha256: c2266eafdc003c5526f58c289c89f31152d515a05524e418f4deed83f179db4d

Contents?: true

Size: 1.1 KB

Versions: 65

Compression:

Stored size: 1.1 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!(
            entry_date: @form.entry_date,
            description: @form.description
          )
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

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