Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
922b38a0
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,发现更多精彩内容 >>
未验证
提交
922b38a0
编写于
8月 28, 2016
作者:
L
Luke Bennett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed inline JS and improved dropdown labels
上级
f157a9e5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
52 deletion
+73
-52
app/assets/javascripts/todos.js
app/assets/javascripts/todos.js
+56
-0
app/helpers/todos_helper.rb
app/helpers/todos_helper.rb
+13
-3
app/views/dashboard/todos/index.html.haml
app/views/dashboard/todos/index.html.haml
+4
-49
未找到文件。
app/assets/javascripts/todos.js
浏览文件 @
922b38a0
...
...
@@ -13,6 +13,7 @@
this
.
perPage
=
this
.
el
.
data
(
'
perPage
'
);
this
.
clearListeners
();
this
.
initBtnListeners
();
this
.
initFilters
();
}
Todos
.
prototype
.
clearListeners
=
function
()
{
...
...
@@ -27,6 +28,61 @@
return
$
(
'
.todo
'
).
on
(
'
click
'
,
this
.
goToTodoUrl
);
};
Todos
.
prototype
.
initFilters
=
function
()
{
new
UsersSelect
();
this
.
initProjectFilterDropdown
();
this
.
initTypeFilterDropdown
();
this
.
initActionFilterDropdown
();
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
(
event
)
{
event
.
preventDefault
();
Turbolinks
.
visit
(
this
.
action
+
'
&
'
+
$
(
this
).
serialize
());
});
};
Todos
.
prototype
.
initProjectFilterDropdown
=
function
()
{
$projectDropdown
=
$
(
'
.js-project-search
'
);
$projectDropdown
.
glDropdown
({
filterable
:
true
,
selectable
:
true
,
fieldName
:
'
project_id
'
,
data
:
$projectDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$projectDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$projectDropdown
.
closest
(
'
form.filter-form
'
).
submit
();
}
}
});
};
Todos
.
prototype
.
initTypeFilterDropdown
=
function
()
{
$typeDropdown
=
$
(
'
.js-type-search
'
);
$typeDropdown
.
glDropdown
({
selectable
:
true
,
fieldName
:
'
type
'
,
data
:
$typeDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$typeDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$typeDropdown
.
closest
(
'
form.filter-form
'
).
submit
();
}
}
});
};
Todos
.
prototype
.
initActionFilterDropdown
=
function
()
{
$actionDropdown
=
$
(
'
.js-action-search
'
);
$actionDropdown
.
glDropdown
({
selectable
:
true
,
fieldName
:
'
action_id
'
,
data
:
$actionDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$actionDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$actionDropdown
.
closest
(
'
form.filter-form
'
).
submit
();
}
}
});
};
Todos
.
prototype
.
doneClicked
=
function
(
e
)
{
var
$this
;
e
.
preventDefault
();
...
...
app/helpers/todos_helper.rb
浏览文件 @
922b38a0
...
...
@@ -98,12 +98,22 @@ module TodosHelper
def
todo_types_options
[
{
text:
'Any Type'
,
id:
'
'
},
{
text:
'Issue'
,
id
:
'Issue'
},
{
text:
'Merge Request'
,
id:
'Merge
Request'
}
{
id:
''
,
text:
'Any Type
'
},
{
id:
'Issue'
,
text
:
'Issue'
},
{
id:
'MergeRequest'
,
text:
'Merge
Request'
}
]
end
def
todo_actions_dropdown_label
(
selected_action_id
,
default_action
)
selected_action
=
todo_actions_options
.
find
{
|
action
|
action
[
:id
]
==
selected_action_id
.
to_i
}
selected_action
?
selected_action
[
:text
]
:
default_action
end
def
todo_types_dropdown_label
(
selected_type
,
default_type
)
selected_type
=
todo_types_options
.
find
{
|
type
|
type
[
:id
]
==
selected_type
&&
type
[
:id
]
!=
''
}
selected_type
?
selected_type
[
:text
]
:
default_type
end
private
def
show_todo_state?
(
todo
)
...
...
app/views/dashboard/todos/index.html.haml
浏览文件 @
922b38a0
...
...
@@ -40,13 +40,13 @@
.filter-item.inline
-
if
params
[
:type
].
present?
=
hidden_field_tag
(
:type
,
params
[
:type
])
=
dropdown_tag
(
params
[
:type
]
||
'Type'
,
options:
{
toggle_class:
'js-type-search js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-type js-filter-submit'
,
data:
{
data:
todo_types_options
,
selected:
params
[
:type
],
field_name:
'type'
,
default_label:
'Type'
}
})
=
dropdown_tag
(
todo_types_dropdown_label
(
params
[
:type
],
'Type'
)
,
options:
{
toggle_class:
'js-type-search js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-type js-filter-submit'
,
data:
{
data:
todo_types_options
}
})
.filter-item.inline.actions-filter
-
if
params
[
:action_id
].
present?
=
hidden_field_tag
(
:action_id
,
params
[
:action_id
])
=
dropdown_tag
(
params
[
:action_id
]
||
'Action'
,
options:
{
toggle_class:
'js-action-search js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-action js-filter-submit'
,
data:
{
data:
todo_actions_options
,
selected:
params
[
:action_id
],
field_name:
'action_id'
,
default_label:
'Action'
}
})
=
dropdown_tag
(
todo_actions_dropdown_label
(
params
[
:action_id
],
'Action'
)
,
options:
{
toggle_class:
'js-action-search js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-action js-filter-submit'
,
data:
{
data:
todo_actions_options
}
})
.pull-right
.dropdown.inline.prepend-left-10
%button
.dropdown-toggle.btn
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
...
...
@@ -80,48 +80,3 @@
=
paginate
@todos
,
theme:
"gitlab"
-
else
.nothing-here-block
You're all done!
:javascript
new
UsersSelect
();
$projectDropdown
=
$
(
'
.js-project-search
'
);
$projectDropdown
.
glDropdown
({
filterable
:
true
,
selectable
:
true
,
fieldName
:
'
project_id
'
,
data
:
$projectDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$projectDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$projectDropdown
.
closest
(
'
form
'
).
submit
();
}
}
});
$typeDropdown
=
$
(
'
.js-type-search
'
);
$typeDropdown
.
glDropdown
({
selectable
:
true
,
fieldName
:
'
type_id
'
,
data
:
$typeDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$typeDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$typeDropdown
.
closest
(
'
form
'
).
submit
();
}
}
});
$actionDropdown
=
$
(
'
.js-action-search
'
);
$actionDropdown
.
glDropdown
({
selectable
:
true
,
fieldName
:
'
action_id
'
,
data
:
$actionDropdown
.
data
(
'
data
'
),
clicked
:
function
()
{
if
(
$actionDropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$actionDropdown
.
closest
(
'
form
'
).
submit
();
}
}
});
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
(
event
)
{
event
.
preventDefault
();
Turbolinks
.
visit
(
this
.
action
+
'
&
'
+
$
(
this
).
serialize
());
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录