diff --git a/src/Mods/Reminder/reminder.js b/src/Mods/Reminder/reminder.js index 66e41b1ce7611707f93e74b9fbc57c765420647a..87f20b21cf0b8f098f21621ce30cea7a51cbf9f1 100644 --- a/src/Mods/Reminder/reminder.js +++ b/src/Mods/Reminder/reminder.js @@ -21,7 +21,7 @@ App.Reminders.add = function(message, week, category = "manual") { * @param {string} [category] * @return {string} */ -App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) { +App.Reminders.list = function list({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) { if (V.reminders.length === 0) { return ""; } @@ -32,18 +32,25 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category = */ let includedCategory = category === "all" ? () => true : c => c === category; + let replace = () => App.UI.replace("#reminder", list({maxFuture: maxFuture, category: category})); + /** * @param {{}} entry */ - let clearEntry = entry => { V.reminders.splice(V.reminders.indexOf(entry), 1); }; + function clearEntry(entry) { + V.reminders.splice(V.reminders.indexOf(entry), 1); + replace(); + } // We only want to remove visible entries function clearOverdue() { V.reminders = V.reminders.filter(e => e.week >= V.week && (e.week > V.week + maxFuture || !includedCategory(e.category))); + replace(); } function clearAll() { V.reminders = V.reminders.filter(e => e.week > V.week + maxFuture || !includedCategory(e.category)); + replace(); } let r = ""; @@ -68,17 +75,17 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category = } week = `in ${numberWithPluralOne(entry.week - V.week, 'week')}`; } - r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry], passage())}</div>`; + r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry])}</div>`; }); if (overdue > 0) { - r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [], passage())}</div>`; + r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [])}</div>`; } if (any) { - r += `<div>${App.UI.link("Clear All", clearAll, [], passage())}</div>`; + r += `<div>${App.UI.link("Clear All", clearAll, [])}</div>`; } - return r; + return `<span id="reminder">${r}</span>`; }; App.Reminders.addField = function() {