Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
97a02fca
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,发现更多精彩内容 >>
提交
97a02fca
编写于
3月 21, 2017
作者:
K
Kushal Pandya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Protected Tags Classes
上级
d20c5427
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
153 addition
and
0 deletion
+153
-0
app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
...vascripts/protected_tags/protected_tag_access_dropdown.js
+29
-0
app/assets/javascripts/protected_tags/protected_tag_create.js
...assets/javascripts/protected_tags/protected_tag_create.js
+45
-0
app/assets/javascripts/protected_tags/protected_tag_dropdown.js
...sets/javascripts/protected_tags/protected_tag_dropdown.js
+79
-0
未找到文件。
app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
0 → 100644
浏览文件 @
97a02fca
/* eslint-disable arrow-parens, no-param-reassign, object-shorthand, no-else-return, comma-dangle, max-len */
(
global
=>
{
global
.
gl
=
global
.
gl
||
{};
gl
.
ProtectedTagAccessDropdown
=
class
{
constructor
(
options
)
{
const
{
$dropdown
,
data
,
onSelect
}
=
options
;
$dropdown
.
glDropdown
({
data
:
data
,
selectable
:
true
,
inputId
:
$dropdown
.
data
(
'
input-id
'
),
fieldName
:
$dropdown
.
data
(
'
field-name
'
),
toggleLabel
(
item
,
el
)
{
if
(
el
.
is
(
'
.is-active
'
))
{
return
item
.
text
;
}
else
{
return
'
Select
'
;
}
},
clicked
(
item
,
$el
,
e
)
{
e
.
preventDefault
();
onSelect
();
}
});
}
};
})(
window
);
app/assets/javascripts/protected_tags/protected_tag_create.js
0 → 100644
浏览文件 @
97a02fca
/* eslint-disable no-new, arrow-parens, no-param-reassign, comma-dangle, max-len */
/* global ProtectedTagDropdown */
(
global
=>
{
global
.
gl
=
global
.
gl
||
{};
gl
.
ProtectedTagCreate
=
class
{
constructor
()
{
this
.
$wrap
=
this
.
$form
=
$
(
'
.new_protected_tag
'
);
this
.
buildDropdowns
();
}
buildDropdowns
()
{
const
$allowedToPushDropdown
=
this
.
$wrap
.
find
(
'
.js-allowed-to-push
'
);
// Cache callback
this
.
onSelectCallback
=
this
.
onSelect
.
bind
(
this
);
// Allowed to Push dropdown
new
gl
.
ProtectedTagAccessDropdown
({
$dropdown
:
$allowedToPushDropdown
,
data
:
gon
.
push_access_levels
,
onSelect
:
this
.
onSelectCallback
});
// Select default
$allowedToPushDropdown
.
data
(
'
glDropdown
'
).
selectRowAtIndex
(
0
);
// Protected tag dropdown
new
ProtectedTagDropdown
({
$dropdown
:
this
.
$wrap
.
find
(
'
.js-protected-tag-select
'
),
onSelect
:
this
.
onSelectCallback
});
}
// This will run after clicked callback
onSelect
()
{
// Enable submit button
const
$tagInput
=
this
.
$wrap
.
find
(
'
input[name="protected_tag[name]"]
'
);
const
$allowedToPushInput
=
this
.
$wrap
.
find
(
'
input[name="protected_tag[push_access_levels_attributes][0][access_level]"]
'
);
this
.
$form
.
find
(
'
input[type="submit"]
'
).
attr
(
'
disabled
'
,
!
(
$tagInput
.
val
()
&&
$allowedToPushInput
.
length
));
}
};
})(
window
);
app/assets/javascripts/protected_tags/protected_tag_dropdown.js
0 → 100644
浏览文件 @
97a02fca
/* eslint-disable comma-dangle, no-unused-vars */
class
ProtectedTagDropdown
{
constructor
(
options
)
{
this
.
onSelect
=
options
.
onSelect
;
this
.
$dropdown
=
options
.
$dropdown
;
this
.
$dropdownContainer
=
this
.
$dropdown
.
parent
();
this
.
$dropdownFooter
=
this
.
$dropdownContainer
.
find
(
'
.dropdown-footer
'
);
this
.
$protectedTag
=
this
.
$dropdownContainer
.
find
(
'
.create-new-protected-tag
'
);
this
.
buildDropdown
();
this
.
bindEvents
();
// Hide footer
this
.
$dropdownFooter
.
addClass
(
'
hidden
'
);
}
buildDropdown
()
{
this
.
$dropdown
.
glDropdown
({
data
:
this
.
getProtectedTags
.
bind
(
this
),
filterable
:
true
,
remote
:
false
,
search
:
{
fields
:
[
'
title
'
]
},
selectable
:
true
,
toggleLabel
(
selected
)
{
return
(
selected
&&
'
id
'
in
selected
)
?
selected
.
title
:
'
Protected Tag
'
;
},
fieldName
:
'
protected_tag[name]
'
,
text
(
protectedTag
)
{
return
_
.
escape
(
protectedTag
.
title
);
},
id
(
protectedTag
)
{
return
_
.
escape
(
protectedTag
.
id
);
},
onFilter
:
this
.
toggleCreateNewButton
.
bind
(
this
),
clicked
:
(
item
,
$el
,
e
)
=>
{
e
.
preventDefault
();
this
.
onSelect
();
}
});
}
bindEvents
()
{
this
.
$protectedTag
.
on
(
'
click
'
,
this
.
onClickCreateWildcard
.
bind
(
this
));
}
onClickCreateWildcard
()
{
this
.
$dropdown
.
data
(
'
glDropdown
'
).
remote
.
execute
();
this
.
$dropdown
.
data
(
'
glDropdown
'
).
selectRowAtIndex
();
}
getProtectedTags
(
term
,
callback
)
{
if
(
this
.
selectedTag
)
{
callback
(
gon
.
open_branches
.
concat
(
this
.
selectedTag
));
}
else
{
callback
(
gon
.
open_branches
);
}
}
toggleCreateNewButton
(
tagName
)
{
this
.
selectedTag
=
{
title
:
tagName
,
id
:
tagName
,
text
:
tagName
};
if
(
tagName
)
{
this
.
$dropdownContainer
.
find
(
'
.create-new-protected-tag code
'
)
.
text
(
tagName
);
}
this
.
$dropdownFooter
.
toggleClass
(
'
hidden
'
,
!
tagName
);
}
}
window
.
ProtectedTagDropdown
=
ProtectedTagDropdown
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录