@conduction/nextcloud-vue 2.61.0 → 2.63.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 (186) hide show
  1. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js +10 -0
  2. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js.map +1 -0
  3. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js +189 -0
  4. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js.map +1 -0
  5. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js +72 -0
  6. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js.map +1 -0
  7. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js +394 -27
  8. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js.map +1 -1
  9. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js.map +1 -1
  10. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js +99 -9
  11. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js.map +1 -1
  12. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js +39 -18
  13. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js.map +1 -1
  14. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js +79 -2
  15. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js.map +1 -1
  16. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js +38 -25
  17. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js.map +1 -1
  18. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue2.js +21 -1
  19. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue2.js.map +1 -1
  20. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue3.js +4 -1
  21. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue3.js.map +1 -1
  22. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue2.js.map +1 -1
  23. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js +53 -37
  24. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js.map +1 -1
  25. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +30 -6
  26. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
  27. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js +2 -2
  28. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
  29. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js +10 -0
  30. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js.map +1 -0
  31. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js +293 -0
  32. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js.map +1 -0
  33. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js +189 -0
  34. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js.map +1 -0
  35. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +256 -23
  36. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
  37. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +119 -51
  38. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
  39. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  40. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js +2 -1
  41. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  42. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js +3 -1
  43. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js.map +1 -1
  44. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js +1 -1
  45. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js.map +1 -1
  46. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js +234 -9
  47. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  48. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +96 -57
  49. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  50. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +51 -2
  51. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  52. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +5 -1
  53. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  54. package/dist/esm/components/CnIndexPage/selfModeActions.js +3 -3
  55. package/dist/esm/components/CnIndexPage/selfModeActions.js.map +1 -1
  56. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue2.js.map +1 -1
  57. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue3.js.map +1 -1
  58. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js +36 -1
  59. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js.map +1 -1
  60. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js +4 -1
  61. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js.map +1 -1
  62. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js +53 -0
  63. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js.map +1 -1
  64. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js +22 -5
  65. package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js.map +1 -1
  66. package/dist/esm/components/CnReportsPage/CnReportsPage.vue2.js.map +1 -1
  67. package/dist/esm/components/CnReportsPage/CnReportsPage.vue3.js.map +1 -1
  68. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js +121 -12
  69. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js.map +1 -1
  70. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js +3 -1
  71. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js.map +1 -1
  72. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js +326 -1
  73. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js.map +1 -1
  74. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js +112 -26
  75. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js.map +1 -1
  76. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js.map +1 -1
  77. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js.map +1 -1
  78. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js +10 -0
  79. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js.map +1 -0
  80. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js +337 -0
  81. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js.map +1 -0
  82. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js +102 -0
  83. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js.map +1 -0
  84. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js +34 -0
  85. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js.map +1 -0
  86. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js +131 -8
  87. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js.map +1 -1
  88. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js +40 -38
  89. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js.map +1 -1
  90. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js +8 -6
  91. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js.map +1 -1
  92. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  93. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  94. package/dist/esm/components/CnWikiPage/CnWikiPage.vue2.js.map +1 -1
  95. package/dist/esm/components/CnWikiPage/CnWikiPage.vue3.js.map +1 -1
  96. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js +19 -0
  97. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js.map +1 -1
  98. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js +1 -1
  99. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js.map +1 -1
  100. package/dist/esm/composables/useDependencyCheck.js +65 -0
  101. package/dist/esm/composables/useDependencyCheck.js.map +1 -0
  102. package/dist/esm/composables/useWalkthrough.js +218 -6
  103. package/dist/esm/composables/useWalkthrough.js.map +1 -1
  104. package/dist/esm/index.js +2 -0
  105. package/dist/esm/index.js.map +1 -1
  106. package/dist/esm/l10n/en.json.js +48 -0
  107. package/dist/esm/l10n/en.json.js.map +1 -1
  108. package/dist/esm/l10n/nl.json.js +48 -0
  109. package/dist/esm/l10n/nl.json.js.map +1 -1
  110. package/dist/esm/nextcloud-vue.css +557 -9
  111. package/dist/esm/store/useObjectStore.js +8 -0
  112. package/dist/esm/store/useObjectStore.js.map +1 -1
  113. package/dist/esm/utils/columnFilters.js +311 -0
  114. package/dist/esm/utils/columnFilters.js.map +1 -0
  115. package/dist/esm/utils/groupAutocomplete.js +123 -0
  116. package/dist/esm/utils/groupAutocomplete.js.map +1 -0
  117. package/dist/esm/utils/libraryWidgetKeys.js +2 -0
  118. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  119. package/dist/esm/utils/pickerOptions.js +198 -0
  120. package/dist/esm/utils/pickerOptions.js.map +1 -0
  121. package/dist/esm/utils/schema.js +83 -7
  122. package/dist/esm/utils/schema.js.map +1 -1
  123. package/dist/esm/utils/timelineEvents.js +174 -0
  124. package/dist/esm/utils/timelineEvents.js.map +1 -0
  125. package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
  126. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  127. package/dist/esm/utils/walkthroughSignals.js +88 -0
  128. package/dist/esm/utils/walkthroughSignals.js.map +1 -0
  129. package/dist/nextcloud-vue.cjs.js +9779 -5236
  130. package/dist/nextcloud-vue.cjs.js.map +2 -2
  131. package/dist/nextcloud-vue.css +557 -9
  132. package/l10n/en.json +48 -0
  133. package/l10n/nl.json +48 -0
  134. package/package.json +3 -2
  135. package/scripts/manifest-schema-hash.js +41 -0
  136. package/scripts/record-manifest-schema-hash.js +52 -0
  137. package/src/components/CnAdminActionCard/CnAdminActionCard.vue +234 -0
  138. package/src/components/CnAdminActionCard/index.js +4 -0
  139. package/src/components/CnAppNav/CnAppNav.vue +394 -27
  140. package/src/components/CnAppRoot/CnAppRoot.vue +129 -15
  141. package/src/components/CnBannerWidget/CnBannerWidget.vue +113 -2
  142. package/src/components/CnBrandStripe/CnBrandStripe.md +16 -0
  143. package/src/components/CnBrandStripe/CnBrandStripe.vue +58 -5
  144. package/src/components/CnChoiceCards/CnChoiceCards.vue +56 -31
  145. package/src/components/CnDashboardPage/CnDashboardPage.vue +32 -8
  146. package/src/components/CnDataTable/CnColumnFilterPopover.vue +524 -0
  147. package/src/components/CnDataTable/CnDataTable.md +4 -1
  148. package/src/components/CnDataTable/CnDataTable.vue +302 -21
  149. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +2 -2
  150. package/src/components/CnFieldHelper/CnFieldHelper.vue +4 -2
  151. package/src/components/CnFormDialog/CnFormDialog.vue +290 -31
  152. package/src/components/CnIndexPage/CnIndexPage.vue +55 -2
  153. package/src/components/CnIndexPage/selfModeActions.js +3 -3
  154. package/src/components/CnLinkCardsPage/CnLinkCardsPage.vue +35 -2
  155. package/src/components/CnObjectListWidget/CnObjectListWidget.vue +39 -1
  156. package/src/components/CnObjectSidebar/CnFilesTab.vue +65 -0
  157. package/src/components/CnReportsPage/CnReportsPage.vue +7 -0
  158. package/src/components/CnResourceSelect/CnResourceSelect.vue +123 -12
  159. package/src/components/CnSetupWizard/CnSetupWizard.vue +392 -3
  160. package/src/components/CnStorePage/CnStorePage.vue +7 -0
  161. package/src/components/CnTimelineWidget/CnTimelineWidget.vue +477 -0
  162. package/src/components/CnTimelineWidget/dashboardRegistration.js +32 -0
  163. package/src/components/CnTimelineWidget/index.js +4 -0
  164. package/src/components/CnWalkthrough/CnWalkthrough.vue +143 -10
  165. package/src/components/CnWidgetGrid/builtInWidgets.js +2 -0
  166. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  167. package/src/components/CnWikiPage/CnWikiPage.vue +7 -0
  168. package/src/components/CnWizardDialog/CnWizardDialog.vue +20 -1
  169. package/src/components/index.js +2 -0
  170. package/src/composables/useDependencyCheck.js +61 -0
  171. package/src/composables/useWalkthrough.js +217 -5
  172. package/src/css/dashboard.css +49 -0
  173. package/src/css/detail-page.css +19 -0
  174. package/src/css/table.css +82 -2
  175. package/src/index.js +2 -0
  176. package/src/public/index.js +5 -0
  177. package/src/schemas/app-manifest-v2.schema.json +23 -1
  178. package/src/store/useObjectStore.js +8 -0
  179. package/src/utils/columnFilters.js +324 -0
  180. package/src/utils/groupAutocomplete.js +119 -0
  181. package/src/utils/libraryWidgetKeys.js +2 -0
  182. package/src/utils/pickerOptions.js +194 -0
  183. package/src/utils/schema.js +83 -7
  184. package/src/utils/timelineEvents.js +171 -0
  185. package/src/utils/validateManifestV2.compiled.js +2 -2
  186. package/src/utils/walkthroughSignals.js +94 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CnResourceSelect.vue3.js","sources":["../../../../src/components/CnResourceSelect/CnResourceSelect.vue?vue&type=template&id=37b7ff6f&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<NcSelect\n\t\t:inputId=\"inputId\"\n\t\t:inputLabel=\"inputLabel\"\n\t\t:modelValue=\"selectedOption\"\n\t\t:options=\"displayOptions\"\n\t\t:loading=\"loading\"\n\t\t:clearable=\"clearable\"\n\t\t:disabled=\"disabled\"\n\t\t:placeholder=\"placeholder\"\n\t\t:filterable=\"false\"\n\t\tlabel=\"label\"\n\t\t@search=\"onSearch\"\n\t\t@update:modelValue=\"onInput\">\n\t\t<template #option=\"{ label: optLabel, __create }\">\n\t\t\t<span v-if=\"__create\" class=\"cn-resource-select__create\">\n\t\t\t\t<Plus :size=\"16\" />\n\t\t\t\t{{ createLabelFor(optLabel) }}\n\t\t\t</span>\n\t\t\t<span v-else>{{ optLabel }}</span>\n\t\t</template>\n\t</NcSelect>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcSelect } from '@nextcloud/vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport { useObjectStore } from '../../store/index.js'\n\n/**\n * CnResourceSelect — an OpenRegister object picker that can CREATE from the\n * search term.\n *\n * Searches a `register` + `schema` for objects matching the typed text and\n * renders them as options. When the typed term matches no existing object, a\n * synthetic **\"Create '<term>'\"** option appears at the bottom; choosing it\n * persists a new object (via `useObjectStore().saveObject`, writing the term to\n * `labelField`) and selects it — so an agent who can't find a client just types\n * the name and makes one inline, never hitting a dead \"no results\" end.\n *\n * Emits `update:modelValue` (the selected object's id) and `create` (the\n * freshly-created object). The label of each option comes from `labelField`\n * (default `name`), the value from the object's id.\n *\n * Backwards-compatible, self-contained: it owns its own search + create flow,\n * so a consumer only needs to pass `register` + `schema` and bind `modelValue`.\n *\n * Three opt-in props cover the cases a plain object picker cannot:\n *\n * - `filters` SCOPES the options to a parent selection, which is what makes a\n * cascading pair work (pick a client, then only that client's contacts are\n * offered). Changing the scope clears a now-invalid selection.\n * - `preload` fetches a first page on mount so the field can be BROWSED, not\n * only searched — the behaviour a user expects from a select.\n * - `createHandler` replaces the built-in save. Creating from a bare term only\n * works while the term is enough to satisfy the schema; the moment a\n * required field must come from somewhere else (a server-minted key, a value\n * worth collecting in a full dialog) the consumer owns the create and\n * resolves the finished object back.\n *\n * Example:\n * ```vue\n * <CnResourceSelect\n * register=\"pipelinq\"\n * schema=\"client\"\n * label-field=\"name\"\n * :model-value=\"clientId\"\n * :input-label=\"t('pipelinq', 'Client')\"\n * @update:modelValue=\"clientId = $event\"\n * @create=\"onClientCreated\" />\n * ```\n */\nexport default {\n\tname: 'CnResourceSelect',\n\n\tcomponents: { NcSelect, Plus },\n\n\tprops: {\n\t\t/** OpenRegister register slug to search/create in. */\n\t\tregister: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** OpenRegister schema slug to search/create in. */\n\t\tschema: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Currently-selected object id (v-model). */\n\t\tmodelValue: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Object field used as the option label AND written on create. */\n\t\tlabelField: {\n\t\t\ttype: String,\n\t\t\tdefault: 'name',\n\t\t},\n\n\t\t/** Accessible input label for the underlying NcSelect. */\n\t\tinputLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** DOM id for the input (a11y association). */\n\t\tinputId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Whether the selection can be cleared. */\n\t\tclearable: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t/** Minimum characters before searching / offering create. */\n\t\tminChars: {\n\t\t\ttype: Number,\n\t\t\tdefault: 2,\n\t\t},\n\n\t\t/**\n\t\t * Whether to offer the inline \"Create '<term>'\" option when the search\n\t\t * yields no exact match. Off → behaves like a plain async object select.\n\t\t */\n\t\tallowCreate: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t/**\n\t\t * Extra fields merged into the payload when creating a new object (e.g.\n\t\t * a fixed `type` or `status`). The `labelField` is always set to the term.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcreateDefaults: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Field filters merged into the search query, so the option list can be\n\t\t * SCOPED to a parent selection — the cascading-select case (pick a\n\t\t * client, then only that client's contacts are offered). Changing this\n\t\t * reloads the options and clears a selection that no longer belongs to\n\t\t * the new scope.\n\t\t *\n\t\t * Example: `:filters=\"{ client: form.client }\"`.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfilters: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Load a first page of options on mount (and whenever `filters`\n\t\t * change) instead of waiting for `minChars` of typing. Lets the field\n\t\t * be BROWSED like a plain select while still searching server-side once\n\t\t * the user types. Off by default so existing consumers keep their\n\t\t * search-only behaviour and issue no extra request.\n\t\t */\n\t\tpreload: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Disable the input — e.g. a dependent select waiting on its parent.\n\t\t */\n\t\tdisabled: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** Placeholder text for the underlying NcSelect. */\n\t\tplaceholder: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Override how a new object is created from the typed term. Receives\n\t\t * `(term, payload)` and MUST resolve to the created object (or a falsy\n\t\t * value to abort, e.g. the user cancelled a dialog).\n\t\t *\n\t\t * Without it the component posts `payload` straight to\n\t\t * `objectStore.saveObject`, which is wrong whenever the schema requires\n\t\t * a field the term cannot supply — a server-minted foreign key, say, or\n\t\t * anything the consumer would rather collect in a full create dialog.\n\t\t *\n\t\t * @type {((term: string, payload: object) => Promise<object|null>)|null}\n\t\t */\n\t\tcreateHandler: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: ['update:modelValue', 'create'],\n\n\tdata() {\n\t\treturn {\n\t\t\tsearch: '',\n\t\t\tloading: false,\n\t\t\toptions: [],\n\t\t\t// The selected option object kept locally so the label shows even\n\t\t\t// before/without a matching search result (e.g. a pre-set modelValue).\n\t\t\tlocalSelected: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** Pinia object store handle (resolved lazily so a Pinia-less test still mounts). */\n\t\tobjectStore() {\n\t\t\ttry {\n\t\t\t\treturn useObjectStore()\n\t\t\t} catch {\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\n\t\t/** The `${register}-${schema}` object-type slug used by the store. */\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\n\t\t/** The currently-selected option, for NcSelect's model-value. */\n\t\tselectedOption() {\n\t\t\tif (this.localSelected && this.localSelected.value === this.modelValue) {\n\t\t\t\treturn this.localSelected\n\t\t\t}\n\t\t\treturn this.options.find((o) => o.value === this.modelValue) || null\n\t\t},\n\n\t\t/**\n\t\t * The option list shown in the dropdown — the search results, plus a\n\t\t * synthetic \"Create '<term>'\" entry when create is allowed and the term\n\t\t * is long enough and matches no existing option label exactly.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tdisplayOptions() {\n\t\t\tconst opts = [...this.options]\n\t\t\tconst term = this.search.trim()\n\t\t\tif (this.allowCreate && term.length >= this.minChars) {\n\t\t\t\tconst exact = opts.some((o) => (o.label || '').toLowerCase() === term.toLowerCase())\n\t\t\t\tif (!exact) {\n\t\t\t\t\topts.push({ value: '__create__', label: term, __create: true })\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn opts\n\t\t},\n\n\t\t/**\n\t\t * Stable string identity for `filters`. Watching the object itself\n\t\t * would re-fire on every parent re-render (a fresh object literal is a\n\t\t * new identity even when the values are unchanged), reloading options\n\t\t * and clobbering the selection in a loop.\n\t\t *\n\t\t * @return {string}\n\t\t */\n\t\tfiltersKey() {\n\t\t\treturn JSON.stringify(this.filters || {})\n\t\t},\n\n\t\t/**\n\t\t * `filters` with empty entries dropped. A parent that has not been\n\t\t * chosen yet holds `null`, and forwarding `client=` as a query param\n\t\t * asks the API for objects whose client is the empty string — which\n\t\t * matches nothing and reads as \"no results\" rather than \"not scoped\".\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\tactiveFilters() {\n\t\t\tconst out = {}\n\t\t\tfor (const [key, value] of Object.entries(this.filters || {})) {\n\t\t\t\tif (value !== null && value !== undefined && value !== '') {\n\t\t\t\t\tout[key] = value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\t},\n\n\twatch: {\n\t\tmodelValue: {\n\t\t\timmediate: true,\n\t\t\thandler() {\n\t\t\t\tthis.ensureSelectedLoaded()\n\t\t\t},\n\t\t},\n\n\t\tfiltersKey(next, prev) {\n\t\t\tif (next === prev) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The scope moved, so anything already selected may no longer be\n\t\t\t// in it. Drop the stale options + selection, then re-seed.\n\t\t\tthis.options = []\n\t\t\tif (this.modelValue) {\n\t\t\t\tthis.localSelected = null\n\t\t\t\tthis.$emit('update:modelValue', '')\n\t\t\t}\n\t\t\tif (this.search.trim().length >= this.minChars) {\n\t\t\t\tthis.onSearch(this.search)\n\t\t\t} else {\n\t\t\t\tthis.loadInitialOptions()\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tthis.loadInitialOptions()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Seed the dropdown with a first page of options so the field can be\n\t\t * browsed without typing. No-op unless `preload` is set.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync loadInitialOptions() {\n\t\t\tif (!this.preload || !this.objectStore) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tconst collection = await this.objectStore.fetchCollectionForOptions(this.typeSlug, {\n\t\t\t\t\t...this.activeFilters,\n\t\t\t\t\t_limit: 20,\n\t\t\t\t})\n\t\t\t\tconst items = Array.isArray(collection)\n\t\t\t\t\t? collection\n\t\t\t\t\t: (this.objectStore.collections[this.typeSlug] || [])\n\t\t\t\tthis.options = items.map((o) => this.toOption(o))\n\t\t\t} catch {\n\t\t\t\tthis.options = []\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The translated \"Create 'X'\" label for the synthetic option.\n\t\t *\n\t\t * @param {string} term The typed term.\n\t\t * @return {string}\n\t\t */\n\t\tcreateLabelFor(term) {\n\t\t\treturn t('nextcloud-vue', 'Create \"{term}\"', { term })\n\t\t},\n\n\t\t/**\n\t\t * Run an object search (debounced via NcSelect's own throttling) for the\n\t\t * typed term. Failures degrade to an empty option list.\n\t\t *\n\t\t * @param {string} term The search term from NcSelect.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSearch(term) {\n\t\t\tthis.search = term || ''\n\t\t\tif (!this.objectStore || this.search.trim().length < this.minChars) {\n\t\t\t\t// Below the search threshold: fall back to the browsable first\n\t\t\t\t// page when preloading, rather than blanking the list.\n\t\t\t\tthis.options = []\n\t\t\t\tthis.loadInitialOptions()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tconst collection = await this.objectStore.fetchCollectionForOptions(this.typeSlug, {\n\t\t\t\t\t...this.activeFilters,\n\t\t\t\t\t_search: this.search.trim(),\n\t\t\t\t\t_limit: 20,\n\t\t\t\t})\n\t\t\t\tconst items = Array.isArray(collection)\n\t\t\t\t\t? collection\n\t\t\t\t\t: (this.objectStore.collections[this.typeSlug] || [])\n\t\t\t\tthis.options = items.map((o) => this.toOption(o))\n\t\t\t} catch {\n\t\t\t\tthis.options = []\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Handle a selection. A real option emits its id; the synthetic create\n\t\t * option triggers object creation.\n\t\t *\n\t\t * @param {object|null} option The chosen option (or null on clear).\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onInput(option) {\n\t\t\tif (!option) {\n\t\t\t\tthis.localSelected = null\n\t\t\t\t/**\n\t\t\t\t * @event update:modelValue The selected (or newly-created) object id, or '' when cleared.\n\t\t\t\t * @type {string}\n\t\t\t\t */\n\t\t\t\tthis.$emit('update:modelValue', '')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (option.__create) {\n\t\t\t\tawait this.createFromTerm(option.label)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.localSelected = option\n\t\t\tthis.$emit('update:modelValue', option.value)\n\t\t},\n\n\t\t/**\n\t\t * Create a new object from the typed term and select it.\n\t\t *\n\t\t * @param {string} term The term to write to `labelField`.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync createFromTerm(term) {\n\t\t\tif (!this.objectStore && !this.createHandler) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst name = (term || '').trim()\n\t\t\tif (!name) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\t// The active scope is part of the new object's identity: a\n\t\t\t\t// contact created while the list is filtered to one client\n\t\t\t\t// belongs to that client. An explicit createDefaults entry\n\t\t\t\t// still wins.\n\t\t\t\tconst payload = { ...this.activeFilters, ...this.createDefaults, [this.labelField]: name }\n\t\t\t\tlet created\n\t\t\t\tif (this.createHandler) {\n\t\t\t\t\t// A falsy resolve means the consumer aborted (cancelled\n\t\t\t\t\t// dialog) — leave the selection untouched.\n\t\t\t\t\tcreated = await this.createHandler(name, payload)\n\t\t\t\t} else {\n\t\t\t\t\tthis.ensureRegistered()\n\t\t\t\t\tcreated = await this.objectStore.saveObject(this.typeSlug, payload)\n\t\t\t\t}\n\t\t\t\tif (!created) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst option = this.toOption(created)\n\t\t\t\tthis.options = [option, ...this.options.filter((o) => o.value !== option.value)]\n\t\t\t\tthis.localSelected = option\n\t\t\t\tthis.$emit('update:modelValue', option.value)\n\t\t\t\t/**\n\t\t\t\t * @event create A new object was created from the search term.\n\t\t\t\t * @type {object} The created OpenRegister object.\n\t\t\t\t */\n\t\t\t\tthis.$emit('create', created)\n\t\t\t} catch (e) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn('[CnResourceSelect] create failed', e)\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Map an OpenRegister object to an option `{ value, label }`.\n\t\t *\n\t\t * @param {object} obj The object.\n\t\t * @return {{value: string, label: string}}\n\t\t */\n\t\ttoOption(obj) {\n\t\t\tconst id = String(obj.id || (obj['@self'] && obj['@self'].id) || '')\n\t\t\tconst label = obj[this.labelField] || obj.name || obj.title || id\n\t\t\treturn { value: id, label }\n\t\t},\n\n\t\t/**\n\t\t * Register the object type with the store (idempotent) so search/create\n\t\t * route to the right register+schema.\n\t\t */\n\t\tensureRegistered() {\n\t\t\tif (this.objectStore && typeof this.objectStore.registerObjectType === 'function') {\n\t\t\t\ttry {\n\t\t\t\t\tthis.objectStore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t} catch {\n\t\t\t\t\t// Already registered or store not ready — non-fatal.\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * When a `modelValue` is set but no matching option is loaded, fetch the\n\t\t * single object so its label renders (e.g. a pre-filled client id).\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync ensureSelectedLoaded() {\n\t\t\tif (!this.modelValue || this.selectedOption || !this.objectStore) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tif (typeof this.objectStore.fetchObject !== 'function') {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst obj = await this.objectStore.fetchObject(this.typeSlug, String(this.modelValue))\n\t\t\t\tif (obj) {\n\t\t\t\t\tthis.localSelected = this.toOption(obj)\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Leave the id un-labelled rather than crash.\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-resource-select__create {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n}\n</style>\n"],"names":["_withCtx","_openBlock","_createElementBlock","_createVNode","_toDisplayString"],"mappings":";;;;AAuByB,EAAA,KAAK,EAAC,4BAAK;;;;;;;;;AAbjC,IAAA,OAAO,EAAE,MAAO,CAAA,OAAA;AAChB,IAAA,UAAU,EAAE,MAAQ,CAAA,UAAA;AACpB,IAAA,UAAU,EAAE,QAAM,CAAA,cAAA;AAClB,IAAA,OAAO,EAAE,QAAc,CAAA,cAAA;AACvB,IAAA,OAAO,EAAE,KAAO,CAAA,OAAA;AAChB,IAAA,SAAS,EAAE,MAAA,CAAA,SAAA;AACX,IAAA,QAAQ,EAAE,MAAM,CAAA,QAAA;AAChB,IAAA,WAAW,EAAE,MAAW,CAAA,WAAA;AACxB,IAAA,UAAU,EAAE,KAAK;SACb,EAAE,OAAM;AACX,IAAA,QAAI,EAAG,QAAQ,CAAA,QAAA;yBACC,EAAE,QAAO,CAAA,OAAA;;AACpB,IAAA,MAAA,EACNA,OAAA,CAAA,GADM,KAAA,EAAA,QAAA,EAAA,QAAA,EAAA,KAAA;MACM,QAAQ;AAApB,WAAAC,SAAA,EAAA,EAAAC,kBAAA,SAAA;YACCC,WAAQ,CAAA,eAAA,EAAA,EAAD,IAAC,EAAA,EAAA,EAAA,CAAA;4BAAA,GACR,GAAAC,eAAA,CAAG,QAAI,CAAA,cAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"CnResourceSelect.vue3.js","sources":["../../../../src/components/CnResourceSelect/CnResourceSelect.vue?vue&type=template&id=37b7ff6f&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<NcSelect\n\t\t:inputId=\"inputId\"\n\t\t:inputLabel=\"inputLabel\"\n\t\t:modelValue=\"selectedOption\"\n\t\t:options=\"displayOptions\"\n\t\t:loading=\"loading\"\n\t\t:clearable=\"clearable\"\n\t\t:disabled=\"disabled\"\n\t\t:placeholder=\"placeholder\"\n\t\t:filterable=\"false\"\n\t\t:multiple=\"multiple\"\n\t\t:keepOpen=\"multiple\"\n\t\tlabel=\"label\"\n\t\t@search=\"onSearch\"\n\t\t@update:modelValue=\"onInput\">\n\t\t<template #option=\"{ label: optLabel, __create }\">\n\t\t\t<span v-if=\"__create\" class=\"cn-resource-select__create\">\n\t\t\t\t<Plus :size=\"16\" />\n\t\t\t\t{{ createLabelFor(optLabel) }}\n\t\t\t</span>\n\t\t\t<span v-else>{{ optLabel }}</span>\n\t\t</template>\n\t</NcSelect>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcSelect } from '@nextcloud/vue'\nimport Plus from 'vue-material-design-icons/Plus.vue'\nimport { useObjectStore } from '../../store/index.js'\n\n/**\n * CnResourceSelect — an OpenRegister object picker that can CREATE from the\n * search term.\n *\n * Searches a `register` + `schema` for objects matching the typed text and\n * renders them as options. When the typed term matches no existing object, a\n * synthetic **\"Create '<term>'\"** option appears at the bottom; choosing it\n * persists a new object (via `useObjectStore().saveObject`, writing the term to\n * `labelField`) and selects it — so an agent who can't find a client just types\n * the name and makes one inline, never hitting a dead \"no results\" end.\n *\n * Emits `update:modelValue` (the selected object's id) and `create` (the\n * freshly-created object). The label of each option comes from `labelField`\n * (default `name`), the value from the object's id.\n *\n * Backwards-compatible, self-contained: it owns its own search + create flow,\n * so a consumer only needs to pass `register` + `schema` and bind `modelValue`.\n *\n * Three opt-in props cover the cases a plain object picker cannot:\n *\n * - `filters` SCOPES the options to a parent selection, which is what makes a\n * cascading pair work (pick a client, then only that client's contacts are\n * offered). Changing the scope clears a now-invalid selection.\n * - `preload` fetches a first page on mount so the field can be BROWSED, not\n * only searched — the behaviour a user expects from a select.\n * - `createHandler` replaces the built-in save. Creating from a bare term only\n * works while the term is enough to satisfy the schema; the moment a\n * required field must come from somewhere else (a server-minted key, a value\n * worth collecting in a full dialog) the consumer owns the create and\n * resolves the finished object back.\n *\n * Example:\n * ```vue\n * <CnResourceSelect\n * register=\"pipelinq\"\n * schema=\"client\"\n * label-field=\"name\"\n * :model-value=\"clientId\"\n * :input-label=\"t('pipelinq', 'Client')\"\n * @update:modelValue=\"clientId = $event\"\n * @create=\"onClientCreated\" />\n * ```\n */\nexport default {\n\tname: 'CnResourceSelect',\n\n\tcomponents: { NcSelect, Plus },\n\n\tprops: {\n\t\t/** OpenRegister register slug to search/create in. */\n\t\tregister: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** OpenRegister schema slug to search/create in. */\n\t\tschema: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Currently-selected object id (v-model), or an array of ids when `multiple`. */\n\t\tmodelValue: {\n\t\t\ttype: [String, Number, Array],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Pick several objects. `modelValue` is then an array of ids, and a\n\t\t * create adds the new object to the selection.\n\t\t */\n\t\tmultiple: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** Object field used as the option label AND written on create. */\n\t\tlabelField: {\n\t\t\ttype: String,\n\t\t\tdefault: 'name',\n\t\t},\n\n\t\t/** Accessible input label for the underlying NcSelect. */\n\t\tinputLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** DOM id for the input (a11y association). */\n\t\tinputId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Whether the selection can be cleared. */\n\t\tclearable: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t/** Minimum characters before searching / offering create. */\n\t\tminChars: {\n\t\t\ttype: Number,\n\t\t\tdefault: 2,\n\t\t},\n\n\t\t/**\n\t\t * Whether to offer the inline \"Create '<term>'\" option when the search\n\t\t * yields no exact match. Off → behaves like a plain async object select.\n\t\t */\n\t\tallowCreate: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\n\t\t/**\n\t\t * Extra fields merged into the payload when creating a new object (e.g.\n\t\t * a fixed `type` or `status`). The `labelField` is always set to the term.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcreateDefaults: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Field filters merged into the search query, so the option list can be\n\t\t * SCOPED to a parent selection — the cascading-select case (pick a\n\t\t * client, then only that client's contacts are offered). Changing this\n\t\t * reloads the options and clears a selection that no longer belongs to\n\t\t * the new scope.\n\t\t *\n\t\t * Example: `:filters=\"{ client: form.client }\"`.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfilters: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Load a first page of options on mount (and whenever `filters`\n\t\t * change) instead of waiting for `minChars` of typing. Lets the field\n\t\t * be BROWSED like a plain select while still searching server-side once\n\t\t * the user types. Off by default so existing consumers keep their\n\t\t * search-only behaviour and issue no extra request.\n\t\t */\n\t\tpreload: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * Disable the input — e.g. a dependent select waiting on its parent.\n\t\t */\n\t\tdisabled: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** Placeholder text for the underlying NcSelect. */\n\t\tplaceholder: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Override how a new object is created from the typed term. Receives\n\t\t * `(term, payload)` and MUST resolve to the created object (or a falsy\n\t\t * value to abort, e.g. the user cancelled a dialog).\n\t\t *\n\t\t * Without it the component posts `payload` straight to\n\t\t * `objectStore.saveObject`, which is wrong whenever the schema requires\n\t\t * a field the term cannot supply — a server-minted foreign key, say, or\n\t\t * anything the consumer would rather collect in a full create dialog.\n\t\t *\n\t\t * @type {((term: string, payload: object) => Promise<object|null>)|null}\n\t\t */\n\t\tcreateHandler: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: ['update:modelValue', 'create'],\n\n\tdata() {\n\t\treturn {\n\t\t\tsearch: '',\n\t\t\tloading: false,\n\t\t\toptions: [],\n\t\t\t// The selected option object kept locally so the label shows even\n\t\t\t// before/without a matching search result (e.g. a pre-set modelValue).\n\t\t\tlocalSelected: null,\n\t\t\t// Options seen so far, keyed by value, so a multiple selection\n\t\t\t// keeps its labels when the search results move on.\n\t\t\tknown: {},\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** Pinia object store handle (resolved lazily so a Pinia-less test still mounts). */\n\t\tobjectStore() {\n\t\t\ttry {\n\t\t\t\treturn useObjectStore()\n\t\t\t} catch {\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The selected ids as strings (multiple mode).\n\t\t *\n\t\t * @return {string[]}\n\t\t */\n\t\tselectedIds() {\n\t\t\tconst value = this.modelValue\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn value.filter((v) => v !== null && v !== undefined && v !== '').map((v) => String(v))\n\t\t\t}\n\t\t\treturn value ? [String(value)] : []\n\t\t},\n\n\t\t/** The `${register}-${schema}` object-type slug used by the store. */\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\n\t\t/** The currently-selected option, for NcSelect's model-value. */\n\t\tselectedOption() {\n\t\t\tif (this.multiple) {\n\t\t\t\treturn this.selectedIds.map((id) => this.known[id]\n\t\t\t\t\t|| this.options.find((o) => o.value === id)\n\t\t\t\t\t|| { value: id, label: id })\n\t\t\t}\n\t\t\tif (this.localSelected && this.localSelected.value === this.modelValue) {\n\t\t\t\treturn this.localSelected\n\t\t\t}\n\t\t\treturn this.options.find((o) => o.value === this.modelValue) || null\n\t\t},\n\n\t\t/**\n\t\t * The option list shown in the dropdown — the search results, plus a\n\t\t * synthetic \"Create '<term>'\" entry when create is allowed and the term\n\t\t * is long enough and matches no existing option label exactly.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tdisplayOptions() {\n\t\t\tconst opts = [...this.options]\n\t\t\tconst term = this.search.trim()\n\t\t\tif (this.allowCreate && term.length >= this.minChars) {\n\t\t\t\tconst exact = opts.some((o) => (o.label || '').toLowerCase() === term.toLowerCase())\n\t\t\t\tif (!exact) {\n\t\t\t\t\topts.push({ value: '__create__', label: term, __create: true })\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn opts\n\t\t},\n\n\t\t/**\n\t\t * Stable string identity for `filters`. Watching the object itself\n\t\t * would re-fire on every parent re-render (a fresh object literal is a\n\t\t * new identity even when the values are unchanged), reloading options\n\t\t * and clobbering the selection in a loop.\n\t\t *\n\t\t * @return {string}\n\t\t */\n\t\tfiltersKey() {\n\t\t\treturn JSON.stringify(this.filters || {})\n\t\t},\n\n\t\t/**\n\t\t * `filters` with empty entries dropped. A parent that has not been\n\t\t * chosen yet holds `null`, and forwarding `client=` as a query param\n\t\t * asks the API for objects whose client is the empty string — which\n\t\t * matches nothing and reads as \"no results\" rather than \"not scoped\".\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\tactiveFilters() {\n\t\t\tconst out = {}\n\t\t\tfor (const [key, value] of Object.entries(this.filters || {})) {\n\t\t\t\tif (value !== null && value !== undefined && value !== '') {\n\t\t\t\t\tout[key] = value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\t},\n\n\twatch: {\n\t\tmodelValue: {\n\t\t\timmediate: true,\n\t\t\thandler() {\n\t\t\t\tthis.ensureSelectedLoaded()\n\t\t\t},\n\t\t},\n\n\t\tfiltersKey(next, prev) {\n\t\t\tif (next === prev) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The scope moved, so anything already selected may no longer be\n\t\t\t// in it. Drop the stale options + selection, then re-seed.\n\t\t\tthis.options = []\n\t\t\tif (this.selectedIds.length > 0) {\n\t\t\t\tthis.localSelected = null\n\t\t\t\tthis.$emit('update:modelValue', this.multiple ? [] : '')\n\t\t\t}\n\t\t\tif (this.search.trim().length >= this.minChars) {\n\t\t\t\tthis.onSearch(this.search)\n\t\t\t} else {\n\t\t\t\tthis.loadInitialOptions()\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tthis.loadInitialOptions()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Seed the dropdown with a first page of options so the field can be\n\t\t * browsed without typing. No-op unless `preload` is set.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync loadInitialOptions() {\n\t\t\tif (!this.preload || !this.objectStore) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tconst collection = await this.objectStore.fetchCollectionForOptions(this.typeSlug, {\n\t\t\t\t\t...this.activeFilters,\n\t\t\t\t\t_limit: 20,\n\t\t\t\t})\n\t\t\t\tconst items = Array.isArray(collection)\n\t\t\t\t\t? collection\n\t\t\t\t\t: (this.objectStore.collections[this.typeSlug] || [])\n\t\t\t\tthis.options = this.remember(items.map((o) => this.toOption(o)))\n\t\t\t} catch {\n\t\t\t\tthis.options = []\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The translated \"Create 'X'\" label for the synthetic option.\n\t\t *\n\t\t * @param {string} term The typed term.\n\t\t * @return {string}\n\t\t */\n\t\tcreateLabelFor(term) {\n\t\t\treturn t('nextcloud-vue', 'Create \"{term}\"', { term })\n\t\t},\n\n\t\t/**\n\t\t * Run an object search (debounced via NcSelect's own throttling) for the\n\t\t * typed term. Failures degrade to an empty option list.\n\t\t *\n\t\t * @param {string} term The search term from NcSelect.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSearch(term) {\n\t\t\tthis.search = term || ''\n\t\t\tif (!this.objectStore || this.search.trim().length < this.minChars) {\n\t\t\t\t// Below the search threshold: fall back to the browsable first\n\t\t\t\t// page when preloading, rather than blanking the list.\n\t\t\t\tthis.options = []\n\t\t\t\tthis.loadInitialOptions()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tconst collection = await this.objectStore.fetchCollectionForOptions(this.typeSlug, {\n\t\t\t\t\t...this.activeFilters,\n\t\t\t\t\t_search: this.search.trim(),\n\t\t\t\t\t_limit: 20,\n\t\t\t\t})\n\t\t\t\tconst items = Array.isArray(collection)\n\t\t\t\t\t? collection\n\t\t\t\t\t: (this.objectStore.collections[this.typeSlug] || [])\n\t\t\t\tthis.options = this.remember(items.map((o) => this.toOption(o)))\n\t\t\t} catch {\n\t\t\t\tthis.options = []\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Handle a selection. A real option emits its id; the synthetic create\n\t\t * option triggers object creation.\n\t\t *\n\t\t * @param {object|null} option The chosen option (or null on clear).\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onInput(option) {\n\t\t\tif (this.multiple) {\n\t\t\t\tawait this.onMultipleInput(Array.isArray(option) ? option : (option ? [option] : []))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!option) {\n\t\t\t\tthis.localSelected = null\n\t\t\t\t/**\n\t\t\t\t * @event update:modelValue The selected (or newly-created) object id, or '' when cleared.\n\t\t\t\t * @type {string}\n\t\t\t\t */\n\t\t\t\tthis.$emit('update:modelValue', '')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (option.__create) {\n\t\t\t\tawait this.createFromTerm(option.label)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.localSelected = option\n\t\t\tthis.$emit('update:modelValue', option.value)\n\t\t},\n\n\t\t/**\n\t\t * Handle a change of a multiple selection. A synthetic create option\n\t\t * creates the object and adds it; the rest emit their ids.\n\t\t *\n\t\t * @param {Array<object>} chosen The selected options.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onMultipleInput(chosen) {\n\t\t\tconst createOption = chosen.find((o) => o && o.__create)\n\t\t\tconst ids = chosen.filter((o) => o && !o.__create).map((o) => String(o.value))\n\t\t\tthis.remember(chosen.filter((o) => o && !o.__create))\n\t\t\tif (!createOption) {\n\t\t\t\tthis.$emit('update:modelValue', ids)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst created = await this.createFromTerm(createOption.label, ids)\n\t\t\tif (!created) {\n\t\t\t\tthis.$emit('update:modelValue', ids)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Cache options by value so their labels survive a new search.\n\t\t *\n\t\t * @param {Array<object>} options Options to remember.\n\t\t * @return {Array<object>} The same options.\n\t\t */\n\t\tremember(options) {\n\t\t\tconst next = { ...this.known }\n\t\t\tfor (const o of options) {\n\t\t\t\tif (o && o.value) {\n\t\t\t\t\tnext[o.value] = o\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.known = next\n\t\t\treturn options\n\t\t},\n\n\t\t/**\n\t\t * Create a new object from the typed term and select it.\n\t\t *\n\t\t * @param {string} term The term to write to `labelField`.\n\t\t * @param {string[]} [keep] Multiple mode: the ids already selected, which the new id joins.\n\t\t * @return {Promise<object|null>} The created object, or null.\n\t\t */\n\t\tasync createFromTerm(term, keep = []) {\n\t\t\tif (!this.objectStore && !this.createHandler) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst name = (term || '').trim()\n\t\t\tif (!name) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\t// The active scope is part of the new object's identity: a\n\t\t\t\t// contact created while the list is filtered to one client\n\t\t\t\t// belongs to that client. An explicit createDefaults entry\n\t\t\t\t// still wins.\n\t\t\t\tconst payload = { ...this.activeFilters, ...this.createDefaults, [this.labelField]: name }\n\t\t\t\tlet created\n\t\t\t\tif (this.createHandler) {\n\t\t\t\t\t// A falsy resolve means the consumer aborted (cancelled\n\t\t\t\t\t// dialog) — leave the selection untouched.\n\t\t\t\t\tcreated = await this.createHandler(name, payload)\n\t\t\t\t} else {\n\t\t\t\t\tthis.ensureRegistered()\n\t\t\t\t\tcreated = await this.objectStore.saveObject(this.typeSlug, payload)\n\t\t\t\t}\n\t\t\t\tif (!created) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\tconst option = this.toOption(created)\n\t\t\t\tthis.remember([option])\n\t\t\t\tthis.options = [option, ...this.options.filter((o) => o.value !== option.value)]\n\t\t\t\tthis.localSelected = option\n\t\t\t\tthis.search = ''\n\t\t\t\tthis.$emit('update:modelValue', this.multiple\n\t\t\t\t\t? [...keep.filter((id) => id !== option.value), option.value]\n\t\t\t\t\t: option.value)\n\t\t\t\t/**\n\t\t\t\t * @event create A new object was created from the search term.\n\t\t\t\t * @type {object} The created OpenRegister object.\n\t\t\t\t */\n\t\t\t\tthis.$emit('create', created)\n\t\t\t\treturn created\n\t\t\t} catch (e) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn('[CnResourceSelect] create failed', e)\n\t\t\t\treturn null\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Map an OpenRegister object to an option `{ value, label }`.\n\t\t *\n\t\t * @param {object} obj The object.\n\t\t * @return {{value: string, label: string}}\n\t\t */\n\t\ttoOption(obj) {\n\t\t\tconst id = String(obj.id || (obj['@self'] && obj['@self'].id) || '')\n\t\t\tconst label = obj[this.labelField] || obj.name || obj.title || id\n\t\t\treturn { value: id, label }\n\t\t},\n\n\t\t/**\n\t\t * Register the object type with the store (idempotent) so search/create\n\t\t * route to the right register+schema.\n\t\t */\n\t\tensureRegistered() {\n\t\t\tif (this.objectStore && typeof this.objectStore.registerObjectType === 'function') {\n\t\t\t\ttry {\n\t\t\t\t\tthis.objectStore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t} catch {\n\t\t\t\t\t// Already registered or store not ready — non-fatal.\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * When a `modelValue` is set but no matching option is loaded, fetch the\n\t\t * single object so its label renders (e.g. a pre-filled client id).\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync ensureSelectedLoaded() {\n\t\t\tif (this.multiple) {\n\t\t\t\tawait this.ensureManyLoaded()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!this.modelValue || this.selectedOption || !this.objectStore) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tthis.ensureRegistered()\n\t\t\t\tif (typeof this.objectStore.fetchObject !== 'function') {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst obj = await this.objectStore.fetchObject(this.typeSlug, String(this.modelValue))\n\t\t\t\tif (obj) {\n\t\t\t\t\tthis.localSelected = this.toOption(obj)\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Leave the id un-labelled rather than crash.\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Multiple mode: fetch each selected id whose label is not known yet.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync ensureManyLoaded() {\n\t\t\tif (!this.objectStore || typeof this.objectStore.fetchObject !== 'function') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst missing = this.selectedIds.filter((id) => !this.known[id] && !this.options.some((o) => o.value === id))\n\t\t\tif (missing.length === 0) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.ensureRegistered()\n\t\t\tfor (const id of missing) {\n\t\t\t\ttry {\n\t\t\t\t\tconst obj = await this.objectStore.fetchObject(this.typeSlug, id)\n\t\t\t\t\tif (obj) {\n\t\t\t\t\t\tthis.remember([this.toOption(obj)])\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Leave the id un-labelled rather than crash.\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-resource-select__create {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n}\n</style>\n"],"names":["_withCtx","_openBlock","_createElementBlock","_createVNode","_toDisplayString"],"mappings":";;;;AAyByB,EAAA,KAAK,EAAC,4BAAK;;;;;;;;;AAfjC,IAAA,OAAO,EAAE,MAAO,CAAA,OAAA;AAChB,IAAA,UAAU,EAAE,MAAQ,CAAA,UAAA;AACpB,IAAA,UAAU,EAAE,QAAM,CAAA,cAAA;AAClB,IAAA,OAAO,EAAE,QAAc,CAAA,cAAA;AACvB,IAAA,OAAO,EAAE,KAAO,CAAA,OAAA;AAChB,IAAA,SAAS,EAAE,MAAO,CAAA,SAAA;AAClB,IAAA,QAAQ,EAAE,MAAQ,CAAA,QAAA;AAClB,IAAA,WAAW,EAAA,MAAA,CAAA,WAAA;AACX,IAAA,UAAU,EAAE,KAAI;AAChB,IAAA,QAAQ,EAAE,MAAQ,CAAA,QAAA;AAClB,IAAA,QAAS,EAAC,MAAQ,CAAA,QAAA;SACd,EAAE,OAAM;AACX,IAAA,QAAI,EAAG,QAAQ,CAAA,QAAA;yBACC,EAAE,QAAO,CAAA,OAAA;;AACpB,IAAA,MAAA,EACNA,OAAA,CAAA,GADM,KAAA,EAAA,QAAA,EAAA,QAAA,EAAA,KAAA;MACM,QAAQ;AAApB,WAAAC,SAAA,EAAA,EAAAC,kBAAA,SAAA;YACCC,WAAQ,CAAA,eAAA,EAAA,EAAD,IAAC,EAAA,EAAA,EAAA,CAAA;4BAAA,GACR,GAAAC,eAAA,CAAG,QAAI,CAAA,cAAA,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;;;;;;;"}
