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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
9373f17b
Commit
9373f17b
authored
Nov 22, 2019
by
Utkarsh Gupta
Committed by
Clement Ho
Nov 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove var from users_select.js
parent
de3430f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
85 deletions
+53
-85
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+53
-85
No files found.
app/assets/javascripts/users_select.js
View file @
9373f17b
/* eslint-disable func-names,
one-var, no-var, prefer-rest-params, vars-on-top
, consistent-return, no-shadow, no-else-return, no-self-compare, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* eslint-disable func-names,
prefer-rest-params
, consistent-return, no-shadow, no-else-return, no-self-compare, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* global Issuable */
/* global Issuable */
/* global emitSidebarEvent */
/* global emitSidebarEvent */
...
@@ -13,7 +13,7 @@ import { parseBoolean } from './lib/utils/common_utils';
...
@@ -13,7 +13,7 @@ import { parseBoolean } from './lib/utils/common_utils';
window
.
emitSidebarEvent
=
window
.
emitSidebarEvent
||
$
.
noop
;
window
.
emitSidebarEvent
=
window
.
emitSidebarEvent
||
$
.
noop
;
function
UsersSelect
(
currentUser
,
els
,
options
=
{})
{
function
UsersSelect
(
currentUser
,
els
,
options
=
{})
{
var
$els
;
const
$els
=
$
(
els
||
'
.js-user-search
'
)
;
this
.
users
=
this
.
users
.
bind
(
this
);
this
.
users
=
this
.
users
.
bind
(
this
);
this
.
user
=
this
.
user
.
bind
(
this
);
this
.
user
=
this
.
user
.
bind
(
this
);
this
.
usersPath
=
'
/autocomplete/users.json
'
;
this
.
usersPath
=
'
/autocomplete/users.json
'
;
...
@@ -28,36 +28,11 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -28,36 +28,11 @@ function UsersSelect(currentUser, els, options = {}) {
const
{
handleClick
}
=
options
;
const
{
handleClick
}
=
options
;
$els
=
$
(
els
);
if
(
!
els
)
{
$els
=
$
(
'
.js-user-search
'
);
}
$els
.
each
(
$els
.
each
(
(
function
(
_this
)
{
(
function
(
_this
)
{
return
function
(
i
,
dropdown
)
{
return
function
(
i
,
dropdown
)
{
var
options
=
{};
const
options
=
{};
var
$block
,
const
$dropdown
=
$
(
dropdown
);
$collapsedSidebar
,
$dropdown
,
$loading
,
$selectbox
,
$value
,
abilityName
,
assignTo
,
assigneeTemplate
,
collapsedAssigneeTemplate
,
defaultLabel
,
defaultNullUser
,
firstUser
,
issueURL
,
selectedId
,
selectedIdDefault
,
showAnyUser
,
showNullUser
,
showMenuAbove
;
$dropdown
=
$
(
dropdown
);
options
.
projectId
=
$dropdown
.
data
(
'
projectId
'
);
options
.
projectId
=
$dropdown
.
data
(
'
projectId
'
);
options
.
groupId
=
$dropdown
.
data
(
'
groupId
'
);
options
.
groupId
=
$dropdown
.
data
(
'
groupId
'
);
options
.
showCurrentUser
=
$dropdown
.
data
(
'
currentUser
'
);
options
.
showCurrentUser
=
$dropdown
.
data
(
'
currentUser
'
);
...
@@ -65,22 +40,25 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -65,22 +40,25 @@ function UsersSelect(currentUser, els, options = {}) {
options
.
todoStateFilter
=
$dropdown
.
data
(
'
todoStateFilter
'
);
options
.
todoStateFilter
=
$dropdown
.
data
(
'
todoStateFilter
'
);
options
.
iid
=
$dropdown
.
data
(
'
iid
'
);
options
.
iid
=
$dropdown
.
data
(
'
iid
'
);
options
.
issuableType
=
$dropdown
.
data
(
'
issuableType
'
);
options
.
issuableType
=
$dropdown
.
data
(
'
issuableType
'
);
showNullUser
=
$dropdown
.
data
(
'
nullUser
'
);
const
showNullUser
=
$dropdown
.
data
(
'
nullUser
'
);
defaultNullUser
=
$dropdown
.
data
(
'
nullUserDefault
'
);
const
defaultNullUser
=
$dropdown
.
data
(
'
nullUserDefault
'
);
showMenuAbove
=
$dropdown
.
data
(
'
showMenuAbove
'
);
const
showMenuAbove
=
$dropdown
.
data
(
'
showMenuAbove
'
);
showAnyUser
=
$dropdown
.
data
(
'
anyUser
'
);
const
showAnyUser
=
$dropdown
.
data
(
'
anyUser
'
);
firstUser
=
$dropdown
.
data
(
'
firstUser
'
);
const
firstUser
=
$dropdown
.
data
(
'
firstUser
'
);
options
.
authorId
=
$dropdown
.
data
(
'
authorId
'
);
options
.
authorId
=
$dropdown
.
data
(
'
authorId
'
);
defaultLabel
=
$dropdown
.
data
(
'
defaultLabel
'
);
const
defaultLabel
=
$dropdown
.
data
(
'
defaultLabel
'
);
issueURL
=
$dropdown
.
data
(
'
issueUpdate
'
);
const
issueURL
=
$dropdown
.
data
(
'
issueUpdate
'
);
$selectbox
=
$dropdown
.
closest
(
'
.selectbox
'
);
const
$selectbox
=
$dropdown
.
closest
(
'
.selectbox
'
);
$block
=
$selectbox
.
closest
(
'
.block
'
);
let
$block
=
$selectbox
.
closest
(
'
.block
'
);
abilityName
=
$dropdown
.
data
(
'
abilityName
'
);
const
abilityName
=
$dropdown
.
data
(
'
abilityName
'
);
$value
=
$block
.
find
(
'
.value
'
);
let
$value
=
$block
.
find
(
'
.value
'
);
$collapsedSidebar
=
$block
.
find
(
'
.sidebar-collapsed-user
'
);
const
$collapsedSidebar
=
$block
.
find
(
'
.sidebar-collapsed-user
'
);
$loading
=
$block
.
find
(
'
.block-loading
'
).
fadeOut
();
const
$loading
=
$block
.
find
(
'
.block-loading
'
).
fadeOut
();
selectedIdDefault
=
defaultNullUser
&&
showNullUser
?
0
:
null
;
const
selectedIdDefault
=
defaultNullUser
&&
showNullUser
?
0
:
null
;
selectedId
=
$dropdown
.
data
(
'
selected
'
);
let
selectedId
=
$dropdown
.
data
(
'
selected
'
);
let
assignTo
;
let
assigneeTemplate
;
let
collapsedAssigneeTemplate
;
if
(
selectedId
===
undefined
)
{
if
(
selectedId
===
undefined
)
{
selectedId
=
selectedIdDefault
;
selectedId
=
selectedIdDefault
;
...
@@ -207,15 +185,15 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -207,15 +185,15 @@ function UsersSelect(currentUser, els, options = {}) {
});
});
assignTo
=
function
(
selected
)
{
assignTo
=
function
(
selected
)
{
var
data
;
const
data
=
{};
data
=
{};
data
[
abilityName
]
=
{};
data
[
abilityName
]
=
{};
data
[
abilityName
].
assignee_id
=
selected
!=
null
?
selected
:
null
;
data
[
abilityName
].
assignee_id
=
selected
!=
null
?
selected
:
null
;
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
return
axios
.
put
(
issueURL
,
data
).
then
(({
data
})
=>
{
return
axios
.
put
(
issueURL
,
data
).
then
(({
data
})
=>
{
var
user
,
tooltipTitle
;
let
user
=
{};
let
tooltipTitle
=
user
.
name
;
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$loading
.
fadeOut
();
$loading
.
fadeOut
();
if
(
data
.
assignee
)
{
if
(
data
.
assignee
)
{
...
@@ -471,10 +449,9 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -471,10 +449,9 @@ function UsersSelect(currentUser, els, options = {}) {
}
}
}
}
var
isIssueIndex
,
isMRIndex
,
page
,
selected
;
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
const
isIssueIndex
=
page
===
'
projects:issues:index
'
;
isIssueIndex
=
page
===
'
projects:issues:index
'
;
const
isMRIndex
=
page
===
page
&&
page
===
'
projects:merge_requests:index
'
;
isMRIndex
=
page
===
page
&&
page
===
'
projects:merge_requests:index
'
;
if
(
if
(
$dropdown
.
hasClass
(
'
js-filter-bulk-update
'
)
||
$dropdown
.
hasClass
(
'
js-filter-bulk-update
'
)
||
$dropdown
.
hasClass
(
'
js-issuable-form-dropdown
'
)
$dropdown
.
hasClass
(
'
js-issuable-form-dropdown
'
)
...
@@ -501,7 +478,7 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -501,7 +478,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
else
if
(
$dropdown
.
hasClass
(
'
js-filter-submit
'
))
{
}
else
if
(
$dropdown
.
hasClass
(
'
js-filter-submit
'
))
{
return
$dropdown
.
closest
(
'
form
'
).
submit
();
return
$dropdown
.
closest
(
'
form
'
).
submit
();
}
else
if
(
!
$dropdown
.
hasClass
(
'
js-multiselect
'
))
{
}
else
if
(
!
$dropdown
.
hasClass
(
'
js-multiselect
'
))
{
selected
=
$dropdown
const
selected
=
$dropdown
.
closest
(
'
.selectbox
'
)
.
closest
(
'
.selectbox
'
)
.
find
(
`input[name='
${
$dropdown
.
data
(
'
fieldName
'
)}
']`
)
.
find
(
`input[name='
${
$dropdown
.
data
(
'
fieldName
'
)}
']`
)
.
val
();
.
val
();
...
@@ -544,9 +521,8 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -544,9 +521,8 @@ function UsersSelect(currentUser, els, options = {}) {
},
},
updateLabel
:
$dropdown
.
data
(
'
dropdownTitle
'
),
updateLabel
:
$dropdown
.
data
(
'
dropdownTitle
'
),
renderRow
(
user
)
{
renderRow
(
user
)
{
var
avatar
,
img
,
username
;
const
username
=
user
.
username
?
`@
${
user
.
username
}
`
:
''
;
username
=
user
.
username
?
`@
${
user
.
username
}
`
:
''
;
const
avatar
=
user
.
avatar_url
?
user
.
avatar_url
:
gon
.
default_avatar_url
;
avatar
=
user
.
avatar_url
?
user
.
avatar_url
:
gon
.
default_avatar_url
;
let
selected
=
false
;
let
selected
=
false
;
...
@@ -565,7 +541,7 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -565,7 +541,7 @@ function UsersSelect(currentUser, els, options = {}) {
selected
=
user
.
id
===
selectedId
;
selected
=
user
.
id
===
selectedId
;
}
}
img
=
''
;
let
img
=
''
;
if
(
user
.
beforeDivider
!=
null
)
{
if
(
user
.
beforeDivider
!=
null
)
{
`<li><a href='#' class='
${
selected
===
true
?
'
is-active
'
:
''
}
'>
${
_
.
escape
(
`<li><a href='#' class='
${
selected
===
true
?
'
is-active
'
:
''
}
'>
${
_
.
escape
(
user
.
name
,
user
.
name
,
...
@@ -586,35 +562,34 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -586,35 +562,34 @@ function UsersSelect(currentUser, els, options = {}) {
$
(
'
.ajax-users-select
'
).
each
(
$
(
'
.ajax-users-select
'
).
each
(
(
function
(
_this
)
{
(
function
(
_this
)
{
return
function
(
i
,
select
)
{
return
function
(
i
,
select
)
{
var
firstUser
,
showAnyUser
,
showEmailUser
,
showNullUser
;
const
options
=
{};
var
options
=
{};
options
.
skipLdap
=
$
(
select
).
hasClass
(
'
skip_ldap
'
);
options
.
skipLdap
=
$
(
select
).
hasClass
(
'
skip_ldap
'
);
options
.
projectId
=
$
(
select
).
data
(
'
projectId
'
);
options
.
projectId
=
$
(
select
).
data
(
'
projectId
'
);
options
.
groupId
=
$
(
select
).
data
(
'
groupId
'
);
options
.
groupId
=
$
(
select
).
data
(
'
groupId
'
);
options
.
showCurrentUser
=
$
(
select
).
data
(
'
currentUser
'
);
options
.
showCurrentUser
=
$
(
select
).
data
(
'
currentUser
'
);
options
.
authorId
=
$
(
select
).
data
(
'
authorId
'
);
options
.
authorId
=
$
(
select
).
data
(
'
authorId
'
);
options
.
skipUsers
=
$
(
select
).
data
(
'
skipUsers
'
);
options
.
skipUsers
=
$
(
select
).
data
(
'
skipUsers
'
);
showNullUser
=
$
(
select
).
data
(
'
nullUser
'
);
const
showNullUser
=
$
(
select
).
data
(
'
nullUser
'
);
showAnyUser
=
$
(
select
).
data
(
'
anyUser
'
);
const
showAnyUser
=
$
(
select
).
data
(
'
anyUser
'
);
showEmailUser
=
$
(
select
).
data
(
'
emailUser
'
);
const
showEmailUser
=
$
(
select
).
data
(
'
emailUser
'
);
firstUser
=
$
(
select
).
data
(
'
firstUser
'
);
const
firstUser
=
$
(
select
).
data
(
'
firstUser
'
);
return
$
(
select
).
select2
({
return
$
(
select
).
select2
({
placeholder
:
__
(
'
Search for a user
'
),
placeholder
:
__
(
'
Search for a user
'
),
multiple
:
$
(
select
).
hasClass
(
'
multiselect
'
),
multiple
:
$
(
select
).
hasClass
(
'
multiselect
'
),
minimumInputLength
:
0
,
minimumInputLength
:
0
,
query
(
query
)
{
query
(
query
)
{
return
_this
.
users
(
query
.
term
,
options
,
users
=>
{
return
_this
.
users
(
query
.
term
,
options
,
users
=>
{
var
anyUser
,
data
,
emailUser
,
index
,
len
,
name
,
nullUser
,
obj
,
ref
;
let
name
;
data
=
{
const
data
=
{
results
:
users
,
results
:
users
,
};
};
if
(
query
.
term
.
length
===
0
)
{
if
(
query
.
term
.
length
===
0
)
{
if
(
firstUser
)
{
if
(
firstUser
)
{
// Move current user to the front of the list
// Move current user to the front of the list
ref
=
data
.
results
;
const
ref
=
data
.
results
;
for
(
index
=
0
,
len
=
ref
.
length
;
index
<
len
;
index
+=
1
)
{
for
(
let
index
=
0
,
len
=
ref
.
length
;
index
<
len
;
index
+=
1
)
{
obj
=
ref
[
index
];
const
obj
=
ref
[
index
];
if
(
obj
.
username
===
firstUser
)
{
if
(
obj
.
username
===
firstUser
)
{
data
.
results
.
splice
(
index
,
1
);
data
.
results
.
splice
(
index
,
1
);
data
.
results
.
unshift
(
obj
);
data
.
results
.
unshift
(
obj
);
...
@@ -623,7 +598,7 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -623,7 +598,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
}
}
}
if
(
showNullUser
)
{
if
(
showNullUser
)
{
nullUser
=
{
const
nullUser
=
{
name
:
s__
(
'
UsersSelect|Unassigned
'
),
name
:
s__
(
'
UsersSelect|Unassigned
'
),
id
:
0
,
id
:
0
,
};
};
...
@@ -634,7 +609,7 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -634,7 +609,7 @@ function UsersSelect(currentUser, els, options = {}) {
if
(
name
===
true
)
{
if
(
name
===
true
)
{
name
=
s__
(
'
UsersSelect|Any User
'
);
name
=
s__
(
'
UsersSelect|Any User
'
);
}
}
anyUser
=
{
const
anyUser
=
{
name
,
name
,
id
:
null
,
id
:
null
,
};
};
...
@@ -646,8 +621,8 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -646,8 +621,8 @@ function UsersSelect(currentUser, els, options = {}) {
data
.
results
.
length
===
0
&&
data
.
results
.
length
===
0
&&
query
.
term
.
match
(
/^
[^
@
]
+@
[^
@
]
+$/
)
query
.
term
.
match
(
/^
[^
@
]
+@
[^
@
]
+$/
)
)
{
)
{
var
trimmed
=
query
.
term
.
trim
();
const
trimmed
=
query
.
term
.
trim
();
emailUser
=
{
const
emailUser
=
{
name
:
sprintf
(
__
(
'
Invite "%{trimmed}" by email
'
),
{
trimmed
}),
name
:
sprintf
(
__
(
'
Invite "%{trimmed}" by email
'
),
{
trimmed
}),
username
:
trimmed
,
username
:
trimmed
,
id
:
trimmed
,
id
:
trimmed
,
...
@@ -659,18 +634,15 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -659,18 +634,15 @@ function UsersSelect(currentUser, els, options = {}) {
});
});
},
},
initSelection
()
{
initSelection
()
{
var
args
;
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
_this
.
initSelection
.
apply
(
_this
,
args
);
return
_this
.
initSelection
.
apply
(
_this
,
args
);
},
},
formatResult
()
{
formatResult
()
{
var
args
;
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
_this
.
formatResult
.
apply
(
_this
,
args
);
return
_this
.
formatResult
.
apply
(
_this
,
args
);
},
},
formatSelection
()
{
formatSelection
()
{
var
args
;
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
_this
.
formatSelection
.
apply
(
_this
,
args
);
return
_this
.
formatSelection
.
apply
(
_this
,
args
);
},
},
dropdownCssClass
:
'
ajax-users-dropdown
'
,
dropdownCssClass
:
'
ajax-users-dropdown
'
,
...
@@ -687,10 +659,9 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -687,10 +659,9 @@ function UsersSelect(currentUser, els, options = {}) {
}
}
UsersSelect
.
prototype
.
initSelection
=
function
(
element
,
callback
)
{
UsersSelect
.
prototype
.
initSelection
=
function
(
element
,
callback
)
{
var
id
,
nullUser
;
const
id
=
$
(
element
).
val
();
id
=
$
(
element
).
val
();
if
(
id
===
'
0
'
)
{
if
(
id
===
'
0
'
)
{
nullUser
=
{
const
nullUser
=
{
name
:
s__
(
'
UsersSelect|Unassigned
'
),
name
:
s__
(
'
UsersSelect|Unassigned
'
),
};
};
return
callback
(
nullUser
);
return
callback
(
nullUser
);
...
@@ -700,11 +671,9 @@ UsersSelect.prototype.initSelection = function(element, callback) {
...
@@ -700,11 +671,9 @@ UsersSelect.prototype.initSelection = function(element, callback) {
};
};
UsersSelect
.
prototype
.
formatResult
=
function
(
user
)
{
UsersSelect
.
prototype
.
formatResult
=
function
(
user
)
{
var
avatar
;
let
avatar
=
gon
.
default_avatar_url
;
if
(
user
.
avatar_url
)
{
if
(
user
.
avatar_url
)
{
avatar
=
user
.
avatar_url
;
avatar
=
user
.
avatar_url
;
}
else
{
avatar
=
gon
.
default_avatar_url
;
}
}
return
`
return
`
<div class='user-result'>
<div class='user-result'>
...
@@ -732,8 +701,7 @@ UsersSelect.prototype.user = function(user_id, callback) {
...
@@ -732,8 +701,7 @@ UsersSelect.prototype.user = function(user_id, callback) {
return
false
;
return
false
;
}
}
var
url
;
let
url
=
this
.
buildUrl
(
this
.
userPath
);
url
=
this
.
buildUrl
(
this
.
userPath
);
url
=
url
.
replace
(
'
:id
'
,
user_id
);
url
=
url
.
replace
(
'
:id
'
,
user_id
);
return
axios
.
get
(
url
).
then
(({
data
})
=>
{
return
axios
.
get
(
url
).
then
(({
data
})
=>
{
callback
(
data
);
callback
(
data
);
...
...
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