Sha256: 259d37b624e50bd8991cad45ec3f842a2d2c991380f1f64b64f329f1b821f6ec

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 KB

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 < Decidim::Command
        def initialize(form, user)
          @form = form
          @user = user
        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, :form

        def create_timeline_entry
          @timeline_entry = Decidim.traceability.create!(
            TimelineEntry,
            @user,
            decidim_accountability_result_id: form.decidim_accountability_result_id,
            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/create_timeline_entry.rb
decidim-accountability-0.27.9 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.3 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.8 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.7 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.6 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.5 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.0.rc5 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.28.0.rc4 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.4 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.3 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.0.rc2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.27.0.rc1 app/commands/decidim/accountability/admin/create_timeline_entry.rb