Class: PlanMyStuff::ProjectItemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PlanMyStuff::ProjectItemsController
- Defined in:
- app/controllers/plan_my_stuff/project_items_controller.rb
Instance Method Summary collapse
-
#assign ⇒ Object
PATCH /projects/:project_id/items/:id/assign.
-
#create ⇒ Object
POST /projects/:project_id/items.
-
#move ⇒ Object
PATCH /projects/:project_id/items/:id/move.
-
#unassign ⇒ Object
PATCH /projects/:project_id/items/:id/unassign.
Instance Method Details
#assign ⇒ Object
PATCH /projects/:project_id/items/:id/assign
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/plan_my_stuff/project_items_controller.rb', line 38 def assign item = find_project_item assignees = parse_assignees(params[:assignee]) item.assign!(assignees) flash[:success] = "Item assigned to #{assignees.join(', ')}." redirect_to(plan_my_stuff.project_path(params[:project_id])) rescue ArgumentError, PMS::Error => e flash[:error] = e. redirect_to(plan_my_stuff.project_path(params[:project_id])) end |
#create ⇒ Object
POST /projects/:project_id/items
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/plan_my_stuff/project_items_controller.rb', line 6 def create project_number = params[:project_id].to_i if params[:draft] == '1' PMS::ProjectItem.create!(params[:title], draft: true, body: params[:body], project_number: project_number) flash[:success] = 'Draft item created.' else issue = PMS::Issue.find(params[:issue_number].to_i) PMS::ProjectItem.create!(issue, project_number: project_number) flash[:success] = "Issue ##{issue.number} added to project." end redirect_to(plan_my_stuff.project_path(project_number)) rescue ArgumentError, PMS::Error, Octokit::Error => e flash[:error] = e. redirect_to(plan_my_stuff.project_path(project_number)) end |
#move ⇒ Object
PATCH /projects/:project_id/items/:id/move
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/plan_my_stuff/project_items_controller.rb', line 25 def move item = find_project_item item.move_to!(params[:status]) flash[:success] = "Item moved to #{params[:status]}." redirect_to(plan_my_stuff.project_path(params[:project_id])) rescue ArgumentError, PMS::Error => e flash[:error] = e. redirect_to(plan_my_stuff.project_path(params[:project_id])) end |
#unassign ⇒ Object
PATCH /projects/:project_id/items/:id/unassign
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/plan_my_stuff/project_items_controller.rb', line 52 def unassign item = find_project_item current_assignees = item.field_values['Assignees'] || [] remaining = current_assignees - [params[:username]] item.assign!(remaining) flash[:success] = "#{params[:username]} unassigned." redirect_to(plan_my_stuff.project_path(params[:project_id])) rescue ArgumentError, PMS::Error => e flash[:error] = e. redirect_to(plan_my_stuff.project_path(params[:project_id])) end |