@@ -1,10 +1,20 @@
1
+ import { getCurrentUser } from '@nextcloud/auth';
2
+ import { loadState } from '@nextcloud/initial-state';
1
3
  import { translate } from '@nextcloud/l10n';
2
4
  import { NcButton, NcNoteCard, NcSelect, NcTextField, NcCheckboxRadioSwitch, NcLoadingIcon } from '@nextcloud/vue';
3
5
  import __sfc_main$1 from '../CnChoiceCards/CnChoiceCards.vue.js';
6
+ import __sfc_main$2 from '../CnLeafDependencySettings/CnLeafDependencySettings.vue.js';
4
7
  import __sfc_main from '../CnWizardDialog/CnWizardDialog.vue.js';
8
+ import { checkDependencies, isDependencyResolved } from '../../composables/useDependencyCheck.js';
5
9
  import { useSetupStatus } from '../../composables/useSetupStatus.js';
6
10
  import { fieldsFromSchema } from '../../utils/schema.js';
7
11
 
12
+ /** Id of the synthetic step shown while a required app is missing. */
13
+ const DEPENDENCY_STEP_ID = 'cn-setup-dependencies';
14
+
15
+ /** The dataset value that means "seed nothing"; it never gets a Load button. */
16
+ const NONE_DATASET = 'none';
17
+
8
18
  /**
9
19
  * CnSetupWizard — abstract, manifest-driven first-time setup wizard (ADR-042).
10
20
  *
@@ -34,6 +44,7 @@ var script = {
34
44
  components: {
35
45
  CnWizardDialog: __sfc_main,
36
46
  CnChoiceCards: __sfc_main$1,
47
+ CnLeafDependencySettings: __sfc_main$2,
37
48
  NcButton,
38
49
  NcNoteCard,
39
50
  NcSelect,
@@ -52,6 +63,11 @@ var script = {
52
63
  * standalone (no CnAppRoot ancestor).
53
64
  */
