@conduction/nextcloud-vue 2.170.0 → 2.172.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 (163) hide show
  1. package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
  2. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
  3. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
  4. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
  5. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +22 -3
  6. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
  7. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
  8. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js +9 -0
  9. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue.js.map +1 -0
  10. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js +242 -0
  11. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue2.js.map +1 -0
  12. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js +200 -0
  13. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroup.vue3.js.map +1 -0
  14. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js +9 -0
  15. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue.js.map +1 -0
  16. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js +186 -0
  17. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue2.js.map +1 -0
  18. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js +24 -0
  19. package/dist/esm/components/CnConditionGroupEditor/CnConditionGroupEditor.vue3.js.map +1 -0
  20. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue.js +1 -1
  21. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js +3 -15
  22. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue2.js.map +1 -1
  23. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js +16 -61
  24. package/dist/esm/components/CnConditionListEditor/CnConditionListEditor.vue3.js.map +1 -1
  25. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js +9 -0
  26. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue.js.map +1 -0
  27. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js +120 -0
  28. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue2.js.map +1 -0
  29. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js +86 -0
  30. package/dist/esm/components/CnConditionListEditor/CnConditionRow.vue3.js.map +1 -0
  31. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +1 -1
  32. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  33. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +9 -9
  34. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  35. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue.js +1 -1
  36. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue2.js.map +1 -1
  37. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue3.js.map +1 -1
  38. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue.js +1 -1
  39. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  40. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  41. package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue.js +1 -1
  42. package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue2.js +75 -4
  43. package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue2.js.map +1 -1
  44. package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue3.js.map +1 -1
  45. package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js +8 -0
  46. package/dist/esm/components/CnDialogActions/CnDialogActions.vue.js.map +1 -0
  47. package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js +101 -0
  48. package/dist/esm/components/CnDialogActions/CnDialogActions.vue2.js.map +1 -0
  49. package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js +54 -0
  50. package/dist/esm/components/CnDialogActions/CnDialogActions.vue3.js.map +1 -0
  51. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
  52. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +7 -3
  53. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
  54. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
  55. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
  56. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +14 -2
  57. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
  58. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +1 -1
  59. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
  60. package/dist/esm/components/CnFilesBrowser/filesBrowser.js +21 -2
  61. package/dist/esm/components/CnFilesBrowser/filesBrowser.js.map +1 -1
  62. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
  63. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +7 -0
  64. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
  65. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +2 -2
  66. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
  67. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +11 -0
  68. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
  69. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +2 -1
  70. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
  71. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue.js +1 -1
  72. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue2.js.map +1 -1
  73. package/dist/esm/components/CnLinkedWidget/CnLinkedWidget.vue3.js.map +1 -1
  74. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js +9 -0
  75. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue.js.map +1 -0
  76. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js +248 -0
  77. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue2.js.map +1 -0
  78. package/dist/esm/components/{CnMassDeleteDialog/CnMassDeleteDialog.vue3.js → CnMassActionDialog/CnMassActionDialog.vue3.js} +66 -52
  79. package/dist/esm/components/CnMassActionDialog/CnMassActionDialog.vue3.js.map +1 -0
  80. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js +0 -3
  81. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue.js.map +1 -1
  82. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js +25 -121
  83. package/dist/esm/components/CnMassDeleteDialog/CnMassDeleteDialog.vue2.js.map +1 -1
  84. package/dist/esm/components/CnNotesCard/CnNotesCard.vue.js +1 -1
  85. package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js +11 -3
  86. package/dist/esm/components/CnNotesCard/CnNotesCard.vue2.js.map +1 -1
  87. package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js +1 -1
  88. package/dist/esm/components/CnNotesCard/CnNotesCard.vue3.js.map +1 -1
  89. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue.js +1 -1
  90. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js +21 -1
  91. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue2.js.map +1 -1
  92. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js +2 -2
  93. package/dist/esm/components/CnObjectSidebar/CnNotesTab.vue3.js.map +1 -1
  94. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  95. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  96. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +23 -5
  97. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  98. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  99. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +3 -0
  100. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  101. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +14 -4
  102. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  103. package/dist/esm/dialogs/CnConfirmDialog.vue.js +1 -1
  104. package/dist/esm/dialogs/CnConfirmDialog.vue2.js.map +1 -1
  105. package/dist/esm/dialogs/CnConfirmDialog.vue3.js +5 -3
  106. package/dist/esm/dialogs/CnConfirmDialog.vue3.js.map +1 -1
  107. package/dist/esm/index.js +3 -0
  108. package/dist/esm/index.js.map +1 -1
  109. package/dist/esm/l10n/en.json.js +16 -1
  110. package/dist/esm/l10n/en.json.js.map +1 -1
  111. package/dist/esm/l10n/nl.json.js +16 -1
  112. package/dist/esm/l10n/nl.json.js.map +1 -1
  113. package/dist/esm/library-style.js +1 -1
  114. package/dist/esm/nextcloud-vue.css +908 -464
  115. package/dist/esm/utils/builtInFormatters.js +19 -1
  116. package/dist/esm/utils/builtInFormatters.js.map +1 -1
  117. package/dist/esm/utils/noteThreads.js +14 -2
  118. package/dist/esm/utils/noteThreads.js.map +1 -1
  119. package/dist/nextcloud-vue.cjs.js +11435 -10084
  120. package/dist/nextcloud-vue.cjs.js.map +2 -2
  121. package/dist/nextcloud-vue.css +908 -464
  122. package/l10n/en.json +16 -1
  123. package/l10n/nl.json +16 -1
  124. package/package.json +1 -1
  125. package/scripts/.jsdoc-baselines.json +1 -1
  126. package/src/components/CnActionDialog/CnActionDialog.vue +4 -1
  127. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +24 -3
  128. package/src/components/CnConditionGroupEditor/CnConditionGroup.vue +528 -0
  129. package/src/components/CnConditionGroupEditor/CnConditionGroupEditor.vue +211 -0
  130. package/src/components/CnConditionGroupEditor/index.js +9 -0
  131. package/src/components/CnConditionListEditor/CnConditionListEditor.vue +15 -78
  132. package/src/components/CnConditionListEditor/CnConditionRow.vue +226 -0
  133. package/src/components/CnDetailPage/CnDetailPage.vue +8 -8
  134. package/src/components/CnDetailWidgetHost/CnDetailWidgetHeaderItems.vue +6 -0
  135. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +0 -6
  136. package/src/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue +75 -4
  137. package/src/components/CnDialogActions/CnDialogActions.vue +124 -0
  138. package/src/components/CnDialogActions/index.js +7 -0
  139. package/src/components/CnFactsWidget/CnFactsWidget.vue +7 -3
  140. package/src/components/CnFilesBrowser/CnFilesBrowser.vue +15 -3
  141. package/src/components/CnFilesBrowser/filesBrowser.js +21 -2
  142. package/src/components/CnFlowsPage/CnFlowBoard.vue +10 -3
  143. package/src/components/CnFlowsPage/CnFlowEditorPage.vue +12 -0
  144. package/src/components/CnLinkedWidget/CnLinkedWidget.vue +7 -0
  145. package/src/components/CnMassActionDialog/CnMassActionDialog.vue +382 -0
  146. package/src/components/CnMassActionDialog/index.js +7 -0
  147. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.md +4 -0
  148. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +25 -254
  149. package/src/components/CnNotesCard/CnNotesCard.vue +12 -4
  150. package/src/components/CnObjectSidebar/CnNotesTab.vue +23 -3
  151. package/src/components/CnTreeView/CnTreeNode.vue +10 -1
  152. package/src/components/CnTreeView/CnTreeView.vue +9 -0
  153. package/src/components/index.js +3 -0
  154. package/src/css/context-menu.css +7 -0
  155. package/src/css/look-board-detail.css +220 -2
  156. package/src/css/look-board-index.css +7 -6
  157. package/src/css/look-board.css +43 -2
  158. package/src/css/patches.css +4 -1
  159. package/src/dialogs/CnConfirmDialog.vue +3 -1
  160. package/src/index.js +3 -0
  161. package/src/utils/builtInFormatters.js +18 -0
  162. package/src/utils/noteThreads.js +13 -1
  163. 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.172.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,
