@conduction/nextcloud-vue 2.170.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.
Files changed (139) hide show
  1. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js +9 -0
  2. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js.map +1 -0
  3. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js +242 -0
  4. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js.map +1 -0
  5. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js +200 -0
  6. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js.map +1 -0
  7. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js +9 -0
  8. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js.map +1 -0
  9. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js +186 -0
  10. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js.map +1 -0
  11. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js +24 -0
  12. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js.map +1 -0
  13. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue.js +1 -1
  14. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js +3 -15
  15. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js.map +1 -1
  16. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js +16 -61
  17. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js.map +1 -1
  18. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js +9 -0
  19. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js.map +1 -0
  20. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js +120 -0
  21. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js.map +1 -0
  22. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js +86 -0
  23. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js.map +1 -0
  24. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +1 -1
  25. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  26. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +9 -9
  27. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  28. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue.js +1 -1
  29. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue2.js.map +1 -1
  30. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue3.js.map +1 -1
  31. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue.js +1 -1
  32. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  33. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  34. package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js +8 -0
  35. package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js.map +1 -0
  36. package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js +101 -0
  37. package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js.map +1 -0
  38. package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js +54 -0
  39. package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js.map +1 -0
  40. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
  41. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +14 -2
  42. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
  43. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +1 -1
  44. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
  45. package/dist/esm/components/CnFilesBrowser/filesBrowser.js +21 -2
  46. package/dist/esm/components/CnFilesBrowser/filesBrowser.js.map +1 -1
  47. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
  48. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +7 -0
  49. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
  50. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +2 -2
  51. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
  52. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +11 -0
  53. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
  54. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +2 -1
  55. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
  56. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue.js +1 -1
  57. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue2.js.map +1 -1
  58. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue3.js.map +1 -1
  59. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js +9 -0
  60. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js.map +1 -0
  61. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js +248 -0
  62. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js.map +1 -0
  63. package/dist/esm/components/{CnMassDeleteDialog/CnMassDeleteDialog.vue3.js → CnMassActionDialog/CnMassActionDialog.vue3.js} +66 -52
  64. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue3.js.map +1 -0
  65. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js +0 -3
  66. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js.map +1 -1
  67. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js +25 -121
  68. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js.map +1 -1
  69. package/dist/esm/components/CnNotesCard/CnNotesCard.vue.js +1 -1
  70. package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js +11 -3
  71. package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js.map +1 -1
  72. package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js +1 -1
  73. package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js.map +1 -1
  74. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue.js +1 -1
  75. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js +21 -1
  76. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js.map +1 -1
  77. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js +2 -2
  78. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js.map +1 -1
  79. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  80. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  81. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +23 -5
  82. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  83. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  84. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +3 -0
  85. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  86. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +14 -4
  87. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  88. package/dist/esm/dialogs/CnConfirmDialog.vue.js +1 -1
  89. package/dist/esm/dialogs/CnConfirmDialog.vue2.js.map +1 -1
  90. package/dist/esm/dialogs/CnConfirmDialog.vue3.js +5 -3
  91. package/dist/esm/dialogs/CnConfirmDialog.vue3.js.map +1 -1
  92. package/dist/esm/index.js +3 -0
  93. package/dist/esm/index.js.map +1 -1
  94. package/dist/esm/l10n/en.json.js +16 -1
  95. package/dist/esm/l10n/en.json.js.map +1 -1
  96. package/dist/esm/l10n/nl.json.js +16 -1
  97. package/dist/esm/l10n/nl.json.js.map +1 -1
  98. package/dist/esm/library-style.js +1 -1
  99. package/dist/esm/nextcloud-vue.css +638 -302
  100. package/dist/esm/utils/noteThreads.js +14 -2
  101. package/dist/esm/utils/noteThreads.js.map +1 -1
  102. package/dist/nextcloud-vue.cjs.js +11316 -10074
  103. package/dist/nextcloud-vue.cjs.js.map +2 -2
  104. package/dist/nextcloud-vue.css +638 -302
  105. package/l10n/en.json +16 -1
  106. package/l10n/nl.json +16 -1
  107. package/package.json +1 -1
  108. package/scripts/.jsdoc-baselines.json +1 -1
  109. package/src/components/CnConditionGroupEditor/CnConditionGroup.vue +528 -0
  110. package/src/components/CnConditionGroupEditor/CnConditionGroupEditor.vue +211 -0
  111. package/src/components/CnConditionGroupEditor/index.js +9 -0
  112. package/src/components/CnConditionListEditor/CnConditionListEditor.vue +15 -78
  113. package/src/components/CnConditionListEditor/CnConditionRow.vue +226 -0
  114. package/src/components/CnDetailPage/CnDetailPage.vue +8 -8
  115. package/src/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue +6 -0
  116. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +0 -6
  117. package/src/components/CnDialogActions/CnDialogActions.vue +124 -0
  118. package/src/components/CnDialogActions/index.js +7 -0
  119. package/src/components/CnFilesBrowser/CnFilesBrowser.vue +15 -3
  120. package/src/components/CnFilesBrowser/filesBrowser.js +21 -2
  121. package/src/components/CnFlowsPage/CnFlowBoard.vue +10 -3
  122. package/src/components/CnFlowsPage/CnFlowEditorPage.vue +12 -0
  123. package/src/components/CnLinkedWidget/CnLinkedWidget.vue +7 -0
  124. package/src/components/CnMassActionDialog/CnMassActionDialog.vue +382 -0
  125. package/src/components/CnMassActionDialog/index.js +7 -0
  126. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.md +4 -0
  127. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +25 -254
  128. package/src/components/CnNotesCard/CnNotesCard.vue +12 -4
  129. package/src/components/CnObjectSidebar/CnNotesTab.vue +23 -3
  130. package/src/components/CnTreeView/CnTreeNode.vue +10 -1
  131. package/src/components/CnTreeView/CnTreeView.vue +9 -0
  132. package/src/components/index.js +3 -0
  133. package/src/css/context-menu.css +7 -0
  134. package/src/css/look-board-detail.css +120 -1
  135. package/src/css/look-board.css +43 -2
  136. package/src/dialogs/CnConfirmDialog.vue +3 -1
  137. package/src/index.js +3 -0
  138. package/src/utils/noteThreads.js +13 -1
  139. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue3.js.map +0 -1
