@conduction/nextcloud-vue 2.56.0-beta.73 → 2.56.0-beta.75
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/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +90 -7
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +82 -79
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue.js +1 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js +12 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js.map +1 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue3.js.map +1 -1
- package/dist/esm/components/CnCardNotices/CnCardNotices.vue.js +1 -1
- package/dist/esm/components/CnCardNotices/CnCardNotices.vue2.js +45 -7
- package/dist/esm/components/CnCardNotices/CnCardNotices.vue2.js.map +1 -1
- package/dist/esm/components/CnCardNotices/CnCardNotices.vue3.js +1 -1
- package/dist/esm/components/CnCardNotices/CnCardNotices.vue3.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +10 -8
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +95 -88
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +40 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +149 -109
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js +10 -4
- package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js +86 -8
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js +137 -121
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js +56 -4
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js +166 -70
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js +9 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js +123 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js +268 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js +9 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js +49 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js +41 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js.map +1 -0
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +116 -8
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +110 -58
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +78 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +44 -3
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
- package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue.js +1 -1
- package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue2.js +112 -1
- package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue3.js +53 -18
- package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue2.js +3 -3
- package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue3.js +108 -74
- package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +219 -83
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +92 -58
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js +56 -0
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js +185 -123
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue.js +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js +2 -0
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js +2 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +197 -63
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +244 -161
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnSearchPage/CnSearchPage.vue.js +1 -1
- package/dist/esm/components/CnSearchPage/CnSearchPage.vue2.js +39 -1
- package/dist/esm/components/CnSearchPage/CnSearchPage.vue2.js.map +1 -1
- package/dist/esm/components/CnSearchPage/CnSearchPage.vue3.js +12 -2
- package/dist/esm/components/CnSearchPage/CnSearchPage.vue3.js.map +1 -1
- package/dist/esm/components/CnStepper/CnStepper.vue.js +1 -1
- package/dist/esm/components/CnStepper/CnStepper.vue2.js.map +1 -1
- package/dist/esm/components/CnStepper/CnStepper.vue3.js.map +1 -1
- package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue.js +1 -1
- package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue2.js +51 -2
- package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue2.js.map +1 -1
- package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue3.js +49 -11
- package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue3.js.map +1 -1
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue.js +9 -0
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue.js.map +1 -0
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue2.js +328 -0
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue3.js +85 -0
- package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnTaskFormWidget/index.js +24 -0
- package/dist/esm/components/CnTaskFormWidget/index.js.map +1 -0
- package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue.js +1 -1
- package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue2.js +8 -2
- package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue3.js +16 -3
- package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
- package/dist/esm/composables/indexSources.js +24 -4
- package/dist/esm/composables/indexSources.js.map +1 -1
- package/dist/esm/composables/useFlowStore.js +75 -4
- package/dist/esm/composables/useFlowStore.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js +17 -0
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js +9 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue2.js +15 -0
- package/dist/esm/dialogs/CnFlowEditModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue3.js +13 -3
- package/dist/esm/dialogs/CnFlowEditModal.vue3.js.map +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js +13 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue3.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +52 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +51 -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 +1203 -812
- package/dist/esm/utils/dialogWidths.js +6 -4
- package/dist/esm/utils/dialogWidths.js.map +1 -1
- package/dist/esm/utils/fieldPill.js +77 -0
- package/dist/esm/utils/fieldPill.js.map +1 -0
- package/dist/esm/utils/flowCondition.js +177 -0
- package/dist/esm/utils/flowCondition.js.map +1 -0
- package/dist/esm/utils/flowRunStatus.js +64 -1
- package/dist/esm/utils/flowRunStatus.js.map +1 -1
- package/dist/esm/utils/flowStepList.js +385 -0
- package/dist/esm/utils/flowStepList.js.map +1 -0
- package/dist/esm/utils/libraryWidgetKeys.js +1 -0
- package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
- package/dist/esm/utils/searchRefusal.js +35 -1
- package/dist/esm/utils/searchRefusal.js.map +1 -1
- package/dist/esm/utils/widgetDispatch.js +1 -1
- package/dist/esm/utils/widgetDispatch.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +14837 -11411
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1203 -812
- package/l10n/en.json +52 -1
- package/l10n/nl.json +51 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +116 -9
- package/src/components/CnBuildiqEditButton/CnBuildiqEditButton.vue +12 -1
- package/src/components/CnCardNotices/CnCardNotices.vue +46 -8
- package/src/components/CnCellRenderer/CnCellRenderer.vue +8 -0
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +61 -2
- package/src/components/CnFilesBrowser/filesBrowserColumns.js +10 -4
- package/src/components/CnFlowDetail/CnFlowDetail.vue +110 -12
- package/src/components/CnFlowDetail/CnFlowDryRunResult.vue +163 -5
- package/src/components/CnFlowDetail/CnFlowStepList.vue +408 -0
- package/src/components/CnFlowDetail/CnFlowViewSwitch.vue +117 -0
- package/src/components/CnFlowDetail/index.js +2 -0
- package/src/components/CnFlowsPage/CnFlowBoard.vue +182 -25
- package/src/components/CnFlowsPage/CnFlowEditorPage.vue +101 -3
- package/src/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue +141 -1
- package/src/components/CnIndexPage/CnIndexHeaderMenu.vue +22 -4
- package/src/components/CnIndexPage/CnIndexPage.vue +172 -13
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +148 -4
- package/src/components/CnObjectSidebar/CnFilesTab.vue +3 -0
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +310 -66
- package/src/components/CnSearchPage/CnSearchPage.vue +50 -1
- package/src/components/CnStepper/CnStepper.vue +14 -5
- package/src/components/CnTaskFormFields/CnTaskFormFields.md +1 -0
- package/src/components/CnTaskFormFields/CnTaskFormFields.vue +89 -3
- package/src/components/CnTaskFormWidget/CnTaskFormWidget.vue +400 -0
- package/src/components/CnTaskFormWidget/index.js +23 -0
- package/src/components/CnTasksWidget/CnTasksWidget.vue +17 -3
- package/src/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
- package/src/components/index.js +2 -1
- package/src/composables/indexSources.js +24 -4
- package/src/composables/useFlowStore.js +75 -4
- package/src/css/index-page.css +10 -0
- package/src/dialogs/CnFlowEdgeEditModal.vue +28 -0
- package/src/dialogs/CnFlowEditModal.vue +26 -6
- package/src/dialogs/CnFlowStepPickerModal.vue +13 -1
- package/src/index.js +3 -0
- package/src/utils/dialogWidths.js +6 -4
- package/src/utils/fieldPill.js +73 -0
- package/src/utils/flowCondition.js +173 -0
- package/src/utils/flowRunStatus.js +63 -0
- package/src/utils/flowStepList.js +381 -0
- package/src/utils/libraryWidgetKeys.js +1 -0
- package/src/utils/searchRefusal.js +33 -0
- package/src/utils/widgetDispatch.js +1 -1
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: EUPL-1.2
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The dialog widths of the screens canon (section 5 of UNIFORM-canon.md), by
|
|
6
|
+
* role. `browse` is the search-and-pick dialog with a filter column beside its
|
|
7
|
+
* results (learniq/LqOpenLesmateriaal). No other width is reachable through the
|
|
8
|
+
* `width` prop of a `Cn*` dialog.
|
|
8
9
|
*
|
|
9
|
-
* @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-
|
|
10
|
+
* @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-four-widths
|
|
10
11
|
* @type {Readonly<Record<string, number>>}
|
|
11
12
|
*/
|
|
12
13
|
const DIALOG_WIDTHS = Object.freeze({
|
|
13
14
|
confirm: 560,
|
|
14
15
|
form: 640,
|
|
15
16
|
wizard: 720,
|
|
17
|
+
browse: 1120,
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogWidths.js","sources":["../../../src/utils/dialogWidths.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\n/**\n * The
|
|
1
|
+
{"version":3,"file":"dialogWidths.js","sources":["../../../src/utils/dialogWidths.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\n/**\n * The dialog widths of the screens canon (section 5 of UNIFORM-canon.md), by\n * role. `browse` is the search-and-pick dialog with a filter column beside its\n * results (learniq/LqOpenLesmateriaal). No other width is reachable through the\n * `width` prop of a `Cn*` dialog.\n *\n * @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-four-widths\n * @type {Readonly<Record<string, number>>}\n */\nexport const DIALOG_WIDTHS = Object.freeze({\n\tconfirm: 560,\n\tform: 640,\n\twizard: 720,\n\tbrowse: 1120,\n})\n\n/**\n * Resolve a width role to its role name and pixel width. An unknown or empty\n * `width` falls back to the component's default role, and an unknown default\n * falls back to `form`.\n *\n * @param {string} [width] The `width` prop value.\n * @param {string} [defaultWidth] The component's default role.\n * @return {{role: string, px: number}} The role name and its width in px.\n */\nexport function resolveDialogWidth(width, defaultWidth) {\n\tconst role = [width, defaultWidth].find((candidate) => Object.hasOwn(DIALOG_WIDTHS, candidate)) || 'form'\n\treturn { role, px: DIALOG_WIDTHS[role] }\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;AAC3C,CAAC,OAAO,EAAE,GAAG;AACb,CAAC,IAAI,EAAE,GAAG;AACV,CAAC,MAAM,EAAE,GAAG;AACZ,CAAC,MAAM,EAAE,IAAI;AACb,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE;AACxD,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,IAAI,OAAM;AAC1G,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE;AACzC;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isBadgeVariant } from './badgeVariants.js';
|
|
2
|
+
import { variantForColor } from './headerFieldChips.js';
|
|
3
|
+
import { readPath } from './readPath.js';
|
|
4
|
+
import { evaluateVisibleWhenLocal } from './visibleWhen.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
8
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
9
|
+
*
|
|
10
|
+
* fieldPill: the status pill a widget draws for a row from a pill config, so
|
|
11
|
+
* a record list, grouped cards and a checklist read the same keys.
|
|
12
|
+
*
|
|
13
|
+
* @module utils/fieldPill
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The pill for a row.
|
|
18
|
+
*
|
|
19
|
+
* `{ field, labels?, colorMap?, colorField?, variant?, variantWhen?, hideValues? }`
|
|
20
|
+
* reads the value at `field`: its label through `labels`, its tone through
|
|
21
|
+
* `colorMap` (keys match case-insensitively), else the colour name at
|
|
22
|
+
* `colorField`, else `variant`. `variantWhen` (`[{ when, variant }]`, the first
|
|
23
|
+
* whose local condition holds for the row) wins over all of them.
|
|
24
|
+
*
|
|
25
|
+
* `{ cases: [{ when, label, variant? }], label?, variant? }` takes the first
|
|
26
|
+
* case whose `when` holds, else the pill's own `label`; a label with `{field}`
|
|
27
|
+
* tokens is filled from the row and draws nothing when it fills to ''.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} row The row.
|
|
30
|
+
* @param {object} pill The pill config.
|
|
31
|
+
* @param {object} [options] Options.
|
|
32
|
+
* @param {(text: string) => string} [options.translate] The app's translate.
|
|
33
|
+
* @param {(template: string, row: object) => string} [options.fill] Fill a template from the row (translated).
|
|
34
|
+
* @return {{label: string, variant: string}|null} The pill, or null.
|
|
35
|
+
* @spec openspec/changes/record-list-pill-cases-footer-choice/specs/record-list/spec.md#requirement-a-record-list-row-pill-can-read-a-state-from-several-fields
|
|
36
|
+
* @spec openspec/changes/grouped-cards-pills-and-counts/specs/grouped-cards-widget/spec.md
|
|
37
|
+
*/
|
|
38
|
+
function fieldPill(row, pill, options = {}) {
|
|
39
|
+
const translate = typeof options.translate === 'function' ? options.translate : (text) => text;
|
|
40
|
+
const fill = typeof options.fill === 'function' ? options.fill : (template) => translate(template);
|
|
41
|
+
if (pill && typeof pill === 'object' && Array.isArray(pill.cases)) {
|
|
42
|
+
const found = pill.cases.find((entry) => entry && typeof entry === 'object' && entry.when && evaluateVisibleWhenLocal(entry.when, row || {}));
|
|
43
|
+
const chosen = found || pill;
|
|
44
|
+
if (typeof chosen.label !== 'string' || chosen.label === '') {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
const label = chosen.label.indexOf('{') === -1 ? translate(chosen.label) : fill(chosen.label, row);
|
|
48
|
+
return label === '' ? null : { label, variant: isBadgeVariant(chosen.variant) ? chosen.variant : 'default' }
|
|
49
|
+
}
|
|
50
|
+
if (!pill || typeof pill !== 'object' || !pill.field) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
const raw = readPath(row, pill.field);
|
|
54
|
+
if (raw === null || raw === undefined || raw === '' || typeof raw === 'object') {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
const key = String(raw);
|
|
58
|
+
if (Array.isArray(pill.hideValues) && pill.hideValues.map(String).includes(key)) {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
const labels = pill.labels && typeof pill.labels === 'object' ? pill.labels : {};
|
|
62
|
+
const map = pill.colorMap && typeof pill.colorMap === 'object' ? pill.colorMap : {};
|
|
63
|
+
const found = Object.keys(map).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
64
|
+
const rule = Array.isArray(pill.variantWhen)
|
|
65
|
+
? pill.variantWhen.find((entry) => entry && entry.when && evaluateVisibleWhenLocal(entry.when, row || {}))
|
|
66
|
+
: null;
|
|
67
|
+
const colour = pill.colorField ? readPath(row, pill.colorField) : null;
|
|
68
|
+
const fromRow = typeof colour === 'string' && colour !== '' ? variantForColor(colour) : null;
|
|
69
|
+
const variant = rule ? rule.variant : (found ? map[found] : (fromRow || pill.variant));
|
|
70
|
+
return {
|
|
71
|
+
label: labels[key] ? translate(labels[key]) : key,
|
|
72
|
+
variant: isBadgeVariant(variant) ? variant : 'default',
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { fieldPill };
|
|
77
|
+
//# sourceMappingURL=fieldPill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldPill.js","sources":["../../../src/utils/fieldPill.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * fieldPill: the status pill a widget draws for a row from a pill config, so\n * a record list, grouped cards and a checklist read the same keys.\n *\n * @module utils/fieldPill\n */\nimport { isBadgeVariant } from './badgeVariants.js'\nimport { variantForColor } from './headerFieldChips.js'\nimport { readPath } from './readPath.js'\nimport { evaluateVisibleWhenLocal } from './visibleWhen.js'\n\n/**\n * The pill for a row.\n *\n * `{ field, labels?, colorMap?, colorField?, variant?, variantWhen?, hideValues? }`\n * reads the value at `field`: its label through `labels`, its tone through\n * `colorMap` (keys match case-insensitively), else the colour name at\n * `colorField`, else `variant`. `variantWhen` (`[{ when, variant }]`, the first\n * whose local condition holds for the row) wins over all of them.\n *\n * `{ cases: [{ when, label, variant? }], label?, variant? }` takes the first\n * case whose `when` holds, else the pill's own `label`; a label with `{field}`\n * tokens is filled from the row and draws nothing when it fills to ''.\n *\n * @param {object} row The row.\n * @param {object} pill The pill config.\n * @param {object} [options] Options.\n * @param {(text: string) => string} [options.translate] The app's translate.\n * @param {(template: string, row: object) => string} [options.fill] Fill a template from the row (translated).\n * @return {{label: string, variant: string}|null} The pill, or null.\n * @spec openspec/changes/record-list-pill-cases-footer-choice/specs/record-list/spec.md#requirement-a-record-list-row-pill-can-read-a-state-from-several-fields\n * @spec openspec/changes/grouped-cards-pills-and-counts/specs/grouped-cards-widget/spec.md\n */\nexport function fieldPill(row, pill, options = {}) {\n\tconst translate = typeof options.translate === 'function' ? options.translate : (text) => text\n\tconst fill = typeof options.fill === 'function' ? options.fill : (template) => translate(template)\n\tif (pill && typeof pill === 'object' && Array.isArray(pill.cases)) {\n\t\tconst found = pill.cases.find((entry) => entry && typeof entry === 'object' && entry.when && evaluateVisibleWhenLocal(entry.when, row || {}))\n\t\tconst chosen = found || pill\n\t\tif (typeof chosen.label !== 'string' || chosen.label === '') {\n\t\t\treturn null\n\t\t}\n\t\tconst label = chosen.label.indexOf('{') === -1 ? translate(chosen.label) : fill(chosen.label, row)\n\t\treturn label === '' ? null : { label, variant: isBadgeVariant(chosen.variant) ? chosen.variant : 'default' }\n\t}\n\tif (!pill || typeof pill !== 'object' || !pill.field) {\n\t\treturn null\n\t}\n\tconst raw = readPath(row, pill.field)\n\tif (raw === null || raw === undefined || raw === '' || typeof raw === 'object') {\n\t\treturn null\n\t}\n\tconst key = String(raw)\n\tif (Array.isArray(pill.hideValues) && pill.hideValues.map(String).includes(key)) {\n\t\treturn null\n\t}\n\tconst labels = pill.labels && typeof pill.labels === 'object' ? pill.labels : {}\n\tconst map = pill.colorMap && typeof pill.colorMap === 'object' ? pill.colorMap : {}\n\tconst found = Object.keys(map).find((k) => k.toLowerCase() === key.toLowerCase())\n\tconst rule = Array.isArray(pill.variantWhen)\n\t\t? pill.variantWhen.find((entry) => entry && entry.when && evaluateVisibleWhenLocal(entry.when, row || {}))\n\t\t: null\n\tconst colour = pill.colorField ? readPath(row, pill.colorField) : null\n\tconst fromRow = typeof colour === 'string' && colour !== '' ? variantForColor(colour) : null\n\tconst variant = rule ? rule.variant : (found ? map[found] : (fromRow || pill.variant))\n\treturn {\n\t\tlabel: labels[key] ? translate(labels[key]) : key,\n\t\tvariant: isBadgeVariant(variant) ? variant : 'default',\n\t}\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE;AACnD,CAAC,MAAM,SAAS,GAAG,OAAO,OAAO,CAAC,SAAS,KAAK,UAAU,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,IAAI,KAAK,KAAI;AAC/F,CAAC,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAC;AACnG,CAAC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACpE,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,IAAI,wBAAwB,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,EAAC;AAC/I,EAAE,MAAM,MAAM,GAAG,KAAK,IAAI,KAAI;AAC9B,EAAE,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,KAAK,EAAE,EAAE;AAC/D,GAAG,OAAO,IAAI;AACd,GAAG;AACH,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,C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AC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,EAAC;AAClF,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;AAC7C,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,wBAAwB,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAC5G,IAAI,KAAI;AACR,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,KAAI;AACvE,CAAC,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,KAAI;AAC7F,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,EAAC;AACvF,CAAC,OAAO;AACR,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG;AACnD,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS;AACxD,EAAE;AACF;;;;"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
5
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Readable text for the JSONLogic that routes a flow.
|
|
11
|
+
*
|
|
12
|
+
* The engine evaluates a condition on one of a node's `exits`, and an edge
|
|
13
|
+
* names its exit in `fromExit`; `condition` on the edge itself is read as well
|
|
14
|
+
* because documents carry it. The JSONLogic stays where it is: this module only
|
|
15
|
+
* says it in words.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {unknown} value A candidate condition.
|
|
20
|
+
* @return {boolean} Whether it is a non-empty JSONLogic object.
|
|
21
|
+
*/
|
|
22
|
+
function isLogic(value) {
|
|
23
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {unknown} operand A `{ var }` operand or a plain value.
|
|
28
|
+
* @return {string|null} The field it reads, without the item's `json.` prefix, or null.
|
|
29
|
+
*/
|
|
30
|
+
function fieldOf(operand) {
|
|
31
|
+
if (operand === null || typeof operand !== 'object' || !('var' in operand)) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
const path = Array.isArray(operand.var) ? operand.var[0] : operand.var;
|
|
35
|
+
|
|
36
|
+
return String(path ?? '').replace(/^json\./, '')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {unknown} value A literal operand.
|
|
41
|
+
* @return {string} It as text.
|
|
42
|
+
*/
|
|
43
|
+
function literal(value) {
|
|
44
|
+
return Array.isArray(value) ? value.map(literal).join(', ') : String(value ?? '')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const comparisons = {
|
|
48
|
+
'==': (parts) => translate('nextcloud-vue', '{field} is {value}', parts),
|
|
49
|
+
'===': (parts) => translate('nextcloud-vue', '{field} is {value}', parts),
|
|
50
|
+
'!=': (parts) => translate('nextcloud-vue', '{field} is not {value}', parts),
|
|
51
|
+
'!==': (parts) => translate('nextcloud-vue', '{field} is not {value}', parts),
|
|
52
|
+
'>': (parts) => translate('nextcloud-vue', '{field} is more than {value}', parts),
|
|
53
|
+
'>=': (parts) => translate('nextcloud-vue', '{field} is at least {value}', parts),
|
|
54
|
+
'<': (parts) => translate('nextcloud-vue', '{field} is less than {value}', parts),
|
|
55
|
+
'<=': (parts) => translate('nextcloud-vue', '{field} is at most {value}', parts),
|
|
56
|
+
in: (parts) => translate('nextcloud-vue', '{field} is one of {value}', parts),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const presence = {
|
|
60
|
+
'!!': (field) => translate('nextcloud-vue', '{field} is filled in', { field }),
|
|
61
|
+
'!': (field) => translate('nextcloud-vue', '{field} is empty', { field }),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} op A comparison operator.
|
|
66
|
+
* @param {Array} args Its operands.
|
|
67
|
+
* @return {string|null} The sentence, or null when neither side is a plain field and value.
|
|
68
|
+
*/
|
|
69
|
+
function compare(op, args) {
|
|
70
|
+
const field = fieldOf(args[0]);
|
|
71
|
+
if (field === null || fieldOf(args[1]) !== null) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return comparisons[op]({ field, value: literal(args[1]) })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} op `and` or `or`.
|
|
80
|
+
* @param {Array} args The joined conditions.
|
|
81
|
+
* @return {string|null} The sentence, or null when one part has no words.
|
|
82
|
+
*/
|
|
83
|
+
function join(op, args) {
|
|
84
|
+
const parts = args.map((part) => {
|
|
85
|
+
const text = sentence(part);
|
|
86
|
+
const nested = isLogic(part) && ('and' in part || 'or' in part) && args.length > 1;
|
|
87
|
+
return text !== null && nested ? `(${text})` : text
|
|
88
|
+
});
|
|
89
|
+
if (parts.length === 0 || parts.includes(null)) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return parts.join(op === 'and' ? ` ${translate('nextcloud-vue', 'and')} ` : ` ${translate('nextcloud-vue', 'or')} `)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {unknown} logic A JSONLogic expression.
|
|
98
|
+
* @return {string|null} It in words, or null when it has none.
|
|
99
|
+
*/
|
|
100
|
+
function sentence(logic) {
|
|
101
|
+
if (!isLogic(logic)) {
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
const [op] = Object.keys(logic);
|
|
105
|
+
const args = [].concat(logic[op]);
|
|
106
|
+
if (op === 'and' || op === 'or') {
|
|
107
|
+
return join(op, args)
|
|
108
|
+
}
|
|
109
|
+
if (comparisons[op]) {
|
|
110
|
+
return compare(op, args)
|
|
111
|
+
}
|
|
112
|
+
const field = presence[op] ? fieldOf(args[0]) : null;
|
|
113
|
+
|
|
114
|
+
return field === null ? null : presence[op](field)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A JSONLogic condition in words.
|
|
119
|
+
*
|
|
120
|
+
* @param {object|null} logic The condition.
|
|
121
|
+
* @return {string} The sentence, a fixed line when it cannot be put in words, or '' without a condition.
|
|
122
|
+
*/
|
|
123
|
+
function flowConditionText(logic) {
|
|
124
|
+
if (!isLogic(logic)) {
|
|
125
|
+
return ''
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return sentence(logic) ?? translate('nextcloud-vue', 'A custom condition')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @param {object} edge The stored edge.
|
|
133
|
+
* @param {object|null} source The node the edge leaves.
|
|
134
|
+
* @return {object|null} The exit the edge leaves through, if the node declares it.
|
|
135
|
+
*/
|
|
136
|
+
function exitOf(edge, source) {
|
|
137
|
+
const exits = Array.isArray(source?.exits) ? source.exits : [];
|
|
138
|
+
|
|
139
|
+
return exits.find((exit) => exit && exit.id === edge?.fromExit) || null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The JSONLogic that decides whether a line is taken.
|
|
144
|
+
*
|
|
145
|
+
* @param {object} edge The stored edge.
|
|
146
|
+
* @param {object|null} source The node the edge leaves.
|
|
147
|
+
* @return {object|null} The condition, or null.
|
|
148
|
+
*/
|
|
149
|
+
function flowEdgeCondition(edge, source) {
|
|
150
|
+
if (isLogic(edge?.condition)) {
|
|
151
|
+
return edge.condition
|
|
152
|
+
}
|
|
153
|
+
const exit = exitOf(edge, source);
|
|
154
|
+
|
|
155
|
+
return isLogic(exit?.condition) ? exit.condition : null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* When a line is taken, in words: its condition, or "Otherwise" on the exit
|
|
160
|
+
* without a condition beside exits that have one.
|
|
161
|
+
*
|
|
162
|
+
* @param {object} edge The stored edge.
|
|
163
|
+
* @param {object|null} source The node the edge leaves.
|
|
164
|
+
* @return {string} The text, or '' for a line that is simply followed.
|
|
165
|
+
*/
|
|
166
|
+
function flowEdgeConditionText(edge, source) {
|
|
167
|
+
const logic = flowEdgeCondition(edge, source);
|
|
168
|
+
if (logic !== null) {
|
|
169
|
+
return flowConditionText(logic)
|
|
170
|
+
}
|
|
171
|
+
const branches = exitOf(edge, source) !== null && source.exits.some((exit) => isLogic(exit?.condition));
|
|
172
|
+
|
|
173
|
+
return branches ? translate('nextcloud-vue', 'Otherwise') : ''
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { flowConditionText, flowEdgeCondition, flowEdgeConditionText };
|
|
177
|
+
//# sourceMappingURL=flowCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowCondition.js","sources":["../../../src/utils/flowCondition.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * Readable text for the JSONLogic that routes a flow.\n *\n * The engine evaluates a condition on one of a node's `exits`, and an edge\n * names its exit in `fromExit`; `condition` on the edge itself is read as well\n * because documents carry it. The JSONLogic stays where it is: this module only\n * says it in words.\n */\n\n/**\n * @param {unknown} value A candidate condition.\n * @return {boolean} Whether it is a non-empty JSONLogic object.\n */\nfunction isLogic(value) {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0\n}\n\n/**\n * @param {unknown} operand A `{ var }` operand or a plain value.\n * @return {string|null} The field it reads, without the item's `json.` prefix, or null.\n */\nfunction fieldOf(operand) {\n\tif (operand === null || typeof operand !== 'object' || !('var' in operand)) {\n\t\treturn null\n\t}\n\tconst path = Array.isArray(operand.var) ? operand.var[0] : operand.var\n\n\treturn String(path ?? '').replace(/^json\\./, '')\n}\n\n/**\n * @param {unknown} value A literal operand.\n * @return {string} It as text.\n */\nfunction literal(value) {\n\treturn Array.isArray(value) ? value.map(literal).join(', ') : String(value ?? '')\n}\n\nconst comparisons = {\n\t'==': (parts) => t('nextcloud-vue', '{field} is {value}', parts),\n\t'===': (parts) => t('nextcloud-vue', '{field} is {value}', parts),\n\t'!=': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),\n\t'!==': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),\n\t'>': (parts) => t('nextcloud-vue', '{field} is more than {value}', parts),\n\t'>=': (parts) => t('nextcloud-vue', '{field} is at least {value}', parts),\n\t'<': (parts) => t('nextcloud-vue', '{field} is less than {value}', parts),\n\t'<=': (parts) => t('nextcloud-vue', '{field} is at most {value}', parts),\n\tin: (parts) => t('nextcloud-vue', '{field} is one of {value}', parts),\n}\n\nconst presence = {\n\t'!!': (field) => t('nextcloud-vue', '{field} is filled in', { field }),\n\t'!': (field) => t('nextcloud-vue', '{field} is empty', { field }),\n}\n\n/**\n * @param {string} op A comparison operator.\n * @param {Array} args Its operands.\n * @return {string|null} The sentence, or null when neither side is a plain field and value.\n */\nfunction compare(op, args) {\n\tconst field = fieldOf(args[0])\n\tif (field === null || fieldOf(args[1]) !== null) {\n\t\treturn null\n\t}\n\n\treturn comparisons[op]({ field, value: literal(args[1]) })\n}\n\n/**\n * @param {string} op `and` or `or`.\n * @param {Array} args The joined conditions.\n * @return {string|null} The sentence, or null when one part has no words.\n */\nfunction join(op, args) {\n\tconst parts = args.map((part) => {\n\t\tconst text = sentence(part)\n\t\tconst nested = isLogic(part) && ('and' in part || 'or' in part) && args.length > 1\n\t\treturn text !== null && nested ? `(${text})` : text\n\t})\n\tif (parts.length === 0 || parts.includes(null)) {\n\t\treturn null\n\t}\n\n\treturn parts.join(op === 'and' ? ` ${t('nextcloud-vue', 'and')} ` : ` ${t('nextcloud-vue', 'or')} `)\n}\n\n/**\n * @param {unknown} logic A JSONLogic expression.\n * @return {string|null} It in words, or null when it has none.\n */\nfunction sentence(logic) {\n\tif (!isLogic(logic)) {\n\t\treturn null\n\t}\n\tconst [op] = Object.keys(logic)\n\tconst args = [].concat(logic[op])\n\tif (op === 'and' || op === 'or') {\n\t\treturn join(op, args)\n\t}\n\tif (comparisons[op]) {\n\t\treturn compare(op, args)\n\t}\n\tconst field = presence[op] ? fieldOf(args[0]) : null\n\n\treturn field === null ? null : presence[op](field)\n}\n\n/**\n * A JSONLogic condition in words.\n *\n * @param {object|null} logic The condition.\n * @return {string} The sentence, a fixed line when it cannot be put in words, or '' without a condition.\n */\nexport function flowConditionText(logic) {\n\tif (!isLogic(logic)) {\n\t\treturn ''\n\t}\n\n\treturn sentence(logic) ?? t('nextcloud-vue', 'A custom condition')\n}\n\n/**\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {object|null} The exit the edge leaves through, if the node declares it.\n */\nfunction exitOf(edge, source) {\n\tconst exits = Array.isArray(source?.exits) ? source.exits : []\n\n\treturn exits.find((exit) => exit && exit.id === edge?.fromExit) || null\n}\n\n/**\n * The JSONLogic that decides whether a line is taken.\n *\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {object|null} The condition, or null.\n */\nexport function flowEdgeCondition(edge, source) {\n\tif (isLogic(edge?.condition)) {\n\t\treturn edge.condition\n\t}\n\tconst exit = exitOf(edge, source)\n\n\treturn isLogic(exit?.condition) ? exit.condition : null\n}\n\n/**\n * When a line is taken, in words: its condition, or \"Otherwise\" on the exit\n * without a condition beside exits that have one.\n *\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {string} The text, or '' for a line that is simply followed.\n */\nexport function flowEdgeConditionText(edge, source) {\n\tconst logic = flowEdgeCondition(edge, source)\n\tif (logic !== null) {\n\t\treturn flowConditionText(logic)\n\t}\n\tconst branches = exitOf(edge, source) !== null && source.exits.some((exit) => isLogic(exit?.condition))\n\n\treturn branches ? t('nextcloud-vue', 'Otherwise') : ''\n}\n"],"names":["t"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,KAAK,EAAE;AACxB,CAAC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;AAC7G,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,OAAO,EAAE;AAC1B,CAAC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,EAAE,KAAK,IAAI,OAAO,CAAC,EAAE;AAC7E,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAG;AACvE;AACA,CAAC,OAAO,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACjD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,KAAK,EAA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68 @@ function flowRunStatuses() {
|
|
|
33
33
|
*/
|
|
34
34
|
const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter'];
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The engine statuses a run waits in for a person or a time.
|
|
38
|
+
*/
|
|
39
|
+
const FLOW_RUN_WAITING_STATUSES = ['suspended', 'awaiting_consent'];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The objects a run works with, each under its role.
|
|
43
|
+
*
|
|
44
|
+
* `subjects` is what the run declared; a run that declared none still has the
|
|
45
|
+
* object its trigger fired on.
|
|
46
|
+
*
|
|
47
|
+
* @param {object} run A run.
|
|
48
|
+
* @return {Array<{role: string, uuid: string}>} The subjects.
|
|
49
|
+
*/
|
|
50
|
+
function flowRunSubjects(run) {
|
|
51
|
+
const declared = Object.entries(run?.subjects || {}).map(([role, subject]) => ({ role, uuid: String(subject?.uuid ?? '') }));
|
|
52
|
+
if (declared.length > 0) {
|
|
53
|
+
return declared
|
|
54
|
+
}
|
|
55
|
+
const uuid = run?.subjectUuid ?? run?.subject?.uuid;
|
|
56
|
+
|
|
57
|
+
return uuid ? [{ role: '', uuid: String(uuid) }] : []
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The tile over the distinct subjects of some runs.
|
|
62
|
+
*
|
|
63
|
+
* @param {Array<object>} runs The runs.
|
|
64
|
+
* @return {object} The tile: how many objects, and under which roles.
|
|
65
|
+
*/
|
|
66
|
+
function subjectsCounter(runs) {
|
|
67
|
+
const subjects = runs.flatMap(flowRunSubjects);
|
|
68
|
+
const roles = [...new Set(subjects.map((subject) => subject.role).filter(Boolean))];
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
id: 'subjects',
|
|
72
|
+
label: translate('nextcloud-vue', 'Subjects'),
|
|
73
|
+
count: new Set(subjects.map((subject) => subject.uuid)).size,
|
|
74
|
+
note: roles.join(', '),
|
|
75
|
+
variant: 'default',
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The counters above a run history (board OrFlowRuns).
|
|
81
|
+
*
|
|
82
|
+
* @param {Array<object>} runs The runs in the list.
|
|
83
|
+
* @return {Array<{id: string, label: string, count: number, note: string, variant: string}>} The tiles.
|
|
84
|
+
*/
|
|
85
|
+
function flowRunCounters(runs) {
|
|
86
|
+
const counted = (statuses) => runs.filter((run) => statuses.includes(run.status)).length;
|
|
87
|
+
const finished = counted(['completed']);
|
|
88
|
+
const share = runs.length > 0 ? `${Math.round((finished / runs.length) * 100)}%` : '';
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
{ id: 'runs', label: translate('nextcloud-vue', 'Runs'), count: runs.length, note: '', variant: 'default' },
|
|
92
|
+
{ id: 'finished', label: translate('nextcloud-vue', 'Finished'), count: finished, note: share, variant: 'success' },
|
|
93
|
+
{ id: 'failed', label: translate('nextcloud-vue', 'Failed'), count: counted(FLOW_RUN_ERROR_STATUSES), note: '', variant: 'error' },
|
|
94
|
+
{ id: 'waiting', label: translate('nextcloud-vue', 'Waiting'), count: counted(FLOW_RUN_WAITING_STATUSES), note: '', variant: 'warning' },
|
|
95
|
+
subjectsCounter(runs),
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { FLOW_RUN_ERROR_STATUSES, flowRunCounters, flowRunStatuses, flowRunSubjects };
|
|
37
100
|
//# sourceMappingURL=flowRunStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowRunStatus.js","sources":["../../../src/utils/flowRunStatus.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * The run statuses a flow list distinguishes, as label and pill colour.\n *\n * The engine's own vocabulary (`FlowRun::STATUS_*`). A status the engine\n * adds later falls through to its raw value with the neutral colour rather\n * than disappearing.\n *\n * @return {Record<string, {label: string, variant: string}>} By engine status.\n */\nexport function flowRunStatuses() {\n\treturn {\n\t\tcompleted: { label: t('nextcloud-vue', 'Finished'), variant: 'success' },\n\t\tfailed: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tdead_letter: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tstopped: { label: t('nextcloud-vue', 'Stopped early'), variant: 'warning' },\n\t\tqueued: { label: t('nextcloud-vue', 'Queued'), variant: 'info' },\n\t\trunning: { label: t('nextcloud-vue', 'Running'), variant: 'info' },\n\t\tsuspended: { label: t('nextcloud-vue', 'Waiting'), variant: 'info' },\n\t\tawaiting_consent: { label: t('nextcloud-vue', 'Awaiting consent'), variant: 'warning' },\n\t}\n}\n\n/**\n * The engine statuses a \"with errors\" filter counts as an error.\n */\nexport const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter']\n"],"names":["t"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,GAAG;AAClC,CAAC,OAAO;AACR,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC1E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACnE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACxE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC7E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AAClE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACpE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACtE,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,kBAAkB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AACzF,EAAE;AACF,CAAC;AACD;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG,CAAC,QAAQ,EAAE,aAAa;;;;"}
|
|
1
|
+
{"version":3,"file":"flowRunStatus.js","sources":["../../../src/utils/flowRunStatus.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * The run statuses a flow list distinguishes, as label and pill colour.\n *\n * The engine's own vocabulary (`FlowRun::STATUS_*`). A status the engine\n * adds later falls through to its raw value with the neutral colour rather\n * than disappearing.\n *\n * @return {Record<string, {label: string, variant: string}>} By engine status.\n */\nexport function flowRunStatuses() {\n\treturn {\n\t\tcompleted: { label: t('nextcloud-vue', 'Finished'), variant: 'success' },\n\t\tfailed: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tdead_letter: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tstopped: { label: t('nextcloud-vue', 'Stopped early'), variant: 'warning' },\n\t\tqueued: { label: t('nextcloud-vue', 'Queued'), variant: 'info' },\n\t\trunning: { label: t('nextcloud-vue', 'Running'), variant: 'info' },\n\t\tsuspended: { label: t('nextcloud-vue', 'Waiting'), variant: 'info' },\n\t\tawaiting_consent: { label: t('nextcloud-vue', 'Awaiting consent'), variant: 'warning' },\n\t}\n}\n\n/**\n * The engine statuses a \"with errors\" filter counts as an error.\n */\nexport const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter']\n\n/**\n * The engine statuses a run waits in for a person or a time.\n */\nconst FLOW_RUN_WAITING_STATUSES = ['suspended', 'awaiting_consent']\n\n/**\n * The objects a run works with, each under its role.\n *\n * `subjects` is what the run declared; a run that declared none still has the\n * object its trigger fired on.\n *\n * @param {object} run A run.\n * @return {Array<{role: string, uuid: string}>} The subjects.\n */\nexport function flowRunSubjects(run) {\n\tconst declared = Object.entries(run?.subjects || {}).map(([role, subject]) => ({ role, uuid: String(subject?.uuid ?? '') }))\n\tif (declared.length > 0) {\n\t\treturn declared\n\t}\n\tconst uuid = run?.subjectUuid ?? run?.subject?.uuid\n\n\treturn uuid ? [{ role: '', uuid: String(uuid) }] : []\n}\n\n/**\n * The tile over the distinct subjects of some runs.\n *\n * @param {Array<object>} runs The runs.\n * @return {object} The tile: how many objects, and under which roles.\n */\nfunction subjectsCounter(runs) {\n\tconst subjects = runs.flatMap(flowRunSubjects)\n\tconst roles = [...new Set(subjects.map((subject) => subject.role).filter(Boolean))]\n\n\treturn {\n\t\tid: 'subjects',\n\t\tlabel: t('nextcloud-vue', 'Subjects'),\n\t\tcount: new Set(subjects.map((subject) => subject.uuid)).size,\n\t\tnote: roles.join(', '),\n\t\tvariant: 'default',\n\t}\n}\n\n/**\n * The counters above a run history (board OrFlowRuns).\n *\n * @param {Array<object>} runs The runs in the list.\n * @return {Array<{id: string, label: string, count: number, note: string, variant: string}>} The tiles.\n */\nexport function flowRunCounters(runs) {\n\tconst counted = (statuses) => runs.filter((run) => statuses.includes(run.status)).length\n\tconst finished = counted(['completed'])\n\tconst share = runs.length > 0 ? `${Math.round((finished / runs.length) * 100)}%` : ''\n\n\treturn [\n\t\t{ id: 'runs', label: t('nextcloud-vue', 'Runs'), count: runs.length, note: '', variant: 'default' },\n\t\t{ id: 'finished', label: t('nextcloud-vue', 'Finished'), count: finished, note: share, variant: 'success' },\n\t\t{ id: 'failed', label: t('nextcloud-vue', 'Failed'), count: counted(FLOW_RUN_ERROR_STATUSES), note: '', variant: 'error' },\n\t\t{ id: 'waiting', label: t('nextcloud-vue', 'Waiting'), count: counted(FLOW_RUN_WAITING_STATUSES), note: '', variant: 'warning' },\n\t\tsubjectsCounter(runs),\n\t]\n}\n"],"names":["t"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,GAAG;AAClC,CAAC,OAAO;AACR,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC1E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACnE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACxE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC7E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AAClE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACpE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACtE,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,kBAAkB,CAAC,EAAE,OAAO,EAAE,S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