Skip to content

Commit ea0c7e2

Browse files
committed
Fixed a bug with update / delete
1 parent 4e28b3f commit ea0c7e2

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

views/modals.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
function resetControls() {
1818
showLoading();
19-
const updateWorkLogIdInput = document.querySelector('input[name="workLogId-update"]');
19+
const updateWorkLogIdInput = document.querySelector('input[name="worklogid-update"]');
2020
updateWorkLogIdInput.value = '';
2121
2222
const updateStartInput = document.querySelector('input[name="start-update"]');

views/updateModal.njk

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="modal-content">
55
<h2>Update work log</h2>
66
<form class="modal-form" id="modal-form-update" method="PUT" action="{{ endpoint }}">
7-
<input type="hidden" name="workLogId-update" value="">
7+
<input type="hidden" name="worklogid-update" value="">
88
<input type="hidden" name="start-update" value="">
99
<input type="hidden" name="duration-update" value="">
1010
<label for="issue-update">Issue:</label>
@@ -27,9 +27,11 @@
2727
// Show the modal when needed
2828
function showUpdateModal(eventObj) {
2929
hideCreateModal();
30+
3031
const workLogId = eventObj.extendedProps.worklogId;
3132
const issueId = eventObj.extendedProps.issueId;
32-
const workLogIdInput = document.querySelector('input[name="workLogId-update"]');
33+
console.log(workLogId + " " + issueId);
34+
const workLogIdInput = document.querySelector('input[name="worklogid-update"]');
3335
workLogIdInput.value = workLogId;
3436
3537
const startInput = document.querySelector('input[name="start-update"]');
@@ -54,16 +56,14 @@
5456
function handleUpdateSubmit(event) {
5557
showLoading();
5658
event.preventDefault();
57-
const form = document.getElementById('modal-form-update');
58-
const formData = new FormData(form);
5959
6060
const reqBody = {
61-
issueId: formData.get("issue-update"),
62-
comment: formData.get("comment-update"),
63-
start: formData.get("start-update"),
64-
duration: formData.get("duration-update")
61+
issueId: document.querySelector("input[name=issue-update]").value,
62+
comment: document.getElementById('comment-update').value,
63+
start: document.querySelector("input[name=start-update]").value,
64+
duration: document.querySelector("input[name=duration-update]").value
6565
};
66-
return fetch('{{ endpoint }}' +formData.get("workLogId-update"), {
66+
return fetch('{{ endpoint }}' +document.querySelector("input[name=worklogid-update]").value, {
6767
method: 'PUT',
6868
headers: {
6969
'Content-Type': 'application/json'
@@ -87,11 +87,9 @@
8787
function handleUpdateDelete(event) {
8888
showLoading();
8989
event.preventDefault();
90-
const form = document.getElementById('modal-form-update');
91-
const formData = new FormData(form);
9290
9391
if (confirm('Are you sure you want to delete this work log ?')) {
94-
return fetch('{{ endpoint }}' + formData.get("workLogId-update") + '?issueId=' + formData.get("issue-update"), {
92+
return fetch('{{ endpoint }}' + document.querySelector("input[name=worklogid-update]").value + '?issueId=' + document.querySelector("input[name=issue-update]").value, {
9593
method: 'DELETE',
9694
})
9795
.then(response => {

0 commit comments

Comments
 (0)