@conduction/nextcloud-vue 2.56.0-beta.73 → 2.56.0-beta.74

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 (120) hide show
  1. package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
  2. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +90 -7
  3. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
  4. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +82 -79
  5. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
  6. package/dist/esm/components/CnCardNotices/CnCardNotices.vue.js +1 -1
  7. package/dist/esm/components/CnCardNotices/CnCardNotices.vue2.js +45 -7
  8. package/dist/esm/components/CnCardNotices/CnCardNotices.vue2.js.map +1 -1
  9. package/dist/esm/components/CnCardNotices/CnCardNotices.vue3.js +1 -1
  10. package/dist/esm/components/CnCardNotices/CnCardNotices.vue3.js.map +1 -1
  11. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
  12. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +40 -1
  13. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
  14. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +149 -109
  15. package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
  16. package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js +10 -4
  17. package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js.map +1 -1
  18. package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue.js +1 -1
  19. package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue2.js +112 -1
  20. package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue2.js.map +1 -1
  21. package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue3.js +53 -18
  22. package/dist/esm/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue3.js.map +1 -1
  23. package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue2.js +3 -3
  24. package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue2.js.map +1 -1
  25. package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue3.js +108 -74
  26. package/dist/esm/components/CnIndexPage/CnIndexHeaderMenu.vue3.js.map +1 -1
  27. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +129 -8
  28. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  29. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +46 -36
  30. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  31. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue.js +1 -1
  32. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js +56 -0
  33. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js.map +1 -1
  34. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js +185 -123
  35. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js.map +1 -1
  36. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue.js +1 -1
  37. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js +2 -0
  38. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js.map +1 -1
  39. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js +2 -1
  40. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js.map +1 -1
  41. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  42. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +197 -63
  43. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  44. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +244 -161
  45. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  46. package/dist/esm/components/CnSearchPage/CnSearchPage.vue.js +1 -1
  47. package/dist/esm/components/CnSearchPage/CnSearchPage.vue2.js +39 -1
  48. package/dist/esm/components/CnSearchPage/CnSearchPage.vue2.js.map +1 -1
  49. package/dist/esm/components/CnSearchPage/CnSearchPage.vue3.js +12 -2
  50. package/dist/esm/components/CnSearchPage/CnSearchPage.vue3.js.map +1 -1
  51. package/dist/esm/components/CnStepper/CnStepper.vue.js +1 -1
  52. package/dist/esm/components/CnStepper/CnStepper.vue2.js.map +1 -1
  53. package/dist/esm/components/CnStepper/CnStepper.vue3.js.map +1 -1
  54. package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue.js +1 -1
  55. package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue2.js +51 -2
  56. package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue2.js.map +1 -1
  57. package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue3.js +49 -11
  58. package/dist/esm/components/CnTaskFormFields/CnTaskFormFields.vue3.js.map +1 -1
  59. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue.js +9 -0
  60. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue.js.map +1 -0
  61. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue2.js +328 -0
  62. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue2.js.map +1 -0
  63. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue3.js +85 -0
  64. package/dist/esm/components/CnTaskFormWidget/CnTaskFormWidget.vue3.js.map +1 -0
  65. package/dist/esm/components/CnTaskFormWidget/index.js +24 -0
  66. package/dist/esm/components/CnTaskFormWidget/index.js.map +1 -0
  67. package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue.js +1 -1
  68. package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue2.js +8 -2
  69. package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue2.js.map +1 -1
  70. package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue3.js +16 -3
  71. package/dist/esm/components/CnTasksWidget/CnTasksWidget.vue3.js.map +1 -1
  72. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  73. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  74. package/dist/esm/index.js +1 -0
  75. package/dist/esm/index.js.map +1 -1
  76. package/dist/esm/l10n/en.json.js +12 -0
  77. package/dist/esm/l10n/en.json.js.map +1 -1
  78. package/dist/esm/l10n/nl.json.js +12 -0
  79. package/dist/esm/l10n/nl.json.js.map +1 -1
  80. package/dist/esm/library-style.js +1 -1
  81. package/dist/esm/nextcloud-vue.css +637 -475
  82. package/dist/esm/utils/fieldPill.js +77 -0
  83. package/dist/esm/utils/fieldPill.js.map +1 -0
  84. package/dist/esm/utils/libraryWidgetKeys.js +1 -0
  85. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  86. package/dist/esm/utils/searchRefusal.js +35 -1
  87. package/dist/esm/utils/searchRefusal.js.map +1 -1
  88. package/dist/esm/utils/widgetDispatch.js +1 -1
  89. package/dist/esm/utils/widgetDispatch.js.map +1 -1
  90. package/dist/nextcloud-vue.cjs.js +7416 -5865
  91. package/dist/nextcloud-vue.cjs.js.map +2 -2
  92. package/dist/nextcloud-vue.css +637 -475
  93. package/l10n/en.json +12 -0
  94. package/l10n/nl.json +12 -0
  95. package/package.json +1 -1
  96. package/src/components/CnActionDialog/CnActionDialog.vue +116 -9
  97. package/src/components/CnCardNotices/CnCardNotices.vue +46 -8
  98. package/src/components/CnFilesBrowser/CnFilesBrowser.vue +61 -2
  99. package/src/components/CnFilesBrowser/filesBrowserColumns.js +10 -4
  100. package/src/components/CnGroupedCardsWidget/CnGroupedCardsWidget.vue +141 -1
  101. package/src/components/CnIndexPage/CnIndexHeaderMenu.vue +22 -4
  102. package/src/components/CnIndexPage/CnIndexPage.vue +143 -13
  103. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +148 -4
  104. package/src/components/CnObjectSidebar/CnFilesTab.vue +3 -0
  105. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +310 -66
  106. package/src/components/CnSearchPage/CnSearchPage.vue +50 -1
  107. package/src/components/CnStepper/CnStepper.vue +14 -5
  108. package/src/components/CnTaskFormFields/CnTaskFormFields.md +1 -0
  109. package/src/components/CnTaskFormFields/CnTaskFormFields.vue +89 -3
  110. package/src/components/CnTaskFormWidget/CnTaskFormWidget.vue +400 -0
  111. package/src/components/CnTaskFormWidget/index.js +23 -0
  112. package/src/components/CnTasksWidget/CnTasksWidget.vue +17 -3
  113. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  114. package/src/components/index.js +1 -0
  115. package/src/css/index-page.css +6 -0
  116. package/src/index.js +1 -0
  117. package/src/utils/fieldPill.js +73 -0
  118. package/src/utils/libraryWidgetKeys.js +1 -0
  119. package/src/utils/searchRefusal.js +33 -0
  120. package/src/utils/widgetDispatch.js +1 -1
