MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / renderGroupedBySubProperty

Method renderGroupedBySubProperty

src/bases/TaskListView.ts:1661–1736  ·  view source on GitHub ↗

* Render tasks grouped by sub-property (when no primary grouping is configured). * This treats the sub-group property as primary grouping.

(taskNotes: TaskInfo[])

Source from the content-addressed store, hash-verified

1659 * This treats the sub-group property as primary grouping.
1660 */
1661 private async renderGroupedBySubProperty(taskNotes: TaskInfo[]): Promise<void> {
1662 const visibleProperties = this.getVisibleProperties();
1663
1664 // Apply search filter
1665 const filteredTasks = this.applySearchFilter(taskNotes);
1666 this.setExpandedRelationshipTaskScope(filteredTasks);
1667 const renderTasks = this.getTopLevelRenderTasks(filteredTasks);
1668 const candidateTasks = this.getTopLevelRenderTasks(taskNotes);
1669 this.setCurrentVisibleTaskPaths(renderTasks);
1670
1671 // Show "no results" if search returned empty but we had tasks
1672 if (this.isSearchWithNoResults(filteredTasks, taskNotes.length)) {
1673 this.clearAllTaskElements();
1674 this.sortScopeTaskPaths.clear();
1675 this.sortScopeCandidateTaskPaths.clear();
1676 if (this.itemsContainer) {
1677 this.renderSearchNoResults(this.itemsContainer);
1678 }
1679 return;
1680 }
1681
1682 const targetDate = createUTCDateFromLocalCalendarDate(new Date());
1683 this.currentTargetDate = targetDate;
1684 const cardOptions = this.getCardOptions(targetDate);
1685
1686 // Group tasks by sub-property
1687 const pathToProps = buildTaskListPathProperties(this.dataAdapter.extractDataItems());
1688 const groupedTasks = groupTasksByTaskListSubProperty(
1689 renderTasks,
1690 this.subGroupPropertyId!,
1691 pathToProps
1692 );
1693 const allGroupedTasks = groupTasksByTaskListSubProperty(
1694 candidateTasks,
1695 this.subGroupPropertyId!,
1696 pathToProps
1697 );
1698 this.setSortScopeCandidatePaths(buildTaskListSubPropertyScopePaths(allGroupedTasks));
1699 this.applyGroupingSnapshot(this.createSubPropertyHierarchySnapshot(groupedTasks));
1700
1701 // Build flat items array (treat sub-groups as primary groups)
1702 const items = buildTaskListSubPropertyRenderItems(groupedTasks, this.collapsedGroups);
1703
1704 // Decide whether to use virtual scrolling
1705 const shouldUseVirtualScrolling = items.length >= this.VIRTUAL_SCROLL_THRESHOLD;
1706
1707 // Switch rendering mode if needed
1708 if (this.useVirtualScrolling && shouldUseVirtualScrolling && this.virtualScroller) {
1709 await this.renderGroupedVirtual(items, visibleProperties, cardOptions);
1710 this.lastFlatPaths = taskNotes.map((task) => task.path);
1711 return;
1712 }
1713
1714 // Full render needed
1715 this.itemsContainer!.empty();
1716 this.currentTaskElements.clear();
1717 this.clearClickTimeouts();
1718 this.taskInfoCache.clear();

Callers 1

renderMethod · 0.95

Tested by

no test coverage detected