package/l10n/en.json CHANGED
@@ -2594,7 +2594,22 @@
2594
2594
  "Shown on the card. Leave empty to show the step type.": "Shown on the card. Leave empty to show the step type.",
2595
2595
  "The full configuration document. The fields above update along.": "The full configuration document. The fields above update along.",
2596
2596
  "This step has no options.": "This step has no options.",
2597
- "{uid} (you)": "{uid} (you)"
2597
+ "{uid} (you)": "{uid} (you)",
2598
+ "The action applies to the following items. Remove any items you want to leave out.": "The action applies to the following items. Remove any items you want to leave out.",
2599
+ "No items selected.": "No items selected.",
2600
+ "Are you sure you want to continue with {count}?": "Are you sure you want to continue with {count}?",
2601
+ "How the conditions combine": "How the conditions combine",
2602
+ "Match all conditions": "Match all conditions",
2603
+ "Match any condition": "Match any condition",
2604
+ "Where": "Where",
2605
+ "and": "and",
2606
+ "all of these": "all of these",
2607
+ "one of these": "one of these",
2608
+ "Add group": "Add group",
2609
+ "Remove group": "Remove group",
2610
+ "Condition": "Condition",
2611
+ "These conditions are kept as written": "These conditions are kept as written",
2612
+ "This group has no conditions yet.": "This group has no conditions yet."
2598
2613
  },
