From 2e7180afaa185c4724bbd806fbc3d53e545b48f3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 13 Nov 2023 14:40:22 -0500 Subject: [PATCH] Fixed already submitted disclaimer - Fixed already submitted disclaimers - Changed already submitted disclaimer color to make it move obvious - Fixed checked todos "Mark as incomplete" button style - Removed old commented code --- public/manifest.json | 2 +- src/displayCheckButton.ts | 31 ++++++++++++++++--------------- src/displayCheckedTodos.ts | 9 +++++++-- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/public/manifest.json b/public/manifest.json index 51b7439..f80c1b7 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -2,7 +2,7 @@ "name": "Canvas Strikethrough", "description": "Mark assignments without deliverables as complete.", "author": "Daniel Stoiber", - "version": "1.1", + "version": "1.2", "manifest_version": 3, "permissions": [ "storage" diff --git a/src/displayCheckButton.ts b/src/displayCheckButton.ts index c0d4862..e855ab3 100644 --- a/src/displayCheckButton.ts +++ b/src/displayCheckButton.ts @@ -8,12 +8,6 @@ function checkButtonHtml(courseId: number, todo: Todo, isChecked: boolean, isSub checkButton.id = 'canvas-strikethrough-check-button'; checkButton.classList.add('Button', 'Button--primary'); - // Grey out button if assignment is already submitted - // if (isSubmitted) { - // checkButton.classList.add('Button--disabled'); - // checkButton.disabled = true; - // } - if (isChecked) { checkButton.onclick = () => { markIncompleteOnclick(courseId, todo, checkButton, true); @@ -37,11 +31,11 @@ function assignmentDisclaimer(): HTMLSpanElement { function gradedDisclaimer(): HTMLSpanElement { const disclaimer: HTMLSpanElement = document.createElement('span'); - disclaimer.innerHTML = 'Note: This assignment has already been graded.'; + disclaimer.innerHTML = 'Note: This assignment has already been submitted.'; disclaimer.style.fontStyle = 'italic'; + disclaimer.style.color = 'var(--ic-link-color)'; return disclaimer; - } async function handleAssignment(courseId: number, assignmentId: number) { @@ -58,7 +52,7 @@ async function handleAssignment(courseId: number, assignmentId: number) { const assignmentData = await assignmentReq.json(); const assignmentName = assignmentData.name; - const isSubmitted = assignmentData.graded_submissions_exist; + const isSubmitted = assignmentData.has_submitted_submissions; // Create todo object const todo: Todo = { @@ -77,17 +71,20 @@ async function handleAssignment(courseId: number, assignmentId: number) { // Create check button const checkButton = checkButtonHtml(courseId, todo, isChecked, isSubmitted); - + buttonDiv.appendChild(header); buttonDiv.appendChild(checkButton); buttonDiv.appendChild(document.createElement('br')); - buttonDiv.appendChild(assignmentDisclaimer()); + // Add disclaimer if assignment is already submitted if (isSubmitted) { - buttonDiv.appendChild(document.createElement('br')); buttonDiv.appendChild(gradedDisclaimer()); + buttonDiv.appendChild(document.createElement('br')); } + // Add disclaimer + buttonDiv.appendChild(assignmentDisclaimer()); + rightSide?.prepend(buttonDiv); } @@ -154,7 +151,7 @@ async function handleEvent(courseId: number, todoId: number | string, eventType: const assignmentData = await assignmentReq.json(); const assignmentName = assignmentData.name; - isSubmitted = assignmentData.graded_submissions_exist; + isSubmitted = assignmentData.has_submitted_submissions; // Create todo object todo = { @@ -181,11 +178,15 @@ async function handleEvent(courseId: number, todoId: number | string, eventType: // Add disclaimer if assignment if (eventType === 'assignment') { header.appendChild(document.createElement('br')); - header.appendChild(assignmentDisclaimer()); + + // Add disclaimer if assignment is already submitted if (isSubmitted) { - header.appendChild(document.createElement('br')); header.appendChild(gradedDisclaimer()); + header.appendChild(document.createElement('br')); } + + // Add disclaimer + header.appendChild(assignmentDisclaimer()); } } diff --git a/src/displayCheckedTodos.ts b/src/displayCheckedTodos.ts index a9ff096..bfff003 100644 --- a/src/displayCheckedTodos.ts +++ b/src/displayCheckedTodos.ts @@ -50,7 +50,6 @@ export async function displayCheckedTodos() { div.id = 'checked-todos'; div.style.display = 'block'; div.style.opacity = '1'; - div.classList.add('ui-droppable'); const ul = document.createElement('ul'); ul.style.listStyleType = 'none'; @@ -83,7 +82,13 @@ export async function displayCheckedTodos() { markAsIncompleteButton.classList.add('Button'); markAsIncompleteButton.classList.add('Button--link'); markAsIncompleteButton.innerText = 'Mark as incomplete'; - markAsIncompleteButton.style.padding = '5px'; + markAsIncompleteButton.style.padding = '3px'; + markAsIncompleteButton.style.margin = '3px'; + markAsIncompleteButton.style.backgroundColor = 'white'; + markAsIncompleteButton.style.color = 'black'; + markAsIncompleteButton.style.borderRadius = '3px'; + markAsIncompleteButton.style.cursor = 'pointer'; + markAsIncompleteButton.style.border = '1px solid black'; markAsIncompleteButton.onclick = () => { markIncompleteOnclick(todo.courseId, todo, markAsIncompleteButton, true);