@conduction/nextcloud-vue 2.92.0 → 2.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js +57 -4
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js.map +1 -1
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js +44 -17
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue.js +1 -1
- package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue2.js +44 -2
- package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue2.js.map +1 -1
- package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js +140 -59
- package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue.js +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +20 -6
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js +3 -2
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +2 -36
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +5 -3
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +6 -4
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFeaturesAndRoadmapPage/CnFeaturesAndRoadmapPage.vue2.js +46 -0
- package/dist/esm/components/CnFeaturesAndRoadmapPage/CnFeaturesAndRoadmapPage.vue2.js.map +1 -1
- package/dist/esm/components/CnFeaturesAndRoadmapPage/CnFeaturesAndRoadmapPage.vue3.js +6 -2
- package/dist/esm/components/CnFeaturesAndRoadmapPage/CnFeaturesAndRoadmapPage.vue3.js.map +1 -1
- package/dist/esm/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue.js +1 -1
- package/dist/esm/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue2.js +82 -9
- package/dist/esm/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue2.js.map +1 -1
- package/dist/esm/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue3.js +104 -90
- package/dist/esm/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue3.js.map +1 -1
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue.js +9 -0
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue.js.map +1 -0
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue2.js +355 -0
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue2.js.map +1 -0
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue3.js +462 -0
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue3.js.map +1 -0
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js +21 -0
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +402 -391
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnIcon/semanticIcons.js +2 -2
- package/dist/esm/components/CnIcon/semanticIcons.js.map +1 -1
- package/dist/esm/components/CnNcWidgetWidget/CnNcWidgetWidget.vue.js +1 -1
- package/dist/esm/components/CnNcWidgetWidget/CnNcWidgetWidget.vue2.js +22 -1
- package/dist/esm/components/CnNcWidgetWidget/CnNcWidgetWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnNcWidgetWidget/CnNcWidgetWidget.vue3.js +20 -14
- package/dist/esm/components/CnNcWidgetWidget/CnNcWidgetWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnNotificationPreferences/CnNotificationPreferences.vue.js +1 -1
- package/dist/esm/components/CnNotificationPreferences/CnNotificationPreferences.vue2.js +2 -0
- package/dist/esm/components/CnNotificationPreferences/CnNotificationPreferences.vue2.js.map +1 -1
- package/dist/esm/components/CnNotificationPreferences/CnNotificationPreferences.vue3.js +15 -5
- package/dist/esm/components/CnNotificationPreferences/CnNotificationPreferences.vue3.js.map +1 -1
- package/dist/esm/components/CnRoadmapTab/CnRoadmapTab.vue.js +1 -1
- package/dist/esm/components/CnRoadmapTab/CnRoadmapTab.vue2.js +8 -30
- package/dist/esm/components/CnRoadmapTab/CnRoadmapTab.vue2.js.map +1 -1
- package/dist/esm/components/CnRoadmapTab/CnRoadmapTab.vue3.js.map +1 -1
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue.js +9 -0
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue.js.map +1 -0
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue2.js +164 -0
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue2.js.map +1 -0
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue3.js +93 -0
- package/dist/esm/components/CnUserSettingsDialog/CnUserSettingsDialog.vue3.js.map +1 -0
- package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue.js +1 -1
- package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue2.js +12 -0
- package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue2.js.map +1 -1
- package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue3.js.map +1 -1
- package/dist/esm/l10n/en.json.js +24 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +24 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +887 -247
- package/dist/esm/utils/featureCatalog.js +135 -0
- package/dist/esm/utils/featureCatalog.js.map +1 -0
- package/dist/esm/utils/fillTemplate.js +74 -3
- package/dist/esm/utils/fillTemplate.js.map +1 -1
- package/dist/esm/utils/headerMeta.js +62 -12
- package/dist/esm/utils/headerMeta.js.map +1 -1
- package/dist/esm/utils/roadmapIssues.js +86 -0
- package/dist/esm/utils/roadmapIssues.js.map +1 -0
- package/dist/esm/utils/userDisplayName.js +47 -0
- package/dist/esm/utils/userDisplayName.js.map +1 -0
- package/dist/esm/utils/validateManifestV2.compiled.js +3 -3
- package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +14820 -12966
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +887 -247
- package/l10n/en.json +24 -1
- package/l10n/nl.json +24 -1
- package/package.json +1 -1
- package/src/components/CnAppRoot/CnAppRoot.md +2 -0
- package/src/components/CnAppRoot/CnAppRoot.vue +66 -5
- package/src/components/CnChoiceCards/CnChoiceCards.md +27 -0
- package/src/components/CnChoiceCards/CnChoiceCards.vue +168 -3
- package/src/components/CnDashboardPage/CnDashboardPage.vue +45 -6
- package/src/components/CnDataTable/CnDataTable.vue +2 -36
- package/src/components/CnDetailPage/CnDetailPage.vue +5 -3
- package/src/components/CnFactsWidget/CnFactsWidget.vue +6 -4
- package/src/components/CnFeaturesAndRoadmapPage/CnFeaturesAndRoadmapPage.vue +51 -1
- package/src/components/CnFeaturesAndRoadmapView/CnFeaturesAndRoadmapView.vue +98 -13
- package/src/components/CnFeaturesBoard/CnFeaturesBoard.vue +1053 -0
- package/src/components/CnFormDialog/CnFormDialog.vue +606 -562
- package/src/components/CnNcWidgetWidget/CnNcWidgetWidget.vue +23 -2
- package/src/components/CnNotificationPreferences/CnNotificationPreferences.vue +5 -0
- package/src/components/CnRoadmapTab/CnRoadmapTab.vue +6 -28
- package/src/components/CnUserSettingsDialog/CnUserSettingsDialog.vue +305 -0
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +12 -0
- package/src/css/dialog.css +47 -0
- package/src/css/look-board-detail.css +8 -0
- package/src/css/look-board.css +33 -0
- package/src/schemas/app-manifest-v2.schema.json +9 -3
- package/src/utils/featureCatalog.js +132 -0
- package/src/utils/fillTemplate.js +73 -2
- package/src/utils/headerMeta.js +62 -12
- package/src/utils/roadmapIssues.js +82 -0
- package/src/utils/userDisplayName.js +54 -0
- package/src/utils/validateManifestV2.compiled.js +3 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
*
|
|
5
|
+
* featureCatalog: the feature list of the Features and roadmap page, read the
|
|
6
|
+
* way the board look draws it. A feature carries a status (available, beta,
|
|
7
|
+
* in progress or planned), an optional category and optional per-language
|
|
8
|
+
* titles (`title_nl`, `summary_nl`) next to the English ones.
|
|
9
|
+
*
|
|
10
|
+
* @module utils/featureCatalog
|
|
11
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The statuses, in the order the filter and the captions list them. */
|
|
15
|
+
const FEATURE_STATUSES = Object.freeze(['available', 'beta', 'in_progress', 'planned']);
|
|
16
|
+
|
|
17
|
+
/** The badge variant of each status. */
|
|
18
|
+
const FEATURE_STATUS_VARIANTS = Object.freeze({
|
|
19
|
+
available: 'success',
|
|
20
|
+
beta: 'warning',
|
|
21
|
+
in_progress: 'primary',
|
|
22
|
+
planned: 'purple',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const STATUS_ALIASES = Object.freeze({
|
|
26
|
+
available: 'available',
|
|
27
|
+
stable: 'available',
|
|
28
|
+
done: 'available',
|
|
29
|
+
released: 'available',
|
|
30
|
+
shipped: 'available',
|
|
31
|
+
beta: 'beta',
|
|
32
|
+
preview: 'beta',
|
|
33
|
+
in_progress: 'in_progress',
|
|
34
|
+
'in-progress': 'in_progress',
|
|
35
|
+
inprogress: 'in_progress',
|
|
36
|
+
building: 'in_progress',
|
|
37
|
+
development: 'in_progress',
|
|
38
|
+
planned: 'planned',
|
|
39
|
+
roadmap: 'planned',
|
|
40
|
+
proposed: 'planned',
|
|
41
|
+
soon: 'planned',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The status key of a feature. A feature without a status is one the app
|
|
46
|
+
* ships, as every entry of the list was before statuses existed.
|
|
47
|
+
*
|
|
48
|
+
* @param {unknown} raw The feature's `status`.
|
|
49
|
+
* @return {string} One of FEATURE_STATUSES.
|
|
50
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-a-feature-has-one-of-four-statuses
|
|
51
|
+
*/
|
|
52
|
+
function featureStatus(raw) {
|
|
53
|
+
if (typeof raw !== 'string' || raw.trim() === '') {
|
|
54
|
+
return 'available'
|
|
55
|
+
}
|
|
56
|
+
return STATUS_ALIASES[raw.trim().toLowerCase()] || 'available'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A text field of a feature in the reader's language: `title_nl` for a Dutch
|
|
61
|
+
* reader when the feature has one, else `title`.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} feature The feature.
|
|
64
|
+
* @param {string} field `title` or `summary`.
|
|
65
|
+
* @param {string} [language] The reader's language tag (`nl`, `nl_NL`, `de-DE`).
|
|
66
|
+
* @return {string} The text, or ''.
|
|
67
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-a-feature-reads-in-the-readers-language
|
|
68
|
+
*/
|
|
69
|
+
function featureText(feature, field, language = '') {
|
|
70
|
+
if (!feature || typeof feature !== 'object') {
|
|
71
|
+
return ''
|
|
72
|
+
}
|
|
73
|
+
const base = String(language || '').split(/[-_]/)[0].toLowerCase();
|
|
74
|
+
const own = base ? feature[`${field}_${base}`] : undefined;
|
|
75
|
+
if (typeof own === 'string' && own.trim() !== '') {
|
|
76
|
+
return own
|
|
77
|
+
}
|
|
78
|
+
return typeof feature[field] === 'string' ? feature[field] : ''
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* How many features carry each status.
|
|
83
|
+
*
|
|
84
|
+
* @param {Array<{status: string}>} features Features with a normalised status.
|
|
85
|
+
* @return {{all: number, available: number, beta: number, in_progress: number, planned: number}} The counts.
|
|
86
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-status-filter-shows-a-count-per-status
|
|
87
|
+
*/
|
|
88
|
+
function countByStatus(features) {
|
|
89
|
+
const counts = { all: features.length, available: 0, beta: 0, in_progress: 0, planned: 0 };
|
|
90
|
+
for (const feature of features) {
|
|
91
|
+
counts[feature.status] += 1;
|
|
92
|
+
}
|
|
93
|
+
return counts
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The features in the reader's language, grouped by category. Groups follow
|
|
98
|
+
* the order of `categories`; features without a known category come first,
|
|
99
|
+
* under no caption. Inside a group the features keep their given order.
|
|
100
|
+
*
|
|
101
|
+
* @param {Array<object>} features The raw features.
|
|
102
|
+
* @param {object} [categories] Category key to caption.
|
|
103
|
+
* @param {string} [language] The reader's language tag.
|
|
104
|
+
* @return {Array<{key: string, label: string, features: Array<object>}>} The groups; a group without features is left out.
|
|
105
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-features-are-grouped-by-category
|
|
106
|
+
*/
|
|
107
|
+
function groupFeatures(features, categories = {}, language = '') {
|
|
108
|
+
const captions = categories && typeof categories === 'object' && !Array.isArray(categories) ? categories : {};
|
|
109
|
+
const groups = [{ key: '', label: '', features: [] }];
|
|
110
|
+
const byKey = { '': groups[0] };
|
|
111
|
+
for (const [key, label] of Object.entries(captions)) {
|
|
112
|
+
const group = { key, label: String(label), features: [] };
|
|
113
|
+
groups.push(group);
|
|
114
|
+
byKey[key] = group;
|
|
115
|
+
}
|
|
116
|
+
for (const raw of Array.isArray(features) ? features : []) {
|
|
117
|
+
if (!raw || typeof raw !== 'object') {
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
const feature = {
|
|
121
|
+
slug: String(raw.slug || raw.id || ''),
|
|
122
|
+
title: featureText(raw, 'title', language) || String(raw.slug || ''),
|
|
123
|
+
summary: featureText(raw, 'summary', language),
|
|
124
|
+
status: featureStatus(raw.status),
|
|
125
|
+
expected: typeof raw.expected === 'string' ? raw.expected : '',
|
|
126
|
+
docsUrl: typeof raw.docsUrl === 'string' ? raw.docsUrl : '',
|
|
127
|
+
};
|
|
128
|
+
const group = byKey[typeof raw.category === 'string' ? raw.category : ''] || byKey[''];
|
|
129
|
+
group.features.push(feature);
|
|
130
|
+
}
|
|
131
|
+
return groups.filter((group) => group.features.length > 0)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { FEATURE_STATUSES, FEATURE_STATUS_VARIANTS, countByStatus, featureStatus, featureText, groupFeatures };
|
|
135
|
+
//# sourceMappingURL=featureCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureCatalog.js","sources":["../../../src/utils/featureCatalog.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * featureCatalog: the feature list of the Features and roadmap page, read the\n * way the board look draws it. A feature carries a status (available, beta,\n * in progress or planned), an optional category and optional per-language\n * titles (`title_nl`, `summary_nl`) next to the English ones.\n *\n * @module utils/featureCatalog\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md\n */\n\n/** The statuses, in the order the filter and the captions list them. */\nexport const FEATURE_STATUSES = Object.freeze(['available', 'beta', 'in_progress', 'planned'])\n\n/** The badge variant of each status. */\nexport const FEATURE_STATUS_VARIANTS = Object.freeze({\n\tavailable: 'success',\n\tbeta: 'warning',\n\tin_progress: 'primary',\n\tplanned: 'purple',\n})\n\nconst STATUS_ALIASES = Object.freeze({\n\tavailable: 'available',\n\tstable: 'available',\n\tdone: 'available',\n\treleased: 'available',\n\tshipped: 'available',\n\tbeta: 'beta',\n\tpreview: 'beta',\n\tin_progress: 'in_progress',\n\t'in-progress': 'in_progress',\n\tinprogress: 'in_progress',\n\tbuilding: 'in_progress',\n\tdevelopment: 'in_progress',\n\tplanned: 'planned',\n\troadmap: 'planned',\n\tproposed: 'planned',\n\tsoon: 'planned',\n})\n\n/**\n * The status key of a feature. A feature without a status is one the app\n * ships, as every entry of the list was before statuses existed.\n *\n * @param {unknown} raw The feature's `status`.\n * @return {string} One of FEATURE_STATUSES.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-a-feature-has-one-of-four-statuses\n */\nexport function featureStatus(raw) {\n\tif (typeof raw !== 'string' || raw.trim() === '') {\n\t\treturn 'available'\n\t}\n\treturn STATUS_ALIASES[raw.trim().toLowerCase()] || 'available'\n}\n\n/**\n * A text field of a feature in the reader's language: `title_nl` for a Dutch\n * reader when the feature has one, else `title`.\n *\n * @param {object} feature The feature.\n * @param {string} field `title` or `summary`.\n * @param {string} [language] The reader's language tag (`nl`, `nl_NL`, `de-DE`).\n * @return {string} The text, or ''.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-a-feature-reads-in-the-readers-language\n */\nexport function featureText(feature, field, language = '') {\n\tif (!feature || typeof feature !== 'object') {\n\t\treturn ''\n\t}\n\tconst base = String(language || '').split(/[-_]/)[0].toLowerCase()\n\tconst own = base ? feature[`${field}_${base}`] : undefined\n\tif (typeof own === 'string' && own.trim() !== '') {\n\t\treturn own\n\t}\n\treturn typeof feature[field] === 'string' ? feature[field] : ''\n}\n\n/**\n * How many features carry each status.\n *\n * @param {Array<{status: string}>} features Features with a normalised status.\n * @return {{all: number, available: number, beta: number, in_progress: number, planned: number}} The counts.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-status-filter-shows-a-count-per-status\n */\nexport function countByStatus(features) {\n\tconst counts = { all: features.length, available: 0, beta: 0, in_progress: 0, planned: 0 }\n\tfor (const feature of features) {\n\t\tcounts[feature.status] += 1\n\t}\n\treturn counts\n}\n\n/**\n * The features in the reader's language, grouped by category. Groups follow\n * the order of `categories`; features without a known category come first,\n * under no caption. Inside a group the features keep their given order.\n *\n * @param {Array<object>} features The raw features.\n * @param {object} [categories] Category key to caption.\n * @param {string} [language] The reader's language tag.\n * @return {Array<{key: string, label: string, features: Array<object>}>} The groups; a group without features is left out.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-features-are-grouped-by-category\n */\nexport function groupFeatures(features, categories = {}, language = '') {\n\tconst captions = categories && typeof categories === 'object' && !Array.isArray(categories) ? categories : {}\n\tconst groups = [{ key: '', label: '', features: [] }]\n\tconst byKey = { '': groups[0] }\n\tfor (const [key, label] of Object.entries(captions)) {\n\t\tconst group = { key, label: String(label), features: [] }\n\t\tgroups.push(group)\n\t\tbyKey[key] = group\n\t}\n\tfor (const raw of Array.isArray(features) ? features : []) {\n\t\tif (!raw || typeof raw !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst feature = {\n\t\t\tslug: String(raw.slug || raw.id || ''),\n\t\t\ttitle: featureText(raw, 'title', language) || String(raw.slug || ''),\n\t\t\tsummary: featureText(raw, 'summary', language),\n\t\t\tstatus: featureStatus(raw.status),\n\t\t\texpected: typeof raw.expected === 'string' ? raw.expected : '',\n\t\t\tdocsUrl: typeof raw.docsUrl === 'string' ? raw.docsUrl : '',\n\t\t}\n\t\tconst group = byKey[typeof raw.category === 'string' ? raw.category : ''] || byKey['']\n\t\tgroup.features.push(feature)\n\t}\n\treturn groups.filter((group) => group.features.length > 0)\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,EAAC;AAC9F;AACA;AACY,MAAC,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;AACrD,CAAC,SAAS,EAAE,SAAS;AACrB,CAAC,IAAI,EAAE,SAAS;AAChB,CAAC,WAAW,EAAE,SAAS;AACvB,CAAC,OAAO,EAAE,QAAQ;AAClB,CAAC,EAAC;AACF;AACA,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;AACrC,CAAC,SAAS,EAAE,WAAW;AACvB,CAAC,MAAM,EAAE,WAAW;AACpB,CAAC,IAAI,EAAE,WAAW;AAClB,CAAC,QAAQ,EAAE,WAAW;AACtB,CAAC,OAAO,EAAE,WAAW;AACrB,CAAC,IAAI,EAAE,MAAM;AACb,CAAC,OAAO,EAAE,MAAM;AAChB,CAAC,WAAW,EAAE,aAAa;AAC3B,CAAC,aAAa,EAAE,aAAa;AAC7B,CAAC,UAAU,EAAE,aAAa;AAC1B,CAAC,QAAQ,EAAE,aAAa;AACxB,CAAC,WAAW,EAAE,aAAa;AAC3B,CAAC,OAAO,EAAE,SAAS;AACnB,CAAC,OAAO,EAAE,SAAS;AACnB,CAAC,QAAQ,EAAE,SAAS;AACpB,CAAC,IAAI,EAAE,SAAS;AAChB,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;AACzC,GAAG,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;AACvE,GAAG,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC;AACjD,GAAG,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;AACpC,GAAG,QAAQ,EAAE,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,GAAG,GAAG,CAAC,QAAQ,GAAG,EAAE;AACjE,GAAG,OAAO,EAAE,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,GAAG,GAAG,CAAC,OAAO,GAAG,EAAE;AAC9D,IAAG;AACH,EAAE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,GAAG,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,EAAE,EAAC;AACxF,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAC;AAC9B,EAAE;AACF,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3D;;;;"}
|
|
@@ -2,6 +2,7 @@ import { formatBoardDate, formatBoardWeekday, formatTimeOfDay, formatRelativeDat
|
|
|
2
2
|
import { parseDateValue } from './dateVariant.js';
|
|
3
3
|
import { formatMoney } from './formatMetric.js';
|
|
4
4
|
import { readPath } from './readPath.js';
|
|
5
|
+
import { userDisplayName } from './userDisplayName.js';
|
|
5
6
|
|
|
6
7
|
// SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
7
8
|
// SPDX-License-Identifier: EUPL-1.2
|
|
@@ -33,11 +34,37 @@ function formatBoardDateTime(value, now = new Date()) {
|
|
|
33
34
|
return `${day}, ${time}`
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A date with the month written out: "7 oktober", or "6 oktober 2026"
|
|
39
|
+
* outside the current year or when `withYear` asks for it.
|
|
40
|
+
*
|
|
41
|
+
* @param {unknown} value A Date, a timestamp or an ISO string.
|
|
42
|
+
* @param {Date} now The reference moment.
|
|
43
|
+
* @param {boolean} [withYear] Always write the year.
|
|
44
|
+
* @return {string} The text, or '' when the value is not a date.
|
|
45
|
+
* @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels
|
|
46
|
+
*/
|
|
47
|
+
function formatLongDate(value, now = new Date(), withYear = false) {
|
|
48
|
+
const date = parseDateValue(value);
|
|
49
|
+
if (date === null) {
|
|
50
|
+
return ''
|
|
51
|
+
}
|
|
52
|
+
const options = { day: 'numeric', month: 'long' };
|
|
53
|
+
if (withYear || date.getFullYear() !== now.getFullYear()) {
|
|
54
|
+
options.year = 'numeric';
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return new Intl.DateTimeFormat(boardDateLocale(), options).format(date)
|
|
58
|
+
} catch {
|
|
59
|
+
return new Intl.DateTimeFormat(undefined, options).format(date)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
36
63
|
/**
|
|
37
64
|
* Format one token value.
|
|
38
65
|
*
|
|
39
66
|
* @param {unknown} value The raw value.
|
|
40
|
-
* @param {string} format `date`, `datetime`, `weekday`, `time`, `relative`, `relativetime`, `days` or '' (as is).
|
|
67
|
+
* @param {string} format `date`, `datetime`, `weekday`, `longdate`, `time`, `user`, `currency`, `relative`, `relativetime`, `days` or '' (as is).
|
|
41
68
|
* @param {Date} now The reference moment.
|
|
42
69
|
* @param {string} [arg] The format's argument (`currency:EUR`, or a row path holding the code).
|
|
43
70
|
* @param {object|null} [object] The row, for a currency read from a field.
|
|
@@ -57,6 +84,12 @@ function formatValue(value, format, now, arg = '', object = null, config = null)
|
|
|
57
84
|
if (format === 'weekday') {
|
|
58
85
|
return formatBoardWeekday(value, now, { today: arg === 'today' })
|
|
59
86
|
}
|
|
87
|
+
if (format === 'longdate') {
|
|
88
|
+
return formatLongDate(value, now, arg === 'year')
|
|
89
|
+
}
|
|
90
|
+
if (format === 'user') {
|
|
91
|
+
return userDisplayName(value)
|
|
92
|
+
}
|
|
60
93
|
if (format === 'time') {
|
|
61
94
|
const date = parseDateValue(value);
|
|
62
95
|
return date === null ? '' : formatTimeOfDay(date)
|
|
@@ -89,7 +122,10 @@ function formatValue(value, format, now, arg = '', object = null, config = null)
|
|
|
89
122
|
* Every `{path}` token is a dot path into the object; `{path|date}` and
|
|
90
123
|
* `{path|datetime}` format it as the boards write dates, `{path|weekday}` adds
|
|
91
124
|
* the short weekday ("wo 7 okt"; `{path|weekday:today}` reads "Vandaag, wo 7 okt"
|
|
92
|
-
* for today), `{path|
|
|
125
|
+
* for today), `{path|longdate}` writes the month out ("7 oktober";
|
|
126
|
+
* `{path|longdate:year}` always adds the year), `{path|time}` is the time
|
|
127
|
+
* of day ("08:45"), `{path|user}` is a user id's display name (looked up
|
|
128
|
+
* once, '' until it arrives), `{path|currency}`,
|
|
93
129
|
* `{path|currency:EUR}` and `{path|currency:field}` write an amount in a
|
|
94
130
|
* currency (a code, or the row field that holds it; without either, or when
|
|
95
131
|
* the row field is empty, the app's reporting currency), `{path|relative}` and
|
|
@@ -149,5 +185,40 @@ function firstFilled(templates, object, translate = (key) => key, now = new Date
|
|
|
149
185
|
return ''
|
|
150
186
|
}
|
|
151
187
|
|
|
152
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Fill a template such as `"{identifier} · {requester}"` field by field
|
|
190
|
+
* (a table column's `secondary` line, a detail page's meta line).
|
|
191
|
+
*
|
|
192
|
+
* A field without a value takes its separator with it: the text between two
|
|
193
|
+
* fields belongs to the field after it, so an empty requester leaves
|
|
194
|
+
* "2026-0002", not "2026-0002 ·", and an empty first field does not leave a
|
|
195
|
+
* leading separator either. Text before the first field and after the last
|
|
196
|
+
* one is kept as written. A template whose fields all have values fills
|
|
197
|
+
* exactly as before.
|
|
198
|
+
*
|
|
199
|
+
* @spec openspec/changes/zuiddrecht-pixel-gaps-3/specs/zuiddrecht-pixel-gaps-3/spec.md#requirement-an-empty-field-takes-its-separator-with-it
|
|
200
|
+
* @param {string} template The template, with `{field}` placeholders.
|
|
201
|
+
* @param {(key: string) => string} valueOf The text of a field ('' when empty).
|
|
202
|
+
* @return {string} The filled template.
|
|
203
|
+
*/
|
|
204
|
+
function joinTemplateParts(template, valueOf) {
|
|
205
|
+
// split() with a capture group alternates literal, field, literal, …
|
|
206
|
+
const parts = template.split(/\{([^}]+)\}/);
|
|
207
|
+
const lead = parts[0];
|
|
208
|
+
const tail = parts[parts.length - 1];
|
|
209
|
+
let body = '';
|
|
210
|
+
for (let i = 1; i < parts.length; i += 2) {
|
|
211
|
+
const value = valueOf(parts[i].trim());
|
|
212
|
+
if (value === '') {
|
|
213
|
+
continue
|
|
214
|
+
}
|
|
215
|
+
// The literal before this field: the separator, unless nothing has
|
|
216
|
+
// been written yet (then there is nothing to separate from).
|
|
217
|
+
const separator = i === 1 ? '' : parts[i - 1];
|
|
218
|
+
body += (body === '' ? '' : separator) + value;
|
|
219
|
+
}
|
|
220
|
+
return lead + body + tail
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { fillTemplate, firstFilled, formatBoardDateTime, formatLongDate, joinTemplateParts };
|
|
153
224
|
//# sourceMappingURL=fillTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillTemplate.js","sources":["../../../src/utils/fillTemplate.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { boardDateLocale, formatBoardDate, formatBoardWeekday, formatRelativeDate, formatTimeOfDay } from './boardDate.js'\nimport { parseDateValue } from './dateVariant.js'\nimport { formatMoney } from './formatMetric.js'\nimport { readPath } from './readPath.js'\n\nconst TOKEN = /\\{([^{}\\s|]+)(?:\\|([a-z]+)(?::([^{}\\s]+))?)?\\}/g\n\n/**\n * A moment in the board's short form with the time: \"4 okt, 10:52\", or\n * \"14 feb 2024, 09:00\" outside the current year.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} [now] The reference moment.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function formatBoardDateTime(value, now = new Date()) {\n\tconst day = formatBoardDate(value, now)\n\tconst date = parseDateValue(value)\n\tif (day === '' || date === null) {\n\t\treturn ''\n\t}\n\tlet time\n\ttry {\n\t\ttime = new Intl.DateTimeFormat(boardDateLocale(), { hour: '2-digit', minute: '2-digit' }).format(date)\n\t} catch {\n\t\ttime = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' }).format(date)\n\t}\n\treturn `${day}, ${time}`\n}\n\n/**\n * Format one token value.\n *\n * @param {unknown} value The raw value.\n * @param {string} format `date`, `datetime`, `weekday`, `time`, `relative`, `relativetime`, `days` or '' (as is).\n * @param {Date} now The reference moment.\n * @param {string} [arg] The format's argument (`currency:EUR`, or a row path holding the code).\n * @param {object|null} [object] The row, for a currency read from a field.\n * @param {object|null} [config] The app config map, for the reporting currency.\n * @return {string} The text, '' when nothing can be shown.\n */\nfunction formatValue(value, format, now, arg = '', object = null, config = null) {\n\tif (value === null || value === undefined || value === '' || typeof value === 'object') {\n\t\treturn ''\n\t}\n\tif (format === 'date') {\n\t\treturn formatBoardDate(value, now)\n\t}\n\tif (format === 'datetime') {\n\t\treturn formatBoardDateTime(value, now)\n\t}\n\tif (format === 'weekday') {\n\t\treturn formatBoardWeekday(value, now, { today: arg === 'today' })\n\t}\n\tif (format === 'time') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : formatTimeOfDay(date)\n\t}\n\tif (format === 'currency') {\n\t\t// `{amount|currency:EUR}` names the code, `{amount|currency:price.code}`\n\t\t// reads it from the row, `{amount|currency}` is the app's reporting\n\t\t// currency (EUR without one).\n\t\tconst isCode = /^[A-Za-z]{3}$/.test(arg)\n\t\treturn formatMoney(value, { currency: isCode ? arg : undefined, currencyField: !isCode && arg ? arg : undefined }, object, config)\n\t}\n\tif (format === 'relative') {\n\t\treturn formatRelativeDate(value, { now })\n\t}\n\tif (format === 'relativetime') {\n\t\treturn formatRelativeDate(value, { now, withTime: true })\n\t}\n\tif (format === 'days') {\n\t\t// Whole days from the date to now (0 for today; negative for a future date).\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : String(Math.floor((now.getTime() - date.getTime()) / 86400000))\n\t}\n\treturn String(value)\n}\n\n/**\n * Fill a row template such as `\"{identifier} · {caseTypeName}\"` or\n * `\"Termijn {deadline|date}\"` from an object.\n *\n * Every `{path}` token is a dot path into the object; `{path|date}` and\n * `{path|datetime}` format it as the boards write dates, `{path|weekday}` adds\n * the short weekday (\"wo 7 okt\"; `{path|weekday:today}` reads \"Vandaag, wo 7 okt\"\n * for today), `{path|time}` is the time of day (\"08:45\"), `{path|currency}`,\n * `{path|currency:EUR}` and `{path|currency:field}` write an amount in a\n * currency (a code, or the row field that holds it; without either, or when\n * the row field is empty, the app's reporting currency), `{path|relative}` and\n * `{path|relativetime}` say \"today\", \"yesterday\" and then the short date\n * (\"vandaag, 09.42\"), and `{path|days}` is the\n * whole days since that date (\"has waited {createdAt|days} days\"). A token without a\n * value empties the WHOLE template, because \"Termijn \" is worse than nothing.\n * A template without tokens is returned as written (a constant label).\n *\n * @param {string} template The template, already translated.\n * @param {object|null} object The object to read.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] The app config map, for the reporting currency of a money token.\n * @return {string} The filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function fillTemplate(template, object, now = new Date(), context = null) {\n\tif (typeof template !== 'string' || template.trim() === '') {\n\t\treturn ''\n\t}\n\tlet missing = false\n\tconst text = template.replace(TOKEN, (_match, path, format, arg) => {\n\t\tconst value = object && typeof object === 'object' ? readPath(object, path) : undefined\n\t\tconst shown = formatValue(value, format || '', now, arg || '', object, context && context.config ? context.config : null)\n\t\tif (shown === '') {\n\t\t\tmissing = true\n\t\t}\n\t\treturn shown\n\t})\n\treturn missing ? '' : text.trim()\n}\n\n/**\n * The first of several templates that fills: `[\"Klaar {closedAt|date}\",\n * \"Termijn {deadline|date}\"]` reads \"Klaar ...\" once the case is closed and\n * \"Termijn ...\" while it is open. A single string is one candidate.\n *\n * @param {string|string[]} templates The candidates, in order.\n * @param {object|null} object The object to read.\n * @param {(key: string) => string} [translate] Applied to each template before filling.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] Passed on to `fillTemplate`.\n * @return {string} The first filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function firstFilled(templates, object, translate = (key) => key, now = new Date(), context = null) {\n\tconst list = Array.isArray(templates) ? templates : [templates]\n\tfor (const template of list) {\n\t\tif (typeof template !== 'string') {\n\t\t\tcontinue\n\t\t}\n\t\tconst text = fillTemplate(translate(template), object, now, context)\n\t\tif (text !== '') {\n\t\t\treturn text\n\t\t}\n\t}\n\treturn ''\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AAKA;AACA,MAAM,KAAK,GAAG,kDAAiD;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE,EAAE;AAC7D,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,EAAE,GAAG,EAAC;AACxC,CAAC,MAAM,IAAI,GAAG,cA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,EAAE;AAC3G,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS,EAAC;AAChE,CAAC,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;AAC9B,EAAE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AACpC,GAAG,QAAQ;AACX,GAAG;AACH,EAAE,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAC;AACtE,EAAE,IAAI,IAAI,KAAK,EAAE,EAAE;AACnB,GAAG,OAAO,IAAI;AACd,GAAG;AACH,EAAE;AACF,CAAC,OAAO,EAAE;AACV;;;;"}
|
|
1
|
+
{"version":3,"file":"fillTemplate.js","sources":["../../../src/utils/fillTemplate.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { boardDateLocale, formatBoardDate, formatBoardWeekday, formatRelativeDate, formatTimeOfDay } from './boardDate.js'\nimport { parseDateValue } from './dateVariant.js'\nimport { formatMoney } from './formatMetric.js'\nimport { readPath } from './readPath.js'\nimport { userDisplayName } from './userDisplayName.js'\n\nconst TOKEN = /\\{([^{}\\s|]+)(?:\\|([a-z]+)(?::([^{}\\s]+))?)?\\}/g\n\n/**\n * A moment in the board's short form with the time: \"4 okt, 10:52\", or\n * \"14 feb 2024, 09:00\" outside the current year.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} [now] The reference moment.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function formatBoardDateTime(value, now = new Date()) {\n\tconst day = formatBoardDate(value, now)\n\tconst date = parseDateValue(value)\n\tif (day === '' || date === null) {\n\t\treturn ''\n\t}\n\tlet time\n\ttry {\n\t\ttime = new Intl.DateTimeFormat(boardDateLocale(), { hour: '2-digit', minute: '2-digit' }).format(date)\n\t} catch {\n\t\ttime = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' }).format(date)\n\t}\n\treturn `${day}, ${time}`\n}\n\n/**\n * A date with the month written out: \"7 oktober\", or \"6 oktober 2026\"\n * outside the current year or when `withYear` asks for it.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} now The reference moment.\n * @param {boolean} [withYear] Always write the year.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\nexport function formatLongDate(value, now = new Date(), withYear = false) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn ''\n\t}\n\tconst options = { day: 'numeric', month: 'long' }\n\tif (withYear || date.getFullYear() !== now.getFullYear()) {\n\t\toptions.year = 'numeric'\n\t}\n\ttry {\n\t\treturn new Intl.DateTimeFormat(boardDateLocale(), options).format(date)\n\t} catch {\n\t\treturn new Intl.DateTimeFormat(undefined, options).format(date)\n\t}\n}\n\n/**\n * Format one token value.\n *\n * @param {unknown} value The raw value.\n * @param {string} format `date`, `datetime`, `weekday`, `longdate`, `time`, `user`, `currency`, `relative`, `relativetime`, `days` or '' (as is).\n * @param {Date} now The reference moment.\n * @param {string} [arg] The format's argument (`currency:EUR`, or a row path holding the code).\n * @param {object|null} [object] The row, for a currency read from a field.\n * @param {object|null} [config] The app config map, for the reporting currency.\n * @return {string} The text, '' when nothing can be shown.\n */\nfunction formatValue(value, format, now, arg = '', object = null, config = null) {\n\tif (value === null || value === undefined || value === '' || typeof value === 'object') {\n\t\treturn ''\n\t}\n\tif (format === 'date') {\n\t\treturn formatBoardDate(value, now)\n\t}\n\tif (format === 'datetime') {\n\t\treturn formatBoardDateTime(value, now)\n\t}\n\tif (format === 'weekday') {\n\t\treturn formatBoardWeekday(value, now, { today: arg === 'today' })\n\t}\n\tif (format === 'longdate') {\n\t\treturn formatLongDate(value, now, arg === 'year')\n\t}\n\tif (format === 'user') {\n\t\treturn userDisplayName(value)\n\t}\n\tif (format === 'time') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : formatTimeOfDay(date)\n\t}\n\tif (format === 'currency') {\n\t\t// `{amount|currency:EUR}` names the code, `{amount|currency:price.code}`\n\t\t// reads it from the row, `{amount|currency}` is the app's reporting\n\t\t// currency (EUR without one).\n\t\tconst isCode = /^[A-Za-z]{3}$/.test(arg)\n\t\treturn formatMoney(value, { currency: isCode ? arg : undefined, currencyField: !isCode && arg ? arg : undefined }, object, config)\n\t}\n\tif (format === 'relative') {\n\t\treturn formatRelativeDate(value, { now })\n\t}\n\tif (format === 'relativetime') {\n\t\treturn formatRelativeDate(value, { now, withTime: true })\n\t}\n\tif (format === 'days') {\n\t\t// Whole days from the date to now (0 for today; negative for a future date).\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : String(Math.floor((now.getTime() - date.getTime()) / 86400000))\n\t}\n\treturn String(value)\n}\n\n/**\n * Fill a row template such as `\"{identifier} · {caseTypeName}\"` or\n * `\"Termijn {deadline|date}\"` from an object.\n *\n * Every `{path}` token is a dot path into the object; `{path|date}` and\n * `{path|datetime}` format it as the boards write dates, `{path|weekday}` adds\n * the short weekday (\"wo 7 okt\"; `{path|weekday:today}` reads \"Vandaag, wo 7 okt\"\n * for today), `{path|longdate}` writes the month out (\"7 oktober\";\n * `{path|longdate:year}` always adds the year), `{path|time}` is the time\n * of day (\"08:45\"), `{path|user}` is a user id's display name (looked up\n * once, '' until it arrives), `{path|currency}`,\n * `{path|currency:EUR}` and `{path|currency:field}` write an amount in a\n * currency (a code, or the row field that holds it; without either, or when\n * the row field is empty, the app's reporting currency), `{path|relative}` and\n * `{path|relativetime}` say \"today\", \"yesterday\" and then the short date\n * (\"vandaag, 09.42\"), and `{path|days}` is the\n * whole days since that date (\"has waited {createdAt|days} days\"). A token without a\n * value empties the WHOLE template, because \"Termijn \" is worse than nothing.\n * A template without tokens is returned as written (a constant label).\n *\n * @param {string} template The template, already translated.\n * @param {object|null} object The object to read.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] The app config map, for the reporting currency of a money token.\n * @return {string} The filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function fillTemplate(template, object, now = new Date(), context = null) {\n\tif (typeof template !== 'string' || template.trim() === '') {\n\t\treturn ''\n\t}\n\tlet missing = false\n\tconst text = template.replace(TOKEN, (_match, path, format, arg) => {\n\t\tconst value = object && typeof object === 'object' ? readPath(object, path) : undefined\n\t\tconst shown = formatValue(value, format || '', now, arg || '', object, context && context.config ? context.config : null)\n\t\tif (shown === '') {\n\t\t\tmissing = true\n\t\t}\n\t\treturn shown\n\t})\n\treturn missing ? '' : text.trim()\n}\n\n/**\n * The first of several templates that fills: `[\"Klaar {closedAt|date}\",\n * \"Termijn {deadline|date}\"]` reads \"Klaar ...\" once the case is closed and\n * \"Termijn ...\" while it is open. A single string is one candidate.\n *\n * @param {string|string[]} templates The candidates, in order.\n * @param {object|null} object The object to read.\n * @param {(key: string) => string} [translate] Applied to each template before filling.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] Passed on to `fillTemplate`.\n * @return {string} The first filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function firstFilled(templates, object, translate = (key) => key, now = new Date(), context = null) {\n\tconst list = Array.isArray(templates) ? templates : [templates]\n\tfor (const template of list) {\n\t\tif (typeof template !== 'string') {\n\t\t\tcontinue\n\t\t}\n\t\tconst text = fillTemplate(translate(template), object, now, context)\n\t\tif (text !== '') {\n\t\t\treturn text\n\t\t}\n\t}\n\treturn ''\n}\n\n/**\n * Fill a template such as `\"{identifier} · {requester}\"` field by field\n * (a table column's `secondary` line, a detail page's meta line).\n *\n * A field without a value takes its separator with it: the text between two\n * fields belongs to the field after it, so an empty requester leaves\n * \"2026-0002\", not \"2026-0002 ·\", and an empty first field does not leave a\n * leading separator either. Text before the first field and after the last\n * one is kept as written. A template whose fields all have values fills\n * exactly as before.\n *\n * @spec openspec/changes/zuiddrecht-pixel-gaps-3/specs/zuiddrecht-pixel-gaps-3/spec.md#requirement-an-empty-field-takes-its-separator-with-it\n * @param {string} template The template, with `{field}` placeholders.\n * @param {(key: string) => string} valueOf The text of a field ('' when empty).\n * @return {string} The filled template.\n */\nexport function joinTemplateParts(template, valueOf) {\n\t// split() with a capture group alternates literal, field, literal, …\n\tconst parts = template.split(/\\{([^}]+)\\}/)\n\tconst lead = parts[0]\n\tconst tail = parts[parts.length - 1]\n\tlet body = ''\n\tfor (let i = 1; i < parts.length; i += 2) {\n\t\tconst value = valueOf(parts[i].trim())\n\t\tif (value === '') {\n\t\t\tcontinue\n\t\t}\n\t\t// The literal before this field: the separator, unless nothing has\n\t\t// been written yet (then there is nothing to separate from).\n\t\tconst separator = i === 1 ? '' : parts[i - 1]\n\t\tbody += (body === '' ? '' : separator) + value\n\t}\n\treturn lead + body + tail\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AAMA;AACA,MAAM,KAAK,GAAG,kDAAiD;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE,EAAE;AAC7D,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,EAAE,GAAG,EAAC;AACxC,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAC;AACnC,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI,EAAE;AAClC,EAAE,OAAO,EAAE;AACX,EAAE;AACF,CAAC,IAAI,KAAI;AACT,CAAC,IAAI;AACL,EAAE,IAAI,GAAG,I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;AACnB,GAAG,OAAO,IAAI;AACd,GAAG;AACH,EAAE;AACF,CAAC,OAAO,EAAE;AACV,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE;AACrD;AACA,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAC;AAC5C,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,EAAC;AACtB,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC;AACrC,CAAC,IAAI,IAAI,GAAG,GAAE;AACd,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAC3C,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAC;AACxC,EAAE,IAAI,KAAK,KAAK,EAAE,EAAE;AACpB,GAAG,QAAQ;AACX,GAAG;AACH;AACA;AACA,EAAE,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC;AAC/C,EAAE,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,IAAI,MAAK;AAChD,EAAE;AACF,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,IAAI;AAC1B;;;;"}
|
|
@@ -1,28 +1,78 @@
|
|
|
1
|
-
import { fillTemplate } from './fillTemplate.js';
|
|
1
|
+
import { joinTemplateParts, fillTemplate } from './fillTemplate.js';
|
|
2
|
+
import { readPath } from './readPath.js';
|
|
2
3
|
|
|
3
4
|
// SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
4
5
|
// SPDX-License-Identifier: EUPL-1.2
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The text of one plain `{path}` token: an enum field reads as its label
|
|
10
|
+
* (`x-enum-labels` / `enumLabels` on the schema property, through the
|
|
11
|
+
* translate function), anything else as the stored value.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} object The record.
|
|
14
|
+
* @param {string} path The dotted path.
|
|
15
|
+
* @param {object|null} schema The record's schema.
|
|
16
|
+
* @param {(text: string) => string} translate The translate function.
|
|
17
|
+
* @return {string} The text, or '' when the field is empty.
|
|
18
|
+
*/
|
|
19
|
+
function plainTokenText(object, path, schema, translate) {
|
|
20
|
+
const value = readPath(object, path);
|
|
21
|
+
if (value === null || value === undefined || value === '' || typeof value === 'object') {
|
|
22
|
+
return ''
|
|
23
|
+
}
|
|
24
|
+
const property = schema && schema.properties && !path.includes('.') ? schema.properties[path] : null;
|
|
25
|
+
const labels = property && (property.enumLabels || property['x-enum-labels']);
|
|
26
|
+
if (labels && typeof labels === 'object' && typeof labels[String(value)] === 'string') {
|
|
27
|
+
return translate(labels[String(value)])
|
|
28
|
+
}
|
|
29
|
+
return String(value)
|
|
30
|
+
}
|
|
31
|
+
|
|
7
32
|
/**
|
|
8
33
|
* Fill a header meta template such as `"via {channel}"` or
|
|
9
|
-
* `"
|
|
34
|
+
* `"{amount|currency:EUR} · {cashier|user} · {at|longdate} {at|time}"` from
|
|
35
|
+
* a record.
|
|
10
36
|
*
|
|
11
37
|
* Every `{path}` token (a dotted path into the record) is replaced by its
|
|
12
|
-
* value
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
38
|
+
* value, an enum field by its label. `{path|format}` tokens format as a
|
|
39
|
+
* record-list row does (the shared `fillTemplate`: date, datetime, weekday,
|
|
40
|
+
* longdate, time, user, currency, relative, relativetime, days). A token
|
|
41
|
+
* without a value drops itself and the separator before it, so a missing
|
|
42
|
+
* cashier leaves "€ 96,41 · 7 oktober"; a line whose every token is empty
|
|
43
|
+
* is '' ("via " is worse than nothing). A template without tokens is
|
|
44
|
+
* returned as written.
|
|
17
45
|
*
|
|
18
46
|
* @param {string} template The template, already translated.
|
|
19
47
|
* @param {object|null} object The record.
|
|
20
|
-
* @param {Date} [
|
|
21
|
-
* @return {string} The line, or '' when
|
|
22
|
-
* @spec openspec/changes/screens-
|
|
48
|
+
* @param {Date|{now?: Date, schema?: object, translate?: Function, config?: object}} [options] The reference moment, or options: `schema` for enum labels, `translate` for those labels, `config` for the reporting currency.
|
|
49
|
+
* @return {string} The line, or '' when nothing can be filled.
|
|
50
|
+
* @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels
|
|
23
51
|
*/
|
|
24
|
-
function resolveHeaderMeta(template, object,
|
|
25
|
-
|
|
52
|
+
function resolveHeaderMeta(template, object, options = {}) {
|
|
53
|
+
const settings = options instanceof Date ? { now: options } : (options || {});
|
|
54
|
+
const now = settings.now || new Date();
|
|
55
|
+
const translate = typeof settings.translate === 'function' ? settings.translate : (text) => text;
|
|
56
|
+
if (typeof template !== 'string' || template.trim() === '') {
|
|
57
|
+
return ''
|
|
58
|
+
}
|
|
59
|
+
if (!/\{[^}]+\}/.test(template)) {
|
|
60
|
+
return template.trim()
|
|
61
|
+
}
|
|
62
|
+
if (!object || typeof object !== 'object') {
|
|
63
|
+
return ''
|
|
64
|
+
}
|
|
65
|
+
let filled = 0;
|
|
66
|
+
const line = joinTemplateParts(template, (token) => {
|
|
67
|
+
const text = token.includes('|')
|
|
68
|
+
? fillTemplate(`{${token}}`, object, now, settings.config ? { config: settings.config } : null)
|
|
69
|
+
: plainTokenText(object, token, settings.schema || null, translate);
|
|
70
|
+
if (text !== '') {
|
|
71
|
+
filled += 1;
|
|
72
|
+
}
|
|
73
|
+
return text
|
|
74
|
+
});
|
|
75
|
+
return filled === 0 ? '' : line.trim()
|
|
26
76
|
}
|
|
27
77
|
|
|
28
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headerMeta.js","sources":["../../../src/utils/headerMeta.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { fillTemplate } from './fillTemplate.js'\n\n/**\n * Fill a header meta template such as `\"via {channel}\"` or\n * `\"
|
|
1
|
+
{"version":3,"file":"headerMeta.js","sources":["../../../src/utils/headerMeta.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { fillTemplate, joinTemplateParts } from './fillTemplate.js'\nimport { readPath } from './readPath.js'\n\n/**\n * The text of one plain `{path}` token: an enum field reads as its label\n * (`x-enum-labels` / `enumLabels` on the schema property, through the\n * translate function), anything else as the stored value.\n *\n * @param {object} object The record.\n * @param {string} path The dotted path.\n * @param {object|null} schema The record's schema.\n * @param {(text: string) => string} translate The translate function.\n * @return {string} The text, or '' when the field is empty.\n */\nfunction plainTokenText(object, path, schema, translate) {\n\tconst value = readPath(object, path)\n\tif (value === null || value === undefined || value === '' || typeof value === 'object') {\n\t\treturn ''\n\t}\n\tconst property = schema && schema.properties && !path.includes('.') ? schema.properties[path] : null\n\tconst labels = property && (property.enumLabels || property['x-enum-labels'])\n\tif (labels && typeof labels === 'object' && typeof labels[String(value)] === 'string') {\n\t\treturn translate(labels[String(value)])\n\t}\n\treturn String(value)\n}\n\n/**\n * Fill a header meta template such as `\"via {channel}\"` or\n * `\"{amount|currency:EUR} · {cashier|user} · {at|longdate} {at|time}\"` from\n * a record.\n *\n * Every `{path}` token (a dotted path into the record) is replaced by its\n * value, an enum field by its label. `{path|format}` tokens format as a\n * record-list row does (the shared `fillTemplate`: date, datetime, weekday,\n * longdate, time, user, currency, relative, relativetime, days). A token\n * without a value drops itself and the separator before it, so a missing\n * cashier leaves \"€ 96,41 · 7 oktober\"; a line whose every token is empty\n * is '' (\"via \" is worse than nothing). A template without tokens is\n * returned as written.\n *\n * @param {string} template The template, already translated.\n * @param {object|null} object The record.\n * @param {Date|{now?: Date, schema?: object, translate?: Function, config?: object}} [options] The reference moment, or options: `schema` for enum labels, `translate` for those labels, `config` for the reporting currency.\n * @return {string} The line, or '' when nothing can be filled.\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\nexport function resolveHeaderMeta(template, object, options = {}) {\n\tconst settings = options instanceof Date ? { now: options } : (options || {})\n\tconst now = settings.now || new Date()\n\tconst translate = typeof settings.translate === 'function' ? settings.translate : (text) => text\n\tif (typeof template !== 'string' || template.trim() === '') {\n\t\treturn ''\n\t}\n\tif (!/\\{[^}]+\\}/.test(template)) {\n\t\treturn template.trim()\n\t}\n\tif (!object || typeof object !== 'object') {\n\t\treturn ''\n\t}\n\tlet filled = 0\n\tconst line = joinTemplateParts(template, (token) => {\n\t\tconst text = token.includes('|')\n\t\t\t? fillTemplate(`{${token}}`, object, now, settings.config ? { config: settings.config } : null)\n\t\t\t: plainTokenText(object, token, settings.schema || null, translate)\n\t\tif (text !== '') {\n\t\t\tfilled += 1\n\t\t}\n\t\treturn text\n\t})\n\treturn filled === 0 ? '' : line.trim()\n}\n\n/**\n * Whether a widget definition is the record's activity (the History tab or\n * card): an audit-trail or timeline widget, or the `activity` integration.\n *\n * @param {object|null} widget The widget definition.\n * @return {boolean} True for an activity widget.\n * @spec openspec/changes/screens-detail-page-parity/specs/detail-page-board-look/spec.md#requirement-history-is-the-last-tab\n */\nexport function isActivityWidget(widget) {\n\tif (!widget || typeof widget !== 'object') {\n\t\treturn false\n\t}\n\tif (widget.type === 'audit-trail' || widget.type === 'timeline') {\n\t\treturn true\n\t}\n\treturn widget.type === 'integration' && widget.integrationId === 'activity'\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,MAAM,EA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C,EAAE,OAAO,KAAK;AACd,EAAE;AACF,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;AAClE,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,aAAa,IAAI,MAAM,CAAC,aAAa,KAAK,UAAU;AAC5E;;;;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import axios__default from '@nextcloud/axios';
|
|
2
|
+
import { generateUrl } from '@nextcloud/router';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
6
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
7
|
+
*
|
|
8
|
+
* roadmapIssues: the forge issues a roadmap shows, fetched through
|
|
9
|
+
* OpenRegister's `github-issue-proxy` with the curated label filter
|
|
10
|
+
* (`enhancement,feature`, per openregister design D23), most-reacted first.
|
|
11
|
+
*
|
|
12
|
+
* @module utils/roadmapIssues
|
|
13
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Fetch the roadmap issues of a repository.
|
|
19
|
+
*
|
|
20
|
+
* `degraded` names why there are none: `pat_not_configured` (OpenRegister has
|
|
21
|
+
* no GitHub token), `rate_limited` (HTTP 429), `error` (anything else), or
|
|
22
|
+
* null when the fetch worked.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} repo `<owner>/<repo>` on the forge.
|
|
25
|
+
* @return {Promise<{items: Array<object>, degraded: (string|null)}>} The issues, most-reacted first.
|
|
26
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues
|
|
27
|
+
*/
|
|
28
|
+
async function fetchRoadmapIssues(repo) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await axios__default.get(generateUrl('/apps/openregister/api/github/issues'), {
|
|
31
|
+
params: { repo, labels: 'enhancement,feature' },
|
|
32
|
+
});
|
|
33
|
+
const data = response.data || {};
|
|
34
|
+
if (data.hint === 'github_pat_not_configured') {
|
|
35
|
+
return { items: [], degraded: 'pat_not_configured' }
|
|
36
|
+
}
|
|
37
|
+
return { items: sortByReactions(Array.isArray(data.items) ? data.items : []), degraded: null }
|
|
38
|
+
} catch (e) {
|
|
39
|
+
const status = e?.response?.status;
|
|
40
|
+
const code = e?.response?.data?.error;
|
|
41
|
+
if (status === 429 || code === 'github_rate_limited' || code === 'rate_limited') {
|
|
42
|
+
return { items: [], degraded: 'rate_limited' }
|
|
43
|
+
}
|
|
44
|
+
return { items: [], degraded: 'error' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Issues ordered by their reaction count, most first.
|
|
50
|
+
*
|
|
51
|
+
* @param {Array<object>} items The issues.
|
|
52
|
+
* @return {Array<object>} A sorted copy.
|
|
53
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues
|
|
54
|
+
*/
|
|
55
|
+
function sortByReactions(items) {
|
|
56
|
+
return [...items].sort((a, b) => (b.reactions?.total_count || 0) - (a.reactions?.total_count || 0))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The roadmap status of an issue from its labels: the first label that
|
|
61
|
+
* `labelStatuses` maps (case-insensitive) decides, else ''.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} issue The issue, with `labels: [{name}]` or `labels: ['name']`.
|
|
64
|
+
* @param {object} labelStatuses Label name to status (`in_progress`, `planned`).
|
|
65
|
+
* @return {string} The status, or '' for no badge.
|
|
66
|
+
* @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues
|
|
67
|
+
*/
|
|
68
|
+
function issueStatus(issue, labelStatuses) {
|
|
69
|
+
if (!labelStatuses || typeof labelStatuses !== 'object') {
|
|
70
|
+
return ''
|
|
71
|
+
}
|
|
72
|
+
const map = {};
|
|
73
|
+
for (const [label, status] of Object.entries(labelStatuses)) {
|
|
74
|
+
map[label.toLowerCase()] = status;
|
|
75
|
+
}
|
|
76
|
+
for (const label of Array.isArray(issue?.labels) ? issue.labels : []) {
|
|
77
|
+
const name = String(typeof label === 'string' ? label : label?.name || '').toLowerCase();
|
|
78
|
+
if (map[name]) {
|
|
79
|
+
return map[name]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return ''
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { fetchRoadmapIssues, issueStatus, sortByReactions };
|
|
86
|
+
//# sourceMappingURL=roadmapIssues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roadmapIssues.js","sources":["../../../src/utils/roadmapIssues.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * roadmapIssues: the forge issues a roadmap shows, fetched through\n * OpenRegister's `github-issue-proxy` with the curated label filter\n * (`enhancement,feature`, per openregister design D23), most-reacted first.\n *\n * @module utils/roadmapIssues\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues\n */\n\nimport axios from '@nextcloud/axios'\nimport { generateUrl } from '@nextcloud/router'\n\n/**\n * Fetch the roadmap issues of a repository.\n *\n * `degraded` names why there are none: `pat_not_configured` (OpenRegister has\n * no GitHub token), `rate_limited` (HTTP 429), `error` (anything else), or\n * null when the fetch worked.\n *\n * @param {string} repo `<owner>/<repo>` on the forge.\n * @return {Promise<{items: Array<object>, degraded: (string|null)}>} The issues, most-reacted first.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues\n */\nexport async function fetchRoadmapIssues(repo) {\n\ttry {\n\t\tconst response = await axios.get(generateUrl('/apps/openregister/api/github/issues'), {\n\t\t\tparams: { repo, labels: 'enhancement,feature' },\n\t\t})\n\t\tconst data = response.data || {}\n\t\tif (data.hint === 'github_pat_not_configured') {\n\t\t\treturn { items: [], degraded: 'pat_not_configured' }\n\t\t}\n\t\treturn { items: sortByReactions(Array.isArray(data.items) ? data.items : []), degraded: null }\n\t} catch (e) {\n\t\tconst status = e?.response?.status\n\t\tconst code = e?.response?.data?.error\n\t\tif (status === 429 || code === 'github_rate_limited' || code === 'rate_limited') {\n\t\t\treturn { items: [], degraded: 'rate_limited' }\n\t\t}\n\t\treturn { items: [], degraded: 'error' }\n\t}\n}\n\n/**\n * Issues ordered by their reaction count, most first.\n *\n * @param {Array<object>} items The issues.\n * @return {Array<object>} A sorted copy.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues\n */\nexport function sortByReactions(items) {\n\treturn [...items].sort((a, b) => (b.reactions?.total_count || 0) - (a.reactions?.total_count || 0))\n}\n\n/**\n * The roadmap status of an issue from its labels: the first label that\n * `labelStatuses` maps (case-insensitive) decides, else ''.\n *\n * @param {object} issue The issue, with `labels: [{name}]` or `labels: ['name']`.\n * @param {object} labelStatuses Label name to status (`in_progress`, `planned`).\n * @return {string} The status, or '' for no badge.\n * @spec openspec/changes/screens-roadmap-board-look/specs/features-roadmap-board-look/spec.md#requirement-the-next-card-lists-the-most-requested-issues\n */\nexport function issueStatus(issue, labelStatuses) {\n\tif (!labelStatuses || typeof labelStatuses !== 'object') {\n\t\treturn ''\n\t}\n\tconst map = {}\n\tfor (const [label, status] of Object.entries(labelStatuses)) {\n\t\tmap[label.toLowerCase()] = status\n\t}\n\tfor (const label of Array.isArray(issue?.labels) ? issue.labels : []) {\n\t\tconst name = String(typeof label === 'string' ? label : label?.name || '').toLowerCase()\n\t\t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3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
6
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
7
|
+
*
|
|
8
|
+
* userDisplayName: a user id's display name for synchronous text (a template
|
|
9
|
+
* token), looked up once through `resolveNextcloudUser` and kept in a
|
|
10
|
+
* reactive cache, so a computed that read it renders again when the name
|
|
11
|
+
* arrives.
|
|
12
|
+
*
|
|
13
|
+
* @module utils/userDisplayName
|
|
14
|
+
* @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const names = reactive({});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The display name of a user id: the cached name, or '' while it is being
|
|
22
|
+
* looked up (the first call starts the lookup). A user that cannot be
|
|
23
|
+
* resolved reads as its id.
|
|
24
|
+
*
|
|
25
|
+
* @param {unknown} uid The user id.
|
|
26
|
+
* @return {string} The display name, or '' while loading.
|
|
27
|
+
* @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels
|
|
28
|
+
*/
|
|
29
|
+
function userDisplayName(uid) {
|
|
30
|
+
if (uid === null || uid === undefined || uid === '' || typeof uid === 'object') {
|
|
31
|
+
return ''
|
|
32
|
+
}
|
|
33
|
+
const id = String(uid);
|
|
34
|
+
if (typeof names[id] === 'string') {
|
|
35
|
+
return names[id]
|
|
36
|
+
}
|
|
37
|
+
if (names[id] === undefined) {
|
|
38
|
+
names[id] = null;
|
|
39
|
+
resolveNextcloudUser(id)
|
|
40
|
+
.then((option) => { names[id] = option && option.label ? String(option.label) : id; })
|
|
41
|
+
.catch(() => { names[id] = id; });
|
|
42
|
+
}
|
|
43
|
+
return ''
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { userDisplayName };
|
|
47
|
+
//# sourceMappingURL=userDisplayName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userDisplayName.js","sources":["../../../src/utils/userDisplayName.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * userDisplayName: a user id's display name for synchronous text (a template\n * token), looked up once through `resolveNextcloudUser` and kept in a\n * reactive cache, so a computed that read it renders again when the name\n * arrives.\n *\n * @module utils/userDisplayName\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\n\nimport { reactive } from 'vue'\nimport { resolveNextcloudUser } from './userAutocomplete.js'\n\nconst names = reactive({})\n\n/**\n * The display name of a user id: the cached name, or '' while it is being\n * looked up (the first call starts the lookup). A user that cannot be\n * resolved reads as its id.\n *\n * @param {unknown} uid The user id.\n * @return {string} The display name, or '' while loading.\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\nexport function userDisplayName(uid) {\n\tif (uid === null || uid === undefined || uid === '' || typeof uid === 'object') {\n\t\treturn ''\n\t}\n\tconst id = String(uid)\n\tif (typeof names[id] === 'string') {\n\t\treturn names[id]\n\t}\n\tif (names[id] === undefined) {\n\t\tnames[id] = null\n\t\tresolveNextcloudUser(id)\n\t\t\t.then((option) => { names[id] = option && option.label ? String(option.label) : id })\n\t\t\t.catch(() => { names[id] = id })\n\t}\n\treturn ''\n}\n\n/**\n * Forget every cached name (tests).\n *\n * @return {void}\n */\nexport function clearUserDisplayNames() {\n\tfor (const key of Object.keys(names)) {\n\t\tdelete names[key]\n\t}\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAC;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,GAAG,EAAE;AACrC,CAAC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;AACjF,EAAE,OAAO,EAAE;AACX,EAAE;AACF,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,EAAC;AACvB,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,QAAQ,EAAE;AACpC,EAAE,OAAO,KAAK,CAAC,EAAE,CAAC;AAClB,EAAE;AACF,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS,EAAE;AAC9B,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,KAAI;AAClB,EAAE,oBAAoB,CAAC,EAAE,CAAC;AAC1B,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAE,EAAE,CAAC;AACxF,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,GAAE,EAAE,EAAC;AACnC,EAAE;AACF,CAAC,OAAO,EAAE;AACV;;;;"}
|