Class: TasksController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/tasks_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



34
35
36
37
38
39
40
# File 'app/controllers/tasks_controller.rb', line 34

def create
  if @task.save
    redirect_to story_tasks_path(@story), notice: t('tasks.create.successful')
  else
    render 'new'
  end
end

#destroyObject



53
54
55
56
# File 'app/controllers/tasks_controller.rb', line 53

def destroy
  @task.destroy
  redirect_to story_tasks_path(@story), notice: t('general.form.destroyed')
end

#editObject



42
43
# File 'app/controllers/tasks_controller.rb', line 42

def edit
end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/tasks_controller.rb', line 11

def index
  @story = Story.find(params[:story_id])
  @project = @story.project
  @tasks = @story.custom_tasks
  @tasks = @tasks.paginate(page: params[:page], per_page: 25)
  @twitter_sidenav_level = 5
end

#newObject



31
32
# File 'app/controllers/tasks_controller.rb', line 31

def new
end

#parentObject



67
68
69
# File 'app/controllers/tasks_controller.rb', line 67

def parent
  @story
end

#resourceObject



58
59
60
61
62
63
# File 'app/controllers/tasks_controller.rb', line 58

def resource
  @task = Task.find(params[:id]) unless @task || !params[:id].present?
  @story = @task.story unless @story || !@task
  @project = @story.project
  @task
end

#resource=(value) ⇒ Object



65
# File 'app/controllers/tasks_controller.rb', line 65

def resource=(value); @task = value; end

#showObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/tasks_controller.rb', line 19

def show
  @hide_sidebar = true
  
  begin
    raise NotImplementedError if @project.product_id.blank?
    
    render "products/types/#{@project.product.class.name.split('Product::').last.tableize.singularize}/tasks/show"
  rescue NotImplementedError, ActionView::MissingTemplate
    render 'show'
  end
end

#updateObject



45
46
47
48
49
50
51
# File 'app/controllers/tasks_controller.rb', line 45

def update
  if @task.update(params[:task])
    redirect_to(
      edit_task_path(@task), notice: t('tasks.update.successful')
    )
  end
end