Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b927473c
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b927473c
编写于
10月 14, 2016
作者:
R
Robert Schilling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Grapify todos API
上级
4b889dbb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
26 deletion
+19
-26
lib/api/todos.rb
lib/api/todos.rb
+19
-26
未找到文件。
lib/api/todos.rb
浏览文件 @
b927473c
...
...
@@ -8,18 +8,19 @@ module API
'issues'
=>
->
(
id
)
{
find_project_issue
(
id
)
}
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
ISSUABLE_TYPES
.
each
do
|
type
,
finder
|
type_id_str
=
"
#{
type
.
singularize
}
_id"
.
to_sym
# Create a todo on an issuable
#
# Parameters:
# id (required) - The ID of a project
# issuable_id (required) - The ID of an issuable
# Example Request:
# POST /projects/:id/issues/:issuable_id/todo
# POST /projects/:id/merge_requests/:issuable_id/todo
desc
'Create a todo on an issuable'
do
success
Entities
::
Todo
end
params
do
requires
type_id_str
,
type:
Integer
,
desc:
'The ID of an issuable'
end
post
":id/
#{
type
}
/:
#{
type_id_str
}
/todo"
do
issuable
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
todo
=
TodoService
.
new
.
mark_todo
(
issuable
,
current_user
).
first
...
...
@@ -40,25 +41,21 @@ module API
end
end
# Get a todo list
#
# Example Request:
# GET /todos
#
desc
'Get a todo list'
do
success
Entities
::
Todo
end
get
do
todos
=
find_todos
present
paginate
(
todos
),
with:
Entities
::
Todo
,
current_user:
current_user
end
# Mark a todo as done
#
# Parameters:
# id: (required) - The ID of the todo being marked as done
#
# Example Request:
# DELETE /todos/:id
#
desc
'Mark a todo as done'
do
success
Entities
::
Todo
end
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the todo being marked as done'
end
delete
':id'
do
todo
=
current_user
.
todos
.
find
(
params
[
:id
])
TodoService
.
new
.
mark_todos_as_done
([
todo
],
current_user
)
...
...
@@ -66,11 +63,7 @@ module API
present
todo
.
reload
,
with:
Entities
::
Todo
,
current_user:
current_user
end
# Mark all todos as done
#
# Example Request:
# DELETE /todos
#
desc
'Mark all todos as done'
delete
do
todos
=
find_todos
TodoService
.
new
.
mark_todos_as_done
(
todos
,
current_user
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录