54
65
  cnTranslate: { default: () => (key) => key },
66
+ /**
67
+ * The app manifest, provided by CnAppRoot. Read only for its
68
+ * `dependencies` when the `dependencies` prop is empty.
69
+ */
70
+ cnManifest: { default: null },
55
71
  },
56
72
 
57
73
  props: {
@@ -161,6 +177,33 @@ var script = {
161
177
  type: Array,
162
178
  default: () => [],
163
179
  },
180
+
181
+ /**
182
+ * The app's dependencies, in the manifest's own shape (app-id strings
183
+ * or `{ id, name?, required? }`). Falls back to the injected manifest's
184
+ * `dependencies`. A missing REQUIRED one replaces every step with the
185
+ * dependency list and disables Next; a missing optional one is listed
186
+ * on the first step and does not block.
187
+ *
188
+ * @type {Array<string|object>}
189
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
190
+ */
191
+ dependencies: {
192
+ type: Array,
193
+ default: () => [],
194
+ },
195
+
196
+ /** Load button label on a dataset card (`loadAction`). */
197
+ loadLabel: {
198
+ type: String,
199
+ default: () => translate('nextcloud-vue', 'Load'),
200
+ },
201
+
202
+ /** Load button label once that dataset loaded in this session. */
203
+ reloadLabel: {
204
+ type: String,
205
+ default: () => translate('nextcloud-vue', 'Load again'),
206
+ },
164
207
  },
