-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tasks and Milestones: Graphiti API
- Loading branch information
Lee Richmond
committed
Mar 31, 2019
1 parent
904d7fe
commit e2eb4eb
Showing
25 changed files
with
1,173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class MilestonesController < ApplicationController | ||
def index | ||
milestones = MilestoneResource.all(params) | ||
respond_with(milestones) | ||
end | ||
|
||
def show | ||
milestone = MilestoneResource.find(params) | ||
respond_with(milestone) | ||
end | ||
|
||
def create | ||
milestone = MilestoneResource.build(params) | ||
|
||
if milestone.save | ||
render jsonapi: milestone, status: 201 | ||
else | ||
render jsonapi_errors: milestone | ||
end | ||
end | ||
|
||
def update | ||
milestone = MilestoneResource.find(params) | ||
|
||
if milestone.update_attributes | ||
render jsonapi: milestone | ||
else | ||
render jsonapi_errors: milestone | ||
end | ||
end | ||
|
||
def destroy | ||
milestone = MilestoneResource.find(params) | ||
|
||
if milestone.destroy | ||
render jsonapi: { meta: {} }, status: 200 | ||
else | ||
render jsonapi_errors: milestone | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class TasksController < ApplicationController | ||
def index | ||
tasks = TaskResource.all(params) | ||
respond_with(tasks) | ||
end | ||
|
||
def show | ||
task = TaskResource.find(params) | ||
respond_with(task) | ||
end | ||
|
||
def create | ||
task = TaskResource.build(params) | ||
|
||
if task.save | ||
render jsonapi: task, status: 201 | ||
else | ||
render jsonapi_errors: task | ||
end | ||
end | ||
|
||
def update | ||
task = TaskResource.find(params) | ||
|
||
if task.update_attributes | ||
render jsonapi: task | ||
else | ||
render jsonapi_errors: task | ||
end | ||
end | ||
|
||
def destroy | ||
task = TaskResource.find(params) | ||
|
||
if task.destroy | ||
render jsonapi: { meta: {} }, status: 200 | ||
else | ||
render jsonapi_errors: task | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class BugResource < TaskResource | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class EpicResource < TaskResource | ||
has_many :milestones | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class FeatureResource < TaskResource | ||
attribute :points, :integer do | ||
rand(20) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class MilestoneResource < ApplicationResource | ||
attribute :epic_id, :integer, only: [:filterable] | ||
attribute :name, :string | ||
|
||
belongs_to :epic do | ||
link do |milestone| | ||
helpers = Rails.application.routes.url_helpers | ||
helpers.task_url(milestone.epic_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class TaskResource < ApplicationResource | ||
self.polymorphic = %w(FeatureResource BugResource EpicResource) | ||
|
||
attribute :employee_id, :integer, only: [:filterable] | ||
attribute :team_id, :integer, only: [:filterable] | ||
attribute :title, :string | ||
|
||
belongs_to :employee | ||
belongs_to :team | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.