@@ -836,10 +836,11 @@ export default {
836
836
  </script>
837
837
 
838
838
  <style scoped>
839
+ /* The parts stand 18px apart, as the board draws the dialog (DqArchiveren). */
839
840
  .cn-action-dialog {
840
841
  display: flex;
841
842
  flex-direction: column;
842
- gap: 16px;
843
+ gap: 18px;
843
844
  }
844
845
 
845
846
  .cn-action-dialog__summary {
@@ -910,6 +911,8 @@ export default {
910
911
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
911
912
  gap: 12px 24px;
912
913
  margin: 0;
914
+ /* The server pads every dl 12px. */
915
+ padding: 0;
913
916
  }
914
917
 
915
918
  .cn-action-dialog__fact {
@@ -306,7 +306,9 @@ function idOf(object) {
306
306
  *
307
307
  * `startAt: "firstOpen"` opens a run that was started earlier at the page of
308
308
  * its first unanswered question (the last page when all are answered), once
309
- * per record; without it the run opens at the first page.
309
+ * per record; `startAt: "lastAnswered"` at the page of its last answered
310
+ * question, where the inspector was; without it the run opens at the first
311
+ * page.
310
312
  *
311
313
  * Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,
312
314
  * a list of strings or `{ value, label }`), `number`, `photo` and `text`.
@@ -524,7 +526,8 @@ export default {
524
526
  /**
525
527
  * The questions of this page that get a photo control: with a
526
528
  * `photoRequired` field, those whose rule is not never (and photo
527
- * questions); without one, the first question of the page.
529
+ * questions), less a `{ whenAnswer }` question answered otherwise that
530
+ * holds no photo; without one, the first question of the page.
528
531
  *
529
532
  * @return {object[]} The questions.
530
533
  * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-question-can-require-a-photo
@@ -534,7 +537,7 @@ export default {
534
537
  return []
535
538
  }
536
539
  if (this.fields.photoRequired) {
537
- return this.pageQuestions.filter((q) => q.kind === 'photo' || q.photoRule !== 'never')
540
+ return this.pageQuestions.filter((q) => q.kind === 'photo' || (q.photoRule !== 'never' && !this.photoRuledOut(q)))
538
541
  }
539
542
  const first = this.currentQuestion
540
543
  const extra = this.pageQuestions.filter((q) => q.kind === 'photo' && q !== first)
@@ -749,6 +752,19 @@ export default {
749
752
  return Boolean(rule && typeof rule === 'object' && String(this.draft[question.id]?.value ?? '') === rule.whenAnswer)
750
753
  },
751
754
 
755
+ /**
756
+ * Whether a question's answer rules its photo out: a `{ whenAnswer }`
757
+ * question answered with another value and holding no photo.
758
+ *
759
+ * @param {object} question The question.
760
+ * @return {boolean} True when no photo control is needed.
761
+ */
762
+ photoRuledOut(question) {
763
+ const rule = question.photoRule
764
+ const value = String(this.draft[question.id]?.value ?? '')
765
+ return Boolean(rule && typeof rule === 'object' && value !== '' && value !== rule.whenAnswer && !this.hasPhoto(question))
766
+ },
767
+
752
768
  /**
753
769
  * Whether a question has a photo, stored or held.
754
770
  *
@@ -901,6 +917,9 @@ export default {
901
917
  if (this.positionedFor !== key && this.content?.startAt === 'firstOpen') {
902
918
  const open = questions.findIndex((question) => !this.isAnswered(question))
903
919
  this.page = open === -1 ? lastPage : Math.floor(open / this.pageSize)
920
+ } else if (this.positionedFor !== key && this.content?.startAt === 'lastAnswered') {
921
+ const last = questions.findLastIndex((question) => this.isAnswered(question))
922
+ this.page = last === -1 ? 0 : Math.floor(last / this.pageSize)
904
923
  }
905
924
  this.positionedFor = key
906
925
  this.page = Math.min(this.page, lastPage)
@@ -1314,6 +1333,8 @@ export default {
1314
1333
  display: flex;
1315
1334
  flex-direction: column;
1316
1335
  gap: 4px;
1336
+ font-size: 14px;
1337
+ font-weight: 600 !important;
1317
1338
  line-height: 1.2;
1318
1339
  }
1319
1340
 
@@ -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>