package/l10n/en.json CHANGED
@@ -2699,6 +2699,18 @@
2699
2699
  "{column}, {row}": "{column}, {row}",
2700
2700
  "{cell}: empty": "{cell}: empty",
2701
2701
  "{cell}: {value}": "{cell}: {value}",
2702
+ "Search term not understood at position {position}:": "Search term not understood at position {position}:",
2703
+ "The list is not filtered; adjust the term.": "The list is not filtered; adjust the term.",
2704
+ "+ Label": "+ Label",
2705
+ "Remove {label}": "Remove {label}",
2706
+ "Select files first": "Select files first",
2707
+ "Save as provisional": "Save as provisional",
2708
+ "Completing was refused: fill in {field}.": "Completing was refused: fill in {field}.",
2709
+ "Saved as provisional.": "Saved as provisional.",
2710
+ "Unsaved input restored: {count} of {total} fields from your previous visit, {date}. Check them and save.": "Unsaved input restored: {count} of {total} fields from your previous visit, {date}. Check them and save.",
2711
+ "Task completed.": "Task completed.",
2712
+ "This task asks nothing to fill in.": "This task asks nothing to fill in.",
2713
+ "Task form": "Task form",
2702
2714
  "No rows match the filters.": "No rows match the filters.",
2703
2715
  "An item cannot be ticked in more than one column.": "An item cannot be ticked in more than one column.",
2704
2716
  "The options could not be read.": "The options could not be read."
package/l10n/nl.json CHANGED
@@ -2964,6 +2964,18 @@
2964
2964
  "{column}, {row}": "{column}, {row}",
