(filterStatus = "all")
| 1803 | |
| 1804 | // Function to render filtered tasks |
| 1805 | const renderTasks = (filterStatus = "all") => { |
| 1806 | taskList.empty(); |
| 1807 | |
| 1808 | let filteredTasks = data.tasks; |
| 1809 | if (filterStatus === "active") { |
| 1810 | filteredTasks = data.tasks.filter( |
| 1811 | (task) => !this.plugin.statusManager.isCompletedStatus(task.status) |
| 1812 | ); |
| 1813 | } else if (filterStatus === "completed") { |
| 1814 | filteredTasks = data.tasks.filter((task) => |
| 1815 | this.plugin.statusManager.isCompletedStatus(task.status) |
| 1816 | ); |
| 1817 | } |
| 1818 | |
| 1819 | // Sort tasks: incomplete first, then by last activity |
| 1820 | filteredTasks.sort((a, b) => { |
| 1821 | const aCompleted = this.plugin.statusManager.isCompletedStatus(a.status); |
| 1822 | const bCompleted = this.plugin.statusManager.isCompletedStatus(b.status); |
| 1823 | |
| 1824 | if (aCompleted !== bCompleted) { |
| 1825 | return aCompleted ? 1 : -1; // Incomplete tasks first |
| 1826 | } |
| 1827 | |
| 1828 | // Sort by last activity (time entries or modification date) |
| 1829 | const getLastActivity = (task: TaskInfo): number => { |
| 1830 | if (task.timeEntries?.length) { |
| 1831 | return Math.max( |
| 1832 | ...task.timeEntries.map((e) => new Date(e.startTime).getTime()) |
| 1833 | ); |
| 1834 | } |
| 1835 | return task.dateModified ? new Date(task.dateModified).getTime() : 0; |
| 1836 | }; |
| 1837 | |
| 1838 | return getLastActivity(b) - getLastActivity(a); |
| 1839 | }); |
| 1840 | |
| 1841 | if (filteredTasks.length === 0) { |
| 1842 | taskList.createDiv({ |
| 1843 | cls: "stats-view__no-data", |
| 1844 | text: this.plugin.i18n.translate("views.stats.noTasks"), |
| 1845 | }); |
| 1846 | return; |
| 1847 | } |
| 1848 | |
| 1849 | // Show task count |
| 1850 | const countEl = taskList.createDiv({ cls: "stats-view__task-count" }); |
| 1851 | countEl.textContent = `Showing ${filteredTasks.length} task${filteredTasks.length !== 1 ? "s" : ""}`; |
| 1852 | |
| 1853 | for (const task of filteredTasks) { |
| 1854 | // Create TaskCard with checkbox disabled as requested |
| 1855 | const visibleProperties = this.plugin.settings.defaultVisibleProperties |
| 1856 | ? convertInternalToUserProperties( |
| 1857 | this.plugin.settings.defaultVisibleProperties, |
| 1858 | this.plugin |
| 1859 | ) |
| 1860 | : undefined; |
| 1861 | const taskCard = createTaskCard(task, this.plugin, visibleProperties); |
| 1862 |
nothing calls this directly
no test coverage detected