@conduction/nextcloud-vue 2.99.0 → 2.100.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 (79) hide show
  1. package/dist/esm/components/CnAdminSettingsShell/CnAdminSettingsShell.vue.js +1 -1
  2. package/dist/esm/components/CnAdminSettingsShell/CnAdminSettingsShell.vue2.js +6 -1
  3. package/dist/esm/components/CnAdminSettingsShell/CnAdminSettingsShell.vue2.js.map +1 -1
  4. package/dist/esm/components/CnAdminSettingsShell/CnAdminSettingsShell.vue3.js +2 -1
  5. package/dist/esm/components/CnAdminSettingsShell/CnAdminSettingsShell.vue3.js.map +1 -1
  6. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +25 -8
  7. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  8. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +5 -3
  9. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  10. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue.js +1 -1
  11. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js +11 -8
  12. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  13. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js +13 -4
  14. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  15. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
  16. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +54 -3
  17. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
  18. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js +16 -2
  19. package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
  20. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
  21. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +42 -7
  22. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
  23. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +121 -57
  24. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
  25. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +10 -0
  26. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
  27. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +2 -1
  28. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
  29. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +136 -7
  30. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  31. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  32. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  33. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +68 -7
  34. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  35. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +256 -240
  36. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  37. package/dist/esm/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue.js +1 -1
  38. package/dist/esm/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue2.js +38 -9
  39. package/dist/esm/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue2.js.map +1 -1
  40. package/dist/esm/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue3.js.map +1 -1
  41. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue.js +1 -1
  42. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js +16 -2
  43. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js.map +1 -1
  44. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js +40 -25
  45. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js.map +1 -1
  46. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue.js +1 -1
  47. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js +7 -7
  48. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js.map +1 -1
  49. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js.map +1 -1
  50. package/dist/esm/l10n/en.json.js +7 -1
  51. package/dist/esm/l10n/en.json.js.map +1 -1
  52. package/dist/esm/l10n/nl.json.js +7 -1
  53. package/dist/esm/l10n/nl.json.js.map +1 -1
  54. package/dist/esm/library-style.js +1 -1
  55. package/dist/esm/nextcloud-vue.css +348 -161
  56. package/dist/esm/utils/validateManifestV2.compiled.js +3 -3
  57. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  58. package/dist/nextcloud-vue.cjs.js +1482 -998
  59. package/dist/nextcloud-vue.cjs.js.map +2 -2
  60. package/dist/nextcloud-vue.css +348 -161
  61. package/l10n/en.json +7 -1
  62. package/l10n/nl.json +7 -1
  63. package/package.json +1 -1
  64. package/src/components/CnAdminSettingsShell/CnAdminSettingsShell.vue +7 -1
  65. package/src/components/CnDetailPage/CnDetailPage.vue +28 -9
  66. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +13 -4
  67. package/src/components/CnFactsWidget/CnFactsWidget.vue +65 -3
  68. package/src/components/CnFlowsPage/CnFlowBoard.vue +77 -2
  69. package/src/components/CnFlowsPage/CnFlowEditorPage.vue +11 -0
  70. package/src/components/CnIndexPage/CnIndexPage.vue +136 -7
  71. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +114 -7
  72. package/src/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue +38 -9
  73. package/src/components/CnSetupWizard/CnSetupWizard.vue +37 -3
  74. package/src/components/CnWizardDialog/CnWizardDialog.vue +7 -7
  75. package/src/css/detail-page.css +15 -0
  76. package/src/css/dialog.css +48 -0
  77. package/src/css/look-board.css +83 -1
  78. package/src/schemas/app-manifest-v2.schema.json +25 -1
  79. package/src/utils/validateManifestV2.compiled.js +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"CnSettingsFieldsSection.vue2.js","sources":["../../../../src/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<CnSettingsSection\n\t\t:name=\"name\"\n\t\t:description=\"description\"\n\t\t:docUrl=\"docUrl\"\n\t\t:wide=\"wide\"\n\t\t:loading=\"loading\"\n\t\t:error=\"loadError !== ''\"\n\t\t:errorMessage=\"loadError\"\n\t\t:onRetry=\"load\"\n\t\tdata-testid=\"cn-settings-fields-section\">\n\t\t<form v-if=\"!loading && loadError === ''\"\n\t\t\tclass=\"cn-settings-fields\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"save\">\n\t\t\t<div class=\"cn-settings-fields__grid\" :class=\"`cn-settings-fields__grid--${columnCount}`\">\n\t\t\t\t<CnSettingsField\n\t\t\t\t\tv-for=\"field in resolvedFields\"\n\t\t\t\t\t:key=\"field.key\"\n\t\t\t\t\tclass=\"cn-settings-fields__field\"\n\t\t\t\t\t:class=\"{ 'cn-settings-fields__field--wide': field.wide }\"\n\t\t\t\t\t:field=\"field\"\n\t\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t\t:error=\"errors[field.key] || unreadable[field.key] || ''\"\n\t\t\t\t\t:hint=\"field.hint\"\n\t\t\t\t\t@update:modelValue=\"setValue(field, $event)\"\n\t\t\t\t\t@uploaded=\"onUploaded(field, $event)\" />\n\t\t\t</div>\n\n\t\t\t<NcNoteCard v-if=\"notice\"\n\t\t\t\t:type=\"notice.type\"\n\t\t\t\t:role=\"notice.type === 'error' ? 'alert' : 'status'\"\n\t\t\t\tdata-testid=\"cn-settings-fields-notice\">\n\t\t\t\t{{ notice.text }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<div class=\"cn-settings-section__save cn-settings-fields__save\">\n\t\t\t\t<span v-if=\"dirty\" class=\"cn-settings-fields__dirty\" data-testid=\"cn-settings-fields-dirty\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Unsaved changes') }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving || !dirty\"\n\t\t\t\t\tdata-testid=\"cn-settings-fields-save\">\n\t\t\t\t\t<template v-if=\"saving\" #icon>\n\t\t\t\t\t\t<NcLoadingIcon :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ resolvedSaveLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</form>\n\t</CnSettingsSection>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'\nimport { prefixUrl } from '../../utils/headers.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { serverErrorMessage } from '../../utils/serverErrorMessage.js'\nimport { CnSettingsField } from '../CnSettingsField/index.js'\nimport { CnSettingsSection } from '../CnSettingsSection/index.js'\n\n/**\n * Up to two initials of a name, for an image field without an image.\n *\n * @param {unknown} name The name.\n * @return {string}\n */\nfunction initialsOf(name) {\n\treturn String(name || '').trim().split(/\\s+/).filter(Boolean).slice(0, 2).map((word) => word[0].toUpperCase()).join('')\n}\n\n/**\n * CnSettingsFieldsSection - a settings section declared as fields: it reads\n * the app's settings, draws the fields in one to three columns, and saves\n * them with ONE Save button for the section.\n *\n * It reads `GET url` (default `/apps/<appId>/api/settings`) and writes the\n * section's fields with `PUT saveUrl` (default the same url). The Save button\n * is on while something changed (\"Unsaved changes\"); a save checks the\n * fields first (required, pattern, min, max) and marks each failing field,\n * then says it saved or why it did not. A `secret` field never shows the\n * stored value: it says a value is stored, and is sent only when something\n * was typed.\n *\n * It renders inside CnAdminSettingsShell and CnSettingsPage, in the default\n * and the board look.\n *\n * ```vue\n * <CnSettingsFieldsSection\n * app-id=\"myapp\"\n * name=\"Connection\"\n * :columns=\"2\"\n * :fields=\"[\n * { key: 'baseUrl', label: 'Server address', required: true, pattern: '^https://', patternMessage: 'Starts with https://' },\n * { key: 'apiKey', label: 'API key', type: 'secret' },\n * { key: 'mode', label: 'Mode', type: 'select', options: [{ value: 'live', label: 'Live' }, { value: 'test', label: 'Test' }] },\n * { key: 'enabled', label: 'Enabled', type: 'switch', hint: 'Off stops every call.' },\n * ]\" />\n * ```\n */\nexport default {\n\tname: 'CnSettingsFieldsSection',\n\n\tcomponents: { CnSettingsField, CnSettingsSection, NcButton, NcLoadingIcon, NcNoteCard },\n\n\tinject: {\n\t\t/** The app's translate function; identity outside CnAppRoot. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/** The section title. */\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** The line under the title. */\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A documentation link beside the title. */\n\t\tdocUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Span the whole settings grid in the board look. */\n\t\twide: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The fields: `[{ key, label, type?, hint?, placeholder?, required?,\n\t\t * pattern?, patternMessage?, min?, max?, rows?, options?, optionsUrl?,\n\t\t * optionsPath?, optionLabel?, optionValue?, default?, readOnly?, wide?,\n\t\t * url?, valuePath?, saveUrl?, saveMethod?, saveKey?, uploadUrl?,\n\t\t * uploadField?, uploadParams?, uploadValuePath?, initials?, initialsFrom? }]`.\n\t\t * `type` is `text` (default), `textarea`, `number`, `switch`, `select`,\n\t\t * `secret` or `image`. `key` names the setting; a dotted key reads a\n\t\t * nested value and is written as written. A field with its own `url`\n\t\t * is read there (at `valuePath`, default its key) and saved to its\n\t\t * `saveUrl` (default that `url`) with `saveMethod` (default POST) under\n\t\t * `saveKey` (default its key), so one section can hold the settings of\n\t\t * several apps. An `image` uploads at once to `uploadUrl`. Labels,\n\t\t * hints, placeholders and messages go through the app's translate\n\t\t * function.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-section-declared-as-fields-reads-and-saves-the-apps-settings\n\t\t */\n\t\tfields: {\n\t\t\ttype: Array,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Columns of the field grid: 1, 2 or 3. A narrow card stacks them. */\n\t\tcolumns: {\n\t\t\ttype: Number,\n\t\t\tdefault: 1,\n\t\t\tvalidator: (value) => [1, 2, 3].includes(value),\n\t\t},\n\n\t\t/** The app id, for the default url `/apps/<appId>/api/settings`. */\n\t\tappId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the settings are read (`GET`); app-absolute or a full URL. */\n\t\turl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the section saves; defaults to `url`. */\n\t\tsaveUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The method of the save request. */\n\t\tsaveMethod: {\n\t\t\ttype: String,\n\t\t\tdefault: 'PUT',\n\t\t\tvalidator: (value) => ['PUT', 'POST', 'PATCH'].includes(String(value).toUpperCase()),\n\t\t},\n\n\t\t/** A dotted path to the values in the GET answer; empty reads the answer itself. */\n\t\tvaluesPath: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The Save button's label. Defaults to \"Save\". */\n\t\tsaveLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['saved', 'save-error'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\tbaseline: {},\n\t\t\tstoredSecrets: {},\n\t\t\t// Field key to the message of a read target that failed.\n\t\t\tunreadable: {},\n\t\t\terrors: {},\n\t\t\tloading: true,\n\t\t\tloadError: '',\n\t\t\tsaving: false,\n\t\t\tnotice: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {number} The column count, 1 to 3. */\n\t\tcolumnCount() {\n\t\t\treturn [1, 2, 3].includes(this.columns) ? this.columns : 1\n\t\t},\n\n\t\t/** @return {string} Where the settings are read: `url`, else the app's settings endpoint. */\n\t\treadTarget() {\n\t\t\treturn this.url || (this.appId ? `/apps/${this.appId}/api/settings` : '')\n\t\t},\n\n\t\t/** @return {string} Where the section saves: `saveUrl`, else the read target. */\n\t\twriteTarget() {\n\t\t\treturn this.saveUrl || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * The declared fields with their text translated and a secret's stored state.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tresolvedFields() {\n\t\t\treturn (Array.isArray(this.fields) ? this.fields : [])\n\t\t\t\t.filter((field) => field && typeof field.key === 'string' && field.key !== '')\n\t\t\t\t.map((field) => ({\n\t\t\t\t\t...field,\n\t\t\t\t\tlabel: this.tr(field.label || field.key),\n\t\t\t\t\thint: this.tr(field.hint || ''),\n\t\t\t\t\tplaceholder: this.tr(field.placeholder || ''),\n\t\t\t\t\tsecretSet: field.type === 'secret' ? !!this.storedSecrets[field.key] : undefined,\n\t\t\t\t\tinitials: field.type === 'image' ? initialsOf(field.initialsFrom ? this.form[field.initialsFrom] : field.initials) : undefined,\n\t\t\t\t\treadOnly: field.readOnly || !!this.unreadable[field.key],\n\t\t\t\t}))\n\t\t},\n\n\t\t/**\n\t\t * Whether something changed since the last load or save.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tdirty() {\n\t\t\treturn this.resolvedFields.some((field) => field.type !== 'image' && !this.same(this.form[field.key], this.baseline[field.key]))\n\t\t},\n\n\t\t/** @return {string} The Save button's label. */\n\t\tresolvedSaveLabel() {\n\t\t\treturn this.saveLabel ? this.tr(this.saveLabel) : t('nextcloud-vue', 'Save')\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.load()\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * @param {string} value A declared string.\n\t\t * @return {string} It through the app's translate function.\n\t\t */\n\t\ttr(value) {\n\t\t\treturn typeof value === 'string' && value !== '' ? this.cnTranslate(value) : (value || '')\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} a A value.\n\t\t * @param {unknown} b Another.\n\t\t * @return {boolean} Whether they count as the same setting.\n\t\t */\n\t\tsame(a, b) {\n\t\t\tconst empty = (v) => v === null || v === undefined || v === ''\n\t\t\tif (empty(a) && empty(b)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t},\n\n\t\t/**\n\t\t * Change a field's value; its error goes until the next save.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {unknown} value The value.\n\t\t * @return {void}\n\t\t */\n\t\tsetValue(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tif (this.errors[field.key]) {\n\t\t\t\tconst { [field.key]: _gone, ...rest } = this.errors\n\t\t\t\tthis.errors = rest\n\t\t\t}\n\t\t\tthis.notice = null\n\t\t},\n\n\t\t/**\n\t\t * Read the settings and fill the fields; a secret's value is never put\n\t\t * in the form, only whether one is stored.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync load() {\n\t\t\tthis.loading = true\n\t\t\tthis.loadError = ''\n\t\t\ttry {\n\t\t\t\t// One GET per distinct read target; the section's own target must\n\t\t\t\t// answer, a field's own target may fail on its own.\n\t\t\t\tconst targets = [...new Set(this.fields\n\t\t\t\t\t.filter((field) => field && field.key)\n\t\t\t\t\t.map((field) => this.readUrlOf(field))\n\t\t\t\t\t.filter(Boolean))]\n\t\t\t\tconst answers = {}\n\t\t\t\tconst failures = {}\n\t\t\t\tawait Promise.all(targets.map(async (target) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await axios.get(prefixUrl(target))\n\t\t\t\t\t\tanswers[target] = response?.data ?? {}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures[target] = error\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t\t\tif (this.readTarget && failures[this.readTarget]) {\n\t\t\t\t\tthrow failures[this.readTarget]\n\t\t\t\t}\n\t\t\t\tconst form = {}\n\t\t\t\tconst stored = {}\n\t\t\t\tconst unreadable = {}\n\t\t\t\tfor (const field of this.fields || []) {\n\t\t\t\t\tif (!field || !field.key) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.readUrlOf(field)\n\t\t\t\t\tif (target && failures[target]) {\n\t\t\t\t\t\tunreadable[field.key] = t('nextcloud-vue', 'This value could not be loaded: {reason}', { reason: serverErrorMessage(failures[target]) })\n\t\t\t\t\t}\n\t\t\t\t\tconst raw = this.readValue(field, target ? answers[target] : null)\n\t\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\t\tstored[field.key] = raw !== null && raw !== undefined && raw !== '' && raw !== false\n\t\t\t\t\t\tform[field.key] = ''\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tform[field.key] = raw === undefined ? (field.default ?? (field.type === 'switch' ? false : '')) : raw\n\t\t\t\t}\n\t\t\t\tthis.form = form\n\t\t\t\tthis.baseline = { ...form }\n\t\t\t\tthis.storedSecrets = stored\n\t\t\t\tthis.unreadable = unreadable\n\t\t\t\tthis.errors = {}\n\t\t\t} catch (error) {\n\t\t\t\tthis.loadError = t('nextcloud-vue', 'The settings could not be loaded: {reason}', { reason: serverErrorMessage(error) })\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 * Where a field is read: its own `url`, else the section's.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-field-can-read-and-save-elsewhere\n\t\t */\n\t\treadUrlOf(field) {\n\t\t\treturn field.url || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * A field's value in its read answer: at its `valuePath` (a field with its\n\t\t * own `url`), else at the section's `valuesPath`, then its `key`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {object|null} data The answer of the field's read target.\n\t\t * @return {unknown}\n\t\t */\n\t\treadValue(field, data) {\n\t\t\tif (!data || typeof data !== 'object') {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (field.url) {\n\t\t\t\treturn readPath(data, field.valuePath || field.key)\n\t\t\t}\n\t\t\tconst values = (this.valuesPath ? readPath(data, this.valuesPath) : data) || {}\n\t\t\treturn Object.hasOwn(values, field.key) ? values[field.key] : readPath(values, field.key)\n\t\t},\n\n\t\t/**\n\t\t * Check the fields: required, pattern, and a number's min and max.\n\t\t *\n\t\t * @return {object} Field key to message; empty when all pass.\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-failing-field-says-why\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = {}\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tconst empty = value === null || value === undefined || value === ''\n\t\t\t\tif (field.type === 'switch' || field.type === 'image' || this.unreadable[field.key]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.required && empty && !(field.type === 'secret' && field.secretSet)) {\n\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} is required.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (empty) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n\t\t\t\t\terrors[field.key] = field.patternMessage ? this.tr(field.patternMessage) : t('nextcloud-vue', '{field} is not in the right form.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'number') {\n\t\t\t\t\tconst number = Number(value)\n\t\t\t\t\tif (Number.isNaN(number)) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be a number.', { field: field.label })\n\t\t\t\t\t} else if (field.min !== undefined && number < field.min) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at least {min}.', { field: field.label, min: field.min })\n\t\t\t\t\t} else if (field.max !== undefined && number > field.max) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at most {max}.', { field: field.label, max: field.max })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\n\t\t/**\n\t\t * Save the section's fields in one request, after checking them. A\n\t\t * secret is sent only when something was typed.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tasync save() {\n\t\t\tif (this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errors = this.validate()\n\t\t\tconst failing = Object.keys(this.errors)\n\t\t\tif (failing.length > 0) {\n\t\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'Check the marked fields.') }\n\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\tconst el = this.$el?.querySelector?.('[aria-invalid=\"true\"], .cn-settings-field__error')\n\t\t\t\t\tconst control = el?.closest?.('.cn-settings-field')?.querySelector?.('input, textarea, [role=\"combobox\"]')\n\t\t\t\t\tcontrol?.focus?.()\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The changed fields, one request per save target, each carrying its\n\t\t\t// own fields under their `saveKey`. A secret goes only when typed; an\n\t\t\t// image is uploaded on its own; a field that could not be read is left out.\n\t\t\tconst groups = new Map()\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tif (field.type === 'image' || this.unreadable[field.key] || this.same(value, this.baseline[field.key])) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'secret' && (value === '' || value === null || value === undefined)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst url = field.saveUrl || (field.url ? field.url : this.writeTarget)\n\t\t\t\tconst method = String(field.saveMethod || (field.saveUrl || field.url ? 'POST' : this.saveMethod)).toLowerCase()\n\t\t\t\tconst id = `${method} ${url}`\n\t\t\t\tif (!groups.has(id)) {\n\t\t\t\t\tgroups.set(id, { url, method, fields: [], data: {} })\n\t\t\t\t}\n\t\t\t\tconst group = groups.get(id)\n\t\t\t\tgroup.fields.push(field)\n\t\t\t\tgroup.data[field.saveKey || field.key] = value\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.notice = null\n\t\t\tconst failed = []\n\t\t\tconst sent = {}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait axios.request({ url: prefixUrl(group.url), method: group.method, data: group.data })\n\t\t\t\t\tObject.assign(sent, group.data)\n\t\t\t\t\tthis.acceptSaved(group.fields)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailed.push({ group, error })\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.saving = false\n\t\t\tif (failed.length === 0) {\n\t\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t\t\t/**\n\t\t\t\t * @event saved The section saved. Payload: what was sent, by save key.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', sent)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst reasons = failed.map(({ group, error }) => (groups.size > 1\n\t\t\t\t? t('nextcloud-vue', '{fields}: {reason}', { fields: group.fields.map((field) => field.label).join(', '), reason: serverErrorMessage(error) })\n\t\t\t\t: serverErrorMessage(error)))\n\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'The settings could not be saved: {reason}', { reason: reasons.join('; ') }) }\n\t\t\t/**\n\t\t\t * @event save-error A save request failed. Payload: the first error.\n\t\t\t */\n\t\t\tthis.$emit('save-error', failed[0].error)\n\t\t},\n\n\t\t/**\n\t\t * Take saved fields as the new baseline; a saved secret reads as stored.\n\t\t *\n\t\t * @param {Array<object>} fields The fields that saved.\n\t\t * @return {void}\n\t\t */\n\t\tacceptSaved(fields) {\n\t\t\tconst form = { ...this.form }\n\t\t\tconst baseline = { ...this.baseline }\n\t\t\tconst stored = { ...this.storedSecrets }\n\t\t\tfor (const field of fields) {\n\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\tstored[field.key] = true\n\t\t\t\t\tform[field.key] = ''\n\t\t\t\t}\n\t\t\t\tbaseline[field.key] = form[field.key]\n\t\t\t}\n\t\t\tthis.form = form\n\t\t\tthis.baseline = baseline\n\t\t\tthis.storedSecrets = stored\n\t\t},\n\n\t\t/**\n\t\t * An image field uploaded a file: its new value is the baseline too.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {string} value The new image url.\n\t\t * @return {void}\n\t\t */\n\t\tonUploaded(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tthis.baseline = { ...this.baseline, [field.key]: value }\n\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-settings-fields {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tcontainer-type: inline-size;\n}\n\n.cn-settings-fields__grid {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 1fr);\n\tgap: 16px 20px;\n}\n\n/* Two or three columns where the card is wide enough; stacked otherwise. */\n@container (min-width: 520px) {\n\t.cn-settings-fields__grid--2,\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(2, minmax(0, 1fr));\n\t}\n}\n\n@container (min-width: 780px) {\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(3, minmax(0, 1fr));\n\t}\n}\n\n.cn-settings-fields__field--wide {\n\tgrid-column: 1 / -1;\n}\n\n.cn-settings-fields__save {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tgap: 12px;\n}\n\n.cn-settings-fields__dirty {\n\tfont-size: 14px;\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["CnSettingsField","CnSettingsSection","t","axios"],"mappings":";;;;;;;;;AAsEA;;AAEC;;AAEA;;AAED,SAAS,UAAU,CAAC,IAAI,EAAE;CACzB,OAAO,MAAM,CAAC,IAAK,IAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAA;AACvH,CAAA;;AAEA;AACC;;AAEA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;AAIA;;AAEA;;AAEA;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,yBAAyB;;AAE/B,CAAA,UAAU,EAAE,mBAAEA,UAAe,qBAAEC,YAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY;;AAEvF,CAAA,MAAM,EAAE;;AAEP,EAAA,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,KAAK;EAC5C;;AAED,CAAA,KAAK,EAAE;AACN;EACA,IAAI,EAAE;GACL,IAAI,EAAE,MAAM;GACZ,QAAQ,EAAE,IAAI;GACd;;;EAGD,WAAW,EAAE;GACZ,IAAI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AK,EAAA;GACxC;;AAED;;AAEC;;;;AAID,EAAA,WAAW,CAAC,MAAM,EAAE;GACnB,MAAM,OAAO,EAAE,GAAG,IAAI,CAAC,IAAK,GAAA;AAC5B,GAAA,MAAM,QAAO,GAAI,EAAE,GAAG,IAAI,CAAC,QAAS,GAAA;AACpC,GAAA,MAAM,MAAO,GAAE,EAAE,GAAG,IAAI,CAAC,aAAc,GAAA;GACvC,KAAK,MAAM,KAAI,IAAK,MAAM,EAAE;IAC3B,IAAI,KAAK,CAAC,SAAS,QAAQ,EAAE;AAC5B,KAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,KAAG;AACvB,KAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA,GAAI,GAAC;AACpB,KAAA;AACA,IAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAA,GAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAA;AACrC,IAAA;GACA,IAAI,CAAC,IAAK,GAAE,KAAG;AACf,GAAA,IAAI,CAAC,QAAO,GAAI,SAAO;GACvB,IAAI,CAAC,aAAY,GAAI,OAAK;GAC1B;;AAED;;AAEC;;AAEA;;;EAGD,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE;AACxB,GAAA,IAAI,CAAC,IAAG,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAM,GAAA;GAC/C,IAAI,CAAC,QAAS,GAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAM,GAAA;GACvD,IAAI,CAAC,MAAO,GAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAE,GAAA;GACpE;EACD;AACF;;;;"}
1
+ {"version":3,"file":"CnSettingsFieldsSection.vue2.js","sources":["../../../../src/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<CnSettingsSection\n\t\t:name=\"name\"\n\t\t:description=\"description\"\n\t\t:docUrl=\"docUrl\"\n\t\t:wide=\"wide\"\n\t\t:loading=\"loading\"\n\t\t:error=\"loadError !== ''\"\n\t\t:errorMessage=\"loadError\"\n\t\t:onRetry=\"load\"\n\t\tdata-testid=\"cn-settings-fields-section\">\n\t\t<form v-if=\"!loading && loadError === ''\"\n\t\t\tclass=\"cn-settings-fields\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"save\">\n\t\t\t<div class=\"cn-settings-fields__grid\" :class=\"`cn-settings-fields__grid--${columnCount}`\">\n\t\t\t\t<CnSettingsField\n\t\t\t\t\tv-for=\"field in resolvedFields\"\n\t\t\t\t\t:key=\"field.key\"\n\t\t\t\t\tclass=\"cn-settings-fields__field\"\n\t\t\t\t\t:class=\"{ 'cn-settings-fields__field--wide': field.wide }\"\n\t\t\t\t\t:field=\"field\"\n\t\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t\t:error=\"errors[field.key] || unreadable[field.key] || ''\"\n\t\t\t\t\t:hint=\"field.hint\"\n\t\t\t\t\t@update:modelValue=\"setValue(field, $event)\"\n\t\t\t\t\t@uploaded=\"onUploaded(field, $event)\" />\n\t\t\t</div>\n\n\t\t\t<NcNoteCard v-if=\"notice\"\n\t\t\t\t:type=\"notice.type\"\n\t\t\t\t:role=\"notice.type === 'error' ? 'alert' : 'status'\"\n\t\t\t\tdata-testid=\"cn-settings-fields-notice\">\n\t\t\t\t{{ notice.text }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<div class=\"cn-settings-section__save cn-settings-fields__save\">\n\t\t\t\t<span v-if=\"dirty\" class=\"cn-settings-fields__dirty\" data-testid=\"cn-settings-fields-dirty\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Unsaved changes') }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving || !dirty\"\n\t\t\t\t\tdata-testid=\"cn-settings-fields-save\">\n\t\t\t\t\t<template v-if=\"saving\" #icon>\n\t\t\t\t\t\t<NcLoadingIcon :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ resolvedSaveLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</form>\n\t</CnSettingsSection>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'\nimport { prefixUrl } from '../../utils/headers.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { serverErrorMessage } from '../../utils/serverErrorMessage.js'\nimport { CnSettingsField } from '../CnSettingsField/index.js'\nimport { CnSettingsSection } from '../CnSettingsSection/index.js'\n\n/**\n * A value by key: the key as written when the object holds it (a flat map\n * with dotted keys such as `integration.brk.mode`), else as a dotted path.\n *\n * @param {object} data The object.\n * @param {string} key The key or dotted path.\n * @return {unknown}\n */\nfunction literalFirst(data, key) {\n\tif (data && typeof data === 'object' && Object.hasOwn(data, key)) {\n\t\treturn data[key]\n\t}\n\treturn readPath(data, key)\n}\n\n/**\n * The request options for a target: an OCS endpoint (`/ocs/...`) needs the\n * `OCS-APIRequest` header; `prefixUrl` already serves it outside index.php.\n *\n * @param {string} url The target.\n * @return {object}\n */\nfunction ocsConfig(url) {\n\treturn /^\\/ocs\\//.test(String(url)) ? { headers: { 'OCS-APIRequest': 'true' } } : {}\n}\n\n/**\n * Up to two initials of a name, for an image field without an image.\n *\n * @param {unknown} name The name.\n * @return {string}\n */\nfunction initialsOf(name) {\n\treturn String(name || '').trim().split(/\\s+/).filter(Boolean).slice(0, 2).map((word) => word[0].toUpperCase()).join('')\n}\n\n/**\n * CnSettingsFieldsSection - a settings section declared as fields: it reads\n * the app's settings, draws the fields in one to three columns, and saves\n * them with ONE Save button for the section.\n *\n * It reads `GET url` (default `/apps/<appId>/api/settings`) and writes the\n * section's fields with `PUT saveUrl` (default the same url). The Save button\n * is on while something changed (\"Unsaved changes\"); a save checks the\n * fields first (required, pattern, min, max) and marks each failing field,\n * then says it saved or why it did not. A `secret` field never shows the\n * stored value: it says a value is stored, and is sent only when something\n * was typed.\n *\n * It renders inside CnAdminSettingsShell and CnSettingsPage, in the default\n * and the board look.\n *\n * ```vue\n * <CnSettingsFieldsSection\n * app-id=\"myapp\"\n * name=\"Connection\"\n * :columns=\"2\"\n * :fields=\"[\n * { key: 'baseUrl', label: 'Server address', required: true, pattern: '^https://', patternMessage: 'Starts with https://' },\n * { key: 'apiKey', label: 'API key', type: 'secret' },\n * { key: 'mode', label: 'Mode', type: 'select', options: [{ value: 'live', label: 'Live' }, { value: 'test', label: 'Test' }] },\n * { key: 'enabled', label: 'Enabled', type: 'switch', hint: 'Off stops every call.' },\n * ]\" />\n * ```\n */\nexport default {\n\tname: 'CnSettingsFieldsSection',\n\n\tcomponents: { CnSettingsField, CnSettingsSection, NcButton, NcLoadingIcon, NcNoteCard },\n\n\tinject: {\n\t\t/** The app's translate function; identity outside CnAppRoot. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/** The section title. */\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** The line under the title. */\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A documentation link beside the title. */\n\t\tdocUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Span the whole settings grid in the board look. */\n\t\twide: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The fields: `[{ key, label, type?, hint?, placeholder?, required?,\n\t\t * pattern?, patternMessage?, min?, max?, rows?, options?, optionsUrl?,\n\t\t * optionsPath?, optionLabel?, optionValue?, default?, readOnly?, wide?,\n\t\t * url?, valuePath?, saveUrl?, saveMethod?, saveKey?, saveParams?, uploadUrl?,\n\t\t * uploadField?, uploadParams?, uploadValuePath?, initials?, initialsFrom? }]`.\n\t\t * `type` is `text` (default), `textarea`, `number`, `switch`, `select`,\n\t\t * `secret` or `image`. `key` names the setting; a dotted key reads a\n\t\t * nested value and is written as written. A field with its own `url`\n\t\t * is read there (at `valuePath`, default its key) and saved to its\n\t\t * `saveUrl` (default that `url`) with `saveMethod` (default POST) under\n\t\t * `saveKey` (default its key), with `saveParams` merged into the body,\n\t\t * so one section can hold the settings of several apps. A target under\n\t\t * `/ocs/` is sent the `OCS-APIRequest` header. An `image` uploads at once to `uploadUrl`. Labels,\n\t\t * hints, placeholders and messages go through the app's translate\n\t\t * function.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-section-declared-as-fields-reads-and-saves-the-apps-settings\n\t\t */\n\t\tfields: {\n\t\t\ttype: Array,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Columns of the field grid: 1, 2 or 3. A narrow card stacks them. */\n\t\tcolumns: {\n\t\t\ttype: Number,\n\t\t\tdefault: 1,\n\t\t\tvalidator: (value) => [1, 2, 3].includes(value),\n\t\t},\n\n\t\t/** The app id, for the default url `/apps/<appId>/api/settings`. */\n\t\tappId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the settings are read (`GET`); app-absolute or a full URL. */\n\t\turl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the section saves; defaults to `url`. */\n\t\tsaveUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The method of the save request. */\n\t\tsaveMethod: {\n\t\t\ttype: String,\n\t\t\tdefault: 'PUT',\n\t\t\tvalidator: (value) => ['PUT', 'POST', 'PATCH'].includes(String(value).toUpperCase()),\n\t\t},\n\n\t\t/** A dotted path to the values in the GET answer; empty reads the answer itself. */\n\t\tvaluesPath: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The Save button's label. Defaults to \"Save\". */\n\t\tsaveLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['saved', 'save-error'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\tbaseline: {},\n\t\t\tstoredSecrets: {},\n\t\t\t// Field key to the message of a read target that failed.\n\t\t\tunreadable: {},\n\t\t\terrors: {},\n\t\t\tloading: true,\n\t\t\tloadError: '',\n\t\t\tsaving: false,\n\t\t\tnotice: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {number} The column count, 1 to 3. */\n\t\tcolumnCount() {\n\t\t\treturn [1, 2, 3].includes(this.columns) ? this.columns : 1\n\t\t},\n\n\t\t/** @return {string} Where the settings are read: `url`, else the app's settings endpoint. */\n\t\treadTarget() {\n\t\t\treturn this.url || (this.appId ? `/apps/${this.appId}/api/settings` : '')\n\t\t},\n\n\t\t/** @return {string} Where the section saves: `saveUrl`, else the read target. */\n\t\twriteTarget() {\n\t\t\treturn this.saveUrl || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * The declared fields with their text translated and a secret's stored state.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tresolvedFields() {\n\t\t\treturn (Array.isArray(this.fields) ? this.fields : [])\n\t\t\t\t.filter((field) => field && typeof field.key === 'string' && field.key !== '')\n\t\t\t\t.map((field) => ({\n\t\t\t\t\t...field,\n\t\t\t\t\tlabel: this.tr(field.label || field.key),\n\t\t\t\t\thint: this.tr(field.hint || ''),\n\t\t\t\t\tplaceholder: this.tr(field.placeholder || ''),\n\t\t\t\t\tsecretSet: field.type === 'secret' ? !!this.storedSecrets[field.key] : undefined,\n\t\t\t\t\tinitials: field.type === 'image' ? initialsOf(field.initialsFrom ? this.form[field.initialsFrom] : field.initials) : undefined,\n\t\t\t\t\treadOnly: field.readOnly || !!this.unreadable[field.key],\n\t\t\t\t}))\n\t\t},\n\n\t\t/**\n\t\t * Whether something changed since the last load or save.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tdirty() {\n\t\t\treturn this.resolvedFields.some((field) => field.type !== 'image' && !this.same(this.form[field.key], this.baseline[field.key]))\n\t\t},\n\n\t\t/** @return {string} The Save button's label. */\n\t\tresolvedSaveLabel() {\n\t\t\treturn this.saveLabel ? this.tr(this.saveLabel) : t('nextcloud-vue', 'Save')\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.load()\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * @param {string} value A declared string.\n\t\t * @return {string} It through the app's translate function.\n\t\t */\n\t\ttr(value) {\n\t\t\treturn typeof value === 'string' && value !== '' ? this.cnTranslate(value) : (value || '')\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} a A value.\n\t\t * @param {unknown} b Another.\n\t\t * @return {boolean} Whether they count as the same setting.\n\t\t */\n\t\tsame(a, b) {\n\t\t\tconst empty = (v) => v === null || v === undefined || v === ''\n\t\t\tif (empty(a) && empty(b)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t},\n\n\t\t/**\n\t\t * Change a field's value; its error goes until the next save.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {unknown} value The value.\n\t\t * @return {void}\n\t\t */\n\t\tsetValue(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tif (this.errors[field.key]) {\n\t\t\t\tconst { [field.key]: _gone, ...rest } = this.errors\n\t\t\t\tthis.errors = rest\n\t\t\t}\n\t\t\tthis.notice = null\n\t\t},\n\n\t\t/**\n\t\t * Read the settings and fill the fields; a secret's value is never put\n\t\t * in the form, only whether one is stored.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync load() {\n\t\t\tthis.loading = true\n\t\t\tthis.loadError = ''\n\t\t\ttry {\n\t\t\t\t// One GET per distinct read target; the section's own target must\n\t\t\t\t// answer, a field's own target may fail on its own.\n\t\t\t\tconst targets = [...new Set(this.fields\n\t\t\t\t\t.filter((field) => field && field.key)\n\t\t\t\t\t.map((field) => this.readUrlOf(field))\n\t\t\t\t\t.filter(Boolean))]\n\t\t\t\tconst answers = {}\n\t\t\t\tconst failures = {}\n\t\t\t\tawait Promise.all(targets.map(async (target) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await axios.get(prefixUrl(target), ocsConfig(target))\n\t\t\t\t\t\tanswers[target] = response?.data ?? {}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures[target] = error\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t\t\tif (this.readTarget && failures[this.readTarget]) {\n\t\t\t\t\tthrow failures[this.readTarget]\n\t\t\t\t}\n\t\t\t\tconst form = {}\n\t\t\t\tconst stored = {}\n\t\t\t\tconst unreadable = {}\n\t\t\t\tfor (const field of this.fields || []) {\n\t\t\t\t\tif (!field || !field.key) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.readUrlOf(field)\n\t\t\t\t\tif (target && failures[target]) {\n\t\t\t\t\t\tunreadable[field.key] = t('nextcloud-vue', 'This value could not be loaded: {reason}', { reason: serverErrorMessage(failures[target]) })\n\t\t\t\t\t}\n\t\t\t\t\tconst raw = this.readValue(field, target ? answers[target] : null)\n\t\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\t\tstored[field.key] = raw !== null && raw !== undefined && raw !== '' && raw !== false\n\t\t\t\t\t\tform[field.key] = ''\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tform[field.key] = raw === undefined ? (field.default ?? (field.type === 'switch' ? false : '')) : raw\n\t\t\t\t}\n\t\t\t\tthis.form = form\n\t\t\t\tthis.baseline = { ...form }\n\t\t\t\tthis.storedSecrets = stored\n\t\t\t\tthis.unreadable = unreadable\n\t\t\t\tthis.errors = {}\n\t\t\t} catch (error) {\n\t\t\t\tthis.loadError = t('nextcloud-vue', 'The settings could not be loaded: {reason}', { reason: serverErrorMessage(error) })\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 * Where a field is read: its own `url`, else the section's.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-field-can-read-and-save-elsewhere\n\t\t */\n\t\treadUrlOf(field) {\n\t\t\treturn field.url || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * A field's value in its read answer: at its `valuePath` (a field with its\n\t\t * own `url`), else at the section's `valuesPath`, then its `key`. A key\n\t\t * the answer holds as written wins over reading it as a dotted path.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {object|null} data The answer of the field's read target.\n\t\t * @return {unknown}\n\t\t */\n\t\treadValue(field, data) {\n\t\t\tif (!data || typeof data !== 'object') {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (field.url) {\n\t\t\t\treturn literalFirst(data, field.valuePath || field.key)\n\t\t\t}\n\t\t\tconst values = (this.valuesPath ? literalFirst(data, this.valuesPath) : data) || {}\n\t\t\treturn literalFirst(values, field.key)\n\t\t},\n\n\t\t/**\n\t\t * Check the fields: required, pattern, and a number's min and max.\n\t\t *\n\t\t * @return {object} Field key to message; empty when all pass.\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-failing-field-says-why\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = {}\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tconst empty = value === null || value === undefined || value === ''\n\t\t\t\tif (field.type === 'switch' || field.type === 'image' || this.unreadable[field.key]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.required && empty && !(field.type === 'secret' && field.secretSet)) {\n\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} is required.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (empty) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n\t\t\t\t\terrors[field.key] = field.patternMessage ? this.tr(field.patternMessage) : t('nextcloud-vue', '{field} is not in the right form.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'number') {\n\t\t\t\t\tconst number = Number(value)\n\t\t\t\t\tif (Number.isNaN(number)) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be a number.', { field: field.label })\n\t\t\t\t\t} else if (field.min !== undefined && number < field.min) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at least {min}.', { field: field.label, min: field.min })\n\t\t\t\t\t} else if (field.max !== undefined && number > field.max) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at most {max}.', { field: field.label, max: field.max })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\n\t\t/**\n\t\t * Save the section's fields in one request, after checking them. A\n\t\t * secret is sent only when something was typed.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tasync save() {\n\t\t\tif (this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errors = this.validate()\n\t\t\tconst failing = Object.keys(this.errors)\n\t\t\tif (failing.length > 0) {\n\t\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'Check the marked fields.') }\n\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\tconst el = this.$el?.querySelector?.('[aria-invalid=\"true\"], .cn-settings-field__error')\n\t\t\t\t\tconst control = el?.closest?.('.cn-settings-field')?.querySelector?.('input, textarea, [role=\"combobox\"]')\n\t\t\t\t\tcontrol?.focus?.()\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The changed fields, one request per save target, each carrying its\n\t\t\t// own fields under their `saveKey`. A secret goes only when typed; an\n\t\t\t// image is uploaded on its own; a field that could not be read is left out.\n\t\t\tconst groups = new Map()\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tif (field.type === 'image' || this.unreadable[field.key] || this.same(value, this.baseline[field.key])) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'secret' && (value === '' || value === null || value === undefined)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst url = field.saveUrl || (field.url ? field.url : this.writeTarget)\n\t\t\t\tconst method = String(field.saveMethod || (field.saveUrl || field.url ? 'POST' : this.saveMethod)).toLowerCase()\n\t\t\t\tconst id = `${method} ${url}`\n\t\t\t\tif (!groups.has(id)) {\n\t\t\t\t\tgroups.set(id, { url, method, fields: [], data: {} })\n\t\t\t\t}\n\t\t\t\tconst group = groups.get(id)\n\t\t\t\tgroup.fields.push(field)\n\t\t\t\tObject.assign(group.data, field.saveParams || {})\n\t\t\t\tgroup.data[field.saveKey || field.key] = value\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.notice = null\n\t\t\tconst failed = []\n\t\t\tconst sent = {}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait axios.request({ url: prefixUrl(group.url), method: group.method, data: group.data, ...ocsConfig(group.url) })\n\t\t\t\t\tObject.assign(sent, group.data)\n\t\t\t\t\tthis.acceptSaved(group.fields)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailed.push({ group, error })\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.saving = false\n\t\t\tif (failed.length === 0) {\n\t\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t\t\t/**\n\t\t\t\t * @event saved The section saved. Payload: what was sent, by save key.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', sent)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst reasons = failed.map(({ group, error }) => (groups.size > 1\n\t\t\t\t? t('nextcloud-vue', '{fields}: {reason}', { fields: group.fields.map((field) => field.label).join(', '), reason: serverErrorMessage(error) })\n\t\t\t\t: serverErrorMessage(error)))\n\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'The settings could not be saved: {reason}', { reason: reasons.join('; ') }) }\n\t\t\t/**\n\t\t\t * @event save-error A save request failed. Payload: the first error.\n\t\t\t */\n\t\t\tthis.$emit('save-error', failed[0].error)\n\t\t},\n\n\t\t/**\n\t\t * Take saved fields as the new baseline; a saved secret reads as stored.\n\t\t *\n\t\t * @param {Array<object>} fields The fields that saved.\n\t\t * @return {void}\n\t\t */\n\t\tacceptSaved(fields) {\n\t\t\tconst form = { ...this.form }\n\t\t\tconst baseline = { ...this.baseline }\n\t\t\tconst stored = { ...this.storedSecrets }\n\t\t\tfor (const field of fields) {\n\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\tstored[field.key] = true\n\t\t\t\t\tform[field.key] = ''\n\t\t\t\t}\n\t\t\t\tbaseline[field.key] = form[field.key]\n\t\t\t}\n\t\t\tthis.form = form\n\t\t\tthis.baseline = baseline\n\t\t\tthis.storedSecrets = stored\n\t\t},\n\n\t\t/**\n\t\t * An image field uploaded a file: its new value is the baseline too.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {string} value The new image url.\n\t\t * @return {void}\n\t\t */\n\t\tonUploaded(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tthis.baseline = { ...this.baseline, [field.key]: value }\n\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-settings-fields {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tcontainer-type: inline-size;\n}\n\n.cn-settings-fields__grid {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 1fr);\n\tgap: 16px 20px;\n}\n\n/* Two or three columns where the card is wide enough; stacked otherwise. */\n@container (min-width: 520px) {\n\t.cn-settings-fields__grid--2,\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(2, minmax(0, 1fr));\n\t}\n}\n\n@container (min-width: 780px) {\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(3, minmax(0, 1fr));\n\t}\n}\n\n.cn-settings-fields__field--wide {\n\tgrid-column: 1 / -1;\n}\n\n.cn-settings-fields__save {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tgap: 12px;\n}\n\n.cn-settings-fields__dirty {\n\tfont-size: 14px;\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["CnSettingsField","CnSettingsSection","t","axios"],"mappings":";;;;;;;;;AAsEA;;AAEC;AACA;;AAEA;AACA;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE;CAChC,IAAI,QAAQ,OAAO,IAAK,KAAI,QAAS,IAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;AACjE,EAAA,OAAO,IAAI,CAAC,GAAG,CAAA;AAChB,EAAA;CACA,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAA;AAC1B,CAAA;;AAEA;;AAEC;AACA;;AAEA;;AAED,SAAS,SAAS,CAAC,GAAG,EAAE;AACvB,CAAA,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,gBAAgB,EAAE,MAAK,EAAI,EAAA,GAAI,EAAC;AACpF,CAAA;;AAEA;;AAEC;;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,KAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,KAAG;AACvB,KAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA,GAAI,GAAC;AACpB,KAAA;AACA,IAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAA,GAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAA;AACrC,IAAA;GACA,IAAI,CAAC,IAAK,GAAE,KAAG;AACf,GAAA,IAAI,CAAC,QAAO,GAAI,SAAO;GACvB,IAAI,CAAC,aAAY,GAAI,OAAK;GAC1B;;AAED;;AAEC;;AAEA;;;EAGD,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE;AACxB,GAAA,IAAI,CAAC,IAAG,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAM,GAAA;GAC/C,IAAI,CAAC,QAAS,GAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAM,GAAA;GACvD,IAAI,CAAC,MAAO,GAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAE,GAAA;GACpE;EACD;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CnSettingsFieldsSection.vue3.js","sources":["../../../../src/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue?vue&type=template&id=65c151a8&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<CnSettingsSection\n\t\t:name=\"name\"\n\t\t:description=\"description\"\n\t\t:docUrl=\"docUrl\"\n\t\t:wide=\"wide\"\n\t\t:loading=\"loading\"\n\t\t:error=\"loadError !== ''\"\n\t\t:errorMessage=\"loadError\"\n\t\t:onRetry=\"load\"\n\t\tdata-testid=\"cn-settings-fields-section\">\n\t\t<form v-if=\"!loading && loadError === ''\"\n\t\t\tclass=\"cn-settings-fields\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"save\">\n\t\t\t<div class=\"cn-settings-fields__grid\" :class=\"`cn-settings-fields__grid--${columnCount}`\">\n\t\t\t\t<CnSettingsField\n\t\t\t\t\tv-for=\"field in resolvedFields\"\n\t\t\t\t\t:key=\"field.key\"\n\t\t\t\t\tclass=\"cn-settings-fields__field\"\n\t\t\t\t\t:class=\"{ 'cn-settings-fields__field--wide': field.wide }\"\n\t\t\t\t\t:field=\"field\"\n\t\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t\t:error=\"errors[field.key] || unreadable[field.key] || ''\"\n\t\t\t\t\t:hint=\"field.hint\"\n\t\t\t\t\t@update:modelValue=\"setValue(field, $event)\"\n\t\t\t\t\t@uploaded=\"onUploaded(field, $event)\" />\n\t\t\t</div>\n\n\t\t\t<NcNoteCard v-if=\"notice\"\n\t\t\t\t:type=\"notice.type\"\n\t\t\t\t:role=\"notice.type === 'error' ? 'alert' : 'status'\"\n\t\t\t\tdata-testid=\"cn-settings-fields-notice\">\n\t\t\t\t{{ notice.text }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<div class=\"cn-settings-section__save cn-settings-fields__save\">\n\t\t\t\t<span v-if=\"dirty\" class=\"cn-settings-fields__dirty\" data-testid=\"cn-settings-fields-dirty\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Unsaved changes') }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving || !dirty\"\n\t\t\t\t\tdata-testid=\"cn-settings-fields-save\">\n\t\t\t\t\t<template v-if=\"saving\" #icon>\n\t\t\t\t\t\t<NcLoadingIcon :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ resolvedSaveLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</form>\n\t</CnSettingsSection>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'\nimport { prefixUrl } from '../../utils/headers.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { serverErrorMessage } from '../../utils/serverErrorMessage.js'\nimport { CnSettingsField } from '../CnSettingsField/index.js'\nimport { CnSettingsSection } from '../CnSettingsSection/index.js'\n\n/**\n * Up to two initials of a name, for an image field without an image.\n *\n * @param {unknown} name The name.\n * @return {string}\n */\nfunction initialsOf(name) {\n\treturn String(name || '').trim().split(/\\s+/).filter(Boolean).slice(0, 2).map((word) => word[0].toUpperCase()).join('')\n}\n\n/**\n * CnSettingsFieldsSection - a settings section declared as fields: it reads\n * the app's settings, draws the fields in one to three columns, and saves\n * them with ONE Save button for the section.\n *\n * It reads `GET url` (default `/apps/<appId>/api/settings`) and writes the\n * section's fields with `PUT saveUrl` (default the same url). The Save button\n * is on while something changed (\"Unsaved changes\"); a save checks the\n * fields first (required, pattern, min, max) and marks each failing field,\n * then says it saved or why it did not. A `secret` field never shows the\n * stored value: it says a value is stored, and is sent only when something\n * was typed.\n *\n * It renders inside CnAdminSettingsShell and CnSettingsPage, in the default\n * and the board look.\n *\n * ```vue\n * <CnSettingsFieldsSection\n * app-id=\"myapp\"\n * name=\"Connection\"\n * :columns=\"2\"\n * :fields=\"[\n * { key: 'baseUrl', label: 'Server address', required: true, pattern: '^https://', patternMessage: 'Starts with https://' },\n * { key: 'apiKey', label: 'API key', type: 'secret' },\n * { key: 'mode', label: 'Mode', type: 'select', options: [{ value: 'live', label: 'Live' }, { value: 'test', label: 'Test' }] },\n * { key: 'enabled', label: 'Enabled', type: 'switch', hint: 'Off stops every call.' },\n * ]\" />\n * ```\n */\nexport default {\n\tname: 'CnSettingsFieldsSection',\n\n\tcomponents: { CnSettingsField, CnSettingsSection, NcButton, NcLoadingIcon, NcNoteCard },\n\n\tinject: {\n\t\t/** The app's translate function; identity outside CnAppRoot. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/** The section title. */\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** The line under the title. */\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A documentation link beside the title. */\n\t\tdocUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Span the whole settings grid in the board look. */\n\t\twide: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The fields: `[{ key, label, type?, hint?, placeholder?, required?,\n\t\t * pattern?, patternMessage?, min?, max?, rows?, options?, optionsUrl?,\n\t\t * optionsPath?, optionLabel?, optionValue?, default?, readOnly?, wide?,\n\t\t * url?, valuePath?, saveUrl?, saveMethod?, saveKey?, uploadUrl?,\n\t\t * uploadField?, uploadParams?, uploadValuePath?, initials?, initialsFrom? }]`.\n\t\t * `type` is `text` (default), `textarea`, `number`, `switch`, `select`,\n\t\t * `secret` or `image`. `key` names the setting; a dotted key reads a\n\t\t * nested value and is written as written. A field with its own `url`\n\t\t * is read there (at `valuePath`, default its key) and saved to its\n\t\t * `saveUrl` (default that `url`) with `saveMethod` (default POST) under\n\t\t * `saveKey` (default its key), so one section can hold the settings of\n\t\t * several apps. An `image` uploads at once to `uploadUrl`. Labels,\n\t\t * hints, placeholders and messages go through the app's translate\n\t\t * function.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-section-declared-as-fields-reads-and-saves-the-apps-settings\n\t\t */\n\t\tfields: {\n\t\t\ttype: Array,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Columns of the field grid: 1, 2 or 3. A narrow card stacks them. */\n\t\tcolumns: {\n\t\t\ttype: Number,\n\t\t\tdefault: 1,\n\t\t\tvalidator: (value) => [1, 2, 3].includes(value),\n\t\t},\n\n\t\t/** The app id, for the default url `/apps/<appId>/api/settings`. */\n\t\tappId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the settings are read (`GET`); app-absolute or a full URL. */\n\t\turl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the section saves; defaults to `url`. */\n\t\tsaveUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The method of the save request. */\n\t\tsaveMethod: {\n\t\t\ttype: String,\n\t\t\tdefault: 'PUT',\n\t\t\tvalidator: (value) => ['PUT', 'POST', 'PATCH'].includes(String(value).toUpperCase()),\n\t\t},\n\n\t\t/** A dotted path to the values in the GET answer; empty reads the answer itself. */\n\t\tvaluesPath: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The Save button's label. Defaults to \"Save\". */\n\t\tsaveLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['saved', 'save-error'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\tbaseline: {},\n\t\t\tstoredSecrets: {},\n\t\t\t// Field key to the message of a read target that failed.\n\t\t\tunreadable: {},\n\t\t\terrors: {},\n\t\t\tloading: true,\n\t\t\tloadError: '',\n\t\t\tsaving: false,\n\t\t\tnotice: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {number} The column count, 1 to 3. */\n\t\tcolumnCount() {\n\t\t\treturn [1, 2, 3].includes(this.columns) ? this.columns : 1\n\t\t},\n\n\t\t/** @return {string} Where the settings are read: `url`, else the app's settings endpoint. */\n\t\treadTarget() {\n\t\t\treturn this.url || (this.appId ? `/apps/${this.appId}/api/settings` : '')\n\t\t},\n\n\t\t/** @return {string} Where the section saves: `saveUrl`, else the read target. */\n\t\twriteTarget() {\n\t\t\treturn this.saveUrl || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * The declared fields with their text translated and a secret's stored state.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tresolvedFields() {\n\t\t\treturn (Array.isArray(this.fields) ? this.fields : [])\n\t\t\t\t.filter((field) => field && typeof field.key === 'string' && field.key !== '')\n\t\t\t\t.map((field) => ({\n\t\t\t\t\t...field,\n\t\t\t\t\tlabel: this.tr(field.label || field.key),\n\t\t\t\t\thint: this.tr(field.hint || ''),\n\t\t\t\t\tplaceholder: this.tr(field.placeholder || ''),\n\t\t\t\t\tsecretSet: field.type === 'secret' ? !!this.storedSecrets[field.key] : undefined,\n\t\t\t\t\tinitials: field.type === 'image' ? initialsOf(field.initialsFrom ? this.form[field.initialsFrom] : field.initials) : undefined,\n\t\t\t\t\treadOnly: field.readOnly || !!this.unreadable[field.key],\n\t\t\t\t}))\n\t\t},\n\n\t\t/**\n\t\t * Whether something changed since the last load or save.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tdirty() {\n\t\t\treturn this.resolvedFields.some((field) => field.type !== 'image' && !this.same(this.form[field.key], this.baseline[field.key]))\n\t\t},\n\n\t\t/** @return {string} The Save button's label. */\n\t\tresolvedSaveLabel() {\n\t\t\treturn this.saveLabel ? this.tr(this.saveLabel) : t('nextcloud-vue', 'Save')\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.load()\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * @param {string} value A declared string.\n\t\t * @return {string} It through the app's translate function.\n\t\t */\n\t\ttr(value) {\n\t\t\treturn typeof value === 'string' && value !== '' ? this.cnTranslate(value) : (value || '')\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} a A value.\n\t\t * @param {unknown} b Another.\n\t\t * @return {boolean} Whether they count as the same setting.\n\t\t */\n\t\tsame(a, b) {\n\t\t\tconst empty = (v) => v === null || v === undefined || v === ''\n\t\t\tif (empty(a) && empty(b)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t},\n\n\t\t/**\n\t\t * Change a field's value; its error goes until the next save.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {unknown} value The value.\n\t\t * @return {void}\n\t\t */\n\t\tsetValue(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tif (this.errors[field.key]) {\n\t\t\t\tconst { [field.key]: _gone, ...rest } = this.errors\n\t\t\t\tthis.errors = rest\n\t\t\t}\n\t\t\tthis.notice = null\n\t\t},\n\n\t\t/**\n\t\t * Read the settings and fill the fields; a secret's value is never put\n\t\t * in the form, only whether one is stored.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync load() {\n\t\t\tthis.loading = true\n\t\t\tthis.loadError = ''\n\t\t\ttry {\n\t\t\t\t// One GET per distinct read target; the section's own target must\n\t\t\t\t// answer, a field's own target may fail on its own.\n\t\t\t\tconst targets = [...new Set(this.fields\n\t\t\t\t\t.filter((field) => field && field.key)\n\t\t\t\t\t.map((field) => this.readUrlOf(field))\n\t\t\t\t\t.filter(Boolean))]\n\t\t\t\tconst answers = {}\n\t\t\t\tconst failures = {}\n\t\t\t\tawait Promise.all(targets.map(async (target) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await axios.get(prefixUrl(target))\n\t\t\t\t\t\tanswers[target] = response?.data ?? {}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures[target] = error\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t\t\tif (this.readTarget && failures[this.readTarget]) {\n\t\t\t\t\tthrow failures[this.readTarget]\n\t\t\t\t}\n\t\t\t\tconst form = {}\n\t\t\t\tconst stored = {}\n\t\t\t\tconst unreadable = {}\n\t\t\t\tfor (const field of this.fields || []) {\n\t\t\t\t\tif (!field || !field.key) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.readUrlOf(field)\n\t\t\t\t\tif (target && failures[target]) {\n\t\t\t\t\t\tunreadable[field.key] = t('nextcloud-vue', 'This value could not be loaded: {reason}', { reason: serverErrorMessage(failures[target]) })\n\t\t\t\t\t}\n\t\t\t\t\tconst raw = this.readValue(field, target ? answers[target] : null)\n\t\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\t\tstored[field.key] = raw !== null && raw !== undefined && raw !== '' && raw !== false\n\t\t\t\t\t\tform[field.key] = ''\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tform[field.key] = raw === undefined ? (field.default ?? (field.type === 'switch' ? false : '')) : raw\n\t\t\t\t}\n\t\t\t\tthis.form = form\n\t\t\t\tthis.baseline = { ...form }\n\t\t\t\tthis.storedSecrets = stored\n\t\t\t\tthis.unreadable = unreadable\n\t\t\t\tthis.errors = {}\n\t\t\t} catch (error) {\n\t\t\t\tthis.loadError = t('nextcloud-vue', 'The settings could not be loaded: {reason}', { reason: serverErrorMessage(error) })\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 * Where a field is read: its own `url`, else the section's.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-field-can-read-and-save-elsewhere\n\t\t */\n\t\treadUrlOf(field) {\n\t\t\treturn field.url || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * A field's value in its read answer: at its `valuePath` (a field with its\n\t\t * own `url`), else at the section's `valuesPath`, then its `key`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {object|null} data The answer of the field's read target.\n\t\t * @return {unknown}\n\t\t */\n\t\treadValue(field, data) {\n\t\t\tif (!data || typeof data !== 'object') {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (field.url) {\n\t\t\t\treturn readPath(data, field.valuePath || field.key)\n\t\t\t}\n\t\t\tconst values = (this.valuesPath ? readPath(data, this.valuesPath) : data) || {}\n\t\t\treturn Object.hasOwn(values, field.key) ? values[field.key] : readPath(values, field.key)\n\t\t},\n\n\t\t/**\n\t\t * Check the fields: required, pattern, and a number's min and max.\n\t\t *\n\t\t * @return {object} Field key to message; empty when all pass.\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-failing-field-says-why\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = {}\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tconst empty = value === null || value === undefined || value === ''\n\t\t\t\tif (field.type === 'switch' || field.type === 'image' || this.unreadable[field.key]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.required && empty && !(field.type === 'secret' && field.secretSet)) {\n\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} is required.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (empty) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n\t\t\t\t\terrors[field.key] = field.patternMessage ? this.tr(field.patternMessage) : t('nextcloud-vue', '{field} is not in the right form.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'number') {\n\t\t\t\t\tconst number = Number(value)\n\t\t\t\t\tif (Number.isNaN(number)) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be a number.', { field: field.label })\n\t\t\t\t\t} else if (field.min !== undefined && number < field.min) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at least {min}.', { field: field.label, min: field.min })\n\t\t\t\t\t} else if (field.max !== undefined && number > field.max) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at most {max}.', { field: field.label, max: field.max })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\n\t\t/**\n\t\t * Save the section's fields in one request, after checking them. A\n\t\t * secret is sent only when something was typed.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tasync save() {\n\t\t\tif (this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errors = this.validate()\n\t\t\tconst failing = Object.keys(this.errors)\n\t\t\tif (failing.length > 0) {\n\t\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'Check the marked fields.') }\n\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\tconst el = this.$el?.querySelector?.('[aria-invalid=\"true\"], .cn-settings-field__error')\n\t\t\t\t\tconst control = el?.closest?.('.cn-settings-field')?.querySelector?.('input, textarea, [role=\"combobox\"]')\n\t\t\t\t\tcontrol?.focus?.()\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The changed fields, one request per save target, each carrying its\n\t\t\t// own fields under their `saveKey`. A secret goes only when typed; an\n\t\t\t// image is uploaded on its own; a field that could not be read is left out.\n\t\t\tconst groups = new Map()\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tif (field.type === 'image' || this.unreadable[field.key] || this.same(value, this.baseline[field.key])) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'secret' && (value === '' || value === null || value === undefined)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst url = field.saveUrl || (field.url ? field.url : this.writeTarget)\n\t\t\t\tconst method = String(field.saveMethod || (field.saveUrl || field.url ? 'POST' : this.saveMethod)).toLowerCase()\n\t\t\t\tconst id = `${method} ${url}`\n\t\t\t\tif (!groups.has(id)) {\n\t\t\t\t\tgroups.set(id, { url, method, fields: [], data: {} })\n\t\t\t\t}\n\t\t\t\tconst group = groups.get(id)\n\t\t\t\tgroup.fields.push(field)\n\t\t\t\tgroup.data[field.saveKey || field.key] = value\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.notice = null\n\t\t\tconst failed = []\n\t\t\tconst sent = {}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait axios.request({ url: prefixUrl(group.url), method: group.method, data: group.data })\n\t\t\t\t\tObject.assign(sent, group.data)\n\t\t\t\t\tthis.acceptSaved(group.fields)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailed.push({ group, error })\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.saving = false\n\t\t\tif (failed.length === 0) {\n\t\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t\t\t/**\n\t\t\t\t * @event saved The section saved. Payload: what was sent, by save key.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', sent)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst reasons = failed.map(({ group, error }) => (groups.size > 1\n\t\t\t\t? t('nextcloud-vue', '{fields}: {reason}', { fields: group.fields.map((field) => field.label).join(', '), reason: serverErrorMessage(error) })\n\t\t\t\t: serverErrorMessage(error)))\n\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'The settings could not be saved: {reason}', { reason: reasons.join('; ') }) }\n\t\t\t/**\n\t\t\t * @event save-error A save request failed. Payload: the first error.\n\t\t\t */\n\t\t\tthis.$emit('save-error', failed[0].error)\n\t\t},\n\n\t\t/**\n\t\t * Take saved fields as the new baseline; a saved secret reads as stored.\n\t\t *\n\t\t * @param {Array<object>} fields The fields that saved.\n\t\t * @return {void}\n\t\t */\n\t\tacceptSaved(fields) {\n\t\t\tconst form = { ...this.form }\n\t\t\tconst baseline = { ...this.baseline }\n\t\t\tconst stored = { ...this.storedSecrets }\n\t\t\tfor (const field of fields) {\n\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\tstored[field.key] = true\n\t\t\t\t\tform[field.key] = ''\n\t\t\t\t}\n\t\t\t\tbaseline[field.key] = form[field.key]\n\t\t\t}\n\t\t\tthis.form = form\n\t\t\tthis.baseline = baseline\n\t\t\tthis.storedSecrets = stored\n\t\t},\n\n\t\t/**\n\t\t * An image field uploaded a file: its new value is the baseline too.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {string} value The new image url.\n\t\t * @return {void}\n\t\t */\n\t\tonUploaded(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tthis.baseline = { ...this.baseline, [field.key]: value }\n\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-settings-fields {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tcontainer-type: inline-size;\n}\n\n.cn-settings-fields__grid {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 1fr);\n\tgap: 16px 20px;\n}\n\n/* Two or three columns where the card is wide enough; stacked otherwise. */\n@container (min-width: 520px) {\n\t.cn-settings-fields__grid--2,\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(2, minmax(0, 1fr));\n\t}\n}\n\n@container (min-width: 780px) {\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(3, minmax(0, 1fr));\n\t}\n}\n\n.cn-settings-fields__field--wide {\n\tgrid-column: 1 / -1;\n}\n\n.cn-settings-fields__save {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tgap: 12px;\n}\n\n.cn-settings-fields__dirty {\n\tfont-size: 14px;\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["_createBlock","_createElementBlock","_normalizeClass","_Fragment","_renderList","_createElementVNode","_toDisplayString","_createTextVNode","_createVNode"],"mappings":";;AA8CQ,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oDAAO,GAAA;;;AACJ,EAAA,KAAA,EAAA,2BAAA;AAAA,EAAA,aAAA,EAAA,0BAAA;;;;;;;;;;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AA,qBAAgB,EAAA,MAAA,KAAA,QAAA,CAAA,QAAA,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;AAChB,kBAAA,UAAQ,EAAE,MAAA,KAAA,QAAA,CAAA,UAAW,CAAA,KAAK,EAAC,MAAO,CAAA,CAAA;;;;aAGzB,KAAA,CAAA,MAAA;8BAAZF,WAKO,CAAA,qBAAA,EAAA;;;kBAHL,IAAI,EAAE,KAAM,CAAA,MAAA,CAAC,IAAI,KAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AAClB,kBAAA,aAAW,EAAC,2BAA2B;;mCACtC,MAAgB;gEAAR,CAAC,IAAI,CAAA,EAAA,CAAA,YAAA;;;;;AAGb,YAAAK,kBAAA,QAAA;eACW,QAAC,CAAA,KAAA;kDAEN,CAAA,MAAA,YAAA,EAAAC,eAAA,CADH,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,iBAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;uBAGG,EAAC,SAAS;AACjB,gBAAA,IAAI,EAAC,QAAK;gBACT,QAAQ,EAAE,KAAM,CAAA,MAAA,IAAA,CAAK,QAAA,CAAA,KAAA;AACtB,gBAAA,aAAS,EAAA,yBAAA;;iCAGE;AAAA,kBAAAC,eAAA,CAAA;;;;iBAFR,KAAA,CAAA,MAAA;;4BAAA,MAAA;kCACF,MAAE;wBAAFC,WAAE,CAAA,wBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CnSettingsFieldsSection.vue3.js","sources":["../../../../src/components/CnSettingsFieldsSection/CnSettingsFieldsSection.vue?vue&type=template&id=090828e4&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<CnSettingsSection\n\t\t:name=\"name\"\n\t\t:description=\"description\"\n\t\t:docUrl=\"docUrl\"\n\t\t:wide=\"wide\"\n\t\t:loading=\"loading\"\n\t\t:error=\"loadError !== ''\"\n\t\t:errorMessage=\"loadError\"\n\t\t:onRetry=\"load\"\n\t\tdata-testid=\"cn-settings-fields-section\">\n\t\t<form v-if=\"!loading && loadError === ''\"\n\t\t\tclass=\"cn-settings-fields\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"save\">\n\t\t\t<div class=\"cn-settings-fields__grid\" :class=\"`cn-settings-fields__grid--${columnCount}`\">\n\t\t\t\t<CnSettingsField\n\t\t\t\t\tv-for=\"field in resolvedFields\"\n\t\t\t\t\t:key=\"field.key\"\n\t\t\t\t\tclass=\"cn-settings-fields__field\"\n\t\t\t\t\t:class=\"{ 'cn-settings-fields__field--wide': field.wide }\"\n\t\t\t\t\t:field=\"field\"\n\t\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t\t:error=\"errors[field.key] || unreadable[field.key] || ''\"\n\t\t\t\t\t:hint=\"field.hint\"\n\t\t\t\t\t@update:modelValue=\"setValue(field, $event)\"\n\t\t\t\t\t@uploaded=\"onUploaded(field, $event)\" />\n\t\t\t</div>\n\n\t\t\t<NcNoteCard v-if=\"notice\"\n\t\t\t\t:type=\"notice.type\"\n\t\t\t\t:role=\"notice.type === 'error' ? 'alert' : 'status'\"\n\t\t\t\tdata-testid=\"cn-settings-fields-notice\">\n\t\t\t\t{{ notice.text }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<div class=\"cn-settings-section__save cn-settings-fields__save\">\n\t\t\t\t<span v-if=\"dirty\" class=\"cn-settings-fields__dirty\" data-testid=\"cn-settings-fields-dirty\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Unsaved changes') }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving || !dirty\"\n\t\t\t\t\tdata-testid=\"cn-settings-fields-save\">\n\t\t\t\t\t<template v-if=\"saving\" #icon>\n\t\t\t\t\t\t<NcLoadingIcon :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ resolvedSaveLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t</form>\n\t</CnSettingsSection>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'\nimport { prefixUrl } from '../../utils/headers.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { serverErrorMessage } from '../../utils/serverErrorMessage.js'\nimport { CnSettingsField } from '../CnSettingsField/index.js'\nimport { CnSettingsSection } from '../CnSettingsSection/index.js'\n\n/**\n * A value by key: the key as written when the object holds it (a flat map\n * with dotted keys such as `integration.brk.mode`), else as a dotted path.\n *\n * @param {object} data The object.\n * @param {string} key The key or dotted path.\n * @return {unknown}\n */\nfunction literalFirst(data, key) {\n\tif (data && typeof data === 'object' && Object.hasOwn(data, key)) {\n\t\treturn data[key]\n\t}\n\treturn readPath(data, key)\n}\n\n/**\n * The request options for a target: an OCS endpoint (`/ocs/...`) needs the\n * `OCS-APIRequest` header; `prefixUrl` already serves it outside index.php.\n *\n * @param {string} url The target.\n * @return {object}\n */\nfunction ocsConfig(url) {\n\treturn /^\\/ocs\\//.test(String(url)) ? { headers: { 'OCS-APIRequest': 'true' } } : {}\n}\n\n/**\n * Up to two initials of a name, for an image field without an image.\n *\n * @param {unknown} name The name.\n * @return {string}\n */\nfunction initialsOf(name) {\n\treturn String(name || '').trim().split(/\\s+/).filter(Boolean).slice(0, 2).map((word) => word[0].toUpperCase()).join('')\n}\n\n/**\n * CnSettingsFieldsSection - a settings section declared as fields: it reads\n * the app's settings, draws the fields in one to three columns, and saves\n * them with ONE Save button for the section.\n *\n * It reads `GET url` (default `/apps/<appId>/api/settings`) and writes the\n * section's fields with `PUT saveUrl` (default the same url). The Save button\n * is on while something changed (\"Unsaved changes\"); a save checks the\n * fields first (required, pattern, min, max) and marks each failing field,\n * then says it saved or why it did not. A `secret` field never shows the\n * stored value: it says a value is stored, and is sent only when something\n * was typed.\n *\n * It renders inside CnAdminSettingsShell and CnSettingsPage, in the default\n * and the board look.\n *\n * ```vue\n * <CnSettingsFieldsSection\n * app-id=\"myapp\"\n * name=\"Connection\"\n * :columns=\"2\"\n * :fields=\"[\n * { key: 'baseUrl', label: 'Server address', required: true, pattern: '^https://', patternMessage: 'Starts with https://' },\n * { key: 'apiKey', label: 'API key', type: 'secret' },\n * { key: 'mode', label: 'Mode', type: 'select', options: [{ value: 'live', label: 'Live' }, { value: 'test', label: 'Test' }] },\n * { key: 'enabled', label: 'Enabled', type: 'switch', hint: 'Off stops every call.' },\n * ]\" />\n * ```\n */\nexport default {\n\tname: 'CnSettingsFieldsSection',\n\n\tcomponents: { CnSettingsField, CnSettingsSection, NcButton, NcLoadingIcon, NcNoteCard },\n\n\tinject: {\n\t\t/** The app's translate function; identity outside CnAppRoot. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/** The section title. */\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** The line under the title. */\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A documentation link beside the title. */\n\t\tdocUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Span the whole settings grid in the board look. */\n\t\twide: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The fields: `[{ key, label, type?, hint?, placeholder?, required?,\n\t\t * pattern?, patternMessage?, min?, max?, rows?, options?, optionsUrl?,\n\t\t * optionsPath?, optionLabel?, optionValue?, default?, readOnly?, wide?,\n\t\t * url?, valuePath?, saveUrl?, saveMethod?, saveKey?, saveParams?, uploadUrl?,\n\t\t * uploadField?, uploadParams?, uploadValuePath?, initials?, initialsFrom? }]`.\n\t\t * `type` is `text` (default), `textarea`, `number`, `switch`, `select`,\n\t\t * `secret` or `image`. `key` names the setting; a dotted key reads a\n\t\t * nested value and is written as written. A field with its own `url`\n\t\t * is read there (at `valuePath`, default its key) and saved to its\n\t\t * `saveUrl` (default that `url`) with `saveMethod` (default POST) under\n\t\t * `saveKey` (default its key), with `saveParams` merged into the body,\n\t\t * so one section can hold the settings of several apps. A target under\n\t\t * `/ocs/` is sent the `OCS-APIRequest` header. An `image` uploads at once to `uploadUrl`. Labels,\n\t\t * hints, placeholders and messages go through the app's translate\n\t\t * function.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-section-declared-as-fields-reads-and-saves-the-apps-settings\n\t\t */\n\t\tfields: {\n\t\t\ttype: Array,\n\t\t\trequired: true,\n\t\t},\n\n\t\t/** Columns of the field grid: 1, 2 or 3. A narrow card stacks them. */\n\t\tcolumns: {\n\t\t\ttype: Number,\n\t\t\tdefault: 1,\n\t\t\tvalidator: (value) => [1, 2, 3].includes(value),\n\t\t},\n\n\t\t/** The app id, for the default url `/apps/<appId>/api/settings`. */\n\t\tappId: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the settings are read (`GET`); app-absolute or a full URL. */\n\t\turl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** Where the section saves; defaults to `url`. */\n\t\tsaveUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The method of the save request. */\n\t\tsaveMethod: {\n\t\t\ttype: String,\n\t\t\tdefault: 'PUT',\n\t\t\tvalidator: (value) => ['PUT', 'POST', 'PATCH'].includes(String(value).toUpperCase()),\n\t\t},\n\n\t\t/** A dotted path to the values in the GET answer; empty reads the answer itself. */\n\t\tvaluesPath: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The Save button's label. Defaults to \"Save\". */\n\t\tsaveLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['saved', 'save-error'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\tbaseline: {},\n\t\t\tstoredSecrets: {},\n\t\t\t// Field key to the message of a read target that failed.\n\t\t\tunreadable: {},\n\t\t\terrors: {},\n\t\t\tloading: true,\n\t\t\tloadError: '',\n\t\t\tsaving: false,\n\t\t\tnotice: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {number} The column count, 1 to 3. */\n\t\tcolumnCount() {\n\t\t\treturn [1, 2, 3].includes(this.columns) ? this.columns : 1\n\t\t},\n\n\t\t/** @return {string} Where the settings are read: `url`, else the app's settings endpoint. */\n\t\treadTarget() {\n\t\t\treturn this.url || (this.appId ? `/apps/${this.appId}/api/settings` : '')\n\t\t},\n\n\t\t/** @return {string} Where the section saves: `saveUrl`, else the read target. */\n\t\twriteTarget() {\n\t\t\treturn this.saveUrl || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * The declared fields with their text translated and a secret's stored state.\n\t\t *\n\t\t * @return {Array<object>}\n\t\t */\n\t\tresolvedFields() {\n\t\t\treturn (Array.isArray(this.fields) ? this.fields : [])\n\t\t\t\t.filter((field) => field && typeof field.key === 'string' && field.key !== '')\n\t\t\t\t.map((field) => ({\n\t\t\t\t\t...field,\n\t\t\t\t\tlabel: this.tr(field.label || field.key),\n\t\t\t\t\thint: this.tr(field.hint || ''),\n\t\t\t\t\tplaceholder: this.tr(field.placeholder || ''),\n\t\t\t\t\tsecretSet: field.type === 'secret' ? !!this.storedSecrets[field.key] : undefined,\n\t\t\t\t\tinitials: field.type === 'image' ? initialsOf(field.initialsFrom ? this.form[field.initialsFrom] : field.initials) : undefined,\n\t\t\t\t\treadOnly: field.readOnly || !!this.unreadable[field.key],\n\t\t\t\t}))\n\t\t},\n\n\t\t/**\n\t\t * Whether something changed since the last load or save.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tdirty() {\n\t\t\treturn this.resolvedFields.some((field) => field.type !== 'image' && !this.same(this.form[field.key], this.baseline[field.key]))\n\t\t},\n\n\t\t/** @return {string} The Save button's label. */\n\t\tresolvedSaveLabel() {\n\t\t\treturn this.saveLabel ? this.tr(this.saveLabel) : t('nextcloud-vue', 'Save')\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.load()\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * @param {string} value A declared string.\n\t\t * @return {string} It through the app's translate function.\n\t\t */\n\t\ttr(value) {\n\t\t\treturn typeof value === 'string' && value !== '' ? this.cnTranslate(value) : (value || '')\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} a A value.\n\t\t * @param {unknown} b Another.\n\t\t * @return {boolean} Whether they count as the same setting.\n\t\t */\n\t\tsame(a, b) {\n\t\t\tconst empty = (v) => v === null || v === undefined || v === ''\n\t\t\tif (empty(a) && empty(b)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t},\n\n\t\t/**\n\t\t * Change a field's value; its error goes until the next save.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {unknown} value The value.\n\t\t * @return {void}\n\t\t */\n\t\tsetValue(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tif (this.errors[field.key]) {\n\t\t\t\tconst { [field.key]: _gone, ...rest } = this.errors\n\t\t\t\tthis.errors = rest\n\t\t\t}\n\t\t\tthis.notice = null\n\t\t},\n\n\t\t/**\n\t\t * Read the settings and fill the fields; a secret's value is never put\n\t\t * in the form, only whether one is stored.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync load() {\n\t\t\tthis.loading = true\n\t\t\tthis.loadError = ''\n\t\t\ttry {\n\t\t\t\t// One GET per distinct read target; the section's own target must\n\t\t\t\t// answer, a field's own target may fail on its own.\n\t\t\t\tconst targets = [...new Set(this.fields\n\t\t\t\t\t.filter((field) => field && field.key)\n\t\t\t\t\t.map((field) => this.readUrlOf(field))\n\t\t\t\t\t.filter(Boolean))]\n\t\t\t\tconst answers = {}\n\t\t\t\tconst failures = {}\n\t\t\t\tawait Promise.all(targets.map(async (target) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await axios.get(prefixUrl(target), ocsConfig(target))\n\t\t\t\t\t\tanswers[target] = response?.data ?? {}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailures[target] = error\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t\t\tif (this.readTarget && failures[this.readTarget]) {\n\t\t\t\t\tthrow failures[this.readTarget]\n\t\t\t\t}\n\t\t\t\tconst form = {}\n\t\t\t\tconst stored = {}\n\t\t\t\tconst unreadable = {}\n\t\t\t\tfor (const field of this.fields || []) {\n\t\t\t\t\tif (!field || !field.key) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst target = this.readUrlOf(field)\n\t\t\t\t\tif (target && failures[target]) {\n\t\t\t\t\t\tunreadable[field.key] = t('nextcloud-vue', 'This value could not be loaded: {reason}', { reason: serverErrorMessage(failures[target]) })\n\t\t\t\t\t}\n\t\t\t\t\tconst raw = this.readValue(field, target ? answers[target] : null)\n\t\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\t\tstored[field.key] = raw !== null && raw !== undefined && raw !== '' && raw !== false\n\t\t\t\t\t\tform[field.key] = ''\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tform[field.key] = raw === undefined ? (field.default ?? (field.type === 'switch' ? false : '')) : raw\n\t\t\t\t}\n\t\t\t\tthis.form = form\n\t\t\t\tthis.baseline = { ...form }\n\t\t\t\tthis.storedSecrets = stored\n\t\t\t\tthis.unreadable = unreadable\n\t\t\t\tthis.errors = {}\n\t\t\t} catch (error) {\n\t\t\t\tthis.loadError = t('nextcloud-vue', 'The settings could not be loaded: {reason}', { reason: serverErrorMessage(error) })\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 * Where a field is read: its own `url`, else the section's.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-field-can-read-and-save-elsewhere\n\t\t */\n\t\treadUrlOf(field) {\n\t\t\treturn field.url || this.readTarget\n\t\t},\n\n\t\t/**\n\t\t * A field's value in its read answer: at its `valuePath` (a field with its\n\t\t * own `url`), else at the section's `valuesPath`, then its `key`. A key\n\t\t * the answer holds as written wins over reading it as a dotted path.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {object|null} data The answer of the field's read target.\n\t\t * @return {unknown}\n\t\t */\n\t\treadValue(field, data) {\n\t\t\tif (!data || typeof data !== 'object') {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (field.url) {\n\t\t\t\treturn literalFirst(data, field.valuePath || field.key)\n\t\t\t}\n\t\t\tconst values = (this.valuesPath ? literalFirst(data, this.valuesPath) : data) || {}\n\t\t\treturn literalFirst(values, field.key)\n\t\t},\n\n\t\t/**\n\t\t * Check the fields: required, pattern, and a number's min and max.\n\t\t *\n\t\t * @return {object} Field key to message; empty when all pass.\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-a-failing-field-says-why\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = {}\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tconst empty = value === null || value === undefined || value === ''\n\t\t\t\tif (field.type === 'switch' || field.type === 'image' || this.unreadable[field.key]) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.required && empty && !(field.type === 'secret' && field.secretSet)) {\n\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} is required.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (empty) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.pattern && !new RegExp(field.pattern).test(String(value))) {\n\t\t\t\t\terrors[field.key] = field.patternMessage ? this.tr(field.patternMessage) : t('nextcloud-vue', '{field} is not in the right form.', { field: field.label })\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'number') {\n\t\t\t\t\tconst number = Number(value)\n\t\t\t\t\tif (Number.isNaN(number)) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be a number.', { field: field.label })\n\t\t\t\t\t} else if (field.min !== undefined && number < field.min) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at least {min}.', { field: field.label, min: field.min })\n\t\t\t\t\t} else if (field.max !== undefined && number > field.max) {\n\t\t\t\t\t\terrors[field.key] = t('nextcloud-vue', '{field} must be at most {max}.', { field: field.label, max: field.max })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\n\t\t/**\n\t\t * Save the section's fields in one request, after checking them. A\n\t\t * secret is sent only when something was typed.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/settings-fields-section/specs/settings-fields-section/spec.md#requirement-one-save-per-section-with-a-dirty-state\n\t\t */\n\t\tasync save() {\n\t\t\tif (this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errors = this.validate()\n\t\t\tconst failing = Object.keys(this.errors)\n\t\t\tif (failing.length > 0) {\n\t\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'Check the marked fields.') }\n\t\t\t\tthis.$nextTick(() => {\n\t\t\t\t\tconst el = this.$el?.querySelector?.('[aria-invalid=\"true\"], .cn-settings-field__error')\n\t\t\t\t\tconst control = el?.closest?.('.cn-settings-field')?.querySelector?.('input, textarea, [role=\"combobox\"]')\n\t\t\t\t\tcontrol?.focus?.()\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// The changed fields, one request per save target, each carrying its\n\t\t\t// own fields under their `saveKey`. A secret goes only when typed; an\n\t\t\t// image is uploaded on its own; a field that could not be read is left out.\n\t\t\tconst groups = new Map()\n\t\t\tfor (const field of this.resolvedFields) {\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\tif (field.type === 'image' || this.unreadable[field.key] || this.same(value, this.baseline[field.key])) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (field.type === 'secret' && (value === '' || value === null || value === undefined)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst url = field.saveUrl || (field.url ? field.url : this.writeTarget)\n\t\t\t\tconst method = String(field.saveMethod || (field.saveUrl || field.url ? 'POST' : this.saveMethod)).toLowerCase()\n\t\t\t\tconst id = `${method} ${url}`\n\t\t\t\tif (!groups.has(id)) {\n\t\t\t\t\tgroups.set(id, { url, method, fields: [], data: {} })\n\t\t\t\t}\n\t\t\t\tconst group = groups.get(id)\n\t\t\t\tgroup.fields.push(field)\n\t\t\t\tObject.assign(group.data, field.saveParams || {})\n\t\t\t\tgroup.data[field.saveKey || field.key] = value\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.notice = null\n\t\t\tconst failed = []\n\t\t\tconst sent = {}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait axios.request({ url: prefixUrl(group.url), method: group.method, data: group.data, ...ocsConfig(group.url) })\n\t\t\t\t\tObject.assign(sent, group.data)\n\t\t\t\t\tthis.acceptSaved(group.fields)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailed.push({ group, error })\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.saving = false\n\t\t\tif (failed.length === 0) {\n\t\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t\t\t/**\n\t\t\t\t * @event saved The section saved. Payload: what was sent, by save key.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', sent)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst reasons = failed.map(({ group, error }) => (groups.size > 1\n\t\t\t\t? t('nextcloud-vue', '{fields}: {reason}', { fields: group.fields.map((field) => field.label).join(', '), reason: serverErrorMessage(error) })\n\t\t\t\t: serverErrorMessage(error)))\n\t\t\tthis.notice = { type: 'error', text: t('nextcloud-vue', 'The settings could not be saved: {reason}', { reason: reasons.join('; ') }) }\n\t\t\t/**\n\t\t\t * @event save-error A save request failed. Payload: the first error.\n\t\t\t */\n\t\t\tthis.$emit('save-error', failed[0].error)\n\t\t},\n\n\t\t/**\n\t\t * Take saved fields as the new baseline; a saved secret reads as stored.\n\t\t *\n\t\t * @param {Array<object>} fields The fields that saved.\n\t\t * @return {void}\n\t\t */\n\t\tacceptSaved(fields) {\n\t\t\tconst form = { ...this.form }\n\t\t\tconst baseline = { ...this.baseline }\n\t\t\tconst stored = { ...this.storedSecrets }\n\t\t\tfor (const field of fields) {\n\t\t\t\tif (field.type === 'secret') {\n\t\t\t\t\tstored[field.key] = true\n\t\t\t\t\tform[field.key] = ''\n\t\t\t\t}\n\t\t\t\tbaseline[field.key] = form[field.key]\n\t\t\t}\n\t\t\tthis.form = form\n\t\t\tthis.baseline = baseline\n\t\t\tthis.storedSecrets = stored\n\t\t},\n\n\t\t/**\n\t\t * An image field uploaded a file: its new value is the baseline too.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @param {string} value The new image url.\n\t\t * @return {void}\n\t\t */\n\t\tonUploaded(field, value) {\n\t\t\tthis.form = { ...this.form, [field.key]: value }\n\t\t\tthis.baseline = { ...this.baseline, [field.key]: value }\n\t\t\tthis.notice = { type: 'success', text: t('nextcloud-vue', 'Saved.') }\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-settings-fields {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tcontainer-type: inline-size;\n}\n\n.cn-settings-fields__grid {\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 1fr);\n\tgap: 16px 20px;\n}\n\n/* Two or three columns where the card is wide enough; stacked otherwise. */\n@container (min-width: 520px) {\n\t.cn-settings-fields__grid--2,\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(2, minmax(0, 1fr));\n\t}\n}\n\n@container (min-width: 780px) {\n\t.cn-settings-fields__grid--3 {\n\t\tgrid-template-columns: repeat(3, minmax(0, 1fr));\n\t}\n}\n\n.cn-settings-fields__field--wide {\n\tgrid-column: 1 / -1;\n}\n\n.cn-settings-fields__save {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tgap: 12px;\n}\n\n.cn-settings-fields__dirty {\n\tfont-size: 14px;\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["_createBlock","_createElementBlock","_normalizeClass","_Fragment","_renderList","_createElementVNode","_toDisplayString","_createTextVNode","_createVNode"],"mappings":";;AA8CQ,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oDAAO,GAAA;;;AACJ,EAAA,KAAA,EAAA,2BAAA;AAAA,EAAA,aAAA,EAAA,0BAAA;;;;;;;;;;uBApCfA;AACC,IAAA,IAAI,EAAE,MAAI,CAAA,IAAA;AACV,IAAA,WAAW,EAAE,MAAU,CAAA,WAAA;AACvB,IAAA,MAAM,EAAE,MAAK,CAAA,MAAA;AACb,IAAA,IAAI,EAAE,MAAI,CAAA,IAAA;AACV,IAAA,OAAO,EAAE,KAAO,CAAA,OAAA;AAChB,IAAA,KAAK,EAAE,KAAS,CAAA,SAAA,KAAA,EAAA;AAChB,IAAA,YAAS,EAAA,KAAA,CAAA,SAAA;AACT,IAAA,OAAO,EAAE,QAAI,CAAA,IAAA;AACb,IAAA,aAAU,EAAC,4BAA4B;;qBACtC;AAAW,MAAA,CAAA,CAAA,KAAA,CAAA,OAAI,IAAA,KAAA,CAAA,SAAA,KAAA,EAAA;wBAAfC;;iBACI,EAAC,oBAAoB;AACxB,YAAA,UAAQ,EAAR,EA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A,CAAA,CAAA,eAAA,EAAA,iBAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;uBAGG,EAAC,SAAS;AACjB,gBAAA,IAAI,EAAC,QAAK;gBACT,QAAQ,EAAE,KAAM,CAAA,MAAA,IAAA,CAAK,QAAA,CAAA,KAAA;AACtB,gBAAA,aAAS,EAAA,yBAAA;;iCAGE;AAAA,kBAAAC,eAAA,CAAA;;;;iBAFR,KAAA,CAAA,MAAA;;4BAAA,MAAA;kCACF,MAAE;wBAAFC,WAAE,CAAA,wBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import script from './CnSetupWizard.vue2.js';
2
2
  import { render } from './CnSetupWizard.vue3.js';
3
3
 
4
4
  script.render = render;
5
- script.__scopeId = "data-v-5670b06f";
5
+ script.__scopeId = "data-v-32874a44";
6
6
  const __sfc_main = script;
7
7
 
8
8
  export { __sfc_main as default };
@@ -5,6 +5,7 @@ import __sfc_main$1 from '../CnChoiceCards/CnChoiceCards.vue.js';
5
5
  import __sfc_main$2 from '../CnLeafDependencySettings/CnLeafDependencySettings.vue.js';
6
6
  import __sfc_main from '../CnWizardDialog/CnWizardDialog.vue.js';
7
7
  import { missingRequiredApps, readServerAppStatuses, checkDependencies, isDependencyResolved } from '../../composables/useDependencyCheck.js';
8
+ import { useLook } from '../../composables/useLook.js';
8
9
  import { useSetupStatus } from '../../composables/useSetupStatus.js';
9
10
  import { fieldsFromSchema } from '../../utils/schema.js';
10
11
 
@@ -221,12 +222,13 @@ var script = {
221
222
  * @return {object} `setupStatus` / `setupStatusLoading` for the option resolver.
222
223
  */
223
224
  setup(props) {
225
+ const { isBoard } = useLook();
224
226
  const wantsSource = (props.steps || []).some((s) => s && s.optionsSource);
225
227
  if (!wantsSource) {
226
- return {}
228
+ return { isBoard }
227
229
  }
228
230
  const { status, loading } = useSetupStatus(props.appId, { setup: { steps: props.steps } });
229
- return { setupStatus: status, setupStatusLoading: loading }
231
+ return { isBoard, setupStatus: status, setupStatusLoading: loading }
230
232
  },
231
233
 
232
234
  data() {
@@ -586,6 +588,18 @@ var script = {
586
588
  return raw === '' ? '' : this.cnTranslate(raw)
587
589
  },
588
590
 
591
+ /**
592
+ * The footnote under a choice step's options, from the step's `note`
593
+ * (or `footnote`), translated like the body.
594
+ *
595
+ * @param {object} step The step declaration.
596
+ * @return {string} The translated footnote, or ''.
597
+ */
598
+ stepNote(step) {
599
+ const raw = (step && (step.note || step.footnote)) || '';
600
+ return raw === '' ? '' : this.cnTranslate(raw)
601
+ },
602
+
589
603
  stepSlot(step) {
590
604
  return 'step-' + step.id
591
605
  },