|
1 | 1 | import { StatusSettings } from '../Config/StatusSettings'; |
2 | 2 | import { MarkdownTable } from '../lib/MarkdownTable'; |
3 | 3 | import { i18n } from '../i18n/i18n'; |
4 | | -import type { StatusConfiguration } from './StatusConfiguration'; |
5 | | -import { StatusType } from './StatusConfiguration'; |
| 4 | +import { GlobalFilter } from '../Config/GlobalFilter'; |
| 5 | +import { type StatusConfiguration, StatusType } from './StatusConfiguration'; |
6 | 6 | import { Status } from './Status'; |
| 7 | +import { StatusRegistry } from './StatusRegistry'; |
7 | 8 |
|
8 | 9 | function getFirstIndex(statusConfigurations: StatusConfiguration[], wantedSymbol: string) { |
9 | 10 | return statusConfigurations.findIndex((s) => s.symbol === wantedSymbol); |
@@ -114,3 +115,28 @@ export function tabulateStatusSettings(statusSettings: StatusSettings) { |
114 | 115 | }); |
115 | 116 | return table.markdown; |
116 | 117 | } |
| 118 | + |
| 119 | +/** |
| 120 | + * Generates a list of Markdown lines, containing sample tasks based on the given status settings. |
| 121 | + * |
| 122 | + * @param {StatusSettings} statusSettings - The settings object containing custom and core statuses. |
| 123 | + * |
| 124 | + * @returns {string[]} An array of markdown strings representing sample tasks. |
| 125 | + * Each task includes a symbol, an introductory text, and the name of the status. |
| 126 | + * Only the actually registered symbols are used; duplicate and empty symbols are ignored. |
| 127 | + * The Global Filter will be added, if it is non-empty. |
| 128 | + */ |
| 129 | +export function sampleTaskLinesForValidStatuses(statusSettings: StatusSettings) { |
| 130 | + const statusRegistry = new StatusRegistry(); |
| 131 | + StatusSettings.applyToStatusRegistry(statusSettings, statusRegistry); |
| 132 | + const registeredStatuses: StatusConfiguration[] = statusRegistry.registeredStatuses; |
| 133 | + |
| 134 | + return registeredStatuses.map((status, index) => { |
| 135 | + const globalFilter = GlobalFilter.getInstance(); |
| 136 | + const globalFilterIfSet = globalFilter.isEmpty() ? '' : globalFilter.get() + ' '; |
| 137 | + const intro = `Sample task ${index + 1}`; |
| 138 | + const symbol = `status symbol=${getPrintableSymbol(status.symbol)}`; |
| 139 | + const name = `status name='${status.name}'`; |
| 140 | + return `- [${status.symbol}] ${globalFilterIfSet}${intro}: ${symbol} ${name}`; |
| 141 | + }); |
| 142 | +} |
0 commit comments