@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
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
3
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Readable text for the JSONLogic that routes a flow.
|
|
10
|
+
*
|
|
11
|
+
* The engine evaluates a condition on one of a node's `exits`, and an edge
|
|
12
|
+
* names its exit in `fromExit`; `condition` on the edge itself is read as well
|
|
13
|
+
* because documents carry it. The JSONLogic stays where it is: this module only
|
|
14
|
+
* says it in words.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {unknown} value A candidate condition.
|
|
19
|
+
* @return {boolean} Whether it is a non-empty JSONLogic object.
|
|
20
|
+
*/
|
|
21
|
+
function isLogic(value) {
|
|
22
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {unknown} operand A `{ var }` operand or a plain value.
|
|
27
|
+
* @return {string|null} The field it reads, without the item's `json.` prefix, or null.
|
|
28
|
+
*/
|
|
29
|
+
function fieldOf(operand) {
|
|
30
|
+
if (operand === null || typeof operand !== 'object' || !('var' in operand)) {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
const path = Array.isArray(operand.var) ? operand.var[0] : operand.var
|
|
34
|
+
|
|
35
|
+
return String(path ?? '').replace(/^json\./, '')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {unknown} value A literal operand.
|
|
40
|
+
* @return {string} It as text.
|
|
41
|
+
*/
|
|
42
|
+
function literal(value) {
|
|
43
|
+
return Array.isArray(value) ? value.map(literal).join(', ') : String(value ?? '')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const comparisons = {
|
|
47
|
+
'==': (parts) => t('nextcloud-vue', '{field} is {value}', parts),
|
|
48
|
+
'===': (parts) => t('nextcloud-vue', '{field} is {value}', parts),
|
|
49
|
+
'!=': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),
|
|
50
|
+
'!==': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),
|
|
51
|
+
'>': (parts) => t('nextcloud-vue', '{field} is more than {value}', parts),
|
|
52
|
+
'>=': (parts) => t('nextcloud-vue', '{field} is at least {value}', parts),
|
|
53
|
+
'<': (parts) => t('nextcloud-vue', '{field} is less than {value}', parts),
|
|
54
|
+
'<=': (parts) => t('nextcloud-vue', '{field} is at most {value}', parts),
|
|
55
|
+
in: (parts) => t('nextcloud-vue', '{field} is one of {value}', parts),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const presence = {
|
|
59
|
+
'!!': (field) => t('nextcloud-vue', '{field} is filled in', { field }),
|
|
60
|
+
'!': (field) => t('nextcloud-vue', '{field} is empty', { field }),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} op A comparison operator.
|
|
65
|
+
* @param {Array} args Its operands.
|
|
66
|
+
* @return {string|null} The sentence, or null when neither side is a plain field and value.
|
|
67
|
+
*/
|
|
68
|
+
function compare(op, args) {
|
|
69
|
+
const field = fieldOf(args[0])
|
|
70
|
+
if (field === null || fieldOf(args[1]) !== null) {
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return comparisons[op]({ field, value: literal(args[1]) })
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} op `and` or `or`.
|
|
79
|
+
* @param {Array} args The joined conditions.
|
|
80
|
+
* @return {string|null} The sentence, or null when one part has no words.
|
|
81
|
+
*/
|
|
82
|
+
function join(op, args) {
|
|
83
|
+
const parts = args.map((part) => {
|
|
84
|
+
const text = sentence(part)
|
|
85
|
+
const nested = isLogic(part) && ('and' in part || 'or' in part) && args.length > 1
|
|
86
|
+
return text !== null && nested ? `(${text})` : text
|
|
87
|
+
})
|
|
88
|
+
if (parts.length === 0 || parts.includes(null)) {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return parts.join(op === 'and' ? ` ${t('nextcloud-vue', 'and')} ` : ` ${t('nextcloud-vue', 'or')} `)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {unknown} logic A JSONLogic expression.
|
|
97
|
+
* @return {string|null} It in words, or null when it has none.
|
|
98
|
+
*/
|
|
99
|
+
function sentence(logic) {
|
|
100
|
+
if (!isLogic(logic)) {
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
const [op] = Object.keys(logic)
|
|
104
|
+
const args = [].concat(logic[op])
|
|
105
|
+
if (op === 'and' || op === 'or') {
|
|
106
|
+
return join(op, args)
|
|
107
|
+
}
|
|
108
|
+
if (comparisons[op]) {
|
|
109
|
+
return compare(op, args)
|
|
110
|
+
}
|
|
111
|
+
const field = presence[op] ? fieldOf(args[0]) : null
|
|
112
|
+
|
|
113
|
+
return field === null ? null : presence[op](field)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A JSONLogic condition in words.
|
|
118
|
+
*
|
|
119
|
+
* @param {object|null} logic The condition.
|
|
120
|
+
* @return {string} The sentence, a fixed line when it cannot be put in words, or '' without a condition.
|
|
121
|
+
*/
|
|
122
|
+
export function flowConditionText(logic) {
|
|
123
|
+
if (!isLogic(logic)) {
|
|
124
|
+
return ''
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return sentence(logic) ?? t('nextcloud-vue', 'A custom condition')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {object} edge The stored edge.
|
|
132
|
+
* @param {object|null} source The node the edge leaves.
|
|
133
|
+
* @return {object|null} The exit the edge leaves through, if the node declares it.
|
|
134
|
+
*/
|
|
135
|
+
function exitOf(edge, source) {
|
|
136
|
+
const exits = Array.isArray(source?.exits) ? source.exits : []
|
|
137
|
+
|
|
138
|
+
return exits.find((exit) => exit && exit.id === edge?.fromExit) || null
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The JSONLogic that decides whether a line is taken.
|
|
143
|
+
*
|
|
144
|
+
* @param {object} edge The stored edge.
|
|
145
|
+
* @param {object|null} source The node the edge leaves.
|
|
146
|
+
* @return {object|null} The condition, or null.
|
|
147
|
+
*/
|
|
148
|
+
export function flowEdgeCondition(edge, source) {
|
|
149
|
+
if (isLogic(edge?.condition)) {
|
|
150
|
+
return edge.condition
|
|
151
|
+
}
|
|
152
|
+
const exit = exitOf(edge, source)
|
|
153
|
+
|
|
154
|
+
return isLogic(exit?.condition) ? exit.condition : null
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* When a line is taken, in words: its condition, or "Otherwise" on the exit
|
|
159
|
+
* without a condition beside exits that have one.
|
|
160
|
+
*
|
|
161
|
+
* @param {object} edge The stored edge.
|
|
162
|
+
* @param {object|null} source The node the edge leaves.
|
|
163
|
+
* @return {string} The text, or '' for a line that is simply followed.
|
|
164
|
+
*/
|
|
165
|
+
export function flowEdgeConditionText(edge, source) {
|
|
166
|
+
const logic = flowEdgeCondition(edge, source)
|
|
167
|
+
if (logic !== null) {
|
|
168
|
+
return flowConditionText(logic)
|
|
169
|
+
}
|
|
170
|
+
const branches = exitOf(edge, source) !== null && source.exits.some((exit) => isLogic(exit?.condition))
|
|
171
|
+
|
|
172
|
+
return branches ? t('nextcloud-vue', 'Otherwise') : ''
|
|
173
|
+
}
|
|
@@ -31,3 +31,66 @@ export function flowRunStatuses() {
|
|
|
31
31
|
* The engine statuses a "with errors" filter counts as an error.
|
|
32
32
|
*/
|
|
33
33
|
export const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter']
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The engine statuses a run waits in for a person or a time.
|
|
37
|
+
*/
|
|
38
|
+
const FLOW_RUN_WAITING_STATUSES = ['suspended', 'awaiting_consent']
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The objects a run works with, each under its role.
|
|
42
|
+
*
|
|
43
|
+
* `subjects` is what the run declared; a run that declared none still has the
|
|
44
|
+
* object its trigger fired on.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} run A run.
|
|
47
|
+
* @return {Array<{role: string, uuid: string}>} The subjects.
|
|
48
|
+
*/
|
|
49
|
+
export function flowRunSubjects(run) {
|
|
50
|
+
const declared = Object.entries(run?.subjects || {}).map(([role, subject]) => ({ role, uuid: String(subject?.uuid ?? '') }))
|
|
51
|
+
if (declared.length > 0) {
|
|
52
|
+
return declared
|
|
53
|
+
}
|
|
54
|
+
const uuid = run?.subjectUuid ?? run?.subject?.uuid
|
|
55
|
+
|
|
56
|
+
return uuid ? [{ role: '', uuid: String(uuid) }] : []
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The tile over the distinct subjects of some runs.
|
|
61
|
+
*
|
|
62
|
+
* @param {Array<object>} runs The runs.
|
|
63
|
+
* @return {object} The tile: how many objects, and under which roles.
|
|
64
|
+
*/
|
|
65
|
+
function subjectsCounter(runs) {
|
|
66
|
+
const subjects = runs.flatMap(flowRunSubjects)
|
|
67
|
+
const roles = [...new Set(subjects.map((subject) => subject.role).filter(Boolean))]
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
id: 'subjects',
|
|
71
|
+
label: t('nextcloud-vue', 'Subjects'),
|
|
72
|
+
count: new Set(subjects.map((subject) => subject.uuid)).size,
|
|
73
|
+
note: roles.join(', '),
|
|
74
|
+
variant: 'default',
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The counters above a run history (board OrFlowRuns).
|
|
80
|
+
*
|
|
81
|
+
* @param {Array<object>} runs The runs in the list.
|
|
82
|
+
* @return {Array<{id: string, label: string, count: number, note: string, variant: string}>} The tiles.
|
|
83
|
+
*/
|
|
84
|
+
export function flowRunCounters(runs) {
|
|
85
|
+
const counted = (statuses) => runs.filter((run) => statuses.includes(run.status)).length
|
|
86
|
+
const finished = counted(['completed'])
|
|
87
|
+
const share = runs.length > 0 ? `${Math.round((finished / runs.length) * 100)}%` : ''
|
|
88
|
+
|
|
89
|
+
return [
|
|
90
|
+
{ id: 'runs', label: t('nextcloud-vue', 'Runs'), count: runs.length, note: '', variant: 'default' },
|
|
91
|
+
{ id: 'finished', label: t('nextcloud-vue', 'Finished'), count: finished, note: share, variant: 'success' },
|
|
92
|
+
{ id: 'failed', label: t('nextcloud-vue', 'Failed'), count: counted(FLOW_RUN_ERROR_STATUSES), note: '', variant: 'error' },
|
|
93
|
+
{ id: 'waiting', label: t('nextcloud-vue', 'Waiting'), count: counted(FLOW_RUN_WAITING_STATUSES), note: '', variant: 'warning' },
|
|
94
|
+
subjectsCounter(runs),
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
3
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The list reading of a flow: the trigger, then the steps in run order.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here is stored. The rows are derived from the flow document the
|
|
12
|
+
* canvas draws and every change goes back into that document, so the two views
|
|
13
|
+
* cannot drift.
|
|
14
|
+
*
|
|
15
|
+
* A `graph` is `{ nodes, lines, startIds, roleOf }`: the document's nodes, the
|
|
16
|
+
* store's `canvasEdges`, its `startNodeIds` and its `roleOfNodeType`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} node A flow node.
|
|
21
|
+
* @return {{x: number, y: number}} Where it stands on the canvas.
|
|
22
|
+
*/
|
|
23
|
+
function placeOf(node) {
|
|
24
|
+
return { x: node.position?.x ?? node.x ?? 0, y: node.position?.y ?? node.y ?? 0 }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {Array<object>} lines The lines.
|
|
29
|
+
* @param {string} key `source` or `target`.
|
|
30
|
+
* @return {Map<string, Array<object>>} The lines by that end.
|
|
31
|
+
*/
|
|
32
|
+
function linesBy(lines, key) {
|
|
33
|
+
const grouped = new Map()
|
|
34
|
+
lines.forEach((line) => grouped.set(line[key], [...(grouped.get(line[key]) || []), line]))
|
|
35
|
+
|
|
36
|
+
return grouped
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The lines that lead onward from the starts. A line back into a step still
|
|
41
|
+
* open is a loop, and a loop has no order to contribute.
|
|
42
|
+
*
|
|
43
|
+
* @param {object} graph The graph.
|
|
44
|
+
* @param graph.lines
|
|
45
|
+
* @param graph.startIds
|
|
46
|
+
* @return {Array<object>} The lines without those going back.
|
|
47
|
+
*/
|
|
48
|
+
function forwardLines({ lines, startIds }) {
|
|
49
|
+
const outgoing = linesBy(lines, 'source')
|
|
50
|
+
const seen = new Map()
|
|
51
|
+
const kept = []
|
|
52
|
+
const visit = (id) => {
|
|
53
|
+
seen.set(id, 'open')
|
|
54
|
+
for (const line of outgoing.get(id) || []) {
|
|
55
|
+
if (seen.get(line.target) !== 'open') {
|
|
56
|
+
kept.push(line)
|
|
57
|
+
}
|
|
58
|
+
if (!seen.has(line.target)) {
|
|
59
|
+
visit(line.target)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
seen.set(id, 'done')
|
|
63
|
+
}
|
|
64
|
+
startIds.filter((id) => !seen.has(id)).forEach(visit)
|
|
65
|
+
|
|
66
|
+
return kept
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* How many steps deep each reached node is, by its longest way in.
|
|
71
|
+
*
|
|
72
|
+
* @param {object} graph The graph.
|
|
73
|
+
* @return {Map<string, number>} The depth per node id; a loose node has none.
|
|
74
|
+
*/
|
|
75
|
+
function depths(graph) {
|
|
76
|
+
const lines = forwardLines(graph)
|
|
77
|
+
const depth = new Map(graph.startIds.map((id) => [id, 0]))
|
|
78
|
+
const deepen = ({ source, target }) => {
|
|
79
|
+
if (depth.has(source) && (depth.get(target) ?? -1) <= depth.get(source)) {
|
|
80
|
+
depth.set(target, depth.get(source) + 1)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
graph.nodes.forEach(() => lines.forEach(deepen))
|
|
84
|
+
|
|
85
|
+
return depth
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The nodes in run order: by depth, then top to bottom and left to right as
|
|
90
|
+
* they stand on the canvas. Nodes nothing leads to come last.
|
|
91
|
+
*
|
|
92
|
+
* @param {object} graph The graph.
|
|
93
|
+
* @return {Array<{node: object, loose: boolean}>} The ordered nodes.
|
|
94
|
+
*/
|
|
95
|
+
export function orderFlowNodes(graph) {
|
|
96
|
+
const depth = depths(graph)
|
|
97
|
+
const entries = graph.nodes.map((node, index) => ({
|
|
98
|
+
node,
|
|
99
|
+
index,
|
|
100
|
+
loose: !depth.has(node.id),
|
|
101
|
+
depth: depth.get(node.id) ?? Infinity,
|
|
102
|
+
...placeOf(node),
|
|
103
|
+
}))
|
|
104
|
+
const byDepth = (a, b) => (a.loose === b.loose ? (a.loose ? 0 : a.depth - b.depth) : (a.loose ? 1 : -1))
|
|
105
|
+
|
|
106
|
+
return entries.sort((a, b) => byDepth(a, b) || a.y - b.y || a.x - b.x || a.index - b.index)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {object} line A drawn line.
|
|
111
|
+
* @return {string} When it is taken: its name, else its condition in words.
|
|
112
|
+
*/
|
|
113
|
+
function lineText(line) {
|
|
114
|
+
return line.data?.label || line.data?.conditionText || ''
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The chip on a step: when the line into it is taken. A plain line in means
|
|
119
|
+
* the step is reached regardless, so there is no condition to name.
|
|
120
|
+
*
|
|
121
|
+
* @param {Array<object>} into The lines into the step.
|
|
122
|
+
* @return {string} The chip's text, or ''.
|
|
123
|
+
*/
|
|
124
|
+
function whenText(into) {
|
|
125
|
+
const texts = into.map(lineText)
|
|
126
|
+
if (texts.length === 0 || texts.includes('')) {
|
|
127
|
+
return ''
|
|
128
|
+
}
|
|
129
|
+
if (into.every((line) => !line.data?.label && !line.data?.condition)) {
|
|
130
|
+
return texts[0]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return t('nextcloud-vue', 'Only if {condition}', { condition: texts.join(` ${t('nextcloud-vue', 'or')} `) })
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {object} graph The graph.
|
|
138
|
+
* @param {string} id A node id.
|
|
139
|
+
* @return {{into: Array<object>, out: Array<object>}} The lines of that node.
|
|
140
|
+
*/
|
|
141
|
+
function linesOf(graph, id) {
|
|
142
|
+
return {
|
|
143
|
+
into: graph.lines.filter((line) => line.target === id),
|
|
144
|
+
out: graph.lines.filter((line) => line.source === id),
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {object} node A node.
|
|
150
|
+
* @return {boolean} Whether it routes through declared exits.
|
|
151
|
+
*/
|
|
152
|
+
function branches(node) {
|
|
153
|
+
return Array.isArray(node.exits) && node.exits.length > 0
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {object} graph The graph.
|
|
158
|
+
* @param {object} node A node.
|
|
159
|
+
* @return {boolean} Whether it may trade places with a neighbour.
|
|
160
|
+
*/
|
|
161
|
+
function isMovable(graph, node) {
|
|
162
|
+
return !branches(node) && !node.start && !node.initial && graph.roleOf(node.type) === 'step'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Whether two neighbours in the list are a plain link of one chain: only then
|
|
167
|
+
* does swapping them mean what the arrows promise. Steps on a branch keep their
|
|
168
|
+
* place until the canvas moves them.
|
|
169
|
+
*
|
|
170
|
+
* @param {object} graph The graph.
|
|
171
|
+
* @param {Array<object>} pair The first and the second node.
|
|
172
|
+
* @return {boolean} Whether they can swap.
|
|
173
|
+
*/
|
|
174
|
+
function canSwap(graph, [first, second]) {
|
|
175
|
+
if (!isMovable(graph, first) || !isMovable(graph, second)) {
|
|
176
|
+
return false
|
|
177
|
+
}
|
|
178
|
+
const { out } = linesOf(graph, first.id)
|
|
179
|
+
const { into, out: onward } = linesOf(graph, second.id)
|
|
180
|
+
|
|
181
|
+
return out.length === 1 && out[0].target === second.id && into.length === 1 && onward.length <= 1
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @param {object} graph The graph.
|
|
186
|
+
* @return {Array<object>} The steps in order, triggers left out.
|
|
187
|
+
*/
|
|
188
|
+
function orderedSteps(graph) {
|
|
189
|
+
return orderFlowNodes(graph).filter(({ node }) => graph.roleOf(node.type) !== 'trigger')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The two steps a move would swap.
|
|
194
|
+
*
|
|
195
|
+
* @param {object} graph The graph.
|
|
196
|
+
* @param {{id: string, by: number}} move The step and -1 (up) or 1 (down).
|
|
197
|
+
* @return {Array<string>|null} Their ids, first in the list first; null when the move cannot be made.
|
|
198
|
+
*/
|
|
199
|
+
export function flowStepSwap(graph, { id, by }) {
|
|
200
|
+
const steps = orderedSteps(graph).map((entry) => entry.node)
|
|
201
|
+
const index = steps.findIndex((node) => node.id === id)
|
|
202
|
+
const pair = by < 0 ? [steps[index - 1], steps[index]] : [steps[index], steps[index + 1]]
|
|
203
|
+
if (index < 0 || !pair[0] || !pair[1]) {
|
|
204
|
+
return null
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return canSwap(graph, pair) ? pair.map((node) => node.id) : null
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Where a step's lines lead, as the routes under a branching step.
|
|
212
|
+
*
|
|
213
|
+
* @param {Array<object>} out The step's outgoing lines.
|
|
214
|
+
* @param {object} names `{ numbers, titleOf }`: step numbers by id and a name fallback.
|
|
215
|
+
* @param names.numbers
|
|
216
|
+
* @param names.titleOf
|
|
217
|
+
* @return {Array<{id: string, label: string, to: string}>} The routes; none when it does not branch.
|
|
218
|
+
*/
|
|
219
|
+
function routesOf(out, { numbers, titleOf }) {
|
|
220
|
+
if (out.length < 2) {
|
|
221
|
+
return []
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return out.map((line) => ({
|
|
225
|
+
id: line.id,
|
|
226
|
+
label: lineText(line) || t('nextcloud-vue', 'Otherwise'),
|
|
227
|
+
to: numbers.has(line.target) ? t('nextcloud-vue', 'Step {n}', { n: numbers.get(line.target) }) : titleOf(line.target),
|
|
228
|
+
}))
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @param {object} graph The graph.
|
|
233
|
+
* @param {object} names `{ numbers, titleOf }`: step numbers by id and a name by node.
|
|
234
|
+
* @return {(entry: {node: object, loose: boolean}) => object} Builds one row.
|
|
235
|
+
*/
|
|
236
|
+
function rowBuilder(graph, names) {
|
|
237
|
+
return ({ node, loose }) => {
|
|
238
|
+
const { into, out } = linesOf(graph, node.id)
|
|
239
|
+
|
|
240
|
+
return { id: node.id, node, role: graph.roleOf(node.type), loose, n: names.numbers.get(node.id), when: whenText(into), routes: routesOf(out, names) }
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The rows of the list.
|
|
246
|
+
*
|
|
247
|
+
* @param {object} graph The graph.
|
|
248
|
+
* @param {(node: object) => string} titleOf The name a node goes by.
|
|
249
|
+
* @return {{triggers: Array<object>, steps: Array<object>}} The rows.
|
|
250
|
+
*/
|
|
251
|
+
export function flowStepRows(graph, titleOf) {
|
|
252
|
+
const ordered = orderFlowNodes(graph)
|
|
253
|
+
const steps = ordered.filter(({ node }) => graph.roleOf(node.type) !== 'trigger')
|
|
254
|
+
const numbers = new Map(steps.map(({ node }, index) => [node.id, index + 1]))
|
|
255
|
+
const row = rowBuilder(graph, { numbers, titleOf: (id) => titleOf(graph.nodes.find((node) => node.id === id) || { id }) })
|
|
256
|
+
const swaps = (index) => index >= 0 && index + 1 < steps.length && canSwap(graph, [steps[index].node, steps[index + 1].node])
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
triggers: ordered.filter(({ node }) => graph.roleOf(node.type) === 'trigger').map(row),
|
|
260
|
+
steps: steps.map((entry, index) => ({ ...row(entry), canMoveUp: swaps(index - 1), canMoveDown: swaps(index) })),
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @param {string|Array<string>} value An edge endpoint, one id or a list.
|
|
266
|
+
* @param {(id: string) => string} change What becomes of an id.
|
|
267
|
+
* @return {string|Array<string>} The endpoint with the ids changed.
|
|
268
|
+
*/
|
|
269
|
+
function mapEndpoint(value, change) {
|
|
270
|
+
return Array.isArray(value) ? value.map(change) : change(value)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @param {object} edge A stored edge.
|
|
275
|
+
* @param {object} change `{ keys, map }`: the endpoint keys to touch and what becomes of an id.
|
|
276
|
+
* @param change.keys
|
|
277
|
+
* @param change.map
|
|
278
|
+
* @return {object} The edge with those endpoints changed, in its own spelling.
|
|
279
|
+
*/
|
|
280
|
+
function mapEdge(edge, { keys, map }) {
|
|
281
|
+
const next = { ...edge }
|
|
282
|
+
keys.filter((key) => key in next).forEach((key) => {
|
|
283
|
+
next[key] = mapEndpoint(next[key], map)
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
return next
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Swap two steps in the stored edges, whichever spelling they use. What led
|
|
291
|
+
* into the first now leads into the second, and the other way round.
|
|
292
|
+
*
|
|
293
|
+
* @param {Array<object>} edges The stored edges.
|
|
294
|
+
* @param {Array<string>} pair The two ids.
|
|
295
|
+
* @return {Array<object>} The new edges.
|
|
296
|
+
*/
|
|
297
|
+
export function swapStepEdges(edges, [first, second]) {
|
|
298
|
+
const map = (id) => (id === first ? second : (id === second ? first : id))
|
|
299
|
+
|
|
300
|
+
return edges.map((edge) => mapEdge(edge, { keys: ['from', 'to', 'source', 'target'], map }))
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @param {object} node A node.
|
|
305
|
+
* @return {object} Its canvas place, in the spellings it carries.
|
|
306
|
+
*/
|
|
307
|
+
function placeFields(node) {
|
|
308
|
+
const { x, y, position } = node
|
|
309
|
+
|
|
310
|
+
return { x, y, position }
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Swap two steps' places on the canvas, so the canvas reads as the list does.
|
|
315
|
+
*
|
|
316
|
+
* @param {Array<object>} nodes The nodes.
|
|
317
|
+
* @param {Array<string>} pair The two ids.
|
|
318
|
+
* @return {Array<object>} The new nodes.
|
|
319
|
+
*/
|
|
320
|
+
export function swapStepPlaces(nodes, [first, second]) {
|
|
321
|
+
const a = nodes.find((node) => node.id === first)
|
|
322
|
+
const b = nodes.find((node) => node.id === second)
|
|
323
|
+
const places = new Map([[first, placeFields(b)], [second, placeFields(a)]])
|
|
324
|
+
|
|
325
|
+
return nodes.map((node) => (places.has(node.id) ? { ...node, ...places.get(node.id) } : node))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Where a step added at the bottom of the list goes in the flow.
|
|
330
|
+
*
|
|
331
|
+
* @param {object} graph The graph, before the step is added.
|
|
332
|
+
* @return {{end: object|null, last: object|null}} The closing step, and the step left without a way on.
|
|
333
|
+
*/
|
|
334
|
+
export function flowStepTail(graph) {
|
|
335
|
+
const reached = orderFlowNodes(graph).filter((entry) => !entry.loose).map((entry) => entry.node)
|
|
336
|
+
const ends = reached.filter((node) => graph.roleOf(node.type) === 'end')
|
|
337
|
+
const open = reached.filter((node) => graph.roleOf(node.type) !== 'end' && linesOf(graph, node.id).out.length === 0)
|
|
338
|
+
|
|
339
|
+
return { end: ends[ends.length - 1] || null, last: open[open.length - 1] || null }
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The edges with a new step in at the bottom: before the closing step when
|
|
344
|
+
* there is one, else after the last step.
|
|
345
|
+
*
|
|
346
|
+
* @param {Array<object>} edges The stored edges.
|
|
347
|
+
* @param {object} insert `{ id, end, last }`: the new step and flowStepTail()'s answer.
|
|
348
|
+
* @param insert.id
|
|
349
|
+
* @param insert.end
|
|
350
|
+
* @param insert.last
|
|
351
|
+
* @return {Array<object>} The new edges.
|
|
352
|
+
*/
|
|
353
|
+
export function insertStepEdges(edges, { id, end, last }) {
|
|
354
|
+
const map = (target) => (target === end?.id ? id : target)
|
|
355
|
+
const leadsToEnd = (edge) => end !== null && [].concat(edge.to ?? edge.target).includes(end.id)
|
|
356
|
+
const reachesEnd = edges.some(leadsToEnd)
|
|
357
|
+
const before = last !== null && !reachesEnd ? [{ from: last.id, to: id }] : []
|
|
358
|
+
const after = end !== null ? [{ from: id, to: end.id }] : []
|
|
359
|
+
|
|
360
|
+
return [...edges.map((edge) => mapEdge(edge, { keys: ['to', 'target'], map })), ...before, ...after]
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The edge that closes the gap a removed step leaves in a chain.
|
|
365
|
+
*
|
|
366
|
+
* @param {object} graph The graph.
|
|
367
|
+
* @param {string} id The step being removed.
|
|
368
|
+
* @return {object|null} The edge, or null when the step is not a plain link of a chain.
|
|
369
|
+
*/
|
|
370
|
+
export function flowStepBridge(graph, id) {
|
|
371
|
+
const node = graph.nodes.find((candidate) => candidate.id === id)
|
|
372
|
+
const { into, out } = linesOf(graph, id)
|
|
373
|
+
const plain = node && !branches(node) && into.length === 1 && out.length === 1
|
|
374
|
+
if (!plain || out[0].target === into[0].source) {
|
|
375
|
+
return null
|
|
376
|
+
}
|
|
377
|
+
const edge = into[0].data.edge
|
|
378
|
+
const single = !Array.isArray(edge.from ?? edge.source) && !Array.isArray(edge.to ?? edge.target)
|
|
379
|
+
|
|
380
|
+
return single ? { ...edge, ['to' in edge ? 'to' : 'target']: out[0].target } : null
|
|
381
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module utils/searchRefusal
|
|
11
11
|
*/
|
|
12
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
12
13
|
|
|
13
14
|
/** `<reason> at position <n>.`, the shape OpenRegister builds the message in. */
|
|
14
15
|
const POSITION_IN_MESSAGE = /\bat position (\d+)\.?\s*$/
|
|
@@ -57,3 +58,35 @@ export function readSearchRefusal(error, term) {
|
|
|
57
58
|
after: typed.slice(index + 1),
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A refused search as a state notice under the search field: the position in
|
|
64
|
+
* the title, the server's reason, then that the list is not filtered. `title`
|
|
65
|
+
* (with `{position}`) and `after` replace the library's words, through the
|
|
66
|
+
* app's translate.
|
|
67
|
+
*
|
|
68
|
+
* @spec openspec/changes/search-refusal-notice/specs/index-search-refusal/spec.md#requirement-a-refused-search-can-keep-the-rows-and-say-so-under-the-search-field
|
|
69
|
+
* @param {{message: string, position: number}} refusal What `readSearchRefusal` read.
|
|
70
|
+
* @param {{title?: string, after?: string}|null} [words] The page's own words.
|
|
71
|
+
* @param {(text: string) => string} [translate] The app's translate.
|
|
72
|
+
* @return {object} The notice (`{ id, variant, role, layout, title, text }`).
|
|
73
|
+
*/
|
|
74
|
+
export function searchRefusalNotice(refusal, words, translate) {
|
|
75
|
+
const tr = typeof translate === 'function' ? translate : (text) => text
|
|
76
|
+
const own = words && typeof words === 'object' ? words : {}
|
|
77
|
+
const position = String(refusal.position)
|
|
78
|
+
const title = typeof own.title === 'string' && own.title !== ''
|
|
79
|
+
? tr(own.title).replace(/\{position\}/g, position)
|
|
80
|
+
: t('nextcloud-vue', 'Search term not understood at position {position}:', { position })
|
|
81
|
+
const after = typeof own.after === 'string' && own.after !== ''
|
|
82
|
+
? tr(own.after)
|
|
83
|
+
: t('nextcloud-vue', 'The list is not filtered; adjust the term.')
|
|
84
|
+
return {
|
|
85
|
+
id: 'search-refusal',
|
|
86
|
+
variant: 'error',
|
|
87
|
+
role: 'alert',
|
|
88
|
+
layout: 'inline',
|
|
89
|
+
title,
|
|
90
|
+
text: [refusal.message, after].filter((part) => part !== '').join(' '),
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -66,7 +66,7 @@ import { canonicalWidgetType } from './widgetTypeAliases.js'
|
|
|
66
66
|
*
|
|
67
67
|
* @type {string[]}
|
|
68
68
|
*/
|
|
69
|
-
export const CONTENT_ONLY_TYPES = Object.freeze(['object-list', 'table', 'files', 'flow-runs', 'tasks', 'events', 'facts', 'linked', 'field-list', 'record-list', 'parties', 'map', 'settings-form', 'switch-rows', 'radio-cards', 'chips-field', 'toggle-table', 'choice-picker', 'checklist', 'object-translations', 'row-mark-list', 'slot-grid', 'handoff', 'macros', 'ai-chat', 'grouped-cards', 'plan', 'record-notes', 'field-groups', 'object-links', 'kb-search', 'share-list'])
|
|
69
|
+
export const CONTENT_ONLY_TYPES = Object.freeze(['object-list', 'table', 'files', 'flow-runs', 'tasks', 'events', 'facts', 'linked', 'field-list', 'record-list', 'parties', 'map', 'settings-form', 'switch-rows', 'radio-cards', 'chips-field', 'toggle-table', 'choice-picker', 'checklist', 'object-translations', 'row-mark-list', 'slot-grid', 'handoff', 'macros', 'ai-chat', 'grouped-cards', 'plan', 'record-notes', 'field-groups', 'object-links', 'kb-search', 'share-list', 'task-form'])
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* The stored content/config blob for a widget definition.
|