fix(admin): fix modal add user groups select box populate
parent
f24065edb1
commit
d71ee006a5
|
@ -6,29 +6,8 @@ $(document).on('shown.bs.modal', '#modalAddDesktop', function () {
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#bulk_actions option[value=""]').prop("selected",true);
|
$('#bulk_actions option[value=""]').prop("selected",true);
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
update_groups();
|
||||||
"url": "/api/groups",
|
|
||||||
success: function(data)
|
|
||||||
{
|
|
||||||
data.forEach(element => {
|
|
||||||
var groupOrigins = [];
|
|
||||||
['keycloak'].forEach(o => {
|
|
||||||
if (element[o]) {
|
|
||||||
groupOrigins.push(o)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
$(".groups-select").append(
|
|
||||||
'<option value="' + element.name + '">' + element.name + '</option>'
|
|
||||||
)
|
|
||||||
});
|
|
||||||
$('.groups-select').select2();
|
|
||||||
},
|
|
||||||
error: function(data)
|
|
||||||
{
|
|
||||||
alert('Something went wrong on our side...')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
@ -123,6 +102,7 @@ $(document).ready(function() {
|
||||||
// Open new user modal
|
// Open new user modal
|
||||||
$('.btn-new-user').on('click', function () {
|
$('.btn-new-user').on('click', function () {
|
||||||
$("#modalAddUserForm")[0].reset();
|
$("#modalAddUserForm")[0].reset();
|
||||||
|
update_groups();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
"url": "/api/user_password",
|
"url": "/api/user_password",
|
||||||
|
@ -634,4 +614,31 @@ $(document).ready(function() {
|
||||||
// $(div_id + ' .role-keycloak-select').val('13da53d5-c50b-42d9-8fbf-84f2ed7cbf9e');
|
// $(div_id + ' .role-keycloak-select').val('13da53d5-c50b-42d9-8fbf-84f2ed7cbf9e');
|
||||||
// $('.groups-select, .role-moodle-select, .role-nextcloud-select, .role-keycloak-select').trigger('change');
|
// $('.groups-select, .role-moodle-select, .role-nextcloud-select, .role-keycloak-select').trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function update_groups(){
|
||||||
|
$(".groups-select").empty()
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
"url": "/api/groups",
|
||||||
|
success: function(data)
|
||||||
|
{
|
||||||
|
data.forEach(element => {
|
||||||
|
var groupOrigins = [];
|
||||||
|
['keycloak'].forEach(o => {
|
||||||
|
if (element[o]) {
|
||||||
|
groupOrigins.push(o)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(".groups-select").append(
|
||||||
|
'<option value="' + element.name + '">' + element.name + '</option>'
|
||||||
|
)
|
||||||
|
});
|
||||||
|
$('.groups-select').select2();
|
||||||
|
},
|
||||||
|
error: function(data)
|
||||||
|
{
|
||||||
|
alert('Something went wrong on our side...')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue