Class: InnerPlan::TasksController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InnerPlan::TasksController
- Defined in:
- app/controllers/inner_plan/tasks_controller.rb
Instance Method Summary collapse
- #complete ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reopen ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_position ⇒ Object
Instance Method Details
#complete ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 55 def complete result = InnerPlan::Task::Operation::Complete.call(params: params) @task = result[:model] respond_to do |format| format.turbo_stream end end |
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 17 def create result = InnerPlan::Task::Operation::Create.call( list_id: params[:list_id], current_user: current_inner_plan_user, params: params.fetch(:task, {}) ) @task, @list = result[:model], result[:list] if result.success? @new_task = InnerPlan::Task.new else render :create_failure, status: :unprocessable_entity end end |
#edit ⇒ Object
32 33 34 35 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 32 def edit @task = InnerPlan::Task.find(params[:id]) render InnerPlan::Tasks::EditView.new(task: @task, focus: params[:focus]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 3 def index @lists = InnerPlan::List::Operation::Index.call end |
#new ⇒ Object
7 8 9 10 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 7 def new @task = InnerPlan::Task.new @list = InnerPlan::List.find(params[:list_id]) end |
#reopen ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 64 def reopen result = InnerPlan::Task::Operation::Reopen.call(params: params) @task = result[:model] respond_to do |format| format.turbo_stream { render :complete } end end |
#show ⇒ Object
12 13 14 15 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 12 def show @task = InnerPlan::Task.find(params[:id]) render InnerPlan::Tasks::ShowView.new(task: @task) end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 37 def update result = InnerPlan::Task::Operation::Update.call( params: params.fetch(:task, {}).merge(id: params[:id]) ) @task = result[:model] if result.success? redirect_to task_path(@task) else render :edit, status: :unprocessable_entity end end |
#update_position ⇒ Object
50 51 52 53 |
# File 'app/controllers/inner_plan/tasks_controller.rb', line 50 def update_position result = InnerPlan::Task::Operation::UpdatePosition.call(params: params) @task = result[:model] end |