@conduction/nextcloud-vue 2.174.0 → 2.176.1

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 (203) hide show
  1. package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
  2. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
  3. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
  4. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
  5. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
  6. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
  7. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
  8. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
  9. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
  10. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
  11. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
  12. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
  13. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +323 -7
  14. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
  15. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
  16. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
  17. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
  18. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
  19. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
  20. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
  21. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
  22. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
  23. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
  24. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
  25. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
  26. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
  27. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
  28. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
  29. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
  30. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
  31. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
  32. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
  33. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
  34. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
  35. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
  36. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
  37. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
  38. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
  39. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +255 -10
  40. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
  41. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +70 -28
  42. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
  43. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +55 -6
  44. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  45. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  46. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
  47. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
  48. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
  49. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
  50. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
  51. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
  52. package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
  53. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
  54. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
  55. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
  56. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
  57. package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
  58. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  59. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
  60. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  61. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
  62. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
  63. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
  64. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
  65. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
  66. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
  67. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +40 -1
  68. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  69. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  70. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
  71. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
  72. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
  73. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
  74. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
  75. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
  76. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
  77. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
  78. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  79. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
  80. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
  81. package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
  82. package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
  83. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
  84. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
  85. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
  86. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
  87. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
  88. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
  89. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
  90. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
  91. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
  92. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  93. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
  94. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  95. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
  96. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  97. package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
  98. package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
  99. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
  100. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
  101. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
  102. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
  103. package/dist/esm/components/CnStorePage/CnStorePage.vue.js +1 -1
  104. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js +3 -3
  105. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js.map +1 -1
  106. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js +5 -5
  107. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js.map +1 -1
  108. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue.js +1 -1
  109. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js +6 -6
  110. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js.map +1 -1
  111. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js +1 -1
  112. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js.map +1 -1
  113. package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
  114. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
  115. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
  116. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
  117. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
  118. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
  119. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
  120. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
  121. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
  122. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
  123. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
  124. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  125. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
  126. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  127. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
  128. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  129. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  130. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
  131. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  132. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
  133. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  134. package/dist/esm/index.js +8 -0
  135. package/dist/esm/index.js.map +1 -1
  136. package/dist/esm/l10n/en.json.js +79 -14
  137. package/dist/esm/l10n/en.json.js.map +1 -1
  138. package/dist/esm/l10n/nl.json.js +79 -14
  139. package/dist/esm/l10n/nl.json.js.map +1 -1
  140. package/dist/esm/library-style.js +1 -1
  141. package/dist/esm/nextcloud-vue.css +1162 -523
  142. package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
  143. package/dist/esm/utils/captureLocation.js +32 -0
  144. package/dist/esm/utils/captureLocation.js.map +1 -0
  145. package/dist/esm/utils/childRecordTotals.js +157 -0
  146. package/dist/esm/utils/childRecordTotals.js.map +1 -0
  147. package/dist/esm/utils/isoDuration.js +51 -1
  148. package/dist/esm/utils/isoDuration.js.map +1 -1
  149. package/dist/esm/utils/parentCrumb.js +86 -0
  150. package/dist/esm/utils/parentCrumb.js.map +1 -0
  151. package/dist/esm/utils/qr.js +649 -0
  152. package/dist/esm/utils/qr.js.map +1 -0
  153. package/dist/esm/utils/schema.js +3 -0
  154. package/dist/esm/utils/schema.js.map +1 -1
  155. package/dist/esm/utils/templateVariables.js +54 -0
  156. package/dist/esm/utils/templateVariables.js.map +1 -0
  157. package/dist/nextcloud-vue.cjs.js +21125 -15025
  158. package/dist/nextcloud-vue.cjs.js.map +2 -2
  159. package/dist/nextcloud-vue.css +1162 -523
  160. package/l10n/en.json +79 -14
  161. package/l10n/nl.json +79 -14
  162. package/package.json +1 -1
  163. package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
  164. package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
  165. package/src/components/CnBlockListEditor/index.js +9 -0
  166. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +377 -10
  167. package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
  168. package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
  169. package/src/components/CnChoiceMatrix/index.js +9 -0
  170. package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
  171. package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
  172. package/src/components/CnDataMatrix/CnDataMatrix.vue +304 -17
  173. package/src/components/CnDetailPage/CnDetailPage.vue +55 -6
  174. package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
  175. package/src/components/CnDisplayScreen/index.js +9 -0
  176. package/src/components/CnDurationField/CnDurationField.vue +330 -5
  177. package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
  178. package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
  179. package/src/components/CnGeoCaptureField/index.js +9 -0
  180. package/src/components/CnIndexPage/CnIndexPage.vue +40 -1
  181. package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
  182. package/src/components/CnQrCode/CnQrCode.vue +321 -0
  183. package/src/components/CnQrCode/index.js +9 -0
  184. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
  185. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
  186. package/src/components/CnRevealField/CnRevealField.vue +273 -0
  187. package/src/components/CnRevealField/index.js +9 -0
  188. package/src/components/CnStorePage/CnStorePage.vue +8 -8
  189. package/src/components/CnStorePage/CnStorePublishDialog.vue +7 -7
  190. package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
  191. package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
  192. package/src/components/CnTransferCard/index.js +9 -0
  193. package/src/components/CnTreeView/CnTreeNode.vue +145 -2
  194. package/src/components/CnTreeView/CnTreeView.vue +210 -6
  195. package/src/components/index.js +7 -0
  196. package/src/index.js +8 -0
  197. package/src/utils/captureLocation.js +29 -0
  198. package/src/utils/childRecordTotals.js +153 -0
  199. package/src/utils/isoDuration.js +50 -0
  200. package/src/utils/parentCrumb.js +83 -0
  201. package/src/utils/qr.js +681 -0
  202. package/src/utils/schema.js +3 -0
  203. package/src/utils/templateVariables.js +51 -0
