GRN2-310: Share Access now dynamically pulls the list of users from the server (#2380)

* Share Access now dynamically pulls the list of users from the server

* Merge users now dynamically pulls the list of users from the server

* Only return the information needed to the front-end
This commit is contained in:
Ahmad Farhat
2020-12-21 17:21:17 -05:00
committed by GitHub
parent 155d214215
commit 86e6056d3c
11 changed files with 111 additions and 40 deletions

View File

@ -74,12 +74,33 @@ $(document).on('turbolinks:load', function(){
$(".bootstrap-select").on("click", function() {
$(".bs-searchbox").siblings().hide()
})
$("#merge-user-select ~ button").on("click", function() {
$(".bs-searchbox").siblings().hide()
})
$(".bs-searchbox input").on("input", function() {
if ($(".bs-searchbox input").val() == '' || $(".bs-searchbox input").val().length < 3) {
$(".select-options").remove()
$(".bs-searchbox").siblings().hide()
} else {
$(".bs-searchbox").siblings().show()
// Manually populate the dropdown
$.get($("#merge-user-select").data("path"), { search: $(".bs-searchbox input").val() }, function(users) {
$(".select-options").remove()
if (users.length > 0) {
users.forEach(function(user) {
let opt = document.createElement("option")
$(opt).val(JSON.stringify({uid: user.uid, email: user.email, name: user.name}))
$(opt).text(user.name)
$(opt).addClass("select-options")
$(opt).attr("data-subtext", user.email)
$("#merge-user-select").append(opt)
})
// Only refresh the select dropdown if there are results to show
$('#merge-user-select').selectpicker('refresh');
}
$(".bs-searchbox").siblings().show()
})
}
})

View File

@ -72,11 +72,32 @@ $(document).on('turbolinks:load', function(){
$(".bs-searchbox").siblings().hide()
})
$("#share-room-select ~ button").on("click", function() {
$(".bs-searchbox").siblings().hide()
})
$(".bs-searchbox input").on("input", function() {
if ($(".bs-searchbox input").val() == '' || $(".bs-searchbox input").val().length < 3) {
$(".select-options").remove()
$(".bs-searchbox").siblings().hide()
} else {
$(".bs-searchbox").siblings().show()
// Manually populate the dropdown
$.get($("#share-room-select").data("path"), { search: $(".bs-searchbox input").val() }, function(users) {
$(".select-options").remove()
if (users.length > 0) {
users.forEach(function(user) {
let opt = document.createElement("option")
$(opt).val(user.uid)
$(opt).text(user.name)
$(opt).addClass("select-options")
$(opt).attr("data-subtext", user.uid)
$("#share-room-select").append(opt)
})
// Only refresh the select dropdown if there are results to show
$('#share-room-select').selectpicker('refresh');
}
$(".bs-searchbox").siblings().show()
})
}
})