2965
2965
  "{cell}: empty": "{cell}: leeg",
2966
2966
  "{cell}: {value}": "{cell}: {value}",
2967
+ "Search term not understood at position {position}:": "Zoekterm niet begrepen op positie {position}:",
2968
+ "The list is not filtered; adjust the term.": "De lijst is niet gefilterd; pas de term aan.",
2969
+ "+ Label": "+ Label",
2970
+ "Remove {label}": "{label} verwijderen",
2971
+ "Select files first": "Selecteer eerst bestanden",
2972
+ "Save as provisional": "Opslaan als voorlopig",
2973
+ "Completing was refused: fill in {field}.": "Afronden is geweigerd: vul {field} in.",
2974
+ "Saved as provisional.": "Opgeslagen als voorlopig.",
2975
+ "Unsaved input restored: {count} of {total} fields from your previous visit, {date}. Check them and save.": "Niet-opgeslagen invoer teruggezet: {count} van de {total} velden uit uw vorige bezoek, {date}. Controleer ze en sla op.",
2976
+ "Task completed.": "Taak afgerond.",
2977
+ "This task asks nothing to fill in.": "Deze taak vraagt niets in te vullen.",
2978
+ "Task form": "Taakformulier",
2967
2979
  "No rows match the filters.": "Geen rijen voldoen aan de filters.",
2968
2980
  "An item cannot be ticked in more than one column.": "Een item kan niet in meer dan één kolom aangevinkt zijn.",
2969
2981
  "The options could not be read.": "De keuzes konden niet worden gelezen."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/nextcloud-vue",
3
- "version": "2.56.0-beta.73",
3
+ "version": "2.56.0-beta.74",
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": {
@@ -11,7 +11,7 @@
11
11
  :noClose="busy"
12
12
  data-testid="cn-action-dialog"
13
13
  @closing="close">
14
- <div v-if="!done" class="cn-action-dialog">
14
+ <div v-if="!done" class="cn-action-dialog" :style="partsGap">
15
15
  <!-- The record the action is about: its title, a meta line, a badge. -->
16
16
  <div v-if="summary" class="cn-action-dialog__summary" data-testid="cn-action-dialog-summary">
17
17
  <span class="cn-action-dialog__summary-icon">
@@ -83,6 +83,7 @@
83
83
  weten..."). -->
84
84
  <NcCheckboxRadioSwitch v-if="field.type === 'checkbox'"
85
85
  class="cn-action-dialog__checkbox"
86
+ :class="{ 'cn-action-dialog__checkbox--plain': field.look === 'plain' }"
86
87
  :modelValue="checkboxValue(field)"
87
88
  type="checkbox"
88
89
  @update:modelValue="(on) => setChecked(field.field, on)">
@@ -159,6 +160,9 @@
159
160
  :modelValue="cardsValue(field)"
160
161
  :options="cardOptions(field)"
161
162
  :label="fill(field.label) || field.field"
163
+ :layout="field.layout === 'rows' ? 'rows' : 'cards'"
164
+ :columns="typeof field.columns === 'number' ? field.columns : 0"
165
+ :hideLabel="field.hideLabel === true"
162
166
  @update:modelValue="(value) => setValue(field.field, value)" />
163
167
  <!-- An optional select or text field: its label above the control,
