mirror of
https://github.com/GuySandler/CanvasRefined.git
synced 2026-11-04 22:37:17 +01:00
hide course from todo list
This commit is contained in:
parent
87176b1973
commit
902eb5b128
@ -2220,10 +2220,22 @@ function isCourseHidden(courseId) {
|
|||||||
return !!card && card.hidden === true;
|
return !!card && card.hidden === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Courses the user ticked "Hide this course from the Better Todo list" in the
|
||||||
|
// card edit menu are dropped from the todo list and its progress display.
|
||||||
|
// This is independent of dashboard visibility (isCourseHidden), so a course
|
||||||
|
// can stay on the dashboard while its items stay off the todo list, and
|
||||||
|
// vice versa. Personal tasks (planner notes with no course) are always kept.
|
||||||
|
function isCourseTodoHidden(courseId) {
|
||||||
|
if (courseId === undefined || courseId === null) return false;
|
||||||
|
const cards = options.custom_cards || {};
|
||||||
|
const card = cards[String(courseId)] || cards[courseId];
|
||||||
|
return !!card && card.hide_todo === true;
|
||||||
|
}
|
||||||
|
|
||||||
function filterHiddenCourses(data) {
|
function filterHiddenCourses(data) {
|
||||||
return data.filter(item => {
|
return data.filter(item => {
|
||||||
const cid = item.course_id || item.context_id || item?.plannable?.course_id;
|
const cid = item.course_id || item.context_id || item?.plannable?.course_id;
|
||||||
return !isCourseHidden(cid);
|
return !isCourseHidden(cid) && !isCourseTodoHidden(cid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
js/popup.js
14
js/popup.js
@ -2410,7 +2410,7 @@ function createCourseButton(courseId, courseData) {
|
|||||||
button.textContent = displayName;
|
button.textContent = displayName;
|
||||||
button.dataset.courseId = courseId;
|
button.dataset.courseId = courseId;
|
||||||
|
|
||||||
if (courseData.img || courseData.hidden || courseData.hide) {
|
if (courseData.img || courseData.hidden || courseData.hide || courseData.hide_todo) {
|
||||||
button.classList.add("customized");
|
button.classList.add("customized");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2469,6 +2469,14 @@ function showCardEditMenu(courseId, courseData) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card-edit-section">
|
||||||
|
<label class="card-edit-label">Better Todo List</label>
|
||||||
|
<div style="display: flex; align-items: center; gap: 8px;">
|
||||||
|
<input type="checkbox" id="card-todo-hidden-input" ${courseData.hide_todo === true ? "checked" : ""}>
|
||||||
|
<span>Hide this course from the Better Todo list</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; gap: 10px; margin-top: 20px;">
|
<div style="display: flex; gap: 10px; margin-top: 20px;">
|
||||||
<button class="big-button" id="save-card-btn">Save Changes</button>
|
<button class="big-button" id="save-card-btn">Save Changes</button>
|
||||||
<button class="customization-button" id="reset-card-btn">Reset to Default</button>
|
<button class="customization-button" id="reset-card-btn">Reset to Default</button>
|
||||||
@ -2512,6 +2520,7 @@ function saveCardChanges(courseId) {
|
|||||||
const codeInput = document.getElementById("card-code-input");
|
const codeInput = document.getElementById("card-code-input");
|
||||||
const imageInput = document.getElementById("card-image-input");
|
const imageInput = document.getElementById("card-image-input");
|
||||||
const hideInput = document.getElementById("card-hide-input");
|
const hideInput = document.getElementById("card-hide-input");
|
||||||
|
const todoHiddenInput = document.getElementById("card-todo-hidden-input");
|
||||||
|
|
||||||
const updates = {
|
const updates = {
|
||||||
name: nameInput.value,
|
name: nameInput.value,
|
||||||
@ -2519,6 +2528,7 @@ function saveCardChanges(courseId) {
|
|||||||
img: imageInput.value,
|
img: imageInput.value,
|
||||||
hidden: hideInput.checked,
|
hidden: hideInput.checked,
|
||||||
hide: hideInput.checked,
|
hide: hideInput.checked,
|
||||||
|
hide_todo: todoHiddenInput.checked,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (imageInput.value !== "" && imageInput.value !== "none") {
|
if (imageInput.value !== "" && imageInput.value !== "none") {
|
||||||
@ -2538,7 +2548,7 @@ function saveCardChanges(courseId) {
|
|||||||
|
|
||||||
|
|
||||||
function resetCardToDefault(courseId) {
|
function resetCardToDefault(courseId) {
|
||||||
updateCards(courseId, { name: "", code: "", img: "", hidden: false, hide: false });
|
updateCards(courseId, { name: "", code: "", img: "", hidden: false, hide: false, hide_todo: false });
|
||||||
displayAlert(false, "Card reset to default settings!");
|
displayAlert(false, "Card reset to default settings!");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user