Sha256: 6f9a8461e0afa14f17f50a1d632043ac527f5245495b78a128316157f168987a

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

module RailsWorkflow
  class OperationTemplateDecorator < Decorator
    delegate_all

    def operation_class
      object.read_attribute(:operation_class).presence || object.operation_class
    end

    def type_title
      object.class.types[object.kind.to_sym][:title]
    end

    def async_text
      object.async ? "Yes" : "No"
    end

    def is_background_text
      object.is_background ? "Yes": "No"
    end

    def other_operations
      if object.persisted?
         object.other_operations.order(id: :asc).to_a
      else
        #operations without current to build dependencies form part
        object.process_template.operations.to_a - [object]
      end
    end


    def default_class
      object.class.types[object.kind.to_sym][:class]
    end

    def default_type
      object.default_type
    end

    def form
      '_form'.prepend(object.kind)
    end

    def assignment
      [
          ::User.role_text(object.role),
          ::User.group_text(object.group)
      ].compact.join(", ")
    end


    def show_dependencies
      if object.dependencies.present?

        object.dependencies.map do |dependency|
          depends_on = OperationTemplate.where(id: dependency['id']).pluck(:title).first
          statuses = object.
              get_status_values.
              select{|status| dependency['statuses'].include? status[0]}
          [depends_on] + statuses.map(&:last)
        end
      else
        []
      end

    end


  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.6 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.5 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.4 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.3 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.2 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.1 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.3.0 app/decorators/rails_workflow/operation_template_decorator.rb
rails_workflow-0.2.2 app/decorators/rails_workflow/operation_template_decorator.rb