@@ -21,18 +21,27 @@
21
21
  class="cn-data-matrix__col-header"
22
22
  :style="col.width ? { width: col.width } : null">
23
23
  {{ col.label || col.key }}
24
+ <span v-if="weightText(col)" class="cn-data-matrix__weight">{{ weightText(col) }}</span>
24
25
  </th>
25
26
  <th v-if="showRowTotals" class="cn-data-matrix__total-header">
26
27
  {{ rowTotalsLabel }}
27
28
  </th>
29
+ <th v-if="showRank" class="cn-data-matrix__total-header cn-data-matrix__rank-header">
30
+ {{ resolvedRankLabel }}
31
+ </th>
28
32
  </tr>
29
33
  </thead>
30
34
  <tbody>
31
35
  <tr v-for="row in rows"
32
36
  :key="row[rowIdKey]"
33
- class="cn-data-matrix__row">
34
- <th v-if="rowHeader" class="cn-data-matrix__row-header" :title="row[rowLabelKey]">
37
+ class="cn-data-matrix__row"
38
+ :class="{ 'cn-data-matrix__row--top': highlightTopRank && ranks.get(row[rowIdKey]) === 1 }">
39
+ <th v-if="rowHeader"
40
+ scope="row"
41
+ class="cn-data-matrix__row-header"
42
+ :title="row[rowLabelKey]">
35
43
  {{ row[rowLabelKey] }}
44
+ <span v-if="rowSublabelKey && row[rowSublabelKey]" class="cn-data-matrix__row-sublabel">{{ row[rowSublabelKey] }}</span>
36
45
  </th>
37
46
  <td v-for="col in columns"
38
47
  :key="col.key"
@@ -45,18 +54,25 @@
45
54
  type="text"
46
55
  class="cn-data-matrix__cell-input"
47
56
  :value="cellValue(row, col)"
57
+ :aria-label="inputLabel(row, col)"
48
58
  :disabled="readOnly || isCellReadOnly(row, col)"
49
59
  @blur="commitEdit(row, col, $event.target.value)"
50
- @keydown.enter="commitEdit(row, col, $event.target.value)"
51
- @keydown.esc="cancelEdit">
60
+ @keydown="onInputKeydown($event, row, col)">
52
61
  <span v-else
53
62
  class="cn-data-matrix__cell-value"
54
- @click="startEdit(row, col)">
63
+ :tabindex="isCellEditable(row, col) ? 0 : null"
64
+ :role="isCellEditable(row, col) ? 'button' : null"
65
+ :aria-label="isCellEditable(row, col) ? cellLabel(row, col) : null"
66
+ @click="startEdit(row, col)"
67
+ @keydown="onCellKeydown($event, row, col)">
55
68
  {{ formatCell(cellValue(row, col), col) }}
56
69
  </span>
