-
-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user search autocomplete #2108
Merged
thelostone-mc
merged 28 commits into
gitcoinco:master
from
octavioamu:feature/autocomplete-users
Aug 30, 2018
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d34ab50
Add user search autocomplete
octavioamu fed7bf1
eslint: fix
thelostone-mc bcd2c72
fix username send
octavioamu b00b6e2
clean code
octavioamu b3cfa17
Merge pull request #2107 from thelostone-mc/crowd
owocki 8bd1eac
Add user search autocomplete
octavioamu 89b1402
fix username send
octavioamu a033fdc
clean code
octavioamu 44cb032
trim spaces
octavioamu dc4d9d2
Merge branch 'feature/autocomplete-users' of https://github.com/octav…
octavioamu b3c5d07
add new line
octavioamu a2ba97c
fix code stickler-ci
octavioamu 880a572
lint fixes
thelostone-mc 719183e
css: removed comments
thelostone-mc 12d5a97
Add user search autocomplete
octavioamu a5f5850
fix username send
octavioamu b9b6b85
clean code
octavioamu 22f0934
Add user search autocomplete
octavioamu eba0c76
fix username send
octavioamu 76a469c
clean code
octavioamu c2f42c4
trim spaces
octavioamu 9a7bd48
add new line
octavioamu c87d78d
fix code stickler-ci
octavioamu 5883a95
satisfy stickler-ci
octavioamu 71f4d2b
404 for not ajax request
octavioamu 30ce720
Merge branch 'feature/autocomplete-users' of https://github.com/octav…
octavioamu 360214b
update packages
octavioamu c70e19e
removed leading @ for autocomplete
thelostone-mc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
$(function() { | ||
$('.username-search').select2({ | ||
ajax: { | ||
url: '/api/v0.1/users_search/', | ||
dataType: 'json', | ||
delay: 250, | ||
data: function(params) { | ||
|
||
let query = { | ||
term: params.term[0] === '@' ? params.term.slice(1) : params.term | ||
}; | ||
|
||
return query; | ||
}, | ||
processResults: function(data) { | ||
return { | ||
results: data | ||
}; | ||
}, | ||
cache: true | ||
}, | ||
placeholder: 'Search by username', | ||
minimumInputLength: 3, | ||
escapeMarkup: function(markup) { | ||
|
||
return markup; | ||
}, | ||
templateResult: formatUser, | ||
templateSelection: formatUserSelection | ||
}); | ||
|
||
function formatUser(user) { | ||
|
||
if (user.loading) { | ||
return user.text; | ||
} | ||
let markup = `<div class="d-flex align-items-baseline"> | ||
<div class="mr-2"> | ||
<img class="rounded-circle" src="${user.avatar_url || static_url + 'v2/images/user-placeholder.png'}" width="40" height="40"/> | ||
</div> | ||
<div class="">${user.text}</div> | ||
</div>`; | ||
|
||
return markup; | ||
} | ||
|
||
function formatUserSelection(user) { | ||
|
||
let selected; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected blank line after variable declarations. (newline-after-var) |
||
|
||
if (user.id) { | ||
selected = `<img class="rounded-circle" src="${user.avatar_url || static_url + 'v2/images/user-placeholder.png'}" width="20" height="20"/> ${user.text}`; | ||
} else { | ||
selected = user.text; | ||
} | ||
return selected; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected blank line after variable declarations. (newline-after-var)