@conduction/nextcloud-vue 2.169.0 → 2.171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +7 -2
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js +9 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js.map +1 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js +242 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js.map +1 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js +200 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js.map +1 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js +9 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js.map +1 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js +186 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js +24 -0
- package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue.js +1 -1
- package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js +3 -15
- package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js +16 -61
- package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js +9 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js.map +1 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js +120 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js.map +1 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js +86 -0
- package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js.map +1 -0
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js +88 -0
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue3.js +4 -3
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue.js +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +46 -3
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js +2 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +9 -9
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue.js +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue.js +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js +9 -3
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js +8 -0
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js.map +1 -0
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js +101 -0
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js.map +1 -0
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js +54 -0
- package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js.map +1 -0
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +14 -2
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js +21 -2
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +7 -0
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +2 -2
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +11 -0
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +2 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
- package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue.js +1 -1
- package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js +9 -0
- package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js.map +1 -0
- package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js +248 -0
- package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js.map +1 -0
- package/dist/esm/components/{CnMassDeleteDialog/CnMassDeleteDialog.vue3.js → CnMassActionDialog/CnMassActionDialog.vue3.js} +66 -52
- package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue3.js.map +1 -0
- package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js +0 -3
- package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js.map +1 -1
- package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js +25 -121
- package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnNotesCard/CnNotesCard.vue.js +1 -1
- package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js +11 -3
- package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js.map +1 -1
- package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js +1 -1
- package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js +13 -6
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue.js +1 -1
- package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js +21 -1
- package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js +2 -2
- package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +23 -5
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +3 -0
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +14 -4
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/dialogs/CnConfirmDialog.vue.js +1 -1
- package/dist/esm/dialogs/CnConfirmDialog.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnConfirmDialog.vue3.js +5 -3
- package/dist/esm/dialogs/CnConfirmDialog.vue3.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue.js +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue2.js +14 -3
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue3.js.map +1 -1
- package/dist/esm/l10n/en.json.js +16 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +16 -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 +874 -496
- package/dist/esm/utils/noteThreads.js +14 -2
- package/dist/esm/utils/noteThreads.js.map +1 -1
- package/dist/esm/utils/objectParties.js +50 -5
- package/dist/esm/utils/objectParties.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +11549 -10100
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +874 -496
- package/l10n/en.json +16 -1
- package/l10n/nl.json +16 -1
- package/package.json +1 -1
- package/scripts/.jsdoc-baselines.json +1 -1
- package/src/components/CnCellRenderer/CnCellRenderer.vue +7 -2
- package/src/components/CnConditionGroupEditor/CnConditionGroup.vue +528 -0
- package/src/components/CnConditionGroupEditor/CnConditionGroupEditor.vue +211 -0
- package/src/components/CnConditionGroupEditor/index.js +9 -0
- package/src/components/CnConditionListEditor/CnConditionListEditor.vue +15 -78
- package/src/components/CnConditionListEditor/CnConditionRow.vue +226 -0
- package/src/components/CnDashboardGrid/CnDashboardGrid.md +1 -0
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +100 -2
- package/src/components/CnDashboardPage/CnDashboardPage.vue +47 -3
- package/src/components/CnDetailPage/CnDetailPage.vue +8 -8
- package/src/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue +6 -0
- package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +9 -9
- package/src/components/CnDialogActions/CnDialogActions.vue +124 -0
- package/src/components/CnDialogActions/index.js +7 -0
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +15 -3
- package/src/components/CnFilesBrowser/filesBrowser.js +21 -2
- package/src/components/CnFlowsPage/CnFlowBoard.vue +10 -3
- package/src/components/CnFlowsPage/CnFlowEditorPage.vue +12 -0
- package/src/components/CnLinkedWidget/CnLinkedWidget.vue +7 -0
- package/src/components/CnMassActionDialog/CnMassActionDialog.vue +382 -0
- package/src/components/CnMassActionDialog/index.js +7 -0
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.md +4 -0
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +25 -254
- package/src/components/CnNotesCard/CnNotesCard.vue +12 -4
- package/src/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue +14 -5
- package/src/components/CnObjectSidebar/CnNotesTab.vue +23 -3
- package/src/components/CnTreeView/CnTreeNode.vue +10 -1
- package/src/components/CnTreeView/CnTreeView.vue +9 -0
- package/src/components/index.js +3 -0
- package/src/css/context-menu.css +7 -0
- package/src/css/dialog.css +7 -5
- package/src/css/look-board-detail.css +120 -1
- package/src/css/look-board-index.css +21 -2
- package/src/css/look-board.css +55 -2
- package/src/dialogs/CnConfirmDialog.vue +3 -1
- package/src/index.js +3 -0
- package/src/integrations/builtin/contacts/CnContactsTab.vue +14 -3
- package/src/integrations/builtin/contacts/__tests__/CnContactsTabBoardRows.spec.js +17 -2
- package/src/utils/noteThreads.js +13 -1
- package/src/utils/objectParties.js +49 -4
- package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue3.js.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import __sfc_main from './CnConditionGroup.vue.js';
|
|
2
|
+
import { operatorsForType, operatorLabel } from '../CnConditionListEditor/conditionOperators.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A rule value as a group: a group keeps its shape with `type` upper-cased; a
|
|
6
|
+
* bare condition, a list of nodes, or `children` without a `type` read as an
|
|
7
|
+
* AND group of them; anything else reads as an empty AND group.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} value The bound value.
|
|
10
|
+
* @return {{type: string, children: Array}} A detached group.
|
|
11
|
+
*/
|
|
12
|
+
function toGroup(value) {
|
|
13
|
+
let copy;
|
|
14
|
+
try {
|
|
15
|
+
copy = JSON.parse(JSON.stringify(value ?? null));
|
|
16
|
+
} catch {
|
|
17
|
+
copy = null;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(copy)) {
|
|
20
|
+
return { type: 'AND', children: copy }
|
|
21
|
+
}
|
|
22
|
+
if (!copy || typeof copy !== 'object') {
|
|
23
|
+
return { type: 'AND', children: [] }
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(copy.children)) {
|
|
26
|
+
return { ...copy, type: copy.type ? String(copy.type).toUpperCase() : 'AND' }
|
|
27
|
+
}
|
|
28
|
+
if ('field' in copy || 'operator' in copy) {
|
|
29
|
+
return { type: 'AND', children: [copy] }
|
|
30
|
+
}
|
|
31
|
+
return { type: 'AND', children: [] }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* CnConditionGroupEditor - the conditions of a rule in groups: each group
|
|
36
|
+
* chooses whether all or any of its conditions must hold, and the root may
|
|
37
|
+
* hold inner groups ("this, and one of these"). Rows are CnConditionRow, the
|
|
38
|
+
* same field, operator and value row as CnConditionListEditor.
|
|
39
|
+
*
|
|
40
|
+
* v-model on `{ type: 'AND' | 'OR', children }`, where a child is a
|
|
41
|
+
* condition `{ field, operator, value }` or another group, in both dialects
|
|
42
|
+
* (`value`/`input` and `modelValue`/`update:modelValue`). Add group shows
|
|
43
|
+
* only on groups above `maxDepth`; a deeper tree still renders every level.
|
|
44
|
+
* A group of another type (NOT) shows as a locked row that can only be
|
|
45
|
+
* removed.
|
|
46
|
+
*/
|
|
47
|
+
var script = {
|
|
48
|
+
name: 'CnConditionGroupEditor',
|
|
49
|
+
|
|
50
|
+
components: { CnConditionGroup: __sfc_main },
|
|
51
|
+
|
|
52
|
+
props: {
|
|
53
|
+
/**
|
|
54
|
+
* The group tree.
|
|
55
|
+
*
|
|
56
|
+
* @type {{type: string, children: Array}}
|
|
57
|
+
*/
|
|
58
|
+
value: { type: [Object, Array], default: () => ({ type: 'AND', children: [] }) },
|
|
59
|
+
/**
|
|
60
|
+
* The same value under Vue 3's v-model name; wins over `value` when passed.
|
|
61
|
+
*
|
|
62
|
+
* @type {object}
|
|
63
|
+
*/
|
|
64
|
+
modelValue: { type: [Object, Array], default: undefined },
|
|
65
|
+
/**
|
|
66
|
+
* The fields a condition may name: `{ id | value, label, type?, format?, options? }`.
|
|
67
|
+
* `type` number or integer types a number, `type` or `format` date picks a
|
|
68
|
+
* date, `type` boolean or `options` (`[{ id, label }]`) make the value a choice.
|
|
69
|
+
*
|
|
70
|
+
* @type {Array<object>}
|
|
71
|
+
*/
|
|
72
|
+
fields: { type: Array, default: () => [] },
|
|
73
|
+
/**
|
|
74
|
+
* The operators, in the host's own names: a map from field type to
|
|
75
|
+
* `[{ value, label }]` (`default` for any other type), or a function
|
|
76
|
+
* `(field) => [{ value, label }]`. Without it, the operators of
|
|
77
|
+
* CnConditionListEditor are offered.
|
|
78
|
+
*
|
|
79
|
+
* @type {object|function(object): Array<{value: string, label: string}>}
|
|
80
|
+
*/
|
|
81
|
+
operators: { type: [Object, Function], default: null },
|
|
82
|
+
/**
|
|
83
|
+
* The deepest level Add group may build; 1 lets the root hold groups
|
|
84
|
+
* of conditions.
|
|
85
|
+
*
|
|
86
|
+
* @type {number}
|
|
87
|
+
*/
|
|
88
|
+
maxDepth: { type: Number, default: 1 },
|
|
89
|
+
/**
|
|
90
|
+
* Messages keyed by node path (`$.children[1].children[0]`), already
|
|
91
|
+
* translated, shown on that row or group.
|
|
92
|
+
*
|
|
93
|
+
* @type {object}
|
|
94
|
+
*/
|
|
95
|
+
errors: { type: Object, default: () => ({}) },
|
|
96
|
+
/**
|
|
97
|
+
* What an empty root says, already translated.
|
|
98
|
+
*
|
|
99
|
+
* @type {string}
|
|
100
|
+
*/
|
|
101
|
+
emptyText: { type: String, default: '' },
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
emits: ['input', 'update:modelValue'],
|
|
105
|
+
|
|
106
|
+
data() {
|
|
107
|
+
return {
|
|
108
|
+
tree: toGroup(this.modelValue !== undefined ? this.modelValue : this.value),
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
computed: {
|
|
113
|
+
fieldList() {
|
|
114
|
+
return this.fields.map((f) => ({ ...f, id: f.id ?? f.value }))
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
watch: {
|
|
119
|
+
value(next) {
|
|
120
|
+
if (this.modelValue === undefined) {
|
|
121
|
+
this.take(next);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
modelValue(next) {
|
|
126
|
+
if (next !== undefined) {
|
|
127
|
+
this.take(next);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
methods: {
|
|
133
|
+
take(next) {
|
|
134
|
+
const group = toGroup(next);
|
|
135
|
+
if (JSON.stringify(group) !== JSON.stringify(this.tree)) {
|
|
136
|
+
this.tree = group;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The operator choices of a field, as `[{ id, label }]`.
|
|
142
|
+
*
|
|
143
|
+
* @param {object|undefined} field The field.
|
|
144
|
+
* @return {Array<{id: string, label: string}>} The choices.
|
|
145
|
+
*/
|
|
146
|
+
operatorsFor(field) {
|
|
147
|
+
let list;
|
|
148
|
+
if (typeof this.operators === 'function') {
|
|
149
|
+
list = this.operators(field);
|
|
150
|
+
} else if (this.operators) {
|
|
151
|
+
list = this.operators[field?.type] || this.operators.default || [];
|
|
152
|
+
} else {
|
|
153
|
+
return operatorsForType(field?.type).map((id) => ({ id, label: operatorLabel(id) }))
|
|
154
|
+
}
|
|
155
|
+
return (list || []).map((o) => ({ id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }))
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Keep the edited tree and tell the consumer, in both v-model dialects.
|
|
160
|
+
*
|
|
161
|
+
* @param {object} next The edited tree.
|
|
162
|
+
* @return {void}
|
|
163
|
+
*/
|
|
164
|
+
onUpdate(next) {
|
|
165
|
+
this.tree = next;
|
|
166
|
+
const copy = JSON.parse(JSON.stringify(next));
|
|
167
|
+
/**
|
|
168
|
+
* The tree changed.
|
|
169
|
+
*
|
|
170
|
+
* @event input
|
|
171
|
+
* @type {object}
|
|
172
|
+
*/
|
|
173
|
+
this.$emit('input', copy);
|
|
174
|
+
/**
|
|
175
|
+
* The tree changed (Vue 3 v-model).
|
|
176
|
+
*
|
|
177
|
+
* @event update:modelValue
|
|
178
|
+
* @type {object}
|
|
179
|
+
*/
|
|
180
|
+
this.$emit('update:modelValue', copy);
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { script as default };
|
|
186
|
+
//# sourceMappingURL=CnConditionGroupEditor.vue2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnConditionGroupEditor.vue2.js","sources":["../../../../src/components/CnConditionGroupEditor/CnConditionGroupEditor.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-condition-group-editor\">\n\t\t<CnConditionGroup\n\t\t\t:node=\"tree\"\n\t\t\t:depth=\"0\"\n\t\t\tpath=\"$\"\n\t\t\t:fields=\"fieldList\"\n\t\t\t:operatorsFor=\"operatorsFor\"\n\t\t\t:maxDepth=\"maxDepth\"\n\t\t\t:errors=\"errors\"\n\t\t\t:emptyText=\"emptyText\"\n\t\t\t@update:node=\"onUpdate\" />\n\t</div>\n</template>\n\n<script>\nimport CnConditionGroup from './CnConditionGroup.vue'\nimport { operatorLabel, operatorsForType } from '../CnConditionListEditor/conditionOperators.js'\n\n/**\n * A rule value as a group: a group keeps its shape with `type` upper-cased; a\n * bare condition, a list of nodes, or `children` without a `type` read as an\n * AND group of them; anything else reads as an empty AND group.\n *\n * @param {unknown} value The bound value.\n * @return {{type: string, children: Array}} A detached group.\n */\nfunction toGroup(value) {\n\tlet copy\n\ttry {\n\t\tcopy = JSON.parse(JSON.stringify(value ?? null))\n\t} catch {\n\t\tcopy = null\n\t}\n\tif (Array.isArray(copy)) {\n\t\treturn { type: 'AND', children: copy }\n\t}\n\tif (!copy || typeof copy !== 'object') {\n\t\treturn { type: 'AND', children: [] }\n\t}\n\tif (Array.isArray(copy.children)) {\n\t\treturn { ...copy, type: copy.type ? String(copy.type).toUpperCase() : 'AND' }\n\t}\n\tif ('field' in copy || 'operator' in copy) {\n\t\treturn { type: 'AND', children: [copy] }\n\t}\n\treturn { type: 'AND', children: [] }\n}\n\n/**\n * CnConditionGroupEditor - the conditions of a rule in groups: each group\n * chooses whether all or any of its conditions must hold, and the root may\n * hold inner groups (\"this, and one of these\"). Rows are CnConditionRow, the\n * same field, operator and value row as CnConditionListEditor.\n *\n * v-model on `{ type: 'AND' | 'OR', children }`, where a child is a\n * condition `{ field, operator, value }` or another group, in both dialects\n * (`value`/`input` and `modelValue`/`update:modelValue`). Add group shows\n * only on groups above `maxDepth`; a deeper tree still renders every level.\n * A group of another type (NOT) shows as a locked row that can only be\n * removed.\n */\nexport default {\n\tname: 'CnConditionGroupEditor',\n\n\tcomponents: { CnConditionGroup },\n\n\tprops: {\n\t\t/**\n\t\t * The group tree.\n\t\t *\n\t\t * @type {{type: string, children: Array}}\n\t\t */\n\t\tvalue: { type: [Object, Array], default: () => ({ type: 'AND', children: [] }) },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tmodelValue: { type: [Object, Array], default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id | value, label, type?, format?, options? }`.\n\t\t * `type` number or integer types a number, `type` or `format` date picks a\n\t\t * date, `type` boolean or `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The operators, in the host's own names: a map from field type to\n\t\t * `[{ value, label }]` (`default` for any other type), or a function\n\t\t * `(field) => [{ value, label }]`. Without it, the operators of\n\t\t * CnConditionListEditor are offered.\n\t\t *\n\t\t * @type {object|function(object): Array<{value: string, label: string}>}\n\t\t */\n\t\toperators: { type: [Object, Function], default: null },\n\t\t/**\n\t\t * The deepest level Add group may build; 1 lets the root hold groups\n\t\t * of conditions.\n\t\t *\n\t\t * @type {number}\n\t\t */\n\t\tmaxDepth: { type: Number, default: 1 },\n\t\t/**\n\t\t * Messages keyed by node path (`$.children[1].children[0]`), already\n\t\t * translated, shown on that row or group.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\terrors: { type: Object, default: () => ({}) },\n\t\t/**\n\t\t * What an empty root says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\ttree: toGroup(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tfieldList() {\n\t\t\treturn this.fields.map((f) => ({ ...f, id: f.id ?? f.value }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.take(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.take(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\ttake(next) {\n\t\t\tconst group = toGroup(next)\n\t\t\tif (JSON.stringify(group) !== JSON.stringify(this.tree)) {\n\t\t\t\tthis.tree = group\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The operator choices of a field, as `[{ id, label }]`.\n\t\t *\n\t\t * @param {object|undefined} field The field.\n\t\t * @return {Array<{id: string, label: string}>} The choices.\n\t\t */\n\t\toperatorsFor(field) {\n\t\t\tlet list\n\t\t\tif (typeof this.operators === 'function') {\n\t\t\t\tlist = this.operators(field)\n\t\t\t} else if (this.operators) {\n\t\t\t\tlist = this.operators[field?.type] || this.operators.default || []\n\t\t\t} else {\n\t\t\t\treturn operatorsForType(field?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t\t}\n\t\t\treturn (list || []).map((o) => ({ id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }))\n\t\t},\n\n\t\t/**\n\t\t * Keep the edited tree and tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @param {object} next The edited tree.\n\t\t * @return {void}\n\t\t */\n\t\tonUpdate(next) {\n\t\t\tthis.tree = next\n\t\t\tconst copy = JSON.parse(JSON.stringify(next))\n\t\t\t/**\n\t\t\t * The tree changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {object}\n\t\t\t */\n\t\t\tthis.$emit('input', copy)\n\t\t\t/**\n\t\t\t * The tree changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {object}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', copy)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-group-editor {\n\tmin-width: 0;\n}\n</style>\n"],"names":["CnConditionGroup"],"mappings":";;;AAwBA;;;;AAIC;AACA;;;AAGD,SAAS,OAAO,CAAC,KAAK,EAAE;AACvB,CAAA,IAAI,KAAG;AACP,CAAA,IAAI;AACH,EAAA,IAAG,GAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,EAAA;AAChD,EAAA,CAAE,MAAM;AACP,EAAA,IAAG,GAAI,KAAG;AACX,EAAA;CACA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACxB,EAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAK,EAAA;AACtC,EAAA;AACA,CAAA,IAAI,CAAC,IAAK,IAAG,OAAO,IAAG,KAAM,QAAQ,EAAE;EACtC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAG,EAAA;AACpC,EAAA;AACA,CAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AACjC,EAAA,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CA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,KAAM,UAAU,EAAE;IACzC,IAAK,GAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAA;IAC1B,MAAK,IAAI,IAAI,CAAC,SAAS,EAAE;IAC1B,IAAG,GAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAA,IAAK,IAAI,CAAC,SAAS,CAAC,OAAM,IAAK,GAAC;IAChE,MAAK;AACN,IAAA,OAAO,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,CAAA,EAAG,CAAC,CAAA;AACpF,IAAA;AACA,GAAA,OAAO,CAAC,IAAG,IAAK,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAC,IAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAM,IAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAA,EAAG,CAAC,CAAA;GACnG;;AAED;;AAEC;AACA;;;AAGD,EAAA,QAAQ,CAAC,IAAI,EAAE;GACd,IAAI,CAAC,IAAK,GAAE,KAAG;AACf,GAAA,MAAM,IAAG,GAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAA;AAC5C;AACC;AACA;;;;GAID,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAA;AACxB;;AAEC;;;;AAID,GAAA,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,IAAI,EAAA;GACpC;EACD;AACF;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, createVNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = { class: "cn-condition-group-editor" };
|
|
4
|
+
|
|
5
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
6
|
+
const _component_CnConditionGroup = resolveComponent("CnConditionGroup");
|
|
7
|
+
|
|
8
|
+
return (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
9
|
+
createVNode(_component_CnConditionGroup, {
|
|
10
|
+
node: $data.tree,
|
|
11
|
+
depth: 0,
|
|
12
|
+
path: "$",
|
|
13
|
+
fields: $options.fieldList,
|
|
14
|
+
operatorsFor: $options.operatorsFor,
|
|
15
|
+
maxDepth: $props.maxDepth,
|
|
16
|
+
errors: $props.errors,
|
|
17
|
+
emptyText: $props.emptyText,
|
|
18
|
+
"onUpdate:node": $options.onUpdate
|
|
19
|
+
}, null, 8 /* PROPS */, ["node", "fields", "operatorsFor", "maxDepth", "errors", "emptyText", "onUpdate:node"])
|
|
20
|
+
]))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { render };
|
|
24
|
+
//# sourceMappingURL=CnConditionGroupEditor.vue3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnConditionGroupEditor.vue3.js","sources":["../../../../src/components/CnConditionGroupEditor/CnConditionGroupEditor.vue?vue&type=template&id=36d77d2d&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-condition-group-editor\">\n\t\t<CnConditionGroup\n\t\t\t:node=\"tree\"\n\t\t\t:depth=\"0\"\n\t\t\tpath=\"$\"\n\t\t\t:fields=\"fieldList\"\n\t\t\t:operatorsFor=\"operatorsFor\"\n\t\t\t:maxDepth=\"maxDepth\"\n\t\t\t:errors=\"errors\"\n\t\t\t:emptyText=\"emptyText\"\n\t\t\t@update:node=\"onUpdate\" />\n\t</div>\n</template>\n\n<script>\nimport CnConditionGroup from './CnConditionGroup.vue'\nimport { operatorLabel, operatorsForType } from '../CnConditionListEditor/conditionOperators.js'\n\n/**\n * A rule value as a group: a group keeps its shape with `type` upper-cased; a\n * bare condition, a list of nodes, or `children` without a `type` read as an\n * AND group of them; anything else reads as an empty AND group.\n *\n * @param {unknown} value The bound value.\n * @return {{type: string, children: Array}} A detached group.\n */\nfunction toGroup(value) {\n\tlet copy\n\ttry {\n\t\tcopy = JSON.parse(JSON.stringify(value ?? null))\n\t} catch {\n\t\tcopy = null\n\t}\n\tif (Array.isArray(copy)) {\n\t\treturn { type: 'AND', children: copy }\n\t}\n\tif (!copy || typeof copy !== 'object') {\n\t\treturn { type: 'AND', children: [] }\n\t}\n\tif (Array.isArray(copy.children)) {\n\t\treturn { ...copy, type: copy.type ? String(copy.type).toUpperCase() : 'AND' }\n\t}\n\tif ('field' in copy || 'operator' in copy) {\n\t\treturn { type: 'AND', children: [copy] }\n\t}\n\treturn { type: 'AND', children: [] }\n}\n\n/**\n * CnConditionGroupEditor - the conditions of a rule in groups: each group\n * chooses whether all or any of its conditions must hold, and the root may\n * hold inner groups (\"this, and one of these\"). Rows are CnConditionRow, the\n * same field, operator and value row as CnConditionListEditor.\n *\n * v-model on `{ type: 'AND' | 'OR', children }`, where a child is a\n * condition `{ field, operator, value }` or another group, in both dialects\n * (`value`/`input` and `modelValue`/`update:modelValue`). Add group shows\n * only on groups above `maxDepth`; a deeper tree still renders every level.\n * A group of another type (NOT) shows as a locked row that can only be\n * removed.\n */\nexport default {\n\tname: 'CnConditionGroupEditor',\n\n\tcomponents: { CnConditionGroup },\n\n\tprops: {\n\t\t/**\n\t\t * The group tree.\n\t\t *\n\t\t * @type {{type: string, children: Array}}\n\t\t */\n\t\tvalue: { type: [Object, Array], default: () => ({ type: 'AND', children: [] }) },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tmodelValue: { type: [Object, Array], default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id | value, label, type?, format?, options? }`.\n\t\t * `type` number or integer types a number, `type` or `format` date picks a\n\t\t * date, `type` boolean or `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The operators, in the host's own names: a map from field type to\n\t\t * `[{ value, label }]` (`default` for any other type), or a function\n\t\t * `(field) => [{ value, label }]`. Without it, the operators of\n\t\t * CnConditionListEditor are offered.\n\t\t *\n\t\t * @type {object|function(object): Array<{value: string, label: string}>}\n\t\t */\n\t\toperators: { type: [Object, Function], default: null },\n\t\t/**\n\t\t * The deepest level Add group may build; 1 lets the root hold groups\n\t\t * of conditions.\n\t\t *\n\t\t * @type {number}\n\t\t */\n\t\tmaxDepth: { type: Number, default: 1 },\n\t\t/**\n\t\t * Messages keyed by node path (`$.children[1].children[0]`), already\n\t\t * translated, shown on that row or group.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\terrors: { type: Object, default: () => ({}) },\n\t\t/**\n\t\t * What an empty root says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\ttree: toGroup(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tfieldList() {\n\t\t\treturn this.fields.map((f) => ({ ...f, id: f.id ?? f.value }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.take(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.take(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\ttake(next) {\n\t\t\tconst group = toGroup(next)\n\t\t\tif (JSON.stringify(group) !== JSON.stringify(this.tree)) {\n\t\t\t\tthis.tree = group\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The operator choices of a field, as `[{ id, label }]`.\n\t\t *\n\t\t * @param {object|undefined} field The field.\n\t\t * @return {Array<{id: string, label: string}>} The choices.\n\t\t */\n\t\toperatorsFor(field) {\n\t\t\tlet list\n\t\t\tif (typeof this.operators === 'function') {\n\t\t\t\tlist = this.operators(field)\n\t\t\t} else if (this.operators) {\n\t\t\t\tlist = this.operators[field?.type] || this.operators.default || []\n\t\t\t} else {\n\t\t\t\treturn operatorsForType(field?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t\t}\n\t\t\treturn (list || []).map((o) => ({ id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }))\n\t\t},\n\n\t\t/**\n\t\t * Keep the edited tree and tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @param {object} next The edited tree.\n\t\t * @return {void}\n\t\t */\n\t\tonUpdate(next) {\n\t\t\tthis.tree = next\n\t\t\tconst copy = JSON.parse(JSON.stringify(next))\n\t\t\t/**\n\t\t\t * The tree changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {object}\n\t\t\t */\n\t\t\tthis.$emit('input', copy)\n\t\t\t/**\n\t\t\t * The tree changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {object}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', copy)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-group-editor {\n\tmin-width: 0;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,2BAAS,GAAA;;;;;AAAlB,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;;AAEC,MAAA,IAAI,EAAE,KAAI,CAAA,IAAA;AACV,MAAA,KAAK,EAAE,CAAC;AACT,MAAA,IAAI,EAAC,GAAG;AACP,MAAA,MAAM,EAAE,QAAS,CAAA,SAAA;AACjB,MAAA,YAAE,EAAA,QAAA,CAAA,YAAA;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnConditionListEditor.vue2.js';
|
|
|
2
2
|
import { render } from './CnConditionListEditor.vue3.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-77809f32";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { translate } from '@nextcloud/l10n';
|
|
2
|
-
import { NcButton
|
|
3
|
-
import Close from 'vue-material-design-icons/Close.vue';
|
|
2
|
+
import { NcButton } from '@nextcloud/vue';
|
|
4
3
|
import Plus from 'vue-material-design-icons/Plus.vue';
|
|
4
|
+
import __sfc_main from './CnConditionRow.vue.js';
|
|
5
5
|
import { operatorsForType, operatorLabel, operatorTakesValue } from './conditionOperators.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -17,7 +17,7 @@ import { operatorsForType, operatorLabel, operatorTakesValue } from './condition
|
|
|
17
17
|
var script = {
|
|
18
18
|
name: 'CnConditionListEditor',
|
|
19
19
|
|
|
20
|
-
components: {
|
|
20
|
+
components: { CnConditionRow: __sfc_main, NcButton, Plus },
|
|
21
21
|
|
|
22
22
|
props: {
|
|
23
23
|
/**
|
|
@@ -110,18 +110,10 @@ var script = {
|
|
|
110
110
|
return this.fields.find((f) => f.id === id)
|
|
111
111
|
},
|
|
112
112
|
|
|
113
|
-
fieldOption(id) {
|
|
114
|
-
return this.fieldOptions.find((o) => o.id === id) || null
|
|
115
|
-
},
|
|
116
|
-
|
|
117
113
|
operatorOptions(fieldId) {
|
|
118
114
|
return operatorsForType(this.fieldOf(fieldId)?.type).map((id) => ({ id, label: operatorLabel(id) }))
|
|
119
115
|
},
|
|
120
116
|
|
|
121
|
-
operatorOption(operator) {
|
|
122
|
-
return operator ? { id: operator, label: operatorLabel(operator) } : null
|
|
123
|
-
},
|
|
124
|
-
|
|
125
117
|
takesValue(operator) {
|
|
126
118
|
return operatorTakesValue(operator)
|
|
127
119
|
},
|
|
@@ -148,10 +140,6 @@ var script = {
|
|
|
148
140
|
return null
|
|
149
141
|
},
|
|
150
142
|
|
|
151
|
-
valueOption(row) {
|
|
152
|
-
return (this.valueOptions(row.field) || []).find((o) => String(o.id) === String(row.value)) || null
|
|
153
|
-
},
|
|
154
|
-
|
|
155
143
|
inputType(fieldId) {
|
|
156
144
|
const type = this.fieldOf(fieldId)?.type;
|
|
157
145
|
if (type === 'number' || type === 'integer') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnConditionListEditor.vue2.js","sources":["../../../../src/components/CnConditionListEditor/CnConditionListEditor.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<fieldset class=\"cn-condition-list\">\n\t\t<legend v-if=\"label\" class=\"cn-condition-list__label\">\n\t\t\t{{ label }}\n\t\t</legend>\n\t\t<p v-if=\"rows.length === 0\" class=\"cn-condition-list__empty\">\n\t\t\t{{ emptyText || t('nextcloud-vue', 'No conditions: the rule always applies.') }}\n\t\t</p>\n\t\t<div\n\t\t\tv-for=\"(row, i) in rows\"\n\t\t\t:key=\"i\"\n\t\t\tclass=\"cn-condition-list__row\">\n\t\t\t<NcSelect\n\t\t\t\tclass=\"cn-condition-list__field\"\n\t\t\t\t:modelValue=\"fieldOption(row.field)\"\n\t\t\t\t:options=\"fieldOptions\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Field')\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t@update:modelValue=\"setField(i, $event)\" />\n\t\t\t<NcSelect\n\t\t\t\tclass=\"cn-condition-list__operator\"\n\t\t\t\t:modelValue=\"operatorOption(row.operator)\"\n\t\t\t\t:options=\"operatorOptions(row.field)\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Operator')\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:disabled=\"!row.field\"\n\t\t\t\t@update:modelValue=\"setOperator(i, $event)\" />\n\t\t\t<template v-if=\"takesValue(row.operator)\">\n\t\t\t\t<NcSelect\n\t\t\t\t\tv-if=\"valueOptions(row.field)\"\n\t\t\t\t\tclass=\"cn-condition-list__value\"\n\t\t\t\t\t:modelValue=\"valueOption(row)\"\n\t\t\t\t\t:options=\"valueOptions(row.field)\"\n\t\t\t\t\tlabel=\"label\"\n\t\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Value')\"\n\t\t\t\t\t:clearable=\"false\"\n\t\t\t\t\t@update:modelValue=\"setValue(i, $event ? $event.id : '')\" />\n\t\t\t\t<NcTextField\n\t\t\t\t\tv-else\n\t\t\t\t\tclass=\"cn-condition-list__value\"\n\t\t\t\t\t:type=\"inputType(row.field)\"\n\t\t\t\t\t:modelValue=\"row.value === undefined || row.value === null ? '' : String(row.value)\"\n\t\t\t\t\t:label=\"t('nextcloud-vue', 'Value')\"\n\t\t\t\t\t@update:modelValue=\"setValue(i, typedValue(row.field, $event))\" />\n\t\t\t</template>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t:aria-label=\"t('nextcloud-vue', 'Remove condition')\"\n\t\t\t\t@click=\"remove(i)\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<Close :size=\"18\" />\n\t\t\t\t</template>\n\t\t\t</NcButton>\n\t\t</div>\n\t\t<NcButton variant=\"tertiary\" :disabled=\"fields.length === 0\" @click=\"add\">\n\t\t\t<template #icon>\n\t\t\t\t<Plus :size=\"18\" />\n\t\t\t</template>\n\t\t\t{{ t('nextcloud-vue', 'Add condition') }}\n\t\t</NcButton>\n\t</fieldset>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcSelect, NcTextField } from '@nextcloud/vue'\nimport Close from 'vue-material-design-icons/Close.vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport { operatorLabel, operatorsForType, operatorTakesValue } from './conditionOperators.js'\n\n/**\n * CnConditionListEditor - the conditions of a rule as rows over an object's\n * own fields: field, operator, value. All rows hold together. The operators\n * follow the field's type (see `operatorsForType`), \"is filled in\" needs no\n * value, and the value is a choice for a choice or yes/no field.\n *\n * v-model on `{ field, operator, value }[]`, in both dialects (`value`/`input`\n * and `modelValue`/`update:modelValue`). Read a condition back as words with\n * `conditionSentence` from `./conditionOperators.js`.\n */\nexport default {\n\tname: 'CnConditionListEditor',\n\n\tcomponents: { NcButton, NcSelect, NcTextField, Close, Plus },\n\n\tprops: {\n\t\t/**\n\t\t * The conditions.\n\t\t *\n\t\t * @type {Array<{field: string, operator: string, value?: unknown}>}\n\t\t */\n\t\tvalue: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {Array}\n\t\t */\n\t\tmodelValue: { type: Array, default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id, label, type, options?, format? }`.\n\t\t * `type` is number, integer, date, boolean, presence or anything else (text);\n\t\t * `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<{id: string, label: string, type?: string, options?: Array}>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The legend above the rows, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tlabel: { type: String, default: '' },\n\t\t/**\n\t\t * What an empty list says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\trows: this.copy(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The field choices.\n\t\t *\n\t\t * @return {Array<{id: string, label: string}>}\n\t\t */\n\t\tfieldOptions() {\n\t\t\treturn this.fields.map((f) => ({ id: f.id, label: f.label || f.id }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A detached copy of the bound conditions.\n\t\t *\n\t\t * @param {Array} list The conditions.\n\t\t * @return {Array} The copy.\n\t\t */\n\t\tcopy(list) {\n\t\t\treturn (Array.isArray(list) ? list : []).map((row) => ({ ...row }))\n\t\t},\n\n\t\t/**\n\t\t * The field with this id.\n\t\t *\n\t\t * @param {string} id The field id.\n\t\t * @return {object|undefined}\n\t\t */\n\t\tfieldOf(id) {\n\t\t\treturn this.fields.find((f) => f.id === id)\n\t\t},\n\n\t\tfieldOption(id) {\n\t\t\treturn this.fieldOptions.find((o) => o.id === id) || null\n\t\t},\n\n\t\toperatorOptions(fieldId) {\n\t\t\treturn operatorsForType(this.fieldOf(fieldId)?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t},\n\n\t\toperatorOption(operator) {\n\t\t\treturn operator ? { id: operator, label: operatorLabel(operator) } : null\n\t\t},\n\n\t\ttakesValue(operator) {\n\t\t\treturn operatorTakesValue(operator)\n\t\t},\n\n\t\t/**\n\t\t * The value choices of a field, or null when its value is typed.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @return {Array<{id: string, label: string}>|null}\n\t\t */\n\t\tvalueOptions(fieldId) {\n\t\t\tconst field = this.fieldOf(fieldId)\n\t\t\tif (field?.type === 'boolean') {\n\t\t\t\treturn [\n\t\t\t\t\t{ id: true, label: t('nextcloud-vue', 'Yes') },\n\t\t\t\t\t{ id: false, label: t('nextcloud-vue', 'No') },\n\t\t\t\t]\n\t\t\t}\n\t\t\tif (Array.isArray(field?.options) && field.options.length > 0) {\n\t\t\t\treturn field.options.map((o) => (typeof o === 'object'\n\t\t\t\t\t? { id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }\n\t\t\t\t\t: { id: o, label: String(o) }))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\tvalueOption(row) {\n\t\t\treturn (this.valueOptions(row.field) || []).find((o) => String(o.id) === String(row.value)) || null\n\t\t},\n\n\t\tinputType(fieldId) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif (type === 'number' || type === 'integer') {\n\t\t\t\treturn 'number'\n\t\t\t}\n\t\t\treturn type === 'date' ? 'date' : 'text'\n\t\t},\n\n\t\t/**\n\t\t * A typed value as stored: a number for a number field.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @param {string} raw What was typed.\n\t\t * @return {string|number}\n\t\t */\n\t\ttypedValue(fieldId, raw) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif ((type === 'number' || type === 'integer') && raw !== '' && !Number.isNaN(Number(raw))) {\n\t\t\t\treturn Number(raw)\n\t\t\t}\n\t\t\treturn raw\n\t\t},\n\n\t\tsetField(i, option) {\n\t\t\tconst field = this.fieldOf(option?.id)\n\t\t\tconst operators = operatorsForType(field?.type)\n\t\t\tthis.rows[i] = { field: option?.id || '', operator: operators[0], value: field?.type === 'boolean' ? true : '' }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetOperator(i, option) {\n\t\t\tconst row = { ...this.rows[i], operator: option?.id || 'eq' }\n\t\t\tif (!operatorTakesValue(row.operator)) {\n\t\t\t\tdelete row.value\n\t\t\t} else if (row.value === undefined) {\n\t\t\t\trow.value = ''\n\t\t\t}\n\t\t\tthis.rows[i] = row\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetValue(i, value) {\n\t\t\tthis.rows[i] = { ...this.rows[i], value }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tadd() {\n\t\t\tthis.rows.push({ field: '', operator: 'eq', value: '' })\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tremove(i) {\n\t\t\tthis.rows.splice(i, 1)\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\t/**\n\t\t * Tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\temitRows() {\n\t\t\tconst next = this.copy(this.rows)\n\t\t\t/**\n\t\t\t * The conditions changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('input', next)\n\t\t\t/**\n\t\t\t * The conditions changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', next)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tmin-width: 0;\n}\n\n.cn-condition-list__label {\n\tfont-weight: 600;\n\tpadding: 0;\n\tmargin-bottom: 4px;\n}\n\n.cn-condition-list__empty {\n\tcolor: var(--color-text-maxcontrast);\n\tmargin: 0;\n}\n\n.cn-condition-list__row {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.6fr) auto;\n\tgap: 8px;\n\talign-items: end;\n}\n\n.cn-condition-list__row > :nth-child(3):last-child {\n\tgrid-column: 4;\n}\n\n@media (max-width: 640px) {\n\t.cn-condition-list__row {\n\t\tgrid-template-columns: minmax(0, 1fr) auto;\n\t}\n}\n</style>\n"],"names":["t"],"mappings":";;;;;;AA6EA;AACC;AACA;AACA;;AAEA;AACA;AACA;;;AAGD,aAAe;CACd,IAAI,EAAE,uBAAuB;;CAE7B,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,IAAG,EAAG;;AAE5D,CAAA,KAAK,EAAE;AACN;AACC;AACA;;;AAGD,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,I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GAAC;AACd,IAAA;AACA,GAAA,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,GAAE,IAAE;AACjB,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;AAED,EAAA,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE;AAClB,GAAA,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAM,GAAA;AACxC,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;EAED,GAAG,GAAG;GACL,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAC,EAAG,EAAA;AACvD,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;AAED,EAAA,MAAM,CAAC,CAAC,EAAE;AACT,GAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAA;AACrB,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;AAED;AACC;AACA;;;EAGD,QAAQ,GAAG;GACV,MAAM,IAAK,GAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAA;AAChC;AACC;AACA;;;;GAID,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAA;AACxB;AACC;AACA;;;;AAID,GAAA,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,IAAI,EAAA;GACpC;EACD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CnConditionListEditor.vue2.js","sources":["../../../../src/components/CnConditionListEditor/CnConditionListEditor.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<fieldset class=\"cn-condition-list\">\n\t\t<legend v-if=\"label\" class=\"cn-condition-list__label\">\n\t\t\t{{ label }}\n\t\t</legend>\n\t\t<p v-if=\"rows.length === 0\" class=\"cn-condition-list__empty\">\n\t\t\t{{ emptyText || t('nextcloud-vue', 'No conditions: the rule always applies.') }}\n\t\t</p>\n\t\t<CnConditionRow\n\t\t\tv-for=\"(row, i) in rows\"\n\t\t\t:key=\"i\"\n\t\t\tclass=\"cn-condition-list__row\"\n\t\t\t:condition=\"row\"\n\t\t\t:fieldOptions=\"fieldOptions\"\n\t\t\t:operatorOptions=\"operatorOptions(row.field)\"\n\t\t\t:valueOptions=\"valueOptions(row.field)\"\n\t\t\t:inputType=\"inputType(row.field)\"\n\t\t\t:showValue=\"takesValue(row.operator)\"\n\t\t\t@field=\"setField(i, $event)\"\n\t\t\t@operator=\"setOperator(i, $event)\"\n\t\t\t@value=\"setValue(i, valueOptions(row.field) ? $event : typedValue(row.field, $event))\"\n\t\t\t@remove=\"remove(i)\" />\n\t\t<NcButton variant=\"tertiary\" :disabled=\"fields.length === 0\" @click=\"add\">\n\t\t\t<template #icon>\n\t\t\t\t<Plus :size=\"18\" />\n\t\t\t</template>\n\t\t\t{{ t('nextcloud-vue', 'Add condition') }}\n\t\t</NcButton>\n\t</fieldset>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton } from '@nextcloud/vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport CnConditionRow from './CnConditionRow.vue'\nimport { operatorLabel, operatorsForType, operatorTakesValue } from './conditionOperators.js'\n\n/**\n * CnConditionListEditor - the conditions of a rule as rows over an object's\n * own fields: field, operator, value. All rows hold together. The operators\n * follow the field's type (see `operatorsForType`), \"is filled in\" needs no\n * value, and the value is a choice for a choice or yes/no field.\n *\n * v-model on `{ field, operator, value }[]`, in both dialects (`value`/`input`\n * and `modelValue`/`update:modelValue`). Read a condition back as words with\n * `conditionSentence` from `./conditionOperators.js`.\n */\nexport default {\n\tname: 'CnConditionListEditor',\n\n\tcomponents: { CnConditionRow, NcButton, Plus },\n\n\tprops: {\n\t\t/**\n\t\t * The conditions.\n\t\t *\n\t\t * @type {Array<{field: string, operator: string, value?: unknown}>}\n\t\t */\n\t\tvalue: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {Array}\n\t\t */\n\t\tmodelValue: { type: Array, default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id, label, type, options?, format? }`.\n\t\t * `type` is number, integer, date, boolean, presence or anything else (text);\n\t\t * `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<{id: string, label: string, type?: string, options?: Array}>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The legend above the rows, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tlabel: { type: String, default: '' },\n\t\t/**\n\t\t * What an empty list says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\trows: this.copy(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The field choices.\n\t\t *\n\t\t * @return {Array<{id: string, label: string}>}\n\t\t */\n\t\tfieldOptions() {\n\t\t\treturn this.fields.map((f) => ({ id: f.id, label: f.label || f.id }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A detached copy of the bound conditions.\n\t\t *\n\t\t * @param {Array} list The conditions.\n\t\t * @return {Array} The copy.\n\t\t */\n\t\tcopy(list) {\n\t\t\treturn (Array.isArray(list) ? list : []).map((row) => ({ ...row }))\n\t\t},\n\n\t\t/**\n\t\t * The field with this id.\n\t\t *\n\t\t * @param {string} id The field id.\n\t\t * @return {object|undefined}\n\t\t */\n\t\tfieldOf(id) {\n\t\t\treturn this.fields.find((f) => f.id === id)\n\t\t},\n\n\t\toperatorOptions(fieldId) {\n\t\t\treturn operatorsForType(this.fieldOf(fieldId)?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t},\n\n\t\ttakesValue(operator) {\n\t\t\treturn operatorTakesValue(operator)\n\t\t},\n\n\t\t/**\n\t\t * The value choices of a field, or null when its value is typed.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @return {Array<{id: string, label: string}>|null}\n\t\t */\n\t\tvalueOptions(fieldId) {\n\t\t\tconst field = this.fieldOf(fieldId)\n\t\t\tif (field?.type === 'boolean') {\n\t\t\t\treturn [\n\t\t\t\t\t{ id: true, label: t('nextcloud-vue', 'Yes') },\n\t\t\t\t\t{ id: false, label: t('nextcloud-vue', 'No') },\n\t\t\t\t]\n\t\t\t}\n\t\t\tif (Array.isArray(field?.options) && field.options.length > 0) {\n\t\t\t\treturn field.options.map((o) => (typeof o === 'object'\n\t\t\t\t\t? { id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }\n\t\t\t\t\t: { id: o, label: String(o) }))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\tinputType(fieldId) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif (type === 'number' || type === 'integer') {\n\t\t\t\treturn 'number'\n\t\t\t}\n\t\t\treturn type === 'date' ? 'date' : 'text'\n\t\t},\n\n\t\t/**\n\t\t * A typed value as stored: a number for a number field.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @param {string} raw What was typed.\n\t\t * @return {string|number}\n\t\t */\n\t\ttypedValue(fieldId, raw) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif ((type === 'number' || type === 'integer') && raw !== '' && !Number.isNaN(Number(raw))) {\n\t\t\t\treturn Number(raw)\n\t\t\t}\n\t\t\treturn raw\n\t\t},\n\n\t\tsetField(i, option) {\n\t\t\tconst field = this.fieldOf(option?.id)\n\t\t\tconst operators = operatorsForType(field?.type)\n\t\t\tthis.rows[i] = { field: option?.id || '', operator: operators[0], value: field?.type === 'boolean' ? true : '' }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetOperator(i, option) {\n\t\t\tconst row = { ...this.rows[i], operator: option?.id || 'eq' }\n\t\t\tif (!operatorTakesValue(row.operator)) {\n\t\t\t\tdelete row.value\n\t\t\t} else if (row.value === undefined) {\n\t\t\t\trow.value = ''\n\t\t\t}\n\t\t\tthis.rows[i] = row\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetValue(i, value) {\n\t\t\tthis.rows[i] = { ...this.rows[i], value }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tadd() {\n\t\t\tthis.rows.push({ field: '', operator: 'eq', value: '' })\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tremove(i) {\n\t\t\tthis.rows.splice(i, 1)\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\t/**\n\t\t * Tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\temitRows() {\n\t\t\tconst next = this.copy(this.rows)\n\t\t\t/**\n\t\t\t * The conditions changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('input', next)\n\t\t\t/**\n\t\t\t * The conditions changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', next)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tmin-width: 0;\n}\n\n.cn-condition-list__label {\n\tfont-weight: 600;\n\tpadding: 0;\n\tmargin-bott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IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAM,GAAA;AACxC,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;EAED,GAAG,GAAG;GACL,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAC,EAAG,EAAA;AACvD,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;AAED,EAAA,MAAM,CAAC,CAAC,EAAE;AACT,GAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAA;AACrB,GAAA,IAAI,CAAC,QAAQ,GAAC;GACd;;AAED;AACC;AACA;;;EAGD,QAAQ,GAAG;GACV,MAAM,IAAK,GAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAA;AAChC;AACC;AACA;;;;GAID,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAA;AACxB;AACC;AACA;;;;AAID,GAAA,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,IAAI,EAAA;GACpC;EACD;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveComponent, openBlock, createElementBlock, toDisplayString, createCommentVNode, Fragment, renderList,
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, toDisplayString, createCommentVNode, Fragment, renderList, createBlock, createVNode, withCtx, createTextVNode } from 'vue';
|
|
2
2
|
|
|
3
3
|
const _hoisted_1 = { class: "cn-condition-list" };
|
|
4
4
|
const _hoisted_2 = {
|
|
@@ -11,11 +11,9 @@ const _hoisted_3 = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
14
|
-
const
|
|
15
|
-
const _component_NcTextField = resolveComponent("NcTextField");
|
|
16
|
-
const _component_Close = resolveComponent("Close");
|
|
17
|
-
const _component_NcButton = resolveComponent("NcButton");
|
|
14
|
+
const _component_CnConditionRow = resolveComponent("CnConditionRow");
|
|
18
15
|
const _component_Plus = resolveComponent("Plus");
|
|
16
|
+
const _component_NcButton = resolveComponent("NcButton");
|
|
19
17
|
|
|
20
18
|
return (openBlock(), createElementBlock("fieldset", _hoisted_1, [
|
|
21
19
|
($props.label)
|
|
@@ -25,63 +23,20 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
25
23
|
? (openBlock(), createElementBlock("p", _hoisted_3, toDisplayString($props.emptyText || $options.t('nextcloud-vue', 'No conditions: the rule always applies.')), 1 /* TEXT */))
|
|
26
24
|
: createCommentVNode("v-if", true),
|
|
27
25
|
(openBlock(true), createElementBlock(Fragment, null, renderList($data.rows, (row, i) => {
|
|
28
|
-
return (openBlock(),
|
|
26
|
+
return (openBlock(), createBlock(_component_CnConditionRow, {
|
|
29
27
|
key: i,
|
|
30
|
-
class: "cn-condition-list__row"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class: "cn-condition-list__operator",
|
|
43
|
-
modelValue: $options.operatorOption(row.operator),
|
|
44
|
-
options: $options.operatorOptions(row.field),
|
|
45
|
-
label: "label",
|
|
46
|
-
inputLabel: $options.t('nextcloud-vue', 'Operator'),
|
|
47
|
-
clearable: false,
|
|
48
|
-
disabled: !row.field,
|
|
49
|
-
"onUpdate:modelValue": $event => ($options.setOperator(i, $event))
|
|
50
|
-
}, null, 8 /* PROPS */, ["modelValue", "options", "inputLabel", "disabled", "onUpdate:modelValue"]),
|
|
51
|
-
($options.takesValue(row.operator))
|
|
52
|
-
? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
53
|
-
($options.valueOptions(row.field))
|
|
54
|
-
? (openBlock(), createBlock(_component_NcSelect, {
|
|
55
|
-
key: 0,
|
|
56
|
-
class: "cn-condition-list__value",
|
|
57
|
-
modelValue: $options.valueOption(row),
|
|
58
|
-
options: $options.valueOptions(row.field),
|
|
59
|
-
label: "label",
|
|
60
|
-
inputLabel: $options.t('nextcloud-vue', 'Value'),
|
|
61
|
-
clearable: false,
|
|
62
|
-
"onUpdate:modelValue": $event => ($options.setValue(i, $event ? $event.id : ''))
|
|
63
|
-
}, null, 8 /* PROPS */, ["modelValue", "options", "inputLabel", "onUpdate:modelValue"]))
|
|
64
|
-
: (openBlock(), createBlock(_component_NcTextField, {
|
|
65
|
-
key: 1,
|
|
66
|
-
class: "cn-condition-list__value",
|
|
67
|
-
type: $options.inputType(row.field),
|
|
68
|
-
modelValue: row.value === undefined || row.value === null ? '' : String(row.value),
|
|
69
|
-
label: $options.t('nextcloud-vue', 'Value'),
|
|
70
|
-
"onUpdate:modelValue": $event => ($options.setValue(i, $options.typedValue(row.field, $event)))
|
|
71
|
-
}, null, 8 /* PROPS */, ["type", "modelValue", "label", "onUpdate:modelValue"]))
|
|
72
|
-
], 64 /* STABLE_FRAGMENT */))
|
|
73
|
-
: createCommentVNode("v-if", true),
|
|
74
|
-
createVNode(_component_NcButton, {
|
|
75
|
-
variant: "tertiary",
|
|
76
|
-
"aria-label": $options.t('nextcloud-vue', 'Remove condition'),
|
|
77
|
-
onClick: $event => ($options.remove(i))
|
|
78
|
-
}, {
|
|
79
|
-
icon: withCtx(() => [
|
|
80
|
-
createVNode(_component_Close, { size: 18 })
|
|
81
|
-
]),
|
|
82
|
-
_: 1 /* STABLE */
|
|
83
|
-
}, 8 /* PROPS */, ["aria-label", "onClick"])
|
|
84
|
-
]))
|
|
28
|
+
class: "cn-condition-list__row",
|
|
29
|
+
condition: row,
|
|
30
|
+
fieldOptions: $options.fieldOptions,
|
|
31
|
+
operatorOptions: $options.operatorOptions(row.field),
|
|
32
|
+
valueOptions: $options.valueOptions(row.field),
|
|
33
|
+
inputType: $options.inputType(row.field),
|
|
34
|
+
showValue: $options.takesValue(row.operator),
|
|
35
|
+
onField: $event => ($options.setField(i, $event)),
|
|
36
|
+
onOperator: $event => ($options.setOperator(i, $event)),
|
|
37
|
+
onValue: $event => ($options.setValue(i, $options.valueOptions(row.field) ? $event : $options.typedValue(row.field, $event))),
|
|
38
|
+
onRemove: $event => ($options.remove(i))
|
|
39
|
+
}, null, 8 /* PROPS */, ["condition", "fieldOptions", "operatorOptions", "valueOptions", "inputType", "showValue", "onField", "onOperator", "onValue", "onRemove"]))
|
|
85
40
|
}), 128 /* KEYED_FRAGMENT */)),
|
|
86
41
|
createVNode(_component_NcButton, {
|
|
87
42
|
variant: "tertiary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnConditionListEditor.vue3.js","sources":["../../../../src/components/CnConditionListEditor/CnConditionListEditor.vue?vue&type=template&id=f00a4cf2&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<fieldset class=\"cn-condition-list\">\n\t\t<legend v-if=\"label\" class=\"cn-condition-list__label\">\n\t\t\t{{ label }}\n\t\t</legend>\n\t\t<p v-if=\"rows.length === 0\" class=\"cn-condition-list__empty\">\n\t\t\t{{ emptyText || t('nextcloud-vue', 'No conditions: the rule always applies.') }}\n\t\t</p>\n\t\t<div\n\t\t\tv-for=\"(row, i) in rows\"\n\t\t\t:key=\"i\"\n\t\t\tclass=\"cn-condition-list__row\">\n\t\t\t<NcSelect\n\t\t\t\tclass=\"cn-condition-list__field\"\n\t\t\t\t:modelValue=\"fieldOption(row.field)\"\n\t\t\t\t:options=\"fieldOptions\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Field')\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t@update:modelValue=\"setField(i, $event)\" />\n\t\t\t<NcSelect\n\t\t\t\tclass=\"cn-condition-list__operator\"\n\t\t\t\t:modelValue=\"operatorOption(row.operator)\"\n\t\t\t\t:options=\"operatorOptions(row.field)\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Operator')\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:disabled=\"!row.field\"\n\t\t\t\t@update:modelValue=\"setOperator(i, $event)\" />\n\t\t\t<template v-if=\"takesValue(row.operator)\">\n\t\t\t\t<NcSelect\n\t\t\t\t\tv-if=\"valueOptions(row.field)\"\n\t\t\t\t\tclass=\"cn-condition-list__value\"\n\t\t\t\t\t:modelValue=\"valueOption(row)\"\n\t\t\t\t\t:options=\"valueOptions(row.field)\"\n\t\t\t\t\tlabel=\"label\"\n\t\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Value')\"\n\t\t\t\t\t:clearable=\"false\"\n\t\t\t\t\t@update:modelValue=\"setValue(i, $event ? $event.id : '')\" />\n\t\t\t\t<NcTextField\n\t\t\t\t\tv-else\n\t\t\t\t\tclass=\"cn-condition-list__value\"\n\t\t\t\t\t:type=\"inputType(row.field)\"\n\t\t\t\t\t:modelValue=\"row.value === undefined || row.value === null ? '' : String(row.value)\"\n\t\t\t\t\t:label=\"t('nextcloud-vue', 'Value')\"\n\t\t\t\t\t@update:modelValue=\"setValue(i, typedValue(row.field, $event))\" />\n\t\t\t</template>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t:aria-label=\"t('nextcloud-vue', 'Remove condition')\"\n\t\t\t\t@click=\"remove(i)\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<Close :size=\"18\" />\n\t\t\t\t</template>\n\t\t\t</NcButton>\n\t\t</div>\n\t\t<NcButton variant=\"tertiary\" :disabled=\"fields.length === 0\" @click=\"add\">\n\t\t\t<template #icon>\n\t\t\t\t<Plus :size=\"18\" />\n\t\t\t</template>\n\t\t\t{{ t('nextcloud-vue', 'Add condition') }}\n\t\t</NcButton>\n\t</fieldset>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcSelect, NcTextField } from '@nextcloud/vue'\nimport Close from 'vue-material-design-icons/Close.vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport { operatorLabel, operatorsForType, operatorTakesValue } from './conditionOperators.js'\n\n/**\n * CnConditionListEditor - the conditions of a rule as rows over an object's\n * own fields: field, operator, value. All rows hold together. The operators\n * follow the field's type (see `operatorsForType`), \"is filled in\" needs no\n * value, and the value is a choice for a choice or yes/no field.\n *\n * v-model on `{ field, operator, value }[]`, in both dialects (`value`/`input`\n * and `modelValue`/`update:modelValue`). Read a condition back as words with\n * `conditionSentence` from `./conditionOperators.js`.\n */\nexport default {\n\tname: 'CnConditionListEditor',\n\n\tcomponents: { NcButton, NcSelect, NcTextField, Close, Plus },\n\n\tprops: {\n\t\t/**\n\t\t * The conditions.\n\t\t *\n\t\t * @type {Array<{field: string, operator: string, value?: unknown}>}\n\t\t */\n\t\tvalue: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {Array}\n\t\t */\n\t\tmodelValue: { type: Array, default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id, label, type, options?, format? }`.\n\t\t * `type` is number, integer, date, boolean, presence or anything else (text);\n\t\t * `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<{id: string, label: string, type?: string, options?: Array}>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The legend above the rows, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tlabel: { type: String, default: '' },\n\t\t/**\n\t\t * What an empty list says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\trows: this.copy(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The field choices.\n\t\t *\n\t\t * @return {Array<{id: string, label: string}>}\n\t\t */\n\t\tfieldOptions() {\n\t\t\treturn this.fields.map((f) => ({ id: f.id, label: f.label || f.id }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A detached copy of the bound conditions.\n\t\t *\n\t\t * @param {Array} list The conditions.\n\t\t * @return {Array} The copy.\n\t\t */\n\t\tcopy(list) {\n\t\t\treturn (Array.isArray(list) ? list : []).map((row) => ({ ...row }))\n\t\t},\n\n\t\t/**\n\t\t * The field with this id.\n\t\t *\n\t\t * @param {string} id The field id.\n\t\t * @return {object|undefined}\n\t\t */\n\t\tfieldOf(id) {\n\t\t\treturn this.fields.find((f) => f.id === id)\n\t\t},\n\n\t\tfieldOption(id) {\n\t\t\treturn this.fieldOptions.find((o) => o.id === id) || null\n\t\t},\n\n\t\toperatorOptions(fieldId) {\n\t\t\treturn operatorsForType(this.fieldOf(fieldId)?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t},\n\n\t\toperatorOption(operator) {\n\t\t\treturn operator ? { id: operator, label: operatorLabel(operator) } : null\n\t\t},\n\n\t\ttakesValue(operator) {\n\t\t\treturn operatorTakesValue(operator)\n\t\t},\n\n\t\t/**\n\t\t * The value choices of a field, or null when its value is typed.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @return {Array<{id: string, label: string}>|null}\n\t\t */\n\t\tvalueOptions(fieldId) {\n\t\t\tconst field = this.fieldOf(fieldId)\n\t\t\tif (field?.type === 'boolean') {\n\t\t\t\treturn [\n\t\t\t\t\t{ id: true, label: t('nextcloud-vue', 'Yes') },\n\t\t\t\t\t{ id: false, label: t('nextcloud-vue', 'No') },\n\t\t\t\t]\n\t\t\t}\n\t\t\tif (Array.isArray(field?.options) && field.options.length > 0) {\n\t\t\t\treturn field.options.map((o) => (typeof o === 'object'\n\t\t\t\t\t? { id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }\n\t\t\t\t\t: { id: o, label: String(o) }))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\tvalueOption(row) {\n\t\t\treturn (this.valueOptions(row.field) || []).find((o) => String(o.id) === String(row.value)) || null\n\t\t},\n\n\t\tinputType(fieldId) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif (type === 'number' || type === 'integer') {\n\t\t\t\treturn 'number'\n\t\t\t}\n\t\t\treturn type === 'date' ? 'date' : 'text'\n\t\t},\n\n\t\t/**\n\t\t * A typed value as stored: a number for a number field.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @param {string} raw What was typed.\n\t\t * @return {string|number}\n\t\t */\n\t\ttypedValue(fieldId, raw) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif ((type === 'number' || type === 'integer') && raw !== '' && !Number.isNaN(Number(raw))) {\n\t\t\t\treturn Number(raw)\n\t\t\t}\n\t\t\treturn raw\n\t\t},\n\n\t\tsetField(i, option) {\n\t\t\tconst field = this.fieldOf(option?.id)\n\t\t\tconst operators = operatorsForType(field?.type)\n\t\t\tthis.rows[i] = { field: option?.id || '', operator: operators[0], value: field?.type === 'boolean' ? true : '' }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetOperator(i, option) {\n\t\t\tconst row = { ...this.rows[i], operator: option?.id || 'eq' }\n\t\t\tif (!operatorTakesValue(row.operator)) {\n\t\t\t\tdelete row.value\n\t\t\t} else if (row.value === undefined) {\n\t\t\t\trow.value = ''\n\t\t\t}\n\t\t\tthis.rows[i] = row\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetValue(i, value) {\n\t\t\tthis.rows[i] = { ...this.rows[i], value }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tadd() {\n\t\t\tthis.rows.push({ field: '', operator: 'eq', value: '' })\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tremove(i) {\n\t\t\tthis.rows.splice(i, 1)\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\t/**\n\t\t * Tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\temitRows() {\n\t\t\tconst next = this.copy(this.rows)\n\t\t\t/**\n\t\t\t * The conditions changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('input', next)\n\t\t\t/**\n\t\t\t * The conditions changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', next)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tmin-width: 0;\n}\n\n.cn-condition-list__label {\n\tfont-weight: 600;\n\tpadding: 0;\n\tmargin-bottom: 4px;\n}\n\n.cn-condition-list__empty {\n\tcolor: var(--color-text-maxcontrast);\n\tmargin: 0;\n}\n\n.cn-condition-list__row {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.6fr) auto;\n\tgap: 8px;\n\talign-items: end;\n}\n\n.cn-condition-list__row > :nth-child(3):last-child {\n\tgrid-column: 4;\n}\n\n@media (max-width: 640px) {\n\t.cn-condition-list__row {\n\t\tgrid-template-columns: minmax(0, 1fr) auto;\n\t}\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_Fragment","_renderList","_createVNode","_createBlock"],"mappings":";;AAWW,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mBAAmB,GAAA;;;AA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AAA,GAAA,CAAA,KAAA,CAAA;AACf,oBAAA,KAAK,EAAE,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,OAAA,CAAA;oBACR,qBAAgB,EAAA,MAAA,KAAA,QAAA,CAAA,QAAA,CAAA,CAAA,EAAA,QAAA,CAAA,UAAA,CAAA,GAAA,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA,CAAA;;;;QAEjBD,WAOQ,CAAA,mBAAA,EAAA;AANT,UAAA,OAAO,EAAC,UAAE;AACT,UAAA,YAAQ,EAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,kBAAA,CAAA;UACR,OAAE,EAAA,MAAA,KAAA,QAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA;;AACQ,UAAA,IAAI,UACd,MAAa;YAAbA,WAAa,CAAA,gBAAA,EAAA,EAAL,IAAI,EAAC,EAAA,EAAA,CAAA;;;;;;IAIhBA;AAAU,MAAA,OAAA,EAAA,UAAA;MAAA,QAAA,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,KAAA,CAAA;AAAA,MAAA,OAAA,EAAA,QAAA,CAAA,GAAA;;AACD,MAAA,IAAA;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnConditionListEditor.vue3.js","sources":["../../../../src/components/CnConditionListEditor/CnConditionListEditor.vue?vue&type=template&id=77809f32&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<fieldset class=\"cn-condition-list\">\n\t\t<legend v-if=\"label\" class=\"cn-condition-list__label\">\n\t\t\t{{ label }}\n\t\t</legend>\n\t\t<p v-if=\"rows.length === 0\" class=\"cn-condition-list__empty\">\n\t\t\t{{ emptyText || t('nextcloud-vue', 'No conditions: the rule always applies.') }}\n\t\t</p>\n\t\t<CnConditionRow\n\t\t\tv-for=\"(row, i) in rows\"\n\t\t\t:key=\"i\"\n\t\t\tclass=\"cn-condition-list__row\"\n\t\t\t:condition=\"row\"\n\t\t\t:fieldOptions=\"fieldOptions\"\n\t\t\t:operatorOptions=\"operatorOptions(row.field)\"\n\t\t\t:valueOptions=\"valueOptions(row.field)\"\n\t\t\t:inputType=\"inputType(row.field)\"\n\t\t\t:showValue=\"takesValue(row.operator)\"\n\t\t\t@field=\"setField(i, $event)\"\n\t\t\t@operator=\"setOperator(i, $event)\"\n\t\t\t@value=\"setValue(i, valueOptions(row.field) ? $event : typedValue(row.field, $event))\"\n\t\t\t@remove=\"remove(i)\" />\n\t\t<NcButton variant=\"tertiary\" :disabled=\"fields.length === 0\" @click=\"add\">\n\t\t\t<template #icon>\n\t\t\t\t<Plus :size=\"18\" />\n\t\t\t</template>\n\t\t\t{{ t('nextcloud-vue', 'Add condition') }}\n\t\t</NcButton>\n\t</fieldset>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton } from '@nextcloud/vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport CnConditionRow from './CnConditionRow.vue'\nimport { operatorLabel, operatorsForType, operatorTakesValue } from './conditionOperators.js'\n\n/**\n * CnConditionListEditor - the conditions of a rule as rows over an object's\n * own fields: field, operator, value. All rows hold together. The operators\n * follow the field's type (see `operatorsForType`), \"is filled in\" needs no\n * value, and the value is a choice for a choice or yes/no field.\n *\n * v-model on `{ field, operator, value }[]`, in both dialects (`value`/`input`\n * and `modelValue`/`update:modelValue`). Read a condition back as words with\n * `conditionSentence` from `./conditionOperators.js`.\n */\nexport default {\n\tname: 'CnConditionListEditor',\n\n\tcomponents: { CnConditionRow, NcButton, Plus },\n\n\tprops: {\n\t\t/**\n\t\t * The conditions.\n\t\t *\n\t\t * @type {Array<{field: string, operator: string, value?: unknown}>}\n\t\t */\n\t\tvalue: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The same value under Vue 3's v-model name; wins over `value` when passed.\n\t\t *\n\t\t * @type {Array}\n\t\t */\n\t\tmodelValue: { type: Array, default: undefined },\n\t\t/**\n\t\t * The fields a condition may name: `{ id, label, type, options?, format? }`.\n\t\t * `type` is number, integer, date, boolean, presence or anything else (text);\n\t\t * `options` (`[{ id, label }]`) make the value a choice.\n\t\t *\n\t\t * @type {Array<{id: string, label: string, type?: string, options?: Array}>}\n\t\t */\n\t\tfields: { type: Array, default: () => [] },\n\t\t/**\n\t\t * The legend above the rows, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tlabel: { type: String, default: '' },\n\t\t/**\n\t\t * What an empty list says, already translated.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\temptyText: { type: String, default: '' },\n\t},\n\n\temits: ['input', 'update:modelValue'],\n\n\tdata() {\n\t\treturn {\n\t\t\trows: this.copy(this.modelValue !== undefined ? this.modelValue : this.value),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The field choices.\n\t\t *\n\t\t * @return {Array<{id: string, label: string}>}\n\t\t */\n\t\tfieldOptions() {\n\t\t\treturn this.fields.map((f) => ({ id: f.id, label: f.label || f.id }))\n\t\t},\n\t},\n\n\twatch: {\n\t\tvalue(next) {\n\t\t\tif (this.modelValue === undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\n\t\tmodelValue(next) {\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.rows = this.copy(next)\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A detached copy of the bound conditions.\n\t\t *\n\t\t * @param {Array} list The conditions.\n\t\t * @return {Array} The copy.\n\t\t */\n\t\tcopy(list) {\n\t\t\treturn (Array.isArray(list) ? list : []).map((row) => ({ ...row }))\n\t\t},\n\n\t\t/**\n\t\t * The field with this id.\n\t\t *\n\t\t * @param {string} id The field id.\n\t\t * @return {object|undefined}\n\t\t */\n\t\tfieldOf(id) {\n\t\t\treturn this.fields.find((f) => f.id === id)\n\t\t},\n\n\t\toperatorOptions(fieldId) {\n\t\t\treturn operatorsForType(this.fieldOf(fieldId)?.type).map((id) => ({ id, label: operatorLabel(id) }))\n\t\t},\n\n\t\ttakesValue(operator) {\n\t\t\treturn operatorTakesValue(operator)\n\t\t},\n\n\t\t/**\n\t\t * The value choices of a field, or null when its value is typed.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @return {Array<{id: string, label: string}>|null}\n\t\t */\n\t\tvalueOptions(fieldId) {\n\t\t\tconst field = this.fieldOf(fieldId)\n\t\t\tif (field?.type === 'boolean') {\n\t\t\t\treturn [\n\t\t\t\t\t{ id: true, label: t('nextcloud-vue', 'Yes') },\n\t\t\t\t\t{ id: false, label: t('nextcloud-vue', 'No') },\n\t\t\t\t]\n\t\t\t}\n\t\t\tif (Array.isArray(field?.options) && field.options.length > 0) {\n\t\t\t\treturn field.options.map((o) => (typeof o === 'object'\n\t\t\t\t\t? { id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }\n\t\t\t\t\t: { id: o, label: String(o) }))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\tinputType(fieldId) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif (type === 'number' || type === 'integer') {\n\t\t\t\treturn 'number'\n\t\t\t}\n\t\t\treturn type === 'date' ? 'date' : 'text'\n\t\t},\n\n\t\t/**\n\t\t * A typed value as stored: a number for a number field.\n\t\t *\n\t\t * @param {string} fieldId The field id.\n\t\t * @param {string} raw What was typed.\n\t\t * @return {string|number}\n\t\t */\n\t\ttypedValue(fieldId, raw) {\n\t\t\tconst type = this.fieldOf(fieldId)?.type\n\t\t\tif ((type === 'number' || type === 'integer') && raw !== '' && !Number.isNaN(Number(raw))) {\n\t\t\t\treturn Number(raw)\n\t\t\t}\n\t\t\treturn raw\n\t\t},\n\n\t\tsetField(i, option) {\n\t\t\tconst field = this.fieldOf(option?.id)\n\t\t\tconst operators = operatorsForType(field?.type)\n\t\t\tthis.rows[i] = { field: option?.id || '', operator: operators[0], value: field?.type === 'boolean' ? true : '' }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetOperator(i, option) {\n\t\t\tconst row = { ...this.rows[i], operator: option?.id || 'eq' }\n\t\t\tif (!operatorTakesValue(row.operator)) {\n\t\t\t\tdelete row.value\n\t\t\t} else if (row.value === undefined) {\n\t\t\t\trow.value = ''\n\t\t\t}\n\t\t\tthis.rows[i] = row\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tsetValue(i, value) {\n\t\t\tthis.rows[i] = { ...this.rows[i], value }\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tadd() {\n\t\t\tthis.rows.push({ field: '', operator: 'eq', value: '' })\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\tremove(i) {\n\t\t\tthis.rows.splice(i, 1)\n\t\t\tthis.emitRows()\n\t\t},\n\n\t\t/**\n\t\t * Tell the consumer, in both v-model dialects.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\temitRows() {\n\t\t\tconst next = this.copy(this.rows)\n\t\t\t/**\n\t\t\t * The conditions changed.\n\t\t\t *\n\t\t\t * @event input\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('input', next)\n\t\t\t/**\n\t\t\t * The conditions changed (Vue 3 v-model).\n\t\t\t *\n\t\t\t * @event update:modelValue\n\t\t\t * @type {Array}\n\t\t\t */\n\t\t\tthis.$emit('update:modelValue', next)\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-condition-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tmin-width: 0;\n}\n\n.cn-condition-list__label {\n\tfont-weight: 600;\n\tpadding: 0;\n\tmargin-bottom: 4px;\n}\n\n.cn-condition-list__empty {\n\tcolor: var(--color-text-maxcontrast);\n\tmargin: 0;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_Fragment","_renderList","_createVNode"],"mappings":";;AAWW,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mBA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AA;AAClB,QAAA,OAAK,aAAE,QAAE,CAAA,QAAA,CAAA,CAAA,EAAA,QAAA,CAAA,YAAA,CAAA,GAAA,CAAA,KAAA,CAAA,GAAA,MAAA,GAAA,QAAA,CAAA,UAAA,CAAA,GAAA,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA,CAAA;QACT,QAAM,EAAA,MAAA,KAAE,QAAM,CAAA,MAAA,CAAC,CAAC,CAAA,CAAA;;;IAClBC;AAAU,MAAA,OAAA,EAAA,UAAA;MAAA,QAAA,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,KAAA,CAAA;AAAA,MAAA,OAAA,EAAA,QAAA,CAAA,GAAA;;AACD,MAAA,IAAA;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import script from './CnConditionRow.vue2.js';
|
|
2
|
+
import { render } from './CnConditionRow.vue3.js';
|
|
3
|
+
|
|
4
|
+
script.render = render;
|
|
5
|
+
script.__scopeId = "data-v-e1c8a9e2";
|
|
6
|
+
const __sfc_main = script;
|
|
7
|
+
|
|
8
|
+
export { __sfc_main as default };
|
|
9
|
+
//# sourceMappingURL=CnConditionRow.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnConditionRow.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|