57
70
  </td>
58
71
  <td v-if="showRowTotals" class="cn-data-matrix__total-cell">
59
- {{ formatCell(rowTotal(row), { type: 'number' }) }}
72
+ {{ formatTotal(rowTotal(row)) }}
73
+ </td>
74
+ <td v-if="showRank" class="cn-data-matrix__total-cell cn-data-matrix__rank-cell">
75
+ {{ ranks.has(row[rowIdKey]) ? ranks.get(row[rowIdKey]) : '' }}
60
76
  </td>
61
77
  </tr>
62
78
  <tr v-if="showColumnTotals" class="cn-data-matrix__totals-row">
@@ -69,8 +85,9 @@
69
85
  {{ formatCell(columnTotal(col), { type: 'number' }) }}
70
86
  </td>
71
87
  <td v-if="showRowTotals" class="cn-data-matrix__total-cell cn-data-matrix__grand-total">
72
- {{ formatCell(grandTotal, { type: 'number' }) }}
88
+ {{ formatTotal(grandTotal) }}
73
89
  </td>
90
+ <td v-if="showRank" class="cn-data-matrix__total-cell" />
74
91
  </tr>
75
92
  </tbody>
76
93
  </table>
@@ -83,10 +100,26 @@
83
100
  </template>
84
101
 
85
102
  <script>
103
+ import { translate as t } from '@nextcloud/l10n'
104
+ import { evalFormula } from '../../utils/evalFormula.js'
86
105
  import { userLocale } from '../../utils/userLocale.js'
106
+
107
+ const ROUNDERS = Object.freeze({ round: Math.round, ceil: Math.ceil, floor: Math.floor })
108
+
109
+ /**
110
+ * The number a cell holds; an empty cell is no number, rather than zero.
111
+ *
112
+ * @param {unknown} raw The cell.
113
+ * @return {number|null} The number, or null.
114
+ */
115
+ function numberIn(raw) {
116
+ return raw === null || raw === undefined || raw === '' || !Number.isFinite(Number(raw)) ? null : Number(raw)
117
+ }
118
+
87
119
  /**
88
120
  * CnDataMatrix — Inline-edit data grid for matrix-shaped data
89
- * (rows × columns). Each cell is click-to-edit; commits emit
121
+ * (rows × columns). Each cell is click-to-edit, and keyboard editable:
122
+ * Tab reaches it, Enter or F2 opens it, Enter commits, Escape cancels. Commits emit
90
123
  * `@cell-edit({ rowId, colKey, value })` so the parent can persist.
91
124
  * Optional row / column / grand totals computed from the live data
92
125
  * with the column's `aggregate` setting (`sum` by default).
@@ -95,8 +128,19 @@ import { userLocale } from '../../utils/userLocale.js'
95
128
  * rubrics — the "spreadsheet" shape where cells are independently
96
129
  * editable values rather than a row/object form.
97
130
  *
98
- * Not a full spreadsheet engine — there's no formula language, no
99
- * cell-range references, no charts. Consumers wanting that should
131
+ * A column with `formula` computes its cells from the other columns and is
132
+ * read only: `now*(rate/100)`, with `prev_now` for the row above and `round`
133
+ * set to `round`, `ceil` or `floor`. A row where the formula has no answer shows
134
+ * its own stored value. Formulas are arithmetic only, through `evalFormula`.
135
+ *
136
+ * A scoring matrix weighs its columns: give each column a `weight` (and an
137
+ * optional `weightLabel` such as "40%"), set `rowTotalsMode="weighted"` and
138
+ * the row total is the weighted mean of the row's scores. `showRank` ranks
139
+ * the rows by that total, highest first, and `highlightTopRank` tints the
140
+ * leading row.
141
+ *
142
+ * Not a full spreadsheet engine — there are no cell-range references, no
143
+ * charts. Consumers wanting that should
100
144
  * embed a dedicated library (e.g. handsontable) and use this for
101
145
  * the simpler cases.
102
146
  *
@@ -128,7 +172,7 @@ export default {
128
172
  /**
129
173
  * Column declarations.
130
174
  *
131
- * @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string}>}
175
+ * @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formula?:string,round?:'round'|'ceil'|'floor',formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string,weight?:number,weightLabel?:string}>}
132
176
  */
133
177
  columns: { type: Array, default: () => [] },
134
178
  /** Field on each row carrying its id. */
