Skip to content

Commit

Permalink
Base Station- finished user admin user editing
Browse files Browse the repository at this point in the history
  • Loading branch information
GregJohnStewart committed Sep 13, 2022
1 parent 07ce40b commit c957dd7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion software/open-qm-base-station/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
// implementation 'org.webjars:js-cookie:2.2.1' //out of date
// implementation 'org.webjars:spin-js:2.1.0'

implementation 'tech.epic-breakfast-productions.openQuarterMaster.lib:open-qm-lib-core:1.0.3-DEV'
implementation 'tech.epic-breakfast-productions.openQuarterMaster.lib:open-qm-lib-core:1.0.4-DEV'
implementation 'tech.epic-breakfast-productions.openQuarterMaster.lib:open-qm-lib-moduleDriver:1.0.1-DEV'

// https://mvnrepository.com/artifact/tech.units/indriya
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ <h5 class="card-title">Roles:</h5>
<div class="col">
<div id="userEditFormMessages"></div>
<form id="userEditItemForm">
<input type="hidden" id="addEditFormId" value="">
<input type="hidden" id="userEditFormUserId" value="">
<div class="mb-3 row">
<label class="col-sm-2 col-form-label">Roles</label>
<div class="col-sm-10" id="userEditRolesInputs">
Expand Down Expand Up @@ -324,6 +324,7 @@ <h5 class="card-title">Roles:</h5>

var userEditItemForm = $("#userEditItemForm");
var userEditModalLabel = $("#userEditModalLabel");
var userEditFormUserId = $("#userEditFormUserId");
var userEditRolesInputs = $("#userEditRolesInputs");

var userEditKeywordDiv = userEditItemForm.find(".keywordInputDiv");
Expand All @@ -337,6 +338,7 @@ <h5 class="card-title">Roles:</h5>

function resetUserEditForm(){
userEditModalLabel.text("");
userEditFormUserId.val("");
for (const [key, input] of Object.entries(userEditRolesInputsMap)) {
input.prop("checked", false);
}
Expand All @@ -347,6 +349,7 @@ <h5 class="card-title">Roles:</h5>

function setupUserEdit(userId){
resetUserEditForm();
userEditFormUserId.val(userId);

doRestCall({
url: "/api/user/" + userId,
Expand All @@ -368,6 +371,34 @@ <h5 class="card-title">Roles:</h5>
}
});
}

userEditItemForm.on("submit", function(e){
e.preventDefault();

let data = {
roles: ["user"]
};

addKeywordAttData(data, userEditKeywordDiv, userEditAttDiv);

for (const [key, input] of Object.entries(userEditRolesInputsMap)) {
if(input.prop("checked")){
data.roles.push(key);
}
}

doRestCall({
url: "/api/user/" + userEditFormUserId.val(),
method: "PUT",
data: data,
fail: function (data){
alert("Error: " + data);
},
done: function (data) {
reloadPageWithMessage("Updated user "+data.username+"!", "success", "Success!");
}
});
});
</script>
{/pageScript}
{/include}

0 comments on commit c957dd7

Please sign in to comment.