Sha256: 50a81de5942e5552a52f38a98dd2f32045e1028ca10feda99b145b72df29e0ec

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 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 < Decidim::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, user)
          @form = form
          @timeline_entry = timeline_entry
          @user = user
        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
          Decidim.traceability.update!(
            timeline_entry,
            @user,
            entry_date: form.entry_date,
            title: form.title,
            description: form.description
          )
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-accountability-0.28.4 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.9 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.3 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.8 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.7 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.6 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.5 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.0.rc5 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.28.0.rc4 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.4 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.3 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.1 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.0 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.0.rc2 app/commands/decidim/accountability/admin/update_timeline_entry.rb
decidim-accountability-0.27.0.rc1 app/commands/decidim/accountability/admin/update_timeline_entry.rb