Sha256: 404864e3c2a582b0545ac806a1297fbaa8b024ba8c062b90b2de7a4864b4b8a9

Contents?: true

Size: 981 Bytes

Versions: 82

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    module Admin
      # This command is executed when the user creates a TimelineEntry
      # for a Result from the admin panel.
      class CreateTimelineEntry < Rectify::Command
        def initialize(form)
          @form = form
        end

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

          transaction do
            create_timeline_entry
          end

          broadcast(:ok)
        end

        private

        attr_reader :timeline_entry

        def create_timeline_entry
          @timeline_entry = TimelineEntry.create!(
            decidim_accountability_result_id: @form.decidim_accountability_result_id,
            entry_date: @form.entry_date,
            description: @form.description
          )
        end
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

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