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
9950dfb0
Commit
9950dfb0
authored
Dec 17, 2019
by
leiminghuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code prettier
parent
4472fd8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
91 deletions
+83
-91
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+83
-91
No files found.
app/assets/javascripts/users_select.js
View file @
9950dfb0
...
...
@@ -29,7 +29,7 @@ function UsersSelect(currentUser, els, options = {}) {
const
{
handleClick
}
=
options
;
const
userSelect
=
this
;
$els
.
each
(
(
i
,
dropdown
)
=>
{
$els
.
each
((
i
,
dropdown
)
=>
{
const
userSelect
=
this
;
const
options
=
{};
const
$dropdown
=
$
(
dropdown
);
...
...
@@ -488,10 +488,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Automatically close dropdown after assignee is selected
// since CE has no multiple assignees
// EE does not have a max-select
if
(
$dropdown
.
data
(
'
maxSelect
'
)
&&
getSelected
().
length
===
$dropdown
.
data
(
'
maxSelect
'
)
)
{
if
(
$dropdown
.
data
(
'
maxSelect
'
)
&&
getSelected
().
length
===
$dropdown
.
data
(
'
maxSelect
'
))
{
// Close the dropdown
$dropdown
.
dropdown
(
'
toggle
'
);
}
...
...
@@ -557,97 +554,92 @@ function UsersSelect(currentUser, els, options = {}) {
});
import
(
/* webpackChunkName: 'select2' */
'
select2/select2
'
)
.
then
(()
=>
{
$
(
'
.ajax-users-select
'
).
each
(
(
i
,
select
)
=>
{
const
options
=
{};
options
.
skipLdap
=
$
(
select
).
hasClass
(
'
skip_ldap
'
);
options
.
projectId
=
$
(
select
).
data
(
'
projectId
'
);
options
.
groupId
=
$
(
select
).
data
(
'
groupId
'
);
options
.
showCurrentUser
=
$
(
select
).
data
(
'
currentUser
'
);
options
.
authorId
=
$
(
select
).
data
(
'
authorId
'
);
options
.
skipUsers
=
$
(
select
).
data
(
'
skipUsers
'
);
const
showNullUser
=
$
(
select
).
data
(
'
nullUser
'
);
const
showAnyUser
=
$
(
select
).
data
(
'
anyUser
'
);
const
showEmailUser
=
$
(
select
).
data
(
'
emailUser
'
);
const
firstUser
=
$
(
select
).
data
(
'
firstUser
'
);
return
$
(
select
).
select2
({
placeholder
:
__
(
'
Search for a user
'
),
multiple
:
$
(
select
).
hasClass
(
'
multiselect
'
),
minimumInputLength
:
0
,
query
(
query
)
{
return
userSelect
.
users
(
query
.
term
,
options
,
users
=>
{
let
name
;
const
data
=
{
results
:
users
,
};
if
(
query
.
term
.
length
===
0
)
{
if
(
firstUser
)
{
// Move current user to the front of the list
const
ref
=
data
.
results
;
for
(
let
index
=
0
,
len
=
ref
.
length
;
index
<
len
;
index
+=
1
)
{
const
obj
=
ref
[
index
];
if
(
obj
.
username
===
firstUser
)
{
data
.
results
.
splice
(
index
,
1
);
data
.
results
.
unshift
(
obj
);
break
;
}
}
}
if
(
showNullUser
)
{
const
nullUser
=
{
name
:
s__
(
'
UsersSelect|Unassigned
'
),
id
:
0
,
};
data
.
results
.
unshift
(
nullUser
);
}
if
(
showAnyUser
)
{
name
=
showAnyUser
;
if
(
name
===
true
)
{
name
=
s__
(
'
UsersSelect|Any User
'
);
$
(
'
.ajax-users-select
'
).
each
((
i
,
select
)
=>
{
const
options
=
{};
options
.
skipLdap
=
$
(
select
).
hasClass
(
'
skip_ldap
'
);
options
.
projectId
=
$
(
select
).
data
(
'
projectId
'
);
options
.
groupId
=
$
(
select
).
data
(
'
groupId
'
);
options
.
showCurrentUser
=
$
(
select
).
data
(
'
currentUser
'
);
options
.
authorId
=
$
(
select
).
data
(
'
authorId
'
);
options
.
skipUsers
=
$
(
select
).
data
(
'
skipUsers
'
);
const
showNullUser
=
$
(
select
).
data
(
'
nullUser
'
);
const
showAnyUser
=
$
(
select
).
data
(
'
anyUser
'
);
const
showEmailUser
=
$
(
select
).
data
(
'
emailUser
'
);
const
firstUser
=
$
(
select
).
data
(
'
firstUser
'
);
return
$
(
select
).
select2
({
placeholder
:
__
(
'
Search for a user
'
),
multiple
:
$
(
select
).
hasClass
(
'
multiselect
'
),
minimumInputLength
:
0
,
query
(
query
)
{
return
userSelect
.
users
(
query
.
term
,
options
,
users
=>
{
let
name
;
const
data
=
{
results
:
users
,
};
if
(
query
.
term
.
length
===
0
)
{
if
(
firstUser
)
{
// Move current user to the front of the list
const
ref
=
data
.
results
;
for
(
let
index
=
0
,
len
=
ref
.
length
;
index
<
len
;
index
+=
1
)
{
const
obj
=
ref
[
index
];
if
(
obj
.
username
===
firstUser
)
{
data
.
results
.
splice
(
index
,
1
);
data
.
results
.
unshift
(
obj
);
break
;
}
const
anyUser
=
{
name
,
id
:
null
,
};
data
.
results
.
unshift
(
anyUser
);
}
}
if
(
showEmailUser
&&
data
.
results
.
length
===
0
&&
query
.
term
.
match
(
/^
[^
@
]
+@
[^
@
]
+$/
)
)
{
const
trimmed
=
query
.
term
.
trim
();
const
emailUser
=
{
name
:
sprintf
(
__
(
'
Invite "%{trimmed}" by email
'
),
{
trimmed
}),
username
:
trimmed
,
id
:
trimmed
,
invite
:
true
,
if
(
showNullUser
)
{
const
nullUser
=
{
name
:
s__
(
'
UsersSelect|Unassigned
'
),
id
:
0
,
};
data
.
results
.
unshift
(
emai
lUser
);
data
.
results
.
unshift
(
nul
lUser
);
}
return
query
.
callback
(
data
);
});
},
initSelection
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
initSelection
.
apply
(
userSelect
,
args
);
},
formatResult
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
formatResult
.
apply
(
userSelect
,
args
);
},
formatSelection
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
formatSelection
.
apply
(
userSelect
,
args
);
},
dropdownCssClass
:
'
ajax-users-dropdown
'
,
// we do not want to escape markup since we are displaying html in results
escapeMarkup
(
m
)
{
return
m
;
},
});
if
(
showAnyUser
)
{
name
=
showAnyUser
;
if
(
name
===
true
)
{
name
=
s__
(
'
UsersSelect|Any User
'
);
}
const
anyUser
=
{
name
,
id
:
null
,
};
data
.
results
.
unshift
(
anyUser
);
}
}
if
(
showEmailUser
&&
data
.
results
.
length
===
0
&&
query
.
term
.
match
(
/^
[^
@
]
+@
[^
@
]
+$/
))
{
const
trimmed
=
query
.
term
.
trim
();
const
emailUser
=
{
name
:
sprintf
(
__
(
'
Invite "%{trimmed}" by email
'
),
{
trimmed
}),
username
:
trimmed
,
id
:
trimmed
,
invite
:
true
,
};
data
.
results
.
unshift
(
emailUser
);
}
return
query
.
callback
(
data
);
});
},
initSelection
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
initSelection
.
apply
(
userSelect
,
args
);
},
formatResult
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
formatResult
.
apply
(
userSelect
,
args
);
},
formatSelection
()
{
const
args
=
1
<=
arguments
.
length
?
[].
slice
.
call
(
arguments
,
0
)
:
[];
return
userSelect
.
formatSelection
.
apply
(
userSelect
,
args
);
},
dropdownCssClass
:
'
ajax-users-dropdown
'
,
// we do not want to escape markup since we are displaying html in results
escapeMarkup
(
m
)
{
return
m
;
},
});
});
})
.
catch
(()
=>
{});
...
...
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