@@ -153,6 +197,22 @@ export default {
153
197
  rowTotalsLabel: { type: String, default: 'Total' },
154
198
  /** Label preceding the column-totals row. */
155
199
  columnTotalsLabel: { type: String, default: 'Total' },
200
+ /**
201
+ * How a row total is computed: `sum` adds the number columns,
202
+ * `weighted` takes the mean of the number columns weighted by each
203
+ * column's `weight`, leaving out a cell without a value.
204
+ */
205
+ rowTotalsMode: { type: String, default: 'sum', validator: (v) => ['sum', 'weighted'].includes(v) },
206
+ /** Fraction digits of the totals; null keeps the locale default. */
207
+ totalsFractionDigits: { type: Number, default: null },
208
+ /** Render a rank column: the rows ranked by their row total, highest first, ties sharing a rank. */
209
+ showRank: { type: Boolean, default: false },
210
+ /** Header of the rank column, already translated; the library default is "Rank". */
211
+ rankLabel: { type: String, default: '' },
212
+ /** Tint the row ranked first. */
213
+ highlightTopRank: { type: Boolean, default: false },
214
+ /** Field on each row with a second line under its label, such as a price. */
215
+ rowSublabelKey: { type: String, default: '' },
156
216
  },
157
217
 
158
218
  emits: ['cell-edit'],
@@ -163,6 +223,69 @@ export default {
163
223
  },
164
224
 
