BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
66da64ae
Commit
66da64ae
authored
Aug 15, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method to serialize board lists as JSON
parent
cd98ff17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
lists_controller.rb
app/controllers/projects/boards/lists_controller.rb
+12
-3
No files found.
app/controllers/projects/boards/lists_controller.rb
View file @
66da64ae
...
...
@@ -5,14 +5,14 @@ module Projects
before_action
:authorize_read_list!
,
only:
[
:index
]
def
index
render
json:
project
.
board
.
lists
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
}
)
render
json:
serialize_as_json
(
project
.
board
.
lists
)
end
def
create
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
project
,
current_user
,
list_params
).
execute
if
list
.
valid?
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
}
)
render
json:
serialize_as_json
(
list
)
else
render
json:
list
.
errors
,
status: :unprocessable_entity
end
...
...
@@ -42,7 +42,7 @@ module Projects
service
=
::
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
render
json:
project
.
board
.
lists
.
label
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
}
)
render
json:
serialize_as_json
(
project
.
board
.
lists
.
label
)
else
head
:unprocessable_entity
end
...
...
@@ -65,6 +65,15 @@ module Projects
def
move_params
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:description
,
:color
,
:priority
]
}
})
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment