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
fc53a115
Commit
fc53a115
authored
Feb 02, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted users_select to use axios
parent
7c4dfb5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
53 deletions
+45
-53
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+45
-53
No files found.
app/assets/javascripts/users_select.js
View file @
fc53a115
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
/* global Issuable */
/* global Issuable */
/* global emitSidebarEvent */
/* global emitSidebarEvent */
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
// TODO: remove eventHub hack after code splitting refactor
// TODO: remove eventHub hack after code splitting refactor
window
.
emitSidebarEvent
=
window
.
emitSidebarEvent
||
$
.
noop
;
window
.
emitSidebarEvent
=
window
.
emitSidebarEvent
||
$
.
noop
;
...
@@ -177,32 +178,28 @@ function UsersSelect(currentUser, els, options = {}) {
...
@@ -177,32 +178,28 @@ function UsersSelect(currentUser, els, options = {}) {
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
return
$
.
ajax
({
return
axios
.
put
(
issueURL
,
data
)
type
:
'
PUT
'
,
.
then
(({
data
})
=>
{
dataType
:
'
json
'
,
var
user
;
url
:
issueURL
,
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
data
:
data
$loading
.
fadeOut
();
}).
done
(
function
(
data
)
{
if
(
data
.
assignee
)
{
var
user
;
user
=
{
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
name
:
data
.
assignee
.
name
,
$loading
.
fadeOut
();
username
:
data
.
assignee
.
username
,
if
(
data
.
assignee
)
{
avatar
:
data
.
assignee
.
avatar_url
user
=
{
};
name
:
data
.
assignee
.
name
,
}
else
{
username
:
data
.
assignee
.
username
,
user
=
{
avatar
:
data
.
assignee
.
avatar_url
name
:
'
Unassigned
'
,
};
username
:
''
,
}
else
{
avatar
:
''
user
=
{
};
name
:
'
Unassigned
'
,
}
username
:
''
,
$value
.
html
(
assigneeTemplate
(
user
));
avatar
:
''
$collapsedSidebar
.
attr
(
'
title
'
,
_
.
escape
(
user
.
name
)).
tooltip
(
'
fixTitle
'
);
};
return
$collapsedSidebar
.
html
(
collapsedAssigneeTemplate
(
user
));
}
});
$value
.
html
(
assigneeTemplate
(
user
));
$collapsedSidebar
.
attr
(
'
title
'
,
_
.
escape
(
user
.
name
)).
tooltip
(
'
fixTitle
'
);
return
$collapsedSidebar
.
html
(
collapsedAssigneeTemplate
(
user
));
});
};
};
collapsedAssigneeTemplate
=
_
.
template
(
'
<% if( avatar ) { %> <a class="author_link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>
'
);
collapsedAssigneeTemplate
=
_
.
template
(
'
<% if( avatar ) { %> <a class="author_link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>
'
);
assigneeTemplate
=
_
.
template
(
'
<% if (username) { %> <a class="author_link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself"> No assignee - <a href="#" class="js-assign-yourself"> assign yourself </a> </span> <% } %>
'
);
assigneeTemplate
=
_
.
template
(
'
<% if (username) { %> <a class="author_link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself"> No assignee - <a href="#" class="js-assign-yourself"> assign yourself </a> </span> <% } %>
'
);
...
@@ -660,38 +657,33 @@ UsersSelect.prototype.user = function(user_id, callback) {
...
@@ -660,38 +657,33 @@ UsersSelect.prototype.user = function(user_id, callback) {
var
url
;
var
url
;
url
=
this
.
buildUrl
(
this
.
userPath
);
url
=
this
.
buildUrl
(
this
.
userPath
);
url
=
url
.
replace
(
'
:id
'
,
user_id
);
url
=
url
.
replace
(
'
:id
'
,
user_id
);
return
$
.
ajax
({
return
axios
.
get
(
url
)
url
:
url
,
.
then
(({
data
})
=>
{
dataType
:
"
json
"
callback
(
data
);
}).
done
(
function
(
user
)
{
});
return
callback
(
user
);
});
};
};
// Return users list. Filtered by query
// Return users list. Filtered by query
// Only active users retrieved
// Only active users retrieved
UsersSelect
.
prototype
.
users
=
function
(
query
,
options
,
callback
)
{
UsersSelect
.
prototype
.
users
=
function
(
query
,
options
,
callback
)
{
var
url
;
const
url
=
this
.
buildUrl
(
this
.
usersPath
);
url
=
this
.
buildUrl
(
this
.
usersPath
);
const
params
=
{
return
$
.
ajax
({
search
:
query
,
url
:
url
,
per_page
:
options
.
perPage
||
20
,
data
:
{
active
:
true
,
search
:
query
,
project_id
:
options
.
projectId
||
null
,
per_page
:
options
.
perPage
||
20
,
group_id
:
options
.
groupId
||
null
,
active
:
true
,
skip_ldap
:
options
.
skipLdap
||
null
,
project_id
:
options
.
projectId
||
null
,
todo_filter
:
options
.
todoFilter
||
null
,
group_id
:
options
.
groupId
||
null
,
todo_state_filter
:
options
.
todoStateFilter
||
null
,
skip_ldap
:
options
.
skipLdap
||
null
,
current_user
:
options
.
showCurrentUser
||
null
,
todo_filter
:
options
.
todoFilter
||
null
,
author_id
:
options
.
authorId
||
null
,
todo_state_filter
:
options
.
todoStateFilter
||
null
,
skip_users
:
options
.
skipUsers
||
null
current_user
:
options
.
showCurrentUser
||
null
,
};
author_id
:
options
.
authorId
||
null
,
return
axios
.
get
(
url
,
{
params
})
skip_users
:
options
.
skipUsers
||
null
.
then
(({
data
})
=>
{
},
callback
(
data
);
dataType
:
"
json
"
});
}).
done
(
function
(
users
)
{
return
callback
(
users
);
});
};
};
UsersSelect
.
prototype
.
buildUrl
=
function
(
url
)
{
UsersSelect
.
prototype
.
buildUrl
=
function
(
url
)
{
...
...
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