165
225
  computed: {
226
+ /** @return {string} The rank column header. */
227
+ resolvedRankLabel() {
228
+ return this.rankLabel || t('nextcloud-vue', 'Rank')
229
+ },
230
+
231
+ /**
232
+ * The rank of every row with a row total: highest total first, rows
233
+ * with an equal total sharing a rank (1, 2, 2, 4).
234
+ *
235
+ * @return {Map<unknown, number>} Rank per row id.
236
+ */
237
+ ranks() {
238
+ const totals = this.rows
239
+ .map((row) => ({ id: row[this.rowIdKey], total: this.rowTotal(row) }))
240
+ .filter((entry) => Number.isFinite(entry.total))
241
+ .sort((a, b) => b.total - a.total)
242
+ const ranks = new Map()
243
+ totals.forEach((entry, index) => {
244
+ const previous = totals[index - 1]
245
+ ranks.set(entry.id, previous && previous.total === entry.total ? ranks.get(previous.id) : index + 1)
246
+ })
247
+ return ranks
248
+ },
249
+
250
+ /**
251
+ * The computed cells of every row, in order. A formula reads the row's
252
+ * numbers by column key and the previous row's as `prev_<key>`, and sees
253
+ * formula columns to its left. A formula without an answer has no entry
254
+ * here, so the cell shows what the row itself holds.
255
+ *
256
+ * @return {Map<object, Record<string, number>>} Computed values per row.
257
+ */
258
+ formulaValues() {
259
+ const values = new Map()
260
+ if (!this.columns.some((col) => col.formula)) {
261
+ return values
262
+ }
263
+ let previous = {}
264
+ for (const row of this.rows) {
265
+ const vars = { ...previous }
266
+ for (const col of this.columns) {
267
+ if (!col.formula && numberIn(row[col.key]) !== null) {
268
+ vars[col.key] = numberIn(row[col.key])
269
+ }
270
+ }
271
+ const computed = {}
272
+ for (const col of this.columns) {
273
+ if (col.formula) {
274
+ const answer = evalFormula(col.formula, vars)
275
+ if (answer !== null) {
276
+ computed[col.key] = (ROUNDERS[col.round] ?? Number)(answer)
277
+ vars[col.key] = computed[col.key]
278
+ } else if (numberIn(row[col.key]) !== null) {
279
+ vars[col.key] = numberIn(row[col.key])
280
+ }
281
+ }
282
+ }
283
+ values.set(row, computed)
284
+ previous = Object.fromEntries(Object.entries(vars).filter(([key]) => !key.startsWith('prev_')).map(([key, value]) => [`prev_${key}`, value]))
285
+ }
286
+ return values
287
+ },
288
+
166
289
  /**
167
290
  * Grand total (sum of every numeric cell). Shown in the
168
291
  * bottom-right corner when both totals are enabled.
@@ -174,7 +297,7 @@ export default {
174
297
  for (const row of this.rows) {
175
298
  for (const col of this.columns) {
176
299
  if (col.type === 'number') {
177
- const v = Number(row[col.key])
300
+ const v = Number(this.cellValue(row, col))
178
301
  if (Number.isFinite(v)) {
179
302
  total += v
180
303
  }
@@ -205,7 +328,98 @@ export default {
205
328
  * @return {boolean}
206
329
  */
207
330
  isCellReadOnly(row, col) {
208
- return Boolean(col.readOnly)
331
+ return Boolean(col.readOnly || col.formula)
332
+ },
333
+
334
+ /**
335
+ * Whether a cell can be edited, and so takes keyboard focus.
336
+ *
337
+ * @param {object} row Row record.
338
+ * @param {object} col Column definition.
339
+ * @return {boolean}
340
+ */
341
+ isCellEditable(row, col) {
342
+ return !this.readOnly && !this.isCellReadOnly(row, col)
343
+ },
344
+
345
+ /**
346
+ * Accessible name of a cell's input: its column and row.
347
+ *
348
+ * @param {object} row Row record.
349
+ * @param {object} col Column definition.
350
+ * @return {string} The label.
351
+ */
352
+ inputLabel(row, col) {
353
+ return t('nextcloud-vue', '{column}, {row}', {
354
+ column: col.label || col.key,
355
+ row: row[this.rowLabelKey] ?? row[this.rowIdKey],
356
+ }, undefined, { escape: false })
357
+ },
358
+
359
+ /**
360
+ * Accessible name of an editable cell: its column, row and value.
361
+ *
362
+ * @param {object} row Row record.
363
+ * @param {object} col Column definition.
364
+ * @return {string} The label.
365
+ */
366
+ cellLabel(row, col) {
367
+ const value = this.formatCell(this.cellValue(row, col), col)
368
+ const vars = { cell: this.inputLabel(row, col), value: String(value) }
369
+ return value === ''
370
+ ? t('nextcloud-vue', '{cell}: empty', vars, undefined, { escape: false })
371
+ : t('nextcloud-vue', '{cell}: {value}', vars, undefined, { escape: false })
372
+ },
373
+
374
+ /**
375
+ * Enter or F2 on a focused cell starts editing it.
376
+ *
377
+ * @param {KeyboardEvent} event The key event.
378
+ * @param {object} row Row record.
379
+ * @param {object} col Column definition.
380
+ * @return {void}
381
+ */
382
+ onCellKeydown(event, row, col) {
383
+ if ((event.key === 'Enter' || event.key === 'F2') && this.isCellEditable(row, col)) {
384
+ event.preventDefault()
385
+ this.startEdit(row, col)
386
+ }
387
+ },
388
+
389
+ /**
390
+ * Enter commits and Escape cancels the edit; both return focus to the cell.
391
+ *
392
+ * @param {KeyboardEvent} event The key event.
393
+ * @param {object} row Row record.
394
+ * @param {object} col Column definition.
395
+ * @return {void}
396
+ */
397
+ onInputKeydown(event, row, col) {
398
+ if (event.key === 'Enter') {
399
+ event.preventDefault()
400
+ this.commitEdit(row, col, event.target.value)
401
+ this.focusCell(row, col)
402
+ } else if (event.key === 'Escape' || event.key === 'Esc') {
403
+ event.preventDefault()
404
+ this.cancelEdit()
405
+ this.focusCell(row, col)
406
+ }
407
+ },
408
+
409
+ /**
410
+ * Move focus to a cell's value after the edit input is gone.
411
+ *
412
+ * @param {object} row Row record.
413
+ * @param {object} col Column definition.
414
+ * @return {void}
415
+ */
416
+ focusCell(row, col) {
417
+ const rowId = String(row[this.rowIdKey])
418
+ this.$nextTick(() => {
419
+ const cell = Array.from(this.$el.querySelectorAll('.cn-data-matrix__cell'))
420
+ .find((td) => td.dataset.rowId === rowId && td.dataset.colKey === col.key)
421
+ cell?.querySelector('.cn-data-matrix__cell-value')?.focus()
422
+ })
209
423
  },
210
424
 
211
425
  /**
@@ -216,6 +430,9 @@ export default {
216
430
  * @return {unknown} The raw value.
217
431
  */
218
432
  cellValue(row, col) {
433
+ if (col.formula && this.formulaValues.get(row)?.[col.key] !== undefined) {
434
+ return this.formulaValues.get(row)[col.key]
435
+ }
219
436
  return row[col.key]
220
437
  },
221
438
 
@@ -321,16 +538,62 @@ export default {
321
538
  },
322
539
 
323
540
  /**
324
- * Per-row total — sum of every numeric column.
541
+ * The weight shown beside a column label: `weightLabel`, else the
542
+ * `weight` itself, or '' for an unweighted column.
543
+ *
544
+ * @param {object} col Column definition.
545
+ * @return {string} The weight text.
546
+ */
547
+ weightText(col) {
548
+ if (typeof col.weightLabel === 'string' && col.weightLabel !== '') {
549
+ return col.weightLabel
550
+ }
551
+ return Number.isFinite(col.weight) ? String(col.weight) : ''
552
+ },
553
+
554
+ /**
555
+ * Format a total with `totalsFractionDigits` when set.
556
+ *
557
+ * @param {number|null} value The total.
558
+ * @return {string} The display string.
559
+ */
560
+ formatTotal(value) {
561
+ if (!Number.isFinite(value)) {
562
+ return ''
563
+ }
564
+ if (this.totalsFractionDigits === null) {
565
+ return this.formatCell(value, { type: 'number' })
566
+ }
567
+ const digits = this.totalsFractionDigits
568
+ return value.toLocaleString(userLocale(), { minimumFractionDigits: digits, maximumFractionDigits: digits })
569
+ },
570
+
571
+ /**
572
+ * Per-row total: the sum of every numeric column, or in `weighted`
573
+ * mode the weighted mean over the weighted columns that hold a value
574
+ * (null when none does).
325
575
  *
326
576
  * @param {object} row Row record.
327
- * @return {number}
577
+ * @return {number|null}
328
578
  */
329
579
  rowTotal(row) {
580
+ if (this.rowTotalsMode === 'weighted') {
581
+ let weighted = 0
582
+ let weights = 0
583
+ for (const col of this.columns) {
584
+ const raw = this.cellValue(row, col)
585
+ const v = Number(raw)
586
+ if (col.type === 'number' && Number.isFinite(col.weight) && col.weight > 0 && raw !== null && raw !== undefined && raw !== '' && Number.isFinite(v)) {
587
+ weighted += v * col.weight
588
+ weights += col.weight
589
+ }
590
+ }
591
+ return weights > 0 ? weighted / weights : null
592
+ }
330
593
  let total = 0
331
594
  for (const col of this.columns) {
332
595
  if (col.type === 'number') {
333
- const v = Number(row[col.key])
596
+ const v = Number(this.cellValue(row, col))
334
597
  if (Number.isFinite(v)) {
335
598
  total += v
336
599
  }
@@ -358,7 +621,7 @@ export default {
358
621
  // `Number(null)` is `0`, which would otherwise be counted and
359
622
  // summed as a real zero value.
360
623
  const values = this.rows
361
- .map((r) => r[col.key])
624
+ .map((r) => this.cellValue(r, col))
362
625
  .filter((v) => v !== null && v !== undefined && v !== '')
363
626
  .map((v) => Number(v))
364
627
  .filter((v) => Number.isFinite(v))
@@ -449,6 +712,11 @@ export default {
449
712
  min-height: 28px;
450
713
  }
451
714
 
715
+ .cn-data-matrix__cell-value:focus-visible {
716
+ outline: 2px solid var(--color-primary-element);
717
+ outline-offset: -2px;
718
+ }
719
+
452
720
  .cn-data-matrix__cell--read-only .cn-data-matrix__cell-value {
453
721
  cursor: default;
454
722
  background: var(--color-background-hover);
@@ -482,6 +750,25 @@ export default {
482
750
  background: var(--color-primary-element-light);
483
751
  }
484
752
 
753
+ .cn-data-matrix__weight {
754
+ color: var(--color-text-maxcontrast);
755
+ font-weight: 400;
756
+ white-space: nowrap;
757
+ }
758
+
759
+ .cn-data-matrix__row-sublabel {
760
+ display: block;
761
+ color: var(--color-text-maxcontrast);
762
+ font-size: 0.85em;
763
+ font-weight: 400;
764
+ }
765
+
766
+ .cn-data-matrix__row--top > th,
767
+ .cn-data-matrix__row--top > td {
768
+ background: var(--color-primary-element-light);
769
+ color: var(--color-primary-element-light-text);
770
+ }
771
+
485
772
  .cn-data-matrix__empty {
486
773
  color: var(--color-text-maxcontrast);
487
774
  font-style: italic;
@@ -1466,6 +1466,7 @@ import { prefixUrl } from '../../utils/headers.js'
1466
1466
  import { HEADING_LEVEL } from '../../utils/headingLevel.js'
1467
1467
  import { interpolateUrlTokens } from '../../utils/interpolateUrlTokens.js'
1468
1468
  import { followLinkClick } from '../../utils/linkNavigation.js'
1469
+ import { parentCrumb } from '../../utils/parentCrumb.js'
1469
1470
  import { patchStoredSelf } from '../../utils/patchStoredSelf.js'
1470
1471
  import { setReadState } from '../../utils/recordInteractions.js'
1471
1472
  import { saveEdited } from '../../utils/saveEdited.js'
@@ -2448,6 +2449,24 @@ export default {
2448
2449
  default: false,
2449
2450
  },
2450
2451
 
2452
+ /**
2453
+ * A condition on the record, in the `visibleWhen` grammar (manifest
2454
+ * `config.readOnlyWhen`): while it holds, the page treats the record
2455
+ * as one it may not update, as with `can.update` false. The Edit
2456
+ * button, the header actions with role `edit` or `update` and the
2457
+ * inline editors are off. `{ field: "mergedInto", op: "notEmpty" }`
2458
+ * keeps a record merged into another from being edited. It is decided
2459
+ * on the page (no `endpoint` or `source`) and may read the
2460
+ * `visibilityContext` records as `@context.<name>.<path>`. Null
2461
+ * (the default) changes nothing.
2462
+ *
2463
+ * @spec openspec/changes/detail-read-only-when/specs/detail-page/spec.md#requirement-a-detail-page-can-make-a-record-read-only-by-a-condition
2464
+ */
2465
+ readOnlyWhen: {
2466
+ type: Object,
2467
+ default: null,
2468
+ },
2469
+
2451
2470
  /**
2452
2471
  * Hide valueless fields on the auto-rendered data widget, instead of
2453
2472
  * showing them with an em dash. See `CnObjectDataWidget`'s `hide-empty`.
@@ -3033,8 +3052,12 @@ export default {
3033
3052
  * @spec openspec/changes/zuiddrecht-pixel-gaps-3/specs/zuiddrecht-pixel-gaps-3/spec.md#requirement-a-breadcrumb-can-name-the-record-by-a-field-and-use-a-text-separator
3034
3053
  * A list of such crumbs draws a deeper trail ("Settings / Case types /"
3035
3054
  * and then the record); `currentField` and `separator` may sit on any
3036
- * of them.
3055
+ * of them. A crumb with `parent` (a `visibilityContext` name) instead
3056
+ * of `label` is the record's parent: its `labelField` value (else its
3057
+ * name), linked by `route` + `param` (default `id`) or `href` with
3058
+ * `{id}`; it drops out when the record has no parent.
3037
3059
  *
3060
+ * @spec openspec/changes/detail-parent-crumb/specs/detail-page/spec.md#requirement-a-sub-record-trail-can-show-its-parent-record
3038
3061
  * @spec openspec/changes/detail-breadcrumb-trail/specs/detail-page/spec.md#requirement-a-record-page-breadcrumb-can-name-more-than-one-level
3039
3062
  * @type {{label: string, route?: string, params?: object, href?: string, icon?: string, currentField?: string, separator?: string}|Array<object>|null}
3040
3063
  */
@@ -5586,13 +5609,30 @@ export default {
5586
5609
  },
5587
5610
 
5588
5611
  /**
5589
- * Whether the record refuses this reader's updates (`can.update === false`).
5612
+ * Whether the record refuses this reader's updates (`can.update === false`),
5613
+ * or the page's `readOnlyWhen` holds for it.
5590
5614
  *
5591
5615
  * @return {boolean}
5592
5616
  * @spec openspec/changes/detail-page-record-rights/specs/detail-page-record-rights/spec.md#requirement-edit-controls-follow-the-records-update-right
5593
5617
  */
5594
5618
  recordUpdateDenied() {
5595
- return Boolean(this.recordCan && this.recordCan.update === false)
5619
+ return Boolean(this.recordCan && this.recordCan.update === false) || this.readOnlyByCondition
5620
+ },
5621
+
5622
+ /**
5623
+ * Whether the page's `readOnlyWhen` holds for the record (and its
5624
+ * `visibilityContext` records). False without the option, and while
5625
+ * the record or those records are still on their way.
5626
+ *
5627
+ * @return {boolean}
5628
+ * @spec openspec/changes/detail-read-only-when/specs/detail-page/spec.md#requirement-a-detail-page-can-make-a-record-read-only-by-a-condition
5629
+ */
5630
+ readOnlyByCondition() {
5631
+ const when = this.readOnlyWhen
5632
+ if (!when || typeof when !== 'object' || !this.widgetVisibilityData || this.visibilityRowsPending) {
5633
+ return false
5634
+ }
5635
+ return detailWidgetVisible({ visibleWhen: when }, this.widgetVisibilityData)
5596
5636
  },
5597
5637
 
5598
5638
  /**
@@ -5657,7 +5697,7 @@ export default {
5657
5697
  */
5658
5698
  declaredCrumbs() {
5659
5699
  const list = Array.isArray(this.breadcrumb) ? this.breadcrumb : (this.breadcrumb ? [this.breadcrumb] : [])
5660
- return list.filter((crumb) => crumb && typeof crumb.label === 'string' && crumb.label !== ''
5700
+ return list.filter((crumb) => crumb && ((typeof crumb.label === 'string' && crumb.label !== '') || (typeof crumb.parent === 'string' && crumb.parent !== ''))
5661
5701
  && (!crumb.visibleWhen || detailWidgetVisible({ visibleWhen: crumb.visibleWhen }, this.widgetVisibilityData)))
5662
5702
  },
5663
5703
 
@@ -5665,11 +5705,14 @@ export default {
5665
5705
  * The breadcrumb trail: the declared crumbs (each a router target from
5666
5706
  * `route` + `params`, or an `href`), then the record's display name
5667
5707
  * as the current crumb. Empty without a declared crumb. A crumb
5668
- * carries `icon` only when the manifest declares one.
5708
+ * carries `icon` only when the manifest declares one. A crumb with
5709
+ * `parent` is the record's parent (see `parentCrumb`) and drops out
5710
+ * when the record has none.
5669
5711
  *
5670
5712
  * @spec openspec/changes/zuiddrecht-pixel-gaps/specs/zuiddrecht-pixel-gaps/spec.md#requirement-a-detail-page-drops-its-eyebrow-and-shows-a-breadcrumb
5671
5713
  * @spec openspec/changes/zuiddrecht-pixel-gaps-2/specs/zuiddrecht-pixel-gaps-2/spec.md#requirement-a-declared-breadcrumb-label-shows-as-text
5672
5714
  * @spec openspec/changes/detail-breadcrumb-trail/specs/detail-page/spec.md#requirement-a-record-page-breadcrumb-can-name-more-than-one-level
5715
+ * @spec openspec/changes/detail-parent-crumb/specs/detail-page/spec.md#requirement-a-sub-record-trail-can-show-its-parent-record
5673
5716
  * @return {Array<{label: string, to?: object, href?: string, icon?: string}>}
5674
5717
  */
5675
5718
  breadcrumbCrumbs() {
@@ -5677,6 +5720,9 @@ export default {
5677
5720
  return []
5678
5721
  }
5679
5722
  const crumbs = this.declaredCrumbs.map((crumb) => {
5723
+ if (typeof crumb.parent === 'string' && crumb.parent !== '') {
5724
+ return parentCrumb(crumb, this.visibilityRefs, this.visibilityRows, this.effectiveTranslate)
5725
+ }
5680
5726
  const entry = { label: this.effectiveTranslate(crumb.label) }
5681
5727
  if (typeof crumb.icon === 'string' && crumb.icon !== '') {
5682
5728
  entry.icon = crumb.icon
@@ -5687,7 +5733,10 @@ export default {
5687
5733
  entry.href = crumb.href
5688
5734
  }
5689
5735
  return entry
5690
- })
5736
+ }).filter((crumb) => crumb !== null)
5737
+ if (crumbs.length === 0) {
5738
+ return []
5739
+ }
5691
5740
  return [...crumbs, { label: this.breadcrumbCurrentLabel }]
5692
5741
  },
5693
5742