165
208
 
166
209
  emits: ['complete', 'close', 'step-change', 'action-result'],
@@ -196,6 +239,9 @@ var script = {
196
239
  actionResult: {},
197
240
  localDone: {},
198
241
  userTouched: {},
242
+ // Per-card load state for `loadAction` steps, keyed by `loadKey()`.
243
+ datasetRunning: {},
244
+ datasetResult: {},
199
245
  }
200
246
  },
201
247
 
@@ -213,11 +259,150 @@ var script = {
213
259
  : this.dialogTitle
214
260
  },
215
261
 
216
- setupSteps() {
262
+ /**
263
+ * Every well-formed step, before `requires` is applied.
264
+ *
265
+ * @return {Array<object>}
266
+ */
267
+ declaredSteps() {
217
268
  return (this.steps || []).filter((s) => s && s.id && s.type)
218
269
  },
219
270
 
271
+ /**
272
+ * Steps that declare `requires` on an app that is not installed and
273
+ * enabled. They are not offered; the summary names them as skipped.
274
+ *
275
+ * @return {Array<{ step: object, missing: Array<string> }>}
276
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
277
+ */
278
+ skippedSteps() {
279
+ return this.declaredSteps
280
+ .filter((s) => Array.isArray(s.requires) && s.requires.length > 0)
281
+ .map((step) => {
282
+ const known = Object.fromEntries(this.dependencyRows.map((d) => [d.id, d]));
283
+ const missing = checkDependencies(step.requires, this.serverAppStatuses)
284
+ .map((row) => known[row.id] || row)
285
+ .filter((row) => !isDependencyResolved(row))
286
+ .map((row) => row.name || row.id);
287
+ return { step, missing }
288
+ })
289
+ .filter((entry) => entry.missing.length > 0)
290
+ },
291
+
292
+ setupSteps() {
293
+ const skipped = new Set(this.skippedSteps.map((entry) => entry.step.id));
294
+ return this.declaredSteps.filter((s) => !skipped.has(s.id))
295
+ },
296
+
297
+ /**
298
+ * Id of the first offered step: where the optional-apps note shows.
299
+ *
300
+ * @return {string}
301
+ */
302
+ firstStepId() {
303
+ return this.setupSteps.length > 0 ? this.setupSteps[0].id : ''
304
+ },
305
+
306
+ /**
307
+ * The dependency declarations to check: the prop, else the manifest's.
308
+ *
309
+ * @return {Array<string|object>}
310
+ */
311
+ dependencyEntries() {
312
+ if (Array.isArray(this.dependencies) && this.dependencies.length > 0) {
313
+ return this.dependencies
314
+ }
315
+ const fromManifest = this.cnManifest && this.cnManifest.dependencies;
316
+ return Array.isArray(fromManifest) ? fromManifest : []
317
+ },
318
+
319
+ /**
320
+ * The `dependency_statuses` initial state an app may inject from PHP.
321
+ * Same source CnAppRoot reads; `{}` when the app injects none.
322
+ *
323
+ * @return {object}
324
+ */
325
+ serverAppStatuses() {
326
+ try {
327
+ return loadState(this.appId, 'dependency_statuses', {}) || {}
328
+ } catch {
329
+ return {}
330
+ }
331
+ },
332
+
333
+ /**
334
+ * The declared dependencies with their live status.
335
+ *
336
+ * @return {Array<object>}
337
+ */
338
+ dependencyRows() {
339
+ return checkDependencies(this.dependencyEntries, this.serverAppStatuses)
340
+ },
341
+
342
+ /** @return {Array<object>} Required dependencies that are missing or disabled. */
343
+ missingRequired() {
344
+ return this.dependencyRows.filter((d) => d.required && !isDependencyResolved(d))
345
+ },
346
+
347
+ /** @return {Array<object>} Optional dependencies that are missing or disabled. */
348
+ missingOptional() {
349
+ return this.dependencyRows.filter((d) => !d.required && !isDependencyResolved(d))
350
+ },
351
+
352
+ /**
353
+ * Whether a required app is missing, so the wizard shows the
354
+ * dependency list instead of its steps and refuses to continue.
355
+ *
356
+ * @return {boolean}
357
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-the-wizard-checks-dependencies-before-any-step
358
+ */
359
+ dependencyBlocked() {
360
+ return this.missingRequired.length > 0
361
+ },
362
+
363
+ dependencyStepSlot() {
364
+ return 'step-' + DEPENDENCY_STEP_ID
365
+ },
366
+
367
+ dependencySectionName() {
368
+ return translate('nextcloud-vue', 'Apps this app needs')
369
+ },
370
+
371
+ dependencyBlockedText() {
372
+ return translate('nextcloud-vue', 'Setup can start once these apps are installed and enabled: {apps}.', {
373
+ apps: this.missingRequired.map((d) => d.name).join(', '),
374
+ })
375
+ },
376
+
377
+ optionalMissingText() {
378
+ return translate('nextcloud-vue', 'Optional, not installed: {apps}. You can add them later.', {
379
+ apps: this.missingOptional.map((d) => d.name).join(', '),
380
+ })
381
+ },
382
+
383
+ /**
384
+ * Whether the current user is a Nextcloud admin; only admins get the
385
+ * install and enable buttons.
386
+ *
387
+ * @return {boolean}
388
+ */
389
+ isAdmin() {
390
+ try {
391
+ const user = getCurrentUser();
392
+ return !!(user && user.isAdmin)
393
+ } catch {
394
+ return false
395
+ }
396
+ },
397
+
220
398
  wizardSteps() {
399
+ if (this.dependencyBlocked) {
400
+ return [{
401
+ id: DEPENDENCY_STEP_ID,
402
+ label: translate('nextcloud-vue', 'Required apps'),
403
+ optional: false,
404
+ }]
405
+ }
221
406
  return this.setupSteps.map((s) => ({
222
407
  id: s.id,
223
408
  label: this.stepTitle(s),
@@ -241,6 +426,15 @@ var script = {
241
426
  * @return {Array<{ id: string, title: string, value: string, done: boolean, notRun: boolean }>}
242
427
  */
243
428
  summaryItems() {
429
+ const skipped = this.skippedSteps
430
+ .filter((entry) => entry.step.type !== 'summary' && entry.step.type !== 'info')
431
+ .map((entry) => ({
432
+ id: entry.step.id,
433
+ title: this.stepTitle(entry.step),
434
+ value: translate('nextcloud-vue', 'Skipped, needs {apps}', { apps: entry.missing.join(', ') }),
435
+ done: false,
436
+ notRun: true,
437
+ }));
244
438
  return this.setupSteps
245
439
  .filter((s) => s.type !== 'summary')
246
440
  .map((step) => {
@@ -277,6 +471,7 @@ var script = {
277
471
  }
278
472
  return { id: step.id, title: this.stepTitle(step), value, done, notRun: false }
279
473
  })
474
+ .concat(skipped)
280
475
  },
281
476
 
282
477
  /**
@@ -337,6 +532,11 @@ var script = {
337
532
  * @return {void}
338
533
  */
339
534
  maybeAutoRunStep(stepId) {
535
+ // Nothing runs while a required app is missing: every action
536
+ // would fail with an error that does not name the app.
537
+ if (this.dependencyBlocked) {
538
+ return
539
+ }
340
540
  const step = this.setupSteps.find((s) => s.id === stepId);
341
541
  if (step && step.type === 'run-action' && !this.isOnDemand(step) && !this.isStepDone(step.id) && !this.running[step.id]) {
342
542
  this.runAction(step);
@@ -719,6 +919,131 @@ var script = {
719
919
  }
720
920
  },
721
921
 
922
+ /**
923
+ * Key for one card's load state.
924
+ *
925
+ * @param {object} step The choice step.
926
+ * @param {object} option The card's option.
927
+ * @return {string}
928
+ */
929
+ loadKey(step, option) {
930
+ return step.id + '::' + String(option && option.value)
931
+ },
932
+
933
+ /**
934
+ * Whether a card gets a Load button: the step declares `loadAction`
935
+ * and the option is not the "seed nothing" answer.
936
+ *
937
+ * @param {object} step The choice step.
938
+ * @param {object} option The card's option.
939
+ * @return {boolean}
940
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-a-dataset-card-loads-itself
941
+ */
942
+ isLoadableOption(step, option) {
943
+ return !!(step && step.loadAction) && !!option && String(option.value) !== NONE_DATASET
944
+ },
945
+
946
+ isDatasetLoading(step, option) {
947
+ return this.datasetRunning[this.loadKey(step, option)] === true
948
+ },
949
+
950
+ datasetResultFor(step, option) {
951
+ return this.datasetResult[this.loadKey(step, option)] || null
952
+ },
953
+
954
+ loadButtonLabel(step, option) {
955
+ if (this.isDatasetLoading(step, option)) {
956
+ return this.runningLabel
957
+ }
958
+ const result = this.datasetResultFor(step, option);
959
+ return (result && result.success) ? this.reloadLabel : this.loadLabel
960
+ },
961
+
962
+ loadAriaLabel(option) {
963
+ return translate('nextcloud-vue', 'Load {name}', { name: option.label })
964
+ },
965
+
966
+ /**
967
+ * Load one dataset from its card: POST `{ dataset }` to the step's
968
+ * `loadAction`, spinner on the button while it runs, the result on the
969
+ * card after. A successful load also selects the card, so the summary
970
+ * and the stored choice name what was loaded.
971
+ *
972
+ * @param {object} step The choice step declaring `loadAction`.
973
+ * @param {object} option The card's option.
974
+ * @return {Promise<void>}
975
+ * @spec openspec/changes/setup-wizard-card-load-and-dependency-gate/specs/cn-setup-wizard/spec.md#requirement-a-dataset-card-loads-itself
976
+ */
977
+ async loadDataset(step, option) {
978
+ if (!this.isLoadableOption(step, option) || this.isDatasetLoading(step, option)) {
979
+ return
980
+ }
981
+ const key = this.loadKey(step, option);
982
+ this.datasetRunning[key] = true;
983
+ this.datasetResult[key] = null;
984
+ let result;
985
+ try {
986
+ const [{ default: axios }, { generateUrl }] = await Promise.all([
987
+ import('@nextcloud/axios'),
988
+ import('@nextcloud/router'),
989
+ ]);
990
+ const { data } = await axios.post(
991
+ generateUrl(`/apps/${this.appId}/api/setup/action/${step.loadAction}`),
992
+ { dataset: option.value },
993
+ );
994
+ result = {
995
+ success: !!data && data.success !== false,
996
+ message: (data && data.message) || translate('nextcloud-vue', 'Loaded.'),
997
+ };
998
+ } catch (err) {
999
+ result = { success: false, message: this.errorMessage(err) };
1000
+ } finally {
1001
+ this.datasetRunning[key] = false;
1002
+ }
1003
+ this.datasetResult[key] = result;
1004
+ if (result.success) {
1005
+ this.selectLoadedOption(step, option);
1006
+ this.localDone[step.id] = true;
1007
+ }
1008
+ this.$emit('action-result', {
1009
+ stepId: step.id,
1010
+ action: step.loadAction,
1011
+ dataset: option.value,
1012
+ ...result,
1013
+ });
1014
+ },
1015
+
1016
+ /**
1017
+ * Select a card that just loaded, adding to (never replacing) the
1018
+ * selection of a `multiple` step.
1019
+ *
1020
+ * @param {object} step The choice step.
1021
+ * @param {object} option The loaded option.
1022
+ * @return {void}
1023
+ */
1024
+ selectLoadedOption(step, option) {
1025
+ if (step.multiple === true) {
1026
+ const current = this.cardModel(step);
1027
+ if (current.some((v) => String(v) === String(option.value))) {
1028
+ return
1029
+ }
1030
+ this.onChoice(step, current.concat([option.value]));
1031
+ return
1032
+ }
1033
+ this.onChoice(step, option.value);
1034
+ },
1035
+
1036
+ /**
1037
+ * A required app was installed from the dependency list. A new app's
1038
+ * scripts and its `OC.appswebroots` entry exist only after a full page
1039
+ * load, and `useAppStatus` caches per page, so reload.
1040
+ *
1041
+ * @return {void}
1042
+ */
1043
+ onDependencyInstalled() {
1044
+ window.location.reload();
1045
+ },
1046
+
722
1047
  /**
723
1048
  * Whether a step is marked on-demand (`onDemand: true`): it runs only
724
1049
  * when the user asks, never automatically, and the summary ticks it