Class: RailsWorkflow::OperationTemplateDecorator

Inherits:
Decorator
  • Object
show all
Defined in:
app/decorators/rails_workflow/operation_template_decorator.rb

Instance Method Summary collapse

Methods inherited from Decorator

collection_decorator_class

Instance Method Details

#assignmentObject



44
45
46
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 44

def assignment
  [assignment_by_role, assignment_by_group].compact.join(', ')
end

#assignment_by_groupObject



52
53
54
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 52

def assignment_by_group
  ::User.group_text(object.group) if object.group
end

#assignment_by_roleObject



48
49
50
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 48

def assignment_by_role
  ::User.role_text(object.role) if object.role
end

#async_textObject



15
16
17
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 15

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

#default_classObject



32
33
34
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 32

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

#default_typeObject



36
37
38
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 36

def default_type
  object.default_type
end

#formObject



40
41
42
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 40

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

#is_background_textObject



19
20
21
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 19

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

#operation_classObject



7
8
9
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 7

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

#other_operationsObject



23
24
25
26
27
28
29
30
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 23

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

#show_dependenciesObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 56

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

#type_titleObject



11
12
13
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 11

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