164
168
  "(optional)" in grey after it (DqUwWachtrij "Sjabloon (niet
@@ -237,7 +241,7 @@
237
241
  </div>
238
242
 
239
243
  <p v-else role="status" data-testid="cn-action-dialog-done">
240
- {{ answerText || text(doneTextOf) || t('nextcloud-vue', 'Done') }}
244
+ {{ doneMessage }}
241
245
  </p>
242
246
 
243
247
  <template #actions>
@@ -260,6 +264,7 @@
260
264
 
261
265
  <script>
262
266
  import axios from '@nextcloud/axios'
267
+ import { showSuccess } from '@nextcloud/dialogs'
263
268
  import { emit } from '@nextcloud/event-bus'
264
269
  import { translate as t } from '@nextcloud/l10n'
265
270
  import { generateUrl } from '@nextcloud/router'
@@ -368,6 +373,16 @@ let reasonSeq = 0
368
373
  * token (`"{fields.permission}"`) sends the value as it is; `{fields.<key>}`
369
374
  * reads a sent value by the key it is sent under. `fieldsInBody: false`
370
375
  * sends only the body.
376
+ * - `{chosen.<field>.<path>}` reads the entry a select field's
377
+ * `optionsSource` gave for the chosen option, and `{objectId}` the record's
378
+ * id, in a body and in `doneText`; `doneText` also reads `{fields.<key>}`.
379
+ * - `closeOnDone: true` says the done text as a toast and closes the dialog
380
+ * rather than showing it in the dialog. `errorText` on the request or on
381
+ * `confirm` words a failure the server gives no message for.
382
+ * - `gap`: the room between the dialog's parts in px (default 18). A cards
383
+ * field takes `layout` (`rows`), `columns` and `hideLabel` as
384
+ * `CnChoiceCards` does; a checkbox field with `look: 'plain'` is a plain
385
+ * checkbox and label, without the tinted box.
371
386
  *
372
387
  * Tokens (`@objectId`, `@object.<field>`) resolve in every url.
373
388
  */
@@ -490,6 +505,38 @@ export default {
490
505
  return this.request?.doneText || this.config.doneText
491
506
  },
492
507
 
508
+ /**
509
+ * What the dialog says once the act ran: the answer, else the done text
510
+ * filled from the sent values, the chosen entries and the record.
511
+ *
512
+ * @spec openspec/changes/action-dialog-share-look-and-outcome/specs/action-dialog/spec.md#requirement-the-done-text-names-what-was-chosen
513
+ * @return {string}
514
+ */
515
+ doneMessage() {
516
+ return this.answerText || this.fill(this.doneTextOf, this.templateContext('')) || this.text(this.doneTextOf) || t('nextcloud-vue', 'Done')
517
+ },
518
+
519
+ /** @return {object|null} The room between the parts, when `gap` sets it. */
520
+ partsGap() {
521
+ return Number.isFinite(this.config.gap) ? { gap: `${this.config.gap}px` } : null
522
+ },
523
+
524
+ /**
525
+ * The entry each select field's `optionsSource` gave for its chosen
526
+ * option, by field name (null when nothing is chosen).
527
+ *
528
+ * @spec openspec/changes/action-dialog-share-look-and-outcome/specs/action-dialog/spec.md#requirement-the-done-text-names-what-was-chosen
529
+ * @return {object}
530
+ */
531
+ chosenRows() {
532
+ const out = {}
533
+ for (const field of this.fields.filter((f) => f.type === 'select' && f.optionsSource)) {
534
+ const value = String(this.plainValue(field))
535
+ out[field.field] = (this.remoteOptions[field.field] || []).find((row) => String(readPath(row, field.optionValue || 'id')) === value) || null
536
+ }
537
+ return out
538
+ },
539
+
493
540
  /** @return {{values: object, record: (object|null)}} What a `visibleWhen` reads. */
494
541
  shownState() {
495
542
  return { values: this.fieldValues, record: this.record }
@@ -1212,18 +1259,58 @@ export default {
1212
1259
  this.refusal = ''
1213
1260
  try {
1214
1261
  await this.runAct(this.reason.trim())
1215
- this.done = true
1216
- emit(PAGE_REFRESH, {})
1217
- /** @event done The action ran. Payload: the sent field values and `reason`. */
1218
- this.$emit('done', { ...this.sentValues, reason: this.reason.trim() })
1262
+ this.finish()
1219
1263
  } catch (failure) {
1220
- const data = failure && failure.response && failure.response.data
1221
- this.refusal = String((data && (data.message || data.error)) || t('nextcloud-vue', 'The action could not be completed.'))
1264
+ this.refusal = this.refusalOf(failure)
1222
1265
  } finally {
1223
1266
  this.busy = false
1224
1267
  }
1225
1268
  },
1226
1269
 
1270
+ /**
1271
+ * After the act: refresh the page, report `done`, and show the done
1272
+ * text, or with `closeOnDone` say it as a toast and close.
1273
+ *
1274
+ * @spec openspec/changes/action-dialog-share-look-and-outcome/specs/action-dialog/spec.md#requirement-the-dialog-can-close-once-the-act-ran
1275
+ * @return {void}
1276
+ */
1277
+ finish() {
1278
+ const closing = this.config.closeOnDone === true
1279
+ this.done = !closing
1280
+ emit(PAGE_REFRESH, {})
1281
+ /** @event done The action ran. Payload: the sent field values and `reason`. */
1282
+ this.$emit('done', { ...this.sentValues, reason: this.reason.trim() })
1283
+ if (closing) {
1284
+ showSuccess(this.doneMessage)
1285
+ this.$emit('close')
1286
+ }
1287
+ },
1288
+
1289
+ /**
1290
+ * A failed act in words: the server's message, else the configured
1291
+ * `errorText`, else the library's sentence.
1292
+ *
1293
+ * @param {unknown} failure The error axios threw.
1294
+ * @return {string}
1295
+ */
1296
+ refusalOf(failure) {
1297
+ const data = failure && failure.response && failure.response.data
1298
+ const said = data && (data.message || data.error)
1299
+ return String(said || this.text(this.request?.errorText || this.confirmConfig.errorText) || t('nextcloud-vue', 'The action could not be completed.'))
1300
+ },
1301
+
1302
+ /**
1303
+ * What a body or done text template reads: the sent values under
1304
+ * `fields`, the record, the reason, the chosen entries under `chosen`
1305
+ * and the record's id as `objectId`.
1306
+ *
1307
+ * @param {string} reason The reason given.
1308
+ * @return {object}
1309
+ */
1310
+ templateContext(reason) {
1311
+ return { fields: this.sentValues, ...(this.record || {}), reason, chosen: this.chosenRows, objectId: this.recordId }
1312
+ },
1313
+
1227
1314
  /**
1228
1315
  * Post the chosen act's request, or dispatch `confirm.action`.
1229
1316
  *
@@ -1269,7 +1356,7 @@ export default {
1269
1356
  * @return {object}
1270
1357
  */
1271
1358
  requestBody(request, reason) {
1272
- const filler = { context: { fields: this.sentValues, ...(this.record || {}), reason }, fill: (value, context) => fillTemplate(value, context) }
1359
+ const filler = { context: this.templateContext(reason), fill: (value, context) => fillTemplate(value, context) }
1273
1360
  const body = {}
1274
1361
  for (const [key, value] of Object.entries(request.body || {})) {
1275
1362
  body[key] = bodyValue(value, filler)
@@ -1535,6 +1622,26 @@ export default {
1535
1622
  font-size: 13px;
1536
1623
  }
1537
1624
 
1625
+ /* A plain checkbox: the box and its label on one line, no tinted card
1626
+ (DqZaakSamenwerken "Alleen een deel van de zaakvelden delen"). */
1627
+ .cn-action-dialog__checkbox--plain.checkbox-radio-switch {
1628
+ padding: 0;
1629
+ }
1630
+
1631
+ .cn-action-dialog__checkbox--plain {
1632
+ border: 0;
1633
+ background: transparent;
1634
+ }
1635
+
1636
+ .cn-action-dialog__checkbox--plain :deep(.checkbox-content) {
1637
+ gap: 10px;
1638
+ align-items: center;
1639
+ }
1640
+
1641
+ .cn-action-dialog__checkbox--plain .cn-action-dialog__checkbox-label {
1642
+ font-size: 14px;
1643
+ }
1644
+
1538
1645
  .cn-action-dialog__checks {
1539
1646
  border: 0;
1540
1647
  display: flex;
@@ -7,7 +7,7 @@
7
7
  <CnNoticeWidget
8
8
  v-for="entry in shown"
9
9
  :key="entry.key"
10
- :content="entry.notice"
10
+ :content="contentOf(entry)"
11
11
  :objectData="objectData"
12
12
  :objectId="objectId"
13
13
  :inline="true"
@@ -17,9 +17,20 @@
17
17
  </template>
18
18
 
19
19
  <script>
20
- import { evaluateVisibleWhen } from '../../utils/visibleWhen.js'
20
+ import { evaluateVisibleWhen, readVisibleWhenValue } from '../../utils/visibleWhen.js'
21
21
  import { CnNoticeWidget } from '../CnNoticeWidget/index.js'
22
22
 
23
+ /**
24
+ * Whether a notice reads its text from an endpoint (`textFrom: { endpoint, field }`).
25
+ *
26
+ * @param {object} notice The notice.
27
+ * @return {boolean}
28
+ */
29
+ function hasTextFrom(notice) {
30
+ const from = notice && notice.textFrom
31
+ return Boolean(from && typeof from === 'object' && typeof from.endpoint === 'string' && from.endpoint !== '' && typeof from.field === 'string' && from.field !== '')
32
+ }
33
+
23
34
  /**
24
35
  * CnCardNotices: the state banners at the top of a card or dialog (R1): an
25
36
  * engine refusal, a partial result, a source that is down, a success. Each
@@ -27,6 +38,8 @@ import { CnNoticeWidget } from '../CnNoticeWidget/index.js'
27
38
  * actions?, dismissible?, visibleWhen? }`) and shows while its `visibleWhen`
28
39
  * holds, read against the card's record (async: a `source` or `endpoint`
29
40
  * condition works too). A dismissed notice stays away until the list changes.
41
+ * A notice with `textFrom: { endpoint, field }` takes its text from that
42
+ * endpoint's answer and shows only while it is a non-empty string.
30
43
  *
31
44
  * Used by CnWidgetWrapper, CnDetailCard, CnDataTable and CnDialog through
32
45
  * their `notices` prop.
@@ -74,6 +87,8 @@ export default {
74
87
  return {
75
88
  // Notice key to whether its condition held.
76
89
  allowed: {},
90
+ // Notice key to the text its `textFrom` endpoint answered.
91
+ texts: {},
77
92
  dismissedKeys: [],
78
93
  }
79
94
  },
@@ -86,7 +101,7 @@ export default {
86
101
  */
87
102
  entries() {
88
103
  return (Array.isArray(this.notices) ? this.notices : [])
89
- .filter((notice) => notice && typeof notice === 'object' && (notice.title || notice.text))
104
+ .filter((notice) => notice && typeof notice === 'object' && (notice.title || notice.text || hasTextFrom(notice)))
90
105
  .map((notice, index) => ({ key: notice.id || `${index}:${notice.title || ''}:${notice.text || ''}`, notice }))
91
106
  },
92
107
 
@@ -97,7 +112,8 @@ export default {
97
112
  */
98
113
  shown() {
99
114
  return this.entries.filter((entry) => !this.dismissedKeys.includes(entry.key)
100
- && (!entry.notice.visibleWhen || this.allowed[entry.key] === true))
115
+ && (!entry.notice.visibleWhen || this.allowed[entry.key] === true)
116
+ && (!hasTextFrom(entry.notice) || typeof this.texts[entry.key] === 'string'))
101
117
  },
102
118
  },
103
119
 
@@ -131,11 +147,33 @@ export default {
131
147
  */
132
148
  async evaluate() {
133
149
  const context = { objectId: this.objectId, object: this.objectData || {} }
134
- const verdicts = await Promise.all(this.entries.map(async (entry) => [
135
- entry.key,
136
- entry.notice.visibleWhen ? await evaluateVisibleWhen(entry.notice.visibleWhen, context) : true,
137
- ]))
150
+ const [verdicts, texts] = await Promise.all([
151
+ Promise.all(this.entries.map(async (entry) => [
152
+ entry.key,
153
+ entry.notice.visibleWhen ? await evaluateVisibleWhen(entry.notice.visibleWhen, context) : true,
154
+ ])),
155
+ Promise.all(this.entries.filter((entry) => hasTextFrom(entry.notice)).map(async (entry) => [
156
+ entry.key,
157
+ await readVisibleWhenValue(entry.notice.textFrom, context).catch(() => null),
158
+ ])),
159
+ ])
138
160
  this.allowed = Object.fromEntries(verdicts)
161
+ this.texts = Object.fromEntries(texts.filter(([, text]) => typeof text === 'string' && text.trim() !== ''))
162
+ },
163
+
164
+ /**
165
+ * The notice as drawn: its `textFrom` answer as its text.
166
+ *
167
+ * @param {{key: string, notice: object}} entry The notice.
168
+ * @return {object} The notice content.
169
+ * @spec openspec/changes/notice-text-from-endpoint/specs/card-state-notices/spec.md#requirement-a-notices-text-can-come-from-an-endpoint
170
+ */
171
+ contentOf(entry) {
172
+ if (!hasTextFrom(entry.notice)) {
173
+ return entry.notice
174
+ }
175
+ const { textFrom, ...notice } = entry.notice
176
+ return { ...notice, text: this.texts[entry.key] }
139
177
  },
140
178
 
141
179
  /**
@@ -74,6 +74,26 @@
74
74
  {{ columnLabel(column) }}
75
75
  </NcActionCheckbox>
76
76
  </NcActions>
77
+ <!-- `toolbarSelectionActions`: a bulk action as a toolbar button,
78
+ off with its reason while nothing is ticked (DqZaakDocumenten
79
+ "Samenvoegen tot één PDF"). -->
80
+ <template v-for="action in toolbarSelectionList" :key="`toolbar-selection-${action.id}`">
81
+ <NcButton
82
+ variant="secondary"
83
+ :disabled="selectedIds.length === 0"
84
+ :title="selectedIds.length === 0 ? action.reason : undefined"
85
+ :aria-describedby="selectedIds.length === 0 ? `${toolbarReasonPrefix}-${action.id}` : undefined"
86
+ :data-testid="`cn-files-browser-toolbar-selection-${action.id}`"
87
+ @click="runBulkAction(action.action)">
88
+ <template v-if="action.icon" #icon>
89
+ <CnIcon :name="action.icon" :size="20" />
90
+ </template>
91
+ {{ action.label }}
92
+ </NcButton>
93
+ <span v-if="selectedIds.length === 0"
94
+ :id="`${toolbarReasonPrefix}-${action.id}`"
95
+ class="hidden-visually">{{ action.reason }}</span>
96
+ </template>
77
97
  <!-- `facetPresentation: "menu"`: each facet as a toolbar menu
78
98
  "<column>: <value>" (DqZaakDocumenten "Trefwoord: alle"),
79
99
  one value at a time, "all" clears it. -->
@@ -265,7 +285,7 @@
265
285
  </div>
266
286
 
267
287
  <!-- The host's bulk actions, once something is selected. -->
268
- <div v-if="bulkEnabled && selectedIds.length > 0"
288
+ <div v-if="bulkEnabled && bulkActions.length > 0 && selectedIds.length > 0"
269
289
  class="cn-files-browser__bulk-bar"
270
290
  role="toolbar"
271
291
  :aria-label="t('nextcloud-vue', 'Actions for the selected files')"
@@ -835,6 +855,8 @@ const FOLDER_CHANGED_CHANNELS = ['cn:page:refresh', 'files:node:created', 'files
835
855
 
836
856
  const FOLDER_CHANGED_DEBOUNCE_MS = 300
837
857
 
858
+ let reasonUid = 0
859
+
838
860
  export default {
839
861
  name: 'CnFilesBrowser',
840
862
 
@@ -1288,6 +1310,20 @@ export default {
1288
1310
  default: () => [],
1289
1311
  },
1290
1312
 
1313
+ /**
1314
+ * Actions on the ticked files drawn as toolbar buttons, declared as
1315
+ * `bulkActions` plus `disabledReason` (translated; default "Select
1316
+ * files first"). Each is disabled, saying why, while no file is
1317
+ * ticked, and turns the row checkboxes on as `bulkActions` does.
1318
+ *
1319
+ * @type {Array<{id: string, label: string, icon?: string, disabledReason?: string}>}
1320
+ * @spec openspec/changes/files-columns-by-flag-and-toolbar-selection/specs/files-browser/spec.md#requirement-a-selection-action-can-sit-in-the-toolbar
1321
+ */
1322
+ toolbarSelectionActions: {
1323
+ type: Array,
1324
+ default: () => [],
1325
+ },
1326
+
1291
1327
  /**
1292
1328
  * The bulk bar's count, as a translatable template with `{count}`
1293
1329
  * ("{count} documents selected"); `selectionLabelOne` is used for one.
@@ -1395,7 +1431,10 @@ export default {
1395
1431
  emits: ['changed'],
1396
1432
 
1397
1433
  data() {
1434
+ reasonUid += 1
1398
1435
  return {
1436
+ /** The id prefix of the toolbar selection buttons' reasons. */
1437
+ toolbarReasonPrefix: `cn-files-browser-reason-${reasonUid}`,
1399
1438
  /** The actions column's measured width while a row button stands in it, else null. */
1400
1439
  actionsColumnWidth: null,
1401
1440
  currentPath: this.rootPath,
@@ -1645,7 +1684,27 @@ export default {
1645
1684
  * @spec openspec/changes/files-browser-hosts-a-documents-list/specs/files-browser/spec.md
1646
1685
  */
1647
1686
  bulkEnabled() {
1648
- return Array.isArray(this.bulkActions) && this.bulkActions.length > 0
1687
+ return (Array.isArray(this.bulkActions) && this.bulkActions.length > 0) || this.toolbarSelectionList.length > 0
1688
+ },
1689
+
1690
+ /**
1691
+ * The toolbar's selection buttons (`toolbarSelectionActions`), labels translated.
1692
+ *
1693
+ * @return {Array<{id: string, label: string, icon: string, reason: string, action: object}>}
1694
+ * @spec openspec/changes/files-columns-by-flag-and-toolbar-selection/specs/files-browser/spec.md#requirement-a-selection-action-can-sit-in-the-toolbar
1695
+ */
1696
+ toolbarSelectionList() {
1697
+ return (Array.isArray(this.toolbarSelectionActions) ? this.toolbarSelectionActions : [])
1698
+ .filter((action) => action && typeof action === 'object' && typeof action.id === 'string' && action.id !== '')
1699
+ .map((action) => ({
1700
+ id: action.id,
1701
+ label: this.hostLabel(action),
1702
+ icon: typeof action.icon === 'string' ? action.icon : '',
1703
+ reason: typeof action.disabledReason === 'string' && action.disabledReason !== ''
1704
+ ? this.cnTranslate(action.disabledReason)
1705
+ : t('nextcloud-vue', 'Select files first'),
1706
+ action,
1707
+ }))
1649
1708
  },
1650
1709
 
1651
1710
  /**
@@ -73,7 +73,8 @@ function requiredAppPresent(requiredApp) {
73
73
  *
74
74
  * A string names a built-in. An object declares its own: `key`, `label`,
75
75
  * `source` (`node`, `attribute` or `row`), `attribute`, `formatter` and
76
- * `sortable`, and `requiredApp` (an app id, or a list of which any one will
76
+ * `sortable`, `hidden` (`true`, or `{ not: <flag> }`: hidden unless the
77
+ * resolved flag is true), and `requiredApp` (an app id, or a list of which any one will
77
78
  * do; without it the column is left out). An entry naming an unknown built-in is dropped here and refused
78
79
  * by the manifest validator, so an author hears about it at authoring time
79
80
  * rather than finding a column missing at runtime.
@@ -102,14 +103,19 @@ export function normaliseFileColumns(columns) {
102
103
  if (!requiredAppPresent(entry.requiredApp)) {
103
104
  return
104
105
  }
105
- if (isBuiltInFileColumn(entry.key) && entry.source === undefined) {
106
- out.push({ ...BUILT_IN_FILE_COLUMNS[entry.key], ...entry, builtIn: true })
106
+ // `hidden: { not: <flag> }`: hidden by default unless the flag is true
107
+ // (Type, Richting and Auteur show on a case type that reviews documents).
108
+ const own = entry.hidden && typeof entry.hidden === 'object' && 'not' in entry.hidden
109
+ ? { ...entry, hidden: entry.hidden.not !== true }
110
+ : entry
111
+ if (isBuiltInFileColumn(own.key) && own.source === undefined) {
112
+ out.push({ ...BUILT_IN_FILE_COLUMNS[own.key], ...own, builtIn: true })
107
113
  return
108
114
  }
109
115
  out.push({
110
116
  source: 'node',
111
117
  sortable: false,
112
- ...entry,
118
+ ...own,
113
119
  builtIn: false,
114
120
  })
115
121
  })