forked from External/greenlight
GRN2-xx: Fixed issue with recording row and added small fix to roles migration (Fixed #717, #718) (#719)
* Fixed issue with recording row and added small fix to roles migration * Fixed issue with edit user avatar * Small bug fixes for user settings * Added autofocus on name field when joining * Added extra check for admin password check * Rubocop fixes
This commit is contained in:
committed by
Jesus Federico
parent
4fc1714db8
commit
60f5cd5c81
@ -15,74 +15,64 @@
|
||||
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$(document).on('turbolinks:load', function(){
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
|
||||
$(".setting-btn").click(function(data){
|
||||
var url = $("body").data("relative-root")
|
||||
if (!url.endsWith("/")) {
|
||||
url += "/"
|
||||
}
|
||||
url += "admins?setting=" + data.target.id
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
|
||||
// Clear the role when the user clicks the x
|
||||
$(".clear-role").click(clearRole)
|
||||
|
||||
window.location.href = url
|
||||
})
|
||||
// When the user selects an item in the dropdown add the role to the user
|
||||
$("#role-select-dropdown").change(function(data){
|
||||
var dropdown = $("#role-select-dropdown");
|
||||
var select_role_id = dropdown.val();
|
||||
|
||||
// Clear the role when the user clicks the x
|
||||
$(".clear-role").click(clearRole)
|
||||
if(select_role_id){
|
||||
// Disable the role in the dropdown
|
||||
var selected_role = dropdown.find('[value=\"' + select_role_id + '\"]');
|
||||
selected_role.prop("disabled", true)
|
||||
|
||||
// When the user selects an item in the dropdown add the role to the user
|
||||
$("#role-select-dropdown").change(function(data){
|
||||
var dropdown = $("#role-select-dropdown");
|
||||
var select_role_id = dropdown.val();
|
||||
// Add the role tag
|
||||
var tag_container = $("#role-tag-container");
|
||||
tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" +
|
||||
selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>");
|
||||
|
||||
if(select_role_id){
|
||||
// Disable the role in the dropdown
|
||||
var selected_role = dropdown.find('[value=\"' + select_role_id + '\"]');
|
||||
selected_role.prop("disabled", true)
|
||||
// Update the role ids input that gets submited on user update
|
||||
var role_ids = $("#user_role_ids").val()
|
||||
role_ids += " " + select_role_id
|
||||
$("#user_role_ids").val(role_ids)
|
||||
|
||||
// Add the clear role function to the tag
|
||||
$("#user-role-tag_" + select_role_id).click(clearRole);
|
||||
|
||||
// Add the role tag
|
||||
var tag_container = $("#role-tag-container");
|
||||
tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" +
|
||||
selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>");
|
||||
|
||||
// Update the role ids input that gets submited on user update
|
||||
var role_ids = $("#user_role_ids").val()
|
||||
role_ids += " " + select_role_id
|
||||
$("#user_role_ids").val(role_ids)
|
||||
|
||||
// Add the clear role function to the tag
|
||||
$("#user-role-tag_" + select_role_id).click(clearRole);
|
||||
|
||||
// Reset the dropdown
|
||||
dropdown.val(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
// Reset the dropdown
|
||||
dropdown.val(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// This function removes the specfied role from a user
|
||||
function clearRole(data){
|
||||
// Get the role id
|
||||
var role_id = $(data.target).data("role-id");
|
||||
var role_tag = $("#user-role-tag_" + role_id);
|
||||
// Get the role id
|
||||
var role_id = $(data.target).data("role-id");
|
||||
var role_tag = $("#user-role-tag_" + role_id);
|
||||
|
||||
// Remove the role tag
|
||||
$(role_tag).remove()
|
||||
// Remove the role tag
|
||||
$(role_tag).remove()
|
||||
|
||||
// Update the role ids input
|
||||
var role_ids = $("#user_role_ids").val()
|
||||
var parsed_ids = role_ids.split(' ')
|
||||
// Update the role ids input
|
||||
var role_ids = $("#user_role_ids").val()
|
||||
var parsed_ids = role_ids.split(' ')
|
||||
|
||||
var index = parsed_ids.indexOf(role_id.toString());
|
||||
var index = parsed_ids.indexOf(role_id.toString());
|
||||
|
||||
if (index > -1) {
|
||||
parsed_ids.splice(index, 1);
|
||||
}
|
||||
if (index > -1) {
|
||||
parsed_ids.splice(index, 1);
|
||||
}
|
||||
|
||||
$("#user_role_ids").val(parsed_ids.join(' '))
|
||||
$("#user_role_ids").val(parsed_ids.join(' '))
|
||||
|
||||
// Enable the role in the role select dropdown
|
||||
var selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]');
|
||||
selected_role.prop("disabled", false)
|
||||
// Enable the role in the role select dropdown
|
||||
var selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]');
|
||||
selected_role.prop("disabled", false)
|
||||
}
|
Reference in New Issue
Block a user