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



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

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

#async_textObject



13
14
15
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 13

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

#default_classObject



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

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

#default_typeObject



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

def default_type
  object.default_type
end

#formObject



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

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

#is_background_textObject



17
18
19
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 17

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

#operation_classObject



5
6
7
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 5

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

#other_operationsObject



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

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



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 51

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



9
10
11
# File 'app/decorators/rails_workflow/operation_template_decorator.rb', line 9

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