Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class UploadedFile {
@Column(nullable = false)
private String filename;

@Column(nullable = true)
@Column(nullable = true, name = "s3key")
private String s3Key;

@Column(nullable = false, updatable = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE audit_log
DROP CONSTRAINT IF EXISTS audit_log_action_check,
ADD CONSTRAINT audit_log_action_check
CHECK (action IN ('CASE_CREATED', 'CASE_ASSIGNED', 'CASE_STATUS_CHANGED', 'COMMENT_ADDED', 'FILE_UPLOADED', 'USER_ROLE_CHANGED', 'CASE_UPDATED'));
9 changes: 5 additions & 4 deletions src/main/resources/static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function downloadFile(fileName) {
async function uploadNewFile(){
const submitBtn = document.getElementById('submitBtn');
const form = submitBtn?.form ?? document.querySelector('form');
const originalText = submitBtn?.innerText ?? null;
if (submitBtn) submitBtn.disabled = true;
const input = document.getElementById('fileInput');
const status = document.getElementById('status');
Expand All @@ -42,7 +43,7 @@ async function uploadNewFile(){
status.innerText = `Processing file ${i + 1} of ${filesToUpload.length}: ${file.name}`;
const res = await apiReq(`/tickets/upload/api/files/upload-url?fileName=${encodeURIComponent(file.name)}&contentType=${encodeURIComponent(file.type)}`);
if (!res) {
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = "Create Ticket"; }
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = originalText; }
return;
}
const { url, fileName: uploadedFileName } = await res.json();
Expand All @@ -67,17 +68,17 @@ async function uploadNewFile(){
hiddenContainer.appendChild(input);
} else {
status.innerText = `Failed to upload ${file.name}. Status: ${putRes.status}`;
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = "Create Ticket"; }
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = originalText; }
return;
}
} catch (error) {
console.error(error);
status.innerText = `Error uploading ${file.name}: ${error.message}`;
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = "Create Ticket"; }
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = originalText; }
return;
}
}
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = "Create Ticket"; }
if (submitBtn) { submitBtn.disabled = false; submitBtn.innerText = originalText; }
status.innerText = "All uploads completed.";
if (form) form.requestSubmit();
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/templates/edit_ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<meta charset="UTF-8">
<title>Edit Ticket</title>
<link rel="stylesheet" th:href="@{/style.css}">
<meta name="_csrf" th:content="${_csrf.token}"/>
<meta name="_csrf_header" th:content="${_csrf.headerName}"/>
<script th:src="@{/js/script.js}" defer></script>
</head>
<body>
Expand All @@ -28,7 +30,7 @@ <h1>Edit Ticket</h1>
</div>
<footer class="ticket-footer">
<div class="ticket-button">
<button onclick="uploadNewFile()" type="button">Save Changes</button>
<button onclick="uploadNewFile()" type="button" id="submitBtn">Save Changes</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the hardcoded "Create Ticket" reset in uploadNewFile and that submitBtn id is also used by the create page.
rg -nP -C2 '"Create Ticket"|getElementById\(\s*[\x27"]submitBtn'
fd -t f -e html | xargs rg -nP -C1 'id\s*=\s*"submitBtn"|onclick\s*=\s*"uploadNewFile'

Repository: ithsjava25/project-backend-untitled-team

Length of output: 3270


Button text will be reset to "Create Ticket" on the Edit Ticket page.

Now that this button is wired with id="submitBtn", the uploadNewFile() function in script.js will reset its text on all completion/error paths. Specifically, lines 45, 70, 76, and 80 hardcode submitBtn.innerText = "Create Ticket", causing the button to incorrectly switch from "Save Changes" to "Create Ticket" after any upload completes or fails. Parameterize the reset label in uploadNewFile() (e.g., capture and restore the original button text) so the correct label is preserved for both create and edit pages.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/resources/templates/edit_ticket.html` at line 33, The
uploadNewFile() handler in script.js currently hardcodes submitBtn.innerText =
"Create Ticket" on multiple completion/error paths which causes the Edit page
button (id="submitBtn") to flip from "Save Changes" to "Create Ticket"; fix by
capturing the button's original text at the start of uploadNewFile() (e.g.,
const originalLabel = submitBtn.innerText) and restore originalLabel instead of
the hardcoded string in all places where submitBtn.innerText is reset
(references: uploadNewFile(), submitBtn variable and the lines that set
submitBtn.innerText = "Create Ticket"); ensure the originalLabel is used on
success, error, and finally paths so Create and Edit pages keep their correct
labels.

<a th:href="@{/user}">Cancel</a>
</div>
</footer>
Expand Down