2
0
mirror of https://github.com/HangarMC/Hangar.git synced 2025-03-19 15:40:50 +08:00

role selection dropdown defaults to current role

Closes 
This commit is contained in:
Jake Potrebic 2020-09-06 23:54:15 -07:00
parent 72f59628ca
commit 922ad37e15
No known key found for this signature in database
GPG Key ID: 7C58557EC9C421F8
2 changed files with 8 additions and 4 deletions
src/main
frontend/src/javascripts
java/io/papermc/hangar/service

@ -21,6 +21,7 @@ function initMember(memberRow) {
// Replace title with select on click
memberRow.find('.fa-edit').parent().click(function(event) {
event.preventDefault();
var currentRole = getItemContainer($(this)).find("span.minor.pull-right").text().replace(/(\r\n|\n|\r|\s)/gm, "");
var saveBtn = $('.btn-members-save');
if (!saveBtn.is(':visible'))
@ -30,8 +31,11 @@ function initMember(memberRow) {
var container = getItemContainer($(this)).addClass('user-changed');
var input = $('#select-role').clone().removeAttr('id').attr('form', 'save');
var roleId = container.find('.role-id').text();
input.find('option:eq(' + roleId + ')').attr('selected', '');
input.find('option').each(function(i, el) {
if($(el).val().endsWith(currentRole)) {
$(el).attr('selected', '')
}
})
// Add input
container.find('span').replaceWith(input.show());

@ -73,8 +73,8 @@ public class OrgFactory {
authOrgUser = new AuthUser(-100, name, dummyEmail, "", Locale.ENGLISH, null);
userDao.get().insert(new UsersTable(authOrgUser.getId(), null, name, dummyEmail, null, List.of(), false, authOrgUser.getLang().toLanguageTag()));
}
// TODO this shouldn't have to be here, but sometimes it seems HangarAuth fails to create the user here fast enough... who knows. The /sync_sso will still add its Org global role.
userDao.get().insert(new UsersTable(authOrgUser.getId(), null, name, dummyEmail, null, List.of(), false, authOrgUser.getLang().toLanguageTag()));
// TODO uncomment this line if you aren't running Machine_Maker's branch of HangarAuth.
// userDao.get().insert(new UsersTable(authOrgUser.getId(), null, name, dummyEmail, null, List.of(), false, authOrgUser.getLang().toLanguageTag()));
// Just a note, the /api/sync_sso creates the org user here, so it will already be created when the above response is returned
OrganizationsTable org = new OrganizationsTable(authOrgUser.getId(), name, ownerId, authOrgUser.getId());