Module: Bumbleworks::Rails::TasksHelper

Included in:
BumbleworksController
Defined in:
app/helpers/bumbleworks/rails/tasks_helper.rb

Instance Method Summary collapse

Instance Method Details

#entity_task_path(task, options = {}) ⇒ Object



27
28
29
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 27

def entity_task_path(task, options = {})
  entity_task_url(task, options.merge(:only_path => true))
end

#entity_task_url(task, options = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 19

def entity_task_url(task, options = {})
  if task.has_entity?
    options[:entity_type] = task.entity.class.entity_type.pluralize
    options[:entity_id] = task.entity.identifier
  end
  main_app.task_url(options.merge(:id => task.id))
end

#entity_tasks_path(entity, options = {}) ⇒ Object



39
40
41
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 39

def entity_tasks_path(entity, options = {})
  entity_tasks_url(entity, options.merge(:only_path => true))
end

#entity_tasks_url(entity, options = {}) ⇒ Object



31
32
33
34
35
36
37
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 31

def entity_tasks_url(entity, options = {})
  if entity
    options[:entity_type] = entity.class.entity_type.pluralize
    options[:entity_id] = entity.identifier
  end
  main_app.tasks_url(options)
end

#render_task_partial(task, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 4

def render_task_partial(task, options = {})
  options[:prefixes] = ["bumbleworks/tasks"]
  options[:prefixes].unshift("#{task.entity.class.entity_type.pluralize}/tasks") if task.has_entity?
  template = "custom/_#{task.nickname}"
  if lookup_context.exists?(template, options[:prefixes])
    options[:template] = template
    render options
  end
end

#task_name(task) ⇒ Object



14
15
16
17
# File 'app/helpers/bumbleworks/rails/tasks_helper.rb', line 14

def task_name(task)
  entity = task.has_entity? ? task.entity.to_param : nil
  I18n.t(task.nickname, :entity => entity, :scope => 'bumbleworks.tasks.names', :default => task.to_s)
end