Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
55e46dfd
Commit
55e46dfd
authored
Jul 19, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lint errors, add constructor info
parent
c9ee6a96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
app/assets/javascripts/protected_branches/protected_branch_dropdown.js
...vascripts/protected_branches/protected_branch_dropdown.js
+22
-17
No files found.
app/assets/javascripts/protected_branches/protected_branch_dropdown.js
View file @
55e46dfd
/* eslint-disable comma-dangle, no-unused-vars */
export
default
class
ProtectedBranchDropdown
{
/**
class
ProtectedBranchDropdown
{
* @param {Object} options containing
* `$dropdown` target element
* `onSelect` event callback
* $dropdown must be an element created using `dropdown_branch()` rails helper
*/
constructor
(
options
)
{
constructor
(
options
)
{
this
.
onSelect
=
options
.
onSelect
;
this
.
onSelect
=
options
.
onSelect
;
this
.
$dropdown
=
options
.
$dropdown
;
this
.
$dropdown
=
options
.
$dropdown
;
...
@@ -12,7 +16,7 @@ class ProtectedBranchDropdown {
...
@@ -12,7 +16,7 @@ class ProtectedBranchDropdown {
this
.
bindEvents
();
this
.
bindEvents
();
// Hide footer
// Hide footer
this
.
$dropdownFooter
.
addClass
(
'
hidden
'
);
this
.
toggleFooter
(
true
);
}
}
buildDropdown
()
{
buildDropdown
()
{
...
@@ -21,7 +25,7 @@ class ProtectedBranchDropdown {
...
@@ -21,7 +25,7 @@ class ProtectedBranchDropdown {
filterable
:
true
,
filterable
:
true
,
remote
:
false
,
remote
:
false
,
search
:
{
search
:
{
fields
:
[
'
title
'
]
fields
:
[
'
title
'
]
,
},
},
selectable
:
true
,
selectable
:
true
,
toggleLabel
(
selected
)
{
toggleLabel
(
selected
)
{
...
@@ -36,10 +40,9 @@ class ProtectedBranchDropdown {
...
@@ -36,10 +40,9 @@ class ProtectedBranchDropdown {
},
},
onFilter
:
this
.
toggleCreateNewButton
.
bind
(
this
),
onFilter
:
this
.
toggleCreateNewButton
.
bind
(
this
),
clicked
:
(
options
)
=>
{
clicked
:
(
options
)
=>
{
const
{
$el
,
e
}
=
options
;
options
.
e
.
preventDefault
();
e
.
preventDefault
();
this
.
onSelect
();
this
.
onSelect
();
}
}
,
});
});
}
}
...
@@ -64,20 +67,22 @@ class ProtectedBranchDropdown {
...
@@ -64,20 +67,22 @@ class ProtectedBranchDropdown {
}
}
toggleCreateNewButton
(
branchName
)
{
toggleCreateNewButton
(
branchName
)
{
if
(
branchName
)
{
this
.
selectedBranch
=
{
this
.
selectedBranch
=
{
title
:
branchName
,
title
:
branchName
,
id
:
branchName
,
id
:
branchName
,
text
:
branchName
text
:
branchName
,
};
};
if
(
branchName
)
{
this
.
$dropdownContainer
this
.
$dropdownContainer
.
find
(
'
.js-create-new-protected-branch code
'
)
.
find
(
'
.js-create-new-protected-branch code
'
)
.
text
(
branchName
);
.
text
(
branchName
);
}
}
this
.
$dropdownFooter
.
toggleClass
(
'
hidden
'
,
!
branchName
);
this
.
toggleFooter
(
!
branchName
);
}
}
}
window
.
ProtectedBranchDropdown
=
ProtectedBranchDropdown
;
toggleFooter
(
toggleState
)
{
this
.
$dropdownFooter
.
toggleClass
(
'
hidden
'
,
toggleState
);
}
}
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