2599
2614
  "plurals": {
2600
2615
  "{count} member": [
package/l10n/nl.json CHANGED
@@ -2859,7 +2859,22 @@
2859
2859
  "Shown on the card. Leave empty to show the step type.": "Staat op de kaart. Laat leeg om het soort stap te tonen.",
2860
2860
  "The full configuration document. The fields above update along.": "Alle instellingen in één document. De velden hierboven passen zich aan.",
2861
2861
  "This step has no options.": "Deze stap heeft geen opties.",
2862
- "{uid} (you)": "{uid} (jij)"
2862
+ "{uid} (you)": "{uid} (jij)",
2863
+ "The action applies to the following items. Remove any items you want to leave out.": "De actie geldt voor de volgende items. Haal items weg die je wilt overslaan.",
2864
+ "No items selected.": "Geen items geselecteerd.",
2865
+ "Are you sure you want to continue with {count}?": "Weet je zeker dat je wilt doorgaan met {count}?",
2866
+ "How the conditions combine": "Hoe de voorwaarden samengaan",
2867
+ "Match all conditions": "Voldoet aan alle voorwaarden",
2868
+ "Match any condition": "Voldoet aan een van de voorwaarden",
2869
+ "Where": "Waarbij",
2870
+ "and": "en",
2871
+ "all of these": "al deze",
2872
+ "one of these": "een van deze",
2873
+ "Add group": "Groep toevoegen",
2874
+ "Remove group": "Groep verwijderen",
2875
+ "Condition": "Voorwaarde",
2876
+ "These conditions are kept as written": "Deze voorwaarden blijven zoals ze zijn geschreven",
2877
+ "This group has no conditions yet.": "Deze groep heeft nog geen voorwaarden."
2863
2878
  },
2864
2879
  "plurals": {
2865
2880
  "{count} member": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/nextcloud-vue",
3
- "version": "2.170.0",
3
+ "version": "2.171.0",
4
4
  "description": "Shared Vue component library for Conduction Nextcloud apps — complements @nextcloud/vue with higher-level components, OpenRegister integration, and NL Design System support",
5
5
  "homepage": "https://github.com/ConductionNL/nextcloud-vue#readme",
6
6
  "bugs": {
@@ -144,7 +144,7 @@
144
144
  "CnMarkdownEditor": 1,
145
145
  "CnMassActionBar": 1,
146
146
  "CnMassCopyDialog": 0.92,
147
- "CnMassDeleteDialog": 0.92,
147
+ "CnMassDeleteDialog": 1,
148
148
  "CnMassExportDialog": 0.93,
149
149
  "CnMassImportDialog": 0.87,
150
150
  "CnMenuItemEditor": 1,
@@ -0,0 +1,528 @@
1
+ <!--
2
+ - SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ - SPDX-License-Identifier: EUPL-1.2
4
+ -->
5
+
6
+ <template>
7
+ <div
8
+ class="cn-condition-group"
9
+ :class="{
10
+ 'cn-condition-group--nested': depth > 0,
11
+ 'cn-condition-group--error': !!ownError,
12
+ }">
13
+ <div class="cn-condition-group__header">
14
+ <fieldset class="cn-condition-group__combinator">
15
+ <legend class="cn-condition-group__legend">
16
+ {{ t('nextcloud-vue', 'How the conditions combine') }}
17
+ </legend>
18
+ <NcCheckboxRadioSwitch
19
+ v-for="choice in combinators"
20
+ :key="choice.value"
21
+ type="radio"
22
+ :class="{ 'cn-condition-group__choice--checked': node.type === choice.value }"
23
+ :name="radioName"
24
+ :value="choice.value"
25
+ :modelValue="node.type"
26
+ @update:modelValue="setType">
27
+ {{ choice.label }}
28
+ </NcCheckboxRadioSwitch>
29
+ </fieldset>
30
+ <NcButton
31
+ v-if="depth > 0"
32
+ class="cn-condition-group__remove-group"
33
+ variant="tertiary"
34
+ @click="$emit('remove')">
35
+ <template #icon>
36
+ <TrashCanOutline :size="16" />
37
+ </template>
38
+ {{ t('nextcloud-vue', 'Remove group') }}
39
+ </NcButton>
40
+ </div>
41
+
42
+ <ol v-if="node.children.length" class="cn-condition-group__rows">
43
+ <li v-for="(child, index) in node.children" :key="index" class="cn-condition-group__item">
44
+ <template v-if="kindOf(child) === 'group'">
45
+ <div class="cn-condition-group__line">
46
+ <span class="cn-condition-group__connector">{{ connector(index) }}</span>
47
+ <span class="cn-condition-group__caption">{{ caption(child) }}</span>
48
+ </div>
49
+ <CnConditionGroup
50
+ class="cn-condition-group__child"
51
+ :node="child"
52
+ :depth="depth + 1"
53
+ :path="childPath(index)"
54
+ :fields="fields"
55
+ :operatorsFor="operatorsFor"
56
+ :maxDepth="maxDepth"
57
+ :errors="errors"
58
+ @update:node="setChild(index, $event)"
59
+ @remove="removeChild(index)" />
60
+ </template>
61
+ <div v-else-if="kindOf(child) === 'locked'" class="cn-condition-group__line">
62
+ <span class="cn-condition-group__connector">{{ connector(index) }}</span>
63
+ <div class="cn-condition-group__locked">
64
+ <Lock :size="16" />
65
+ <span>{{ t('nextcloud-vue', 'These conditions are kept as written') }}</span>
66
+ <NcButton
67
+ class="cn-condition-group__pill"
68
+ variant="tertiary"
69
+ :aria-label="t('nextcloud-vue', 'Remove group')"
70
+ :title="t('nextcloud-vue', 'Remove group')"
71
+ @click="removeChild(index)">
72
+ <template #icon>
73
+ <TrashCanOutline :size="18" />
74
+ </template>
75
+ </NcButton>
76
+ </div>
77
+ </div>
78
+ <div v-else class="cn-condition-group__line">
79
+ <span class="cn-condition-group__connector">{{ connector(index) }}</span>
80
+ <CnConditionRow
81
+ class="cn-condition-group__row"
82
+ :condition="child"
83
+ :fieldOptions="fieldOptionsFor(child)"
84
+ :operatorOptions="operatorOptionsFor(child)"
85
+ :valueOptions="valueOptionsFor(child)"
86
+ :inputType="inputTypeFor(child)"
87
+ :showValue="operatorTakesValue(child.operator)"
88
+ :controlLabels="controlLabels"
89
+ :error="errors[childPath(index)] || ''"
90
+ hideLabels
91
+ @field="setField(index, $event)"
92
+ @operator="setOperator(index, $event)"
93
+ @value="setValue(index, child, $event)"
94
+ @remove="removeChild(index)">
95
+ <template #remove-icon>
96
+ <TrashCanOutline :size="18" />
97
+ </template>
98
+ </CnConditionRow>
99
+ </div>
100
+ </li>
101
+ </ol>
102
+ <p v-else class="cn-condition-group__empty">
103
+ {{ depth === 0 && emptyText ? emptyText : t('nextcloud-vue', 'This group has no conditions yet.') }}
104
+ </p>
105
+
106
+ <p v-if="ownError" class="cn-condition-group__error" role="alert">
107
+ {{ ownError }}
108
+ </p>
109
+
110
+ <div class="cn-condition-group__actions">
111
+ <NcButton variant="tertiary" :disabled="fields.length === 0" @click="addCondition">
112
+ <template #icon>
113
+ <Plus :size="16" />
114
+ </template>
115
+ {{ t('nextcloud-vue', 'Add condition') }}
116
+ </NcButton>
117
+ <NcButton v-if="depth < maxDepth"
118
+ variant="tertiary"
119
+ :disabled="fields.length === 0"
120
+ @click="addGroup">
121
+ <template #icon>
122
+ <FolderPlusOutline :size="16" />
123
+ </template>
124
+ {{ t('nextcloud-vue', 'Add group') }}
125
+ </NcButton>
126
+ </div>
127
+ </div>
128
+ </template>
129
+
130
+ <script>
131
+ import { translate as t } from '@nextcloud/l10n'
132
+ import { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'
133
+ import FolderPlusOutline from 'vue-material-design-icons/FolderPlusOutline.vue'
134
+ import Lock from 'vue-material-design-icons/Lock.vue'
135
+ import Plus from 'vue-material-design-icons/Plus.vue'
136
+ import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
137
+ import CnConditionRow from '../CnConditionListEditor/CnConditionRow.vue'
138
+ import { operatorTakesValue } from '../CnConditionListEditor/conditionOperators.js'
139
+
140
+ let groupSeq = 0
141
+
142
+ /**
143
+ * CnConditionGroup - one group of CnConditionGroupEditor: the combinator
144
+ * choice, its rows, and the groups inside it, drawn recursively. Internal to
145
+ * the editor, which owns the tree.
146
+ */
147
+ export default {
148
+ name: 'CnConditionGroup',
149
+
150
+ components: { CnConditionRow, FolderPlusOutline, Lock, NcButton, NcCheckboxRadioSwitch, Plus, TrashCanOutline },
151
+
152
+ props: {
153
+ /** The group: `{ type: 'AND' | 'OR', children }`. */
154
+ node: { type: Object, required: true },
155
+ /** How deep this group sits; the root is 0. */
156
+ depth: { type: Number, default: 0 },
157
+ /** This group's path in validator notation (`$.children[1]`). */
158
+ path: { type: String, default: '$' },
159
+ /** The fields, normalised to `{ id, label, type, format?, options? }`. */
160
+ fields: { type: Array, default: () => [] },
161
+ /** The operators of a field, `(field) => [{ id, label }]`. */
162
+ operatorsFor: { type: Function, required: true },
163
+ /** The deepest group Add group may create. */
164
+ maxDepth: { type: Number, default: 1 },
165
+ /** Messages keyed by node path. */
166
+ errors: { type: Object, default: () => ({}) },
167
+ /** What an empty root says, already translated. */
168
+ emptyText: { type: String, default: '' },
169
+ },
170
+
171
+ emits: ['update:node', 'remove'],
172
+
173
+ data() {
174
+ groupSeq += 1
175
+ return { radioName: `cn-condition-group-${groupSeq}` }
176
+ },
177
+
178
+ computed: {
179
+ combinators() {
180
+ return [
181
+ { value: 'AND', label: t('nextcloud-vue', 'Match all conditions') },
182
+ { value: 'OR', label: t('nextcloud-vue', 'Match any condition') },
183
+ ]
184
+ },
185
+
186
+ controlLabels() {
187
+ return {
188
+ field: t('nextcloud-vue', 'Field'),
189
+ operator: t('nextcloud-vue', 'Condition'),
190
+ value: t('nextcloud-vue', 'Value'),
191
+ }
192
+ },
193
+
194
+ ownError() {
195
+ return this.errors[this.path] || ''
196
+ },
197
+ },
198
+
199
+ methods: {
200
+ t,
201
+ operatorTakesValue,
202
+
203
+ /**
204
+ * What a child is: a group drawn as a card, a group the editor keeps
205
+ * as written (NOT), or a condition.
206
+ *
207
+ * @param {object} child The child node.
208
+ * @return {string} group, locked or condition.
209
+ */
210
+ kindOf(child) {
211
+ if (!Array.isArray(child?.children)) {
212
+ return 'condition'
213
+ }
214
+ return ['AND', 'OR'].includes(String(child.type || 'AND').toUpperCase()) ? 'group' : 'locked'
215
+ },
216
+
217
+ /**
218
+ * The word before a row: Where on the first, then and or or.
219
+ *
220
+ * @param {number} index The row index.
221
+ * @return {string} The word.
222
+ */
223
+ connector(index) {
224
+ if (index === 0) {
225
+ return t('nextcloud-vue', 'Where')
226
+ }
227
+ return this.node.type === 'OR' ? t('nextcloud-vue', 'or') : t('nextcloud-vue', 'and')
228
+ },
229
+
230
+ caption(child) {
231
+ return String(child.type).toUpperCase() === 'OR'
232
+ ? t('nextcloud-vue', 'one of these')
233
+ : t('nextcloud-vue', 'all of these')
234
+ },
235
+
236
+ childPath(index) {
237
+ return `${this.path}.children[${index}]`
238
+ },
239
+
240
+ fieldOf(id) {
241
+ return this.fields.find((f) => f.id === id)
242
+ },
243
+
244
+ /**
245
+ * The field choices, plus a stored field the list does not offer.
246
+ *
247
+ * @param {object} child The condition.
248
+ * @return {Array<{id: string, label: string}>} The choices.
249
+ */
250
+ fieldOptionsFor(child) {
251
+ const options = this.fields.map((f) => ({ id: f.id, label: f.label || f.id }))
252
+ if (child.field && !options.some((o) => o.id === child.field)) {
253
+ options.push({ id: child.field, label: child.field })
254
+ }
255
+ return options
256
+ },
257
+
258
+ /**
259
+ * The operator choices of the condition's field, plus a stored
260
+ * operator the list does not offer.
261
+ *
262
+ * @param {object} child The condition.
263
+ * @return {Array<{id: string, label: string}>} The choices.
264
+ */
265
+ operatorOptionsFor(child) {
266
+ const options = this.operatorsFor(this.fieldOf(child.field))
267
+ if (child.operator && !options.some((o) => o.id === child.operator)) {
268
+ return [...options, { id: child.operator, label: child.operator }]
269
+ }
270
+ return options
271
+ },
272
+
273
+ valueOptionsFor(child) {
274
+ const field = this.fieldOf(child.field)
275
+ if (field?.type === 'boolean') {
276
+ return [
277
+ { id: true, label: t('nextcloud-vue', 'Yes') },
278
+ { id: false, label: t('nextcloud-vue', 'No') },
279
+ ]
280
+ }
281
+ if (Array.isArray(field?.options) && field.options.length > 0) {
282
+ return field.options.map((o) => (typeof o === 'object'
283
+ ? { id: o.id ?? o.value, label: o.label ?? String(o.id ?? o.value) }
284
+ : { id: o, label: String(o) }))
285
+ }
286
+ return null
287
+ },
288
+
289
+ inputTypeFor(child) {
290
+ const field = this.fieldOf(child.field)
291
+ if (field?.type === 'number' || field?.type === 'integer') {
292
+ return 'number'
293
+ }
294
+ return field?.type === 'date' || field?.format === 'date' ? 'date' : 'text'
295
+ },
296
+
297
+ emitNode(next) {
298
+ this.$emit('update:node', next)
299
+ },
300
+
301
+ setChildren(children) {
302
+ this.emitNode({ ...this.node, children })
303
+ },
304
+
305
+ setChild(index, next) {
306
+ const children = [...this.node.children]
307
+ children[index] = next
308
+ this.setChildren(children)
309
+ },
310
+
311
+ removeChild(index) {
312
+ this.setChildren(this.node.children.filter((_, i) => i !== index))
313
+ },
314
+
315
+ setType(type) {
316
+ this.emitNode({ ...this.node, type: type === 'OR' ? 'OR' : 'AND' })
317
+ },
318
+
319
+ addCondition() {
320
+ this.setChildren([...this.node.children, { field: '', operator: '', value: '' }])
321
+ },
322
+
323
+ addGroup() {
324
+ this.setChildren([...this.node.children, { type: 'AND', children: [{ field: '', operator: '', value: '' }] }])
325
+ },
326
+
327
+ /**
328
+ * Pick a field: the operator resets to the field's first one and the
329
+ * value clears, since a value for another field rarely fits.
330
+ *
331
+ * @param {number} index The row index.
332
+ * @param {object} option The field choice.
333
+ */
334
+ setField(index, option) {
335
+ const field = this.fieldOf(option?.id)
336
+ const first = this.operatorsFor(field)[0]
337
+ this.setChild(index, {
338
+ field: option?.id || '',
339
+ operator: first ? first.id : '',
340
+ value: field?.type === 'boolean' ? true : '',
341
+ })
342
+ },
343
+
344
+ setOperator(index, option) {
345
+ const next = { ...this.node.children[index], operator: option?.id || '' }
346
+ if (!operatorTakesValue(next.operator)) {
347
+ delete next.value
348
+ } else if (next.value === undefined) {
349
+ next.value = ''
350
+ }
351
+ this.setChild(index, next)
352
+ },
353
+
354
+ /**
355
+ * Set a value, as a number for a number field.
356
+ *
357
+ * @param {number} index The row index.
358
+ * @param {object} child The condition.
359
+ * @param {unknown} raw The picked or typed value.
360
+ */
361
+ setValue(index, child, raw) {
362
+ let value = raw
363
+ if (this.inputTypeFor(child) === 'number' && raw !== '' && !Number.isNaN(Number(raw))) {
364
+ value = Number(raw)
365
+ }
366
+ this.setChild(index, { ...child, value })
367
+ },
368
+ },
369
+ }
370
+ </script>
371
+
372
+ <style scoped>
373
+ .cn-condition-group {
374
+ display: flex;
375
+ flex-direction: column;
376
+ gap: 10px;
377
+ min-width: 0;
378
+ padding: 14px;
379
+ border: 1px solid var(--color-border);
380
+ border-radius: var(--border-radius-large);
381
+ --cn-condition-row-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.25fr) auto;
382
+ --cn-condition-row-align: center;
383
+ }
384
+
385
+ .cn-condition-group--nested {
386
+ margin-inline-start: 52px;
387
+ padding: 12px 12px 8px;
388
+ border-color: var(--color-border);
389
+ border-inline-start: 3px solid var(--color-primary-element);
390
+ border-radius: var(--border-radius-element, 8px);
391
+ background: var(--color-background-hover);
392
+ }
393
+
394
+ .cn-condition-group--error {
395
+ border-color: var(--color-border-error, var(--color-error));
396
+ }
397
+
398
+ .cn-condition-group__header {
399
+ display: flex;
400
+ flex-wrap: wrap;
401
+ align-items: center;
402
+ justify-content: space-between;
403
+ gap: 8px;
404
+ }
405
+
406
+ .cn-condition-group__combinator {
407
+ display: flex;
408
+ flex-wrap: wrap;
409
+ align-items: center;
410
+ gap: 8px 18px;
411
+ margin: 0;
412
+ padding: 0;
413
+ border: 0;
414
+ min-width: 0;
415
+ }
416
+
417
+ .cn-condition-group__legend {
418
+ float: inline-start;
419
+ margin-inline-end: 6px;
420
+ padding: 0;
421
+ font-size: 13px;
422
+ color: var(--color-text-maxcontrast);
423
+ }
424
+
425
+ .cn-condition-group__choice--checked :deep(.checkbox-radio-switch__text) {
426
+ font-weight: 600;
427
+ }
428
+
429
+ .cn-condition-group__remove-group {
430
+ color: var(--color-text-error, var(--color-error));
431
+ }
432
+
433
+ .cn-condition-group__rows {
434
+ display: flex;
435
+ flex-direction: column;
436
+ gap: 10px;
437
+ margin: 0;
438
+ padding: 0;
439
+ list-style: none;
440
+ }
441
+
442
+ .cn-condition-group__item {
443
+ display: flex;
444
+ flex-direction: column;
445
+ gap: 10px;
446
+ min-width: 0;
447
+ }
448
+
449
+ .cn-condition-group__line {
450
+ display: flex;
451
+ align-items: center;
452
+ gap: 8px;
453
+ min-width: 0;
454
+ }
455
+
456
+ .cn-condition-group__connector {
457
+ flex: 0 0 44px;
458
+ font-size: 13px;
459
+ font-weight: 600;
460
+ color: var(--color-text-maxcontrast);
461
+ }
462
+
463
+ .cn-condition-group__caption {
464
+ font-size: 13px;
465
+ color: var(--color-text-maxcontrast);
466
+ }
467
+
468
+ .cn-condition-group__row {
469
+ flex: 1 1 auto;
470
+ }
471
+
472
+ .cn-condition-group__locked {
473
+ display: flex;
474
+ flex: 1 1 auto;
475
+ align-items: center;
476
+ gap: 8px;
477
+ min-height: var(--default-clickable-area);
478
+ padding: 0 0 0 10px;
479
+ border: 1px dashed var(--color-border-dark);
480
+ border-radius: var(--border-radius-element, 8px);
481
+ color: var(--color-text-maxcontrast);
482
+ }
483
+
484
+ .cn-condition-group__locked > span {
485
+ flex: 1 1 auto;
486
+ }
487
+
488
+ .cn-condition-group__pill,
489
+ .cn-condition-group__row :deep(.cn-condition-row__remove) {
490
+ border-radius: var(--border-radius-pill, 17px);
491
+ }
492
+
493
+ .cn-condition-group__empty {
494
+ margin: 0;
495
+ padding: 12px;
496
+ border: 1px dashed var(--color-border-dark);
497
+ border-radius: var(--border-radius-large);
498
+ color: var(--color-text-maxcontrast);
499
+ text-align: center;
500
+ }
501
+
502
+ .cn-condition-group__error {
503
+ margin: 0;
504
+ color: var(--color-text-error, var(--color-error));
505
+ font-size: 0.9em;
506
+ }
507
+
508
+ .cn-condition-group__actions {
509
+ display: flex;
510
+ flex-wrap: wrap;
511
+ gap: 6px;
512
+ padding-inline-start: 44px;
513
+ }
514
+
515
+ @media (max-width: 640px) {
516
+ .cn-condition-group--nested {
517
+ margin-inline-start: 12px;
518
+ }
519
+
520
+ .cn-condition-group__line {
521
+ flex-wrap: wrap;
522
+ }
523
+
524
+ .cn-condition-group__actions {
525
+ padding-inline-start: 0;
526
+ }
527
+ }
528
+ </style>