@conduction/nextcloud-vue 2.174.0 → 2.175.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.
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
- package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +63 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +63 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1134 -499
- package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
- package/dist/esm/utils/captureLocation.js +32 -0
- package/dist/esm/utils/captureLocation.js.map +1 -0
- package/dist/esm/utils/childRecordTotals.js +157 -0
- package/dist/esm/utils/childRecordTotals.js.map +1 -0
- package/dist/esm/utils/isoDuration.js +51 -1
- package/dist/esm/utils/isoDuration.js.map +1 -1
- package/dist/esm/utils/qr.js +649 -0
- package/dist/esm/utils/qr.js.map +1 -0
- package/dist/esm/utils/schema.js +3 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/templateVariables.js +54 -0
- package/dist/esm/utils/templateVariables.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +20307 -14544
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1134 -499
- package/l10n/en.json +63 -1
- package/l10n/nl.json +63 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
- package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
- package/src/components/CnBlockListEditor/index.js +9 -0
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
- package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
- package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
- package/src/components/CnChoiceMatrix/index.js +9 -0
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
- package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
- package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
- package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
- package/src/components/CnDisplayScreen/index.js +9 -0
- package/src/components/CnDurationField/CnDurationField.vue +330 -5
- package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
- package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
- package/src/components/CnGeoCaptureField/index.js +9 -0
- package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
- package/src/components/CnQrCode/CnQrCode.vue +321 -0
- package/src/components/CnQrCode/index.js +9 -0
- package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
- package/src/components/CnRevealField/CnRevealField.vue +273 -0
- package/src/components/CnRevealField/index.js +9 -0
- package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
- package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
- package/src/components/CnTransferCard/index.js +9 -0
- package/src/components/CnTreeView/CnTreeNode.vue +145 -2
- package/src/components/CnTreeView/CnTreeView.vue +210 -6
- package/src/components/index.js +7 -0
- package/src/index.js +8 -0
- package/src/utils/captureLocation.js +29 -0
- package/src/utils/childRecordTotals.js +153 -0
- package/src/utils/isoDuration.js +50 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnCreateFormWidget.vue2.js","sources":["../../../../src/components/CnCreateFormWidget/CnCreateFormWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnFormWidgetBase\n\t\tv-bind=\"rootAttrs\"\n\t\tblockClass=\"cn-create-form-widget\"\n\t\t:fields=\"formFields\"\n\t\t:model=\"form\"\n\t\t:canSubmit=\"canSubmit\"\n\t\t:submitting=\"saving\"\n\t\t:submitLabel=\"submitLabel\"\n\t\t:submittingLabel=\"savingLabel\"\n\t\t:errorMessage=\"errorMessage\"\n\t\t@update:field=\"onFieldUpdate\"\n\t\t@submit=\"onSubmit\">\n\t\t<template v-for=\"field in slotFields\" #[`field-${field.key}`] :key=\"field.key\">\n\t\t\t<CnResourceSelect\n\t\t\t\tv-if=\"field.type === 'reference'\"\n\t\t\t\t:register=\"field.register || register\"\n\t\t\t\t:schema=\"field.schema\"\n\t\t\t\t:labelField=\"field.labelField || 'name'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:inputLabel=\"field.label\"\n\t\t\t\t:preload=\"true\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:allowCreate=\"false\"\n\t\t\t\t@update:modelValue=\"(id) => onFieldUpdate({ key: field.key, value: id || '' })\" />\n\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\tv-else-if=\"field.type === 'checkbox'\"\n\t\t\t\t:modelValue=\"form[field.key] === true\"\n\t\t\t\t:data-testid=\"`cn-create-form-checkbox-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\">\n\t\t\t\t{{ field.label }}\n\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t<a\n\t\t\t\tv-if=\"linkHref(field)\"\n\t\t\t\tclass=\"cn-create-form-widget__link\"\n\t\t\t\t:href=\"linkHref(field)\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t:data-testid=\"`cn-create-form-link-${field.key}`\">\n\t\t\t\t{{ field.linkLabel }}\n\t\t\t</a>\n\t\t</template>\n\n\t\t<template #actions>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:wide=\"content.wideSubmit !== false\"\n\t\t\t\t:disabled=\"saving || !canSubmit\"\n\t\t\t\tdata-testid=\"cn-create-form-submit\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t<template v-if=\"content.submitIcon\" #icon>\n\t\t\t\t\t<CnIcon :name=\"content.submitIcon\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ saving ? savingLabel : submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnFormWidgetBase>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'\nimport { camelize } from 'vue'\nimport CnFormWidgetBase from '../CnFormWidgetBase/CnFormWidgetBase.vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnResourceSelect from '../CnResourceSelect/CnResourceSelect.vue'\nimport { useObjectStore } from '../../store/index.js'\nimport { isOptionsFrom, loadOptionsFrom } from '../../utils/optionsFrom.js'\nimport { resolveDeepTokens, resolveFilterValue } from '../../utils/resolveFilterTokens.js'\n\n/**\n * CnCreateFormWidget — the `create-form` dashboard widget: a card that creates\n * one OpenRegister object from the fields its manifest declares (PqLoyaliteit\n * \"Aanmelding loyaliteit\").\n *\n * `content`: `{ register, schema, fields, values?, submitLabel?, submitIcon?,\n * successMessage?, wideSubmit? }`. Each field is `{ key, label, type?, required?,\n * default?, optionsFrom?, schema?, labelField?, link? }`:\n *\n * - `type`: `text` (default), `select` (options from `optionsFrom`, the shape a\n * page filter takes), `reference` (a search over `schema`, labelled by\n * `labelField`) or `checkbox`. A required checkbox must be ticked, any other\n * required field filled, before the create is allowed.\n * - `default` seeds the field and may be a `@workspace.<key>` token, so a page\n * filter preselects it.\n * - `link` (`{ label, from: { field, path } }`, on a checkbox or reference\n * field) draws a link under it to the value at `path` of the option chosen in\n * the select `field`, such as a programme's terms (`optionsFrom.keepFields`\n * keeps that value on the option).\n *\n * `values` are written with every create, after token resolution (`@now`,\n * `@workspace.<key>`). After a create the fields return to their defaults.\n *\n * @spec openspec/changes/create-form-widget/specs/create-form-widget/spec.md#requirement-a-dashboard-card-can-create-an-object-from-declared-fields\n */\nexport default {\n\tname: 'CnCreateFormWidget',\n\n\tcomponents: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch },\n\n\tinject: {\n\t\t/** Page-level workspace context from CnDashboardPage, for `@workspace.<key>` defaults. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host app's translate function. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\t// A dashboard binds the widget's `content` keys as attributes too; they must\n\t// not reach CnFormWidgetBase's own props.\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * The widget config, see the component description.\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\temits: ['saved'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\toptionsByField: {},\n\t\t\tsaving: false,\n\t\t\terrorMessage: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\trootAttrs() {\n\t\t\tconst own = new Set(Object.keys(CnFormWidgetBase.props || {}))\n\t\t\treturn Object.fromEntries(Object.entries(this.$attrs).filter(([key]) => !own.has(camelize(key))))\n\t\t},\n\n\t\tregister() {\n\t\t\treturn this.content.register || ''\n\t\t},\n\n\t\tschema() {\n\t\t\treturn this.content.schema || ''\n\t\t},\n\n\t\tfields() {\n\t\t\treturn (Array.isArray(this.content.fields) ? this.content.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\ttype: field.type || 'text',\n\t\t\t\t\tlabel: this.copy(field.label || ''),\n\t\t\t\t\tlinkLabel: this.copy(field.link?.label || ''),\n\t\t\t\t}))\n\t\t},\n\n\t\t/** The descriptors CnFormWidgetBase draws; reference and checkbox fields come from slots. */\n\t\tformFields() {\n\t\t\treturn this.fields.map((field) => (field.type === 'select'\n\t\t\t\t? { key: field.key, type: 'select', label: field.label, options: this.selectOptions(field) }\n\t\t\t\t: { key: field.key, type: field.type === 'text' ? 'text' : 'custom', label: field.type === 'checkbox' ? '' : field.label }))\n\t\t},\n\n\t\t/** The fields drawn through a `field-<key>` slot: a reference or a checkbox. */\n\t\tslotFields() {\n\t\t\treturn this.fields.filter((field) => field.type === 'reference' || field.type === 'checkbox')\n\t\t},\n\n\t\tworkspace() {\n\t\t\tconst c = this.cnWorkspaceContext\n\t\t\tconst bag = c && typeof c === 'object' && 'value' in c ? c.value : c\n\t\t\treturn bag && typeof bag === 'object' ? bag : {}\n\t\t},\n\n\t\t/** The defaults, `@workspace.<key>` resolved; recomputed when a page filter changes. */\n\t\tdefaults() {\n\t\t\tconst out = {}\n\t\t\tfor (const field of this.fields) {\n\t\t\t\tconst raw = field.default !== undefined ? field.default : (field.type === 'checkbox' ? false : '')\n\t\t\t\tconst value = resolveFilterValue(raw, { workspace: this.workspace })\n\t\t\t\tout[field.key] = typeof value === 'string' && value.startsWith('@') ? '' : value\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\n\t\tcanSubmit() {\n\t\t\treturn this.fields.every((field) => {\n\t\t\t\tif (field.required !== true) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\treturn field.type === 'checkbox' ? value === true : value !== undefined && value !== null && value !== ''\n\t\t\t})\n\t\t},\n\n\t\tsubmitLabel() {\n\t\t\treturn this.copy(this.content.submitLabel) || t('nextcloud-vue', 'Create')\n\t\t},\n\n\t\tsavingLabel() {\n\t\t\treturn t('nextcloud-vue', 'Creating…')\n\t\t},\n\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\t},\n\n\twatch: {\n\t\tdefaults: {\n\t\t\timmediate: true,\n\t\t\thandler(next, previous) {\n\t\t\t\tfor (const [key, value] of Object.entries(next)) {\n\t\t\t\t\t// A default that moved (the page filter changed) follows into\n\t\t\t\t\t// a field the reader left at the previous default.\n\t\t\t\t\tif (this.form[key] === undefined || (previous && this.form[key] === previous[key])) {\n\t\t\t\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.loadOptions()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the host's translate, else the library's.\n\t\t *\n\t\t * @param {string} key The string.\n\t\t * @return {string}\n\t\t */\n\t\tcopy(key) {\n\t\t\tif (typeof key !== 'string' || key === '') {\n\t\t\t\treturn key\n\t\t\t}\n\t\t\tconst host = typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : key\n\t\t\treturn typeof host === 'string' && host !== '' ? host : key\n\t\t},\n\n\t\t/**\n\t\t * @param {object} field A select field.\n\t\t * @return {Array<{value: (string|number), label: string}>}\n\t\t */\n\t\tselectOptions(field) {\n\t\t\treturn (this.optionsByField[field.key] || []).map((o) => ({ value: o.id, label: o.label }))\n\t\t},\n\n\t\t/**\n\t\t * The href of a field's link: the value at `link.from.path` of the option\n\t\t * chosen in the select `link.from.field`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string} The href, or '' when there is none.\n\t\t */\n\t\tlinkHref(field) {\n\t\t\tconst from = field.link?.from\n\t\t\tif (!from || !from.field || !from.path) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst chosen = (this.optionsByField[from.field] || []).find((o) => String(o.id) === String(this.form[from.field]))\n\t\t\tconst href = chosen?.data?.[from.path]\n\t\t\treturn typeof href === 'string' && /^https?:\\/\\//i.test(href) ? href : ''\n\t\t},\n\n\t\tasync loadOptions() {\n\t\t\tconst ctx = { workspace: this.workspace }\n\t\t\tawait Promise.all(this.fields\n\t\t\t\t.filter((field) => field.type === 'select' && isOptionsFrom(field.optionsFrom))\n\t\t\t\t.map(async (field) => {\n\t\t\t\t\tlet options\n\t\t\t\t\ttry {\n\t\t\t\t\t\toptions = await loadOptionsFrom(field.optionsFrom, ctx)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\toptions = []\n\t\t\t\t\t}\n\t\t\t\t\tthis.optionsByField = { ...this.optionsByField, [field.key]: options }\n\t\t\t\t\tif ((this.form[field.key] === '' || this.form[field.key] === undefined) && options.length > 0) {\n\t\t\t\t\t\tthis.form = { ...this.form, [field.key]: options[0].id }\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t},\n\n\t\tonFieldUpdate({ key, value }) {\n\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\tthis.errorMessage = ''\n\t\t},\n\n\t\t/**\n\t\t * Create the object from the fields and the declared `values`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.canSubmit || this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst store = (() => {\n\t\t\t\ttry {\n\t\t\t\t\treturn useObjectStore()\n\t\t\t\t} catch {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})()\n\t\t\tif (!store || !this.register || !this.schema) {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.errorMessage = ''\n\t\t\ttry {\n\t\t\t\tconst values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace })\n\t\t\t\tconst payload = { ...values }\n\t\t\t\tfor (const field of this.fields) {\n\t\t\t\t\tpayload[field.key] = this.form[field.key]\n\t\t\t\t}\n\t\t\t\tif (typeof store.registerObjectType === 'function' && !store.objectTypeRegistry?.[this.typeSlug]) {\n\t\t\t\t\tstore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t}\n\t\t\t\tconst result = await store.saveObject(this.typeSlug, payload)\n\t\t\t\tif (!result) {\n\t\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.form = { ...this.form, ...this.defaults }\n\t\t\t\t/**\n\t\t\t\t * @event saved The object was created. Payload: what the store answered.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', result)\n\t\t\t} catch {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-create-form-widget__link {\n\tdisplay: inline-block;\n\tmargin-top: 8px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["CnFormWidg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O,EAAA;IAC5D,IAAI,CAAC,MAAM,EAAE;KACZ,IAAI,CAAC,YAAW,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA,IAAKA,SAAC,CAAC,eAAe,EAAE,2BAA2B,EAAA;KAC1G,MAAK;AACN,KAAA;AACA,IAAA,IAAI,CAAC,IAAG,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,QAAS,GAAA;AAC7C;;;IAGA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAA;AAC3B,IAAA,CAAE,MAAM;IACP,IAAI,CAAC,YAAW,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA,IAAKA,SAAC,CAAC,eAAe,EAAE,2BAA2B,EAAA;AAC3G,IAAA,SAAU;AACT,IAAA,IAAI,CAAC,MAAO,GAAE,MAAI;AACnB,IAAA;GACA;EACD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CnCreateFormWidget.vue2.js","sources":["../../../../src/components/CnCreateFormWidget/CnCreateFormWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnFormWidgetBase\n\t\tv-bind=\"rootAttrs\"\n\t\tblockClass=\"cn-create-form-widget\"\n\t\t:fields=\"formFields\"\n\t\t:model=\"form\"\n\t\t:canSubmit=\"canSubmit\"\n\t\t:submitting=\"saving\"\n\t\t:submitLabel=\"submitLabel\"\n\t\t:submittingLabel=\"savingLabel\"\n\t\t:errorMessage=\"errorMessage\"\n\t\t@update:field=\"onFieldUpdate\"\n\t\t@submit=\"onSubmit\">\n\t\t<template v-for=\"field in slotFields\" #[`field-${field.key}`] :key=\"field.key\">\n\t\t\t<CnResourceSelect\n\t\t\t\tv-if=\"field.type === 'reference'\"\n\t\t\t\t:register=\"field.register || register\"\n\t\t\t\t:schema=\"field.schema\"\n\t\t\t\t:labelField=\"field.labelField || 'name'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:inputLabel=\"field.label\"\n\t\t\t\t:preload=\"true\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:allowCreate=\"false\"\n\t\t\t\t@update:modelValue=\"(id) => onFieldUpdate({ key: field.key, value: id || '' })\" />\n\t\t\t<NcTextField\n\t\t\t\tv-else-if=\"field.type === 'date' || field.type === 'number'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:type=\"field.type\"\n\t\t\t\t:label=\"field.label\"\n\t\t\t\t:step=\"field.type === 'number' ? (field.step || 'any') : undefined\"\n\t\t\t\t:min=\"field.min\"\n\t\t\t\t:max=\"field.max\"\n\t\t\t\t:data-testid=\"`cn-create-form-input-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\" />\n\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\tv-else-if=\"field.type === 'checkbox'\"\n\t\t\t\t:modelValue=\"form[field.key] === true\"\n\t\t\t\t:data-testid=\"`cn-create-form-checkbox-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\">\n\t\t\t\t{{ field.label }}\n\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t<a\n\t\t\t\tv-if=\"linkHref(field)\"\n\t\t\t\tclass=\"cn-create-form-widget__link\"\n\t\t\t\t:href=\"linkHref(field)\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t:data-testid=\"`cn-create-form-link-${field.key}`\">\n\t\t\t\t{{ field.linkLabel }}\n\t\t\t</a>\n\t\t</template>\n\n\t\t<template #actions>\n\t\t\t<span v-if=\"timerConfig && timerStartedAt !== null\"\n\t\t\t\tclass=\"cn-create-form-widget__elapsed\"\n\t\t\t\trole=\"timer\"\n\t\t\t\tdata-testid=\"cn-create-form-elapsed\">{{ elapsedText }}</span>\n\t\t\t<NcButton\n\t\t\t\tv-if=\"timerConfig\"\n\t\t\t\tdata-testid=\"cn-create-form-timer\"\n\t\t\t\t@click=\"toggleTimer\">\n\t\t\t\t{{ timerStartedAt === null ? timerStartLabel : timerStopLabel }}\n\t\t\t</NcButton>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:wide=\"content.wideSubmit !== false\"\n\t\t\t\t:disabled=\"saving || !canSubmit\"\n\t\t\t\tdata-testid=\"cn-create-form-submit\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t<template v-if=\"content.submitIcon\" #icon>\n\t\t\t\t\t<CnIcon :name=\"content.submitIcon\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ saving ? savingLabel : submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnFormWidgetBase>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcTextField } from '@nextcloud/vue'\nimport { camelize } from 'vue'\nimport CnFormWidgetBase from '../CnFormWidgetBase/CnFormWidgetBase.vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnResourceSelect from '../CnResourceSelect/CnResourceSelect.vue'\nimport { useObjectStore } from '../../store/index.js'\nimport { isOptionsFrom, loadOptionsFrom } from '../../utils/optionsFrom.js'\nimport { resolveDeepTokens, resolveFilterValue } from '../../utils/resolveFilterTokens.js'\n\n/**\n * CnCreateFormWidget — the `create-form` dashboard widget: a card that creates\n * one OpenRegister object from the fields its manifest declares (PqLoyaliteit\n * \"Aanmelding loyaliteit\").\n *\n * `content`: `{ register, schema, fields, values?, submitLabel?, submitIcon?,\n * successMessage?, wideSubmit? }`. Each field is `{ key, label, type?, required?,\n * default?, optionsFrom?, schema?, labelField?, link? }`:\n *\n * - `type`: `text` (default), `select` (options from `optionsFrom`, the shape a\n * page filter takes), `reference` (a search over `schema`, labelled by\n * `labelField`) or `checkbox`. A required checkbox must be ticked, any other\n * required field filled, before the create is allowed.\n * - `default` seeds the field and may be a `@workspace.<key>` token, so a page\n * filter preselects it.\n * - `link` (`{ label, from: { field, path } }`, on a checkbox or reference\n * field) draws a link under it to the value at `path` of the option chosen in\n * the select `field`, such as a programme's terms (`optionsFrom.keepFields`\n * keeps that value on the option).\n *\n * `values` are written with every create, after token resolution (`@now`,\n * `@workspace.<key>`). After a create the fields return to their defaults.\n *\n * @spec openspec/changes/create-form-widget/specs/create-form-widget/spec.md#requirement-a-dashboard-card-can-create-an-object-from-declared-fields\n */\nexport default {\n\tname: 'CnCreateFormWidget',\n\n\tcomponents: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch, NcTextField },\n\n\tinject: {\n\t\t/** Page-level workspace context from CnDashboardPage, for `@workspace.<key>` defaults. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host app's translate function. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\t// A dashboard binds the widget's `content` keys as attributes too; they must\n\t// not reach CnFormWidgetBase's own props.\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * The widget config, see the component description.\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The record of a detail page, for `@objectId` in `values`. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The record of a detail page, for `@object.<field>` in `values`. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: ['saved'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\toptionsByField: {},\n\t\t\tsaving: false,\n\t\t\terrorMessage: '',\n\t\t\ttimerStartedAt: null,\n\t\t\ttimerNow: 0,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\trootAttrs() {\n\t\t\tconst own = new Set(Object.keys(CnFormWidgetBase.props || {}))\n\t\t\treturn Object.fromEntries(Object.entries(this.$attrs).filter(([key]) => !own.has(camelize(key))))\n\t\t},\n\n\t\tregister() {\n\t\t\treturn this.content.register || ''\n\t\t},\n\n\t\tschema() {\n\t\t\treturn this.content.schema || ''\n\t\t},\n\n\t\tfields() {\n\t\t\treturn (Array.isArray(this.content.fields) ? this.content.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\ttype: field.type || 'text',\n\t\t\t\t\tlabel: this.copy(field.label || ''),\n\t\t\t\t\tlinkLabel: this.copy(field.link?.label || ''),\n\t\t\t\t}))\n\t\t},\n\n\t\t/** The descriptors CnFormWidgetBase draws; reference and checkbox fields come from slots. */\n\t\tformFields() {\n\t\t\treturn this.fields.map((field) => (field.type === 'select'\n\t\t\t\t? { key: field.key, type: 'select', label: field.label, options: this.selectOptions(field) }\n\t\t\t\t: { key: field.key, type: field.type === 'text' ? 'text' : 'custom', label: field.type === 'checkbox' ? '' : field.label }))\n\t\t},\n\n\t\t/** The fields drawn through a `field-<key>` slot. */\n\t\tslotFields() {\n\t\t\treturn this.fields.filter((field) => ['reference', 'checkbox', 'date', 'number'].includes(field.type))\n\t\t},\n\n\t\tworkspace() {\n\t\t\tconst c = this.cnWorkspaceContext\n\t\t\tconst bag = c && typeof c === 'object' && 'value' in c ? c.value : c\n\t\t\treturn bag && typeof bag === 'object' ? bag : {}\n\t\t},\n\n\t\t/** The defaults, `@workspace.<key>` resolved; recomputed when a page filter changes. */\n\t\tdefaults() {\n\t\t\tconst out = {}\n\t\t\tfor (const field of this.fields) {\n\t\t\t\tconst raw = field.default !== undefined ? field.default : (field.type === 'checkbox' ? false : '')\n\t\t\t\tconst value = resolveFilterValue(raw, { workspace: this.workspace })\n\t\t\t\tout[field.key] = typeof value === 'string' && value.startsWith('@') ? '' : value\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\n\t\tcanSubmit() {\n\t\t\treturn this.fields.every((field) => {\n\t\t\t\tif (field.required !== true) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\treturn field.type === 'checkbox' ? value === true : value !== undefined && value !== null && value !== ''\n\t\t\t})\n\t\t},\n\n\t\tsubmitLabel() {\n\t\t\treturn this.copy(this.content.submitLabel) || t('nextcloud-vue', 'Create')\n\t\t},\n\n\t\tsavingLabel() {\n\t\t\treturn t('nextcloud-vue', 'Creating…')\n\t\t},\n\n\t\t/** `content.timer` when it names a field of this form, else null. */\n\t\ttimerConfig() {\n\t\t\tconst timer = this.content.timer\n\t\t\treturn timer && this.fields.some((field) => field.key === timer.field) ? timer : null\n\t\t},\n\n\t\ttimerStartLabel() {\n\t\t\treturn this.copy(this.timerConfig?.startLabel) || t('nextcloud-vue', 'Start timer')\n\t\t},\n\n\t\ttimerStopLabel() {\n\t\t\treturn this.copy(this.timerConfig?.stopLabel) || t('nextcloud-vue', 'Stop timer')\n\t\t},\n\n\t\t/** The running timer as h:mm:ss. */\n\t\telapsedText() {\n\t\t\tconst seconds = Math.max(0, Math.floor((this.timerNow - this.timerStartedAt) / 1000))\n\t\t\tconst minutes = String(Math.floor(seconds / 60) % 60).padStart(2, '0')\n\t\t\treturn `${Math.floor(seconds / 3600)}:${minutes}:${String(seconds % 60).padStart(2, '0')}`\n\t\t},\n\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\t},\n\n\twatch: {\n\t\tdefaults: {\n\t\t\timmediate: true,\n\t\t\thandler(next, previous) {\n\t\t\t\tfor (const [key, value] of Object.entries(next)) {\n\t\t\t\t\t// A default that moved (the page filter changed) follows into\n\t\t\t\t\t// a field the reader left at the previous default.\n\t\t\t\t\tif (this.form[key] === undefined || (previous && this.form[key] === previous[key])) {\n\t\t\t\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.loadOptions()\n\t},\n\n\tbeforeUnmount() {\n\t\tclearInterval(this.timerInterval)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Start the timer, or stop it and write the time into its field: hours\n\t\t * with two decimals, minutes with `unit: \"minutes\"`, never less than the\n\t\t * smallest step so a short run does not read as nothing.\n\t\t *\n\t\t * @spec openspec/changes/create-form-date-number-timer/specs/create-form-date-number-timer/spec.md#requirement-a-timer-fills-a-field\n\t\t * @return {void}\n\t\t */\n\t\ttoggleTimer() {\n\t\t\tif (this.timerStartedAt === null) {\n\t\t\t\tthis.timerStartedAt = Date.now()\n\t\t\t\tthis.timerNow = this.timerStartedAt\n\t\t\t\tthis.timerInterval = setInterval(() => {\n\t\t\t\t\tthis.timerNow = Date.now()\n\t\t\t\t}, 1000)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tclearInterval(this.timerInterval)\n\t\t\tconst milliseconds = Date.now() - this.timerStartedAt\n\t\t\tthis.timerStartedAt = null\n\t\t\tconst value = this.timerConfig.unit === 'minutes'\n\t\t\t\t? Math.max(1, Math.round(milliseconds / 60000))\n\t\t\t\t: Math.max(0.01, Math.round(milliseconds / 36000) / 100)\n\t\t\tthis.onFieldUpdate({ key: this.timerConfig.field, value: String(value) })\n\t\t},\n\n\t\t/**\n\t\t * A manifest string through the host's translate, else the library's.\n\t\t *\n\t\t * @param {string} key The string.\n\t\t * @return {string}\n\t\t */\n\t\tcopy(key) {\n\t\t\tif (typeof key !== 'string' || key === '') {\n\t\t\t\treturn key\n\t\t\t}\n\t\t\tconst host = typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : key\n\t\t\treturn typeof host === 'string' && host !== '' ? host : key\n\t\t},\n\n\t\t/**\n\t\t * @param {object} field A select field.\n\t\t * @return {Array<{value: (string|number), label: string}>}\n\t\t */\n\t\tselectOptions(field) {\n\t\t\treturn (this.optionsByField[field.key] || []).map((o) => ({ value: o.id, label: o.label }))\n\t\t},\n\n\t\t/**\n\t\t * The href of a field's link: the value at `link.from.path` of the option\n\t\t * chosen in the select `link.from.field`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string} The href, or '' when there is none.\n\t\t */\n\t\tlinkHref(field) {\n\t\t\tconst from = field.link?.from\n\t\t\tif (!from || !from.field || !from.path) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst chosen = (this.optionsByField[from.field] || []).find((o) => String(o.id) === String(this.form[from.field]))\n\t\t\tconst href = chosen?.data?.[from.path]\n\t\t\treturn typeof href === 'string' && /^https?:\\/\\//i.test(href) ? href : ''\n\t\t},\n\n\t\tasync loadOptions() {\n\t\t\tconst ctx = { workspace: this.workspace }\n\t\t\tawait Promise.all(this.fields\n\t\t\t\t.filter((field) => field.type === 'select' && isOptionsFrom(field.optionsFrom))\n\t\t\t\t.map(async (field) => {\n\t\t\t\t\tlet options\n\t\t\t\t\ttry {\n\t\t\t\t\t\toptions = await loadOptionsFrom(field.optionsFrom, ctx)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\toptions = []\n\t\t\t\t\t}\n\t\t\t\t\tthis.optionsByField = { ...this.optionsByField, [field.key]: options }\n\t\t\t\t\tif ((this.form[field.key] === '' || this.form[field.key] === undefined) && options.length > 0) {\n\t\t\t\t\t\tthis.form = { ...this.form, [field.key]: options[0].id }\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t},\n\n\t\tonFieldUpdate({ key, value }) {\n\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\tthis.errorMessage = ''\n\t\t},\n\n\t\t/**\n\t\t * Create the object from the fields and the declared `values`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.canSubmit || this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst store = (() => {\n\t\t\t\ttry {\n\t\t\t\t\treturn useObjectStore()\n\t\t\t\t} catch {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})()\n\t\t\tif (!store || !this.register || !this.schema) {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.errorMessage = ''\n\t\t\ttry {\n\t\t\t\tconst values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace, objectId: this.objectId, object: this.objectData })\n\t\t\t\tconst payload = { ...values }\n\t\t\t\tfor (const field of this.fields) {\n\t\t\t\t\tconst value = this.form[field.key]\n\t\t\t\t\tpayload[field.key] = field.type === 'number' && value !== '' && value !== null && value !== undefined ? Number(value) : value\n\t\t\t\t}\n\t\t\t\tif (typeof store.registerObjectType === 'function' && !store.objectTypeRegistry?.[this.typeSlug]) {\n\t\t\t\t\tstore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t}\n\t\t\t\tconst result = await store.saveObject(this.typeSlug, payload)\n\t\t\t\tif (!result) {\n\t\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.form = { ...this.form, ...this.defaults }\n\t\t\t\t/**\n\t\t\t\t * @event saved The object was created. Payload: what the store answered.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', result)\n\t\t\t} catch {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-create-form-widget__link {\n\tdisplay: inline-block;\n\tmargin-top: 8px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n\ttext-decoration: underline;\n}\n\n.cn-create-form-widget__elapsed {\n\talign-self: center;\n\tfont-variant-numeric: tabular-nums;\n}\n</style>\n"],"names":["CnFormWidgetBase","CnIcon","CnResourceSelect","t"],"mappings":";;;;;;;;;;AA8FA;AACC;AACA;;AAEA;A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AM,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAA;IAC5D,IAAI,CAAC,MAAM,EAAE;KACZ,IAAI,CAAC,YAAW,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA,IAAKA,SAAC,CAAC,eAAe,EAAE,2BAA2B,EAAA;KAC1G,MAAK;AACN,KAAA;AACA,IAAA,IAAI,CAAC,IAAG,GAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,QAAS,GAAA;AAC7C;;;IAGA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAA;AAC3B,IAAA,CAAE,MAAM;IACP,IAAI,CAAC,YAAW,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA,IAAKA,SAAC,CAAC,eAAe,EAAE,2BAA2B,EAAA;AAC3G,IAAA,SAAU;AACT,IAAA,IAAI,CAAC,MAAO,GAAE,MAAI;AACnB,IAAA;GACA;EACD;AACF;;;;"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { resolveComponent, openBlock, createBlock, mergeProps, createSlots, withCtx,
|
|
1
|
+
import { resolveComponent, openBlock, createBlock, mergeProps, createSlots, withCtx, createElementBlock, toDisplayString, createCommentVNode, createTextVNode, createVNode, renderList } from 'vue';
|
|
2
2
|
|
|
3
3
|
const _hoisted_1 = ["href", "data-testid"];
|
|
4
|
+
const _hoisted_2 = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "cn-create-form-widget__elapsed",
|
|
7
|
+
role: "timer",
|
|
8
|
+
"data-testid": "cn-create-form-elapsed"
|
|
9
|
+
};
|
|
4
10
|
|
|
5
11
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
6
12
|
const _component_CnResourceSelect = resolveComponent("CnResourceSelect");
|
|
13
|
+
const _component_NcTextField = resolveComponent("NcTextField");
|
|
7
14
|
const _component_NcCheckboxRadioSwitch = resolveComponent("NcCheckboxRadioSwitch");
|
|
8
|
-
const _component_CnIcon = resolveComponent("CnIcon");
|
|
9
15
|
const _component_NcButton = resolveComponent("NcButton");
|
|
16
|
+
const _component_CnIcon = resolveComponent("CnIcon");
|
|
10
17
|
const _component_CnFormWidgetBase = resolveComponent("CnFormWidgetBase");
|
|
11
18
|
|
|
12
19
|
return (openBlock(), createBlock(_component_CnFormWidgetBase, mergeProps($options.rootAttrs, {
|
|
@@ -22,6 +29,21 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
22
29
|
onSubmit: $options.onSubmit
|
|
23
30
|
}), createSlots({
|
|
24
31
|
actions: withCtx(() => [
|
|
32
|
+
($options.timerConfig && $data.timerStartedAt !== null)
|
|
33
|
+
? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString($options.elapsedText), 1 /* TEXT */))
|
|
34
|
+
: createCommentVNode("v-if", true),
|
|
35
|
+
($options.timerConfig)
|
|
36
|
+
? (openBlock(), createBlock(_component_NcButton, {
|
|
37
|
+
key: 1,
|
|
38
|
+
"data-testid": "cn-create-form-timer",
|
|
39
|
+
onClick: $options.toggleTimer
|
|
40
|
+
}, {
|
|
41
|
+
default: withCtx(() => [
|
|
42
|
+
createTextVNode(toDisplayString($data.timerStartedAt === null ? $options.timerStartLabel : $options.timerStopLabel), 1 /* TEXT */)
|
|
43
|
+
]),
|
|
44
|
+
_: 1 /* STABLE */
|
|
45
|
+
}, 8 /* PROPS */, ["onClick"]))
|
|
46
|
+
: createCommentVNode("v-if", true),
|
|
25
47
|
createVNode(_component_NcButton, {
|
|
26
48
|
variant: "primary",
|
|
27
49
|
wide: $props.content.wideSubmit !== false,
|
|
@@ -67,22 +89,34 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
67
89
|
allowCreate: false,
|
|
68
90
|
"onUpdate:modelValue": (id) => $options.onFieldUpdate({ key: field.key, value: id || '' })
|
|
69
91
|
}, null, 8 /* PROPS */, ["register", "schema", "labelField", "modelValue", "inputLabel", "onUpdate:modelValue"]))
|
|
70
|
-
: (field.type === '
|
|
71
|
-
? (openBlock(), createBlock(
|
|
92
|
+
: (field.type === 'date' || field.type === 'number')
|
|
93
|
+
? (openBlock(), createBlock(_component_NcTextField, {
|
|
72
94
|
key: 1,
|
|
73
|
-
modelValue: $data.form[field.key]
|
|
74
|
-
|
|
95
|
+
modelValue: $data.form[field.key],
|
|
96
|
+
type: field.type,
|
|
97
|
+
label: field.label,
|
|
98
|
+
step: field.type === 'number' ? (field.step || 'any') : undefined,
|
|
99
|
+
min: field.min,
|
|
100
|
+
max: field.max,
|
|
101
|
+
"data-testid": `cn-create-form-input-${field.key}`,
|
|
75
102
|
"onUpdate:modelValue": (v) => $options.onFieldUpdate({ key: field.key, value: v })
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
103
|
+
}, null, 8 /* PROPS */, ["modelValue", "type", "label", "step", "min", "max", "data-testid", "onUpdate:modelValue"]))
|
|
104
|
+
: (field.type === 'checkbox')
|
|
105
|
+
? (openBlock(), createBlock(_component_NcCheckboxRadioSwitch, {
|
|
106
|
+
key: 2,
|
|
107
|
+
modelValue: $data.form[field.key] === true,
|
|
108
|
+
"data-testid": `cn-create-form-checkbox-${field.key}`,
|
|
109
|
+
"onUpdate:modelValue": (v) => $options.onFieldUpdate({ key: field.key, value: v })
|
|
110
|
+
}, {
|
|
111
|
+
default: withCtx(() => [
|
|
112
|
+
createTextVNode(toDisplayString(field.label), 1 /* TEXT */)
|
|
113
|
+
]),
|
|
114
|
+
_: 2 /* DYNAMIC */
|
|
115
|
+
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["modelValue", "data-testid", "onUpdate:modelValue"]))
|
|
116
|
+
: createCommentVNode("v-if", true),
|
|
83
117
|
($options.linkHref(field))
|
|
84
118
|
? (openBlock(), createElementBlock("a", {
|
|
85
|
-
key:
|
|
119
|
+
key: 3,
|
|
86
120
|
class: "cn-create-form-widget__link",
|
|
87
121
|
href: $options.linkHref(field),
|
|
88
122
|
target: "_blank",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnCreateFormWidget.vue3.js","sources":["../../../../src/components/CnCreateFormWidget/CnCreateFormWidget.vue?vue&type=template&id=4c24b607&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnFormWidgetBase\n\t\tv-bind=\"rootAttrs\"\n\t\tblockClass=\"cn-create-form-widget\"\n\t\t:fields=\"formFields\"\n\t\t:model=\"form\"\n\t\t:canSubmit=\"canSubmit\"\n\t\t:submitting=\"saving\"\n\t\t:submitLabel=\"submitLabel\"\n\t\t:submittingLabel=\"savingLabel\"\n\t\t:errorMessage=\"errorMessage\"\n\t\t@update:field=\"onFieldUpdate\"\n\t\t@submit=\"onSubmit\">\n\t\t<template v-for=\"field in slotFields\" #[`field-${field.key}`] :key=\"field.key\">\n\t\t\t<CnResourceSelect\n\t\t\t\tv-if=\"field.type === 'reference'\"\n\t\t\t\t:register=\"field.register || register\"\n\t\t\t\t:schema=\"field.schema\"\n\t\t\t\t:labelField=\"field.labelField || 'name'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:inputLabel=\"field.label\"\n\t\t\t\t:preload=\"true\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:allowCreate=\"false\"\n\t\t\t\t@update:modelValue=\"(id) => onFieldUpdate({ key: field.key, value: id || '' })\" />\n\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\tv-else-if=\"field.type === 'checkbox'\"\n\t\t\t\t:modelValue=\"form[field.key] === true\"\n\t\t\t\t:data-testid=\"`cn-create-form-checkbox-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\">\n\t\t\t\t{{ field.label }}\n\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t<a\n\t\t\t\tv-if=\"linkHref(field)\"\n\t\t\t\tclass=\"cn-create-form-widget__link\"\n\t\t\t\t:href=\"linkHref(field)\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t:data-testid=\"`cn-create-form-link-${field.key}`\">\n\t\t\t\t{{ field.linkLabel }}\n\t\t\t</a>\n\t\t</template>\n\n\t\t<template #actions>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:wide=\"content.wideSubmit !== false\"\n\t\t\t\t:disabled=\"saving || !canSubmit\"\n\t\t\t\tdata-testid=\"cn-create-form-submit\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t<template v-if=\"content.submitIcon\" #icon>\n\t\t\t\t\t<CnIcon :name=\"content.submitIcon\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ saving ? savingLabel : submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnFormWidgetBase>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'\nimport { camelize } from 'vue'\nimport CnFormWidgetBase from '../CnFormWidgetBase/CnFormWidgetBase.vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnResourceSelect from '../CnResourceSelect/CnResourceSelect.vue'\nimport { useObjectStore } from '../../store/index.js'\nimport { isOptionsFrom, loadOptionsFrom } from '../../utils/optionsFrom.js'\nimport { resolveDeepTokens, resolveFilterValue } from '../../utils/resolveFilterTokens.js'\n\n/**\n * CnCreateFormWidget — the `create-form` dashboard widget: a card that creates\n * one OpenRegister object from the fields its manifest declares (PqLoyaliteit\n * \"Aanmelding loyaliteit\").\n *\n * `content`: `{ register, schema, fields, values?, submitLabel?, submitIcon?,\n * successMessage?, wideSubmit? }`. Each field is `{ key, label, type?, required?,\n * default?, optionsFrom?, schema?, labelField?, link? }`:\n *\n * - `type`: `text` (default), `select` (options from `optionsFrom`, the shape a\n * page filter takes), `reference` (a search over `schema`, labelled by\n * `labelField`) or `checkbox`. A required checkbox must be ticked, any other\n * required field filled, before the create is allowed.\n * - `default` seeds the field and may be a `@workspace.<key>` token, so a page\n * filter preselects it.\n * - `link` (`{ label, from: { field, path } }`, on a checkbox or reference\n * field) draws a link under it to the value at `path` of the option chosen in\n * the select `field`, such as a programme's terms (`optionsFrom.keepFields`\n * keeps that value on the option).\n *\n * `values` are written with every create, after token resolution (`@now`,\n * `@workspace.<key>`). After a create the fields return to their defaults.\n *\n * @spec openspec/changes/create-form-widget/specs/create-form-widget/spec.md#requirement-a-dashboard-card-can-create-an-object-from-declared-fields\n */\nexport default {\n\tname: 'CnCreateFormWidget',\n\n\tcomponents: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch },\n\n\tinject: {\n\t\t/** Page-level workspace context from CnDashboardPage, for `@workspace.<key>` defaults. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host app's translate function. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\t// A dashboard binds the widget's `content` keys as attributes too; they must\n\t// not reach CnFormWidgetBase's own props.\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * The widget config, see the component description.\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\temits: ['saved'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\toptionsByField: {},\n\t\t\tsaving: false,\n\t\t\terrorMessage: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\trootAttrs() {\n\t\t\tconst own = new Set(Object.keys(CnFormWidgetBase.props || {}))\n\t\t\treturn Object.fromEntries(Object.entries(this.$attrs).filter(([key]) => !own.has(camelize(key))))\n\t\t},\n\n\t\tregister() {\n\t\t\treturn this.content.register || ''\n\t\t},\n\n\t\tschema() {\n\t\t\treturn this.content.schema || ''\n\t\t},\n\n\t\tfields() {\n\t\t\treturn (Array.isArray(this.content.fields) ? this.content.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\ttype: field.type || 'text',\n\t\t\t\t\tlabel: this.copy(field.label || ''),\n\t\t\t\t\tlinkLabel: this.copy(field.link?.label || ''),\n\t\t\t\t}))\n\t\t},\n\n\t\t/** The descriptors CnFormWidgetBase draws; reference and checkbox fields come from slots. */\n\t\tformFields() {\n\t\t\treturn this.fields.map((field) => (field.type === 'select'\n\t\t\t\t? { key: field.key, type: 'select', label: field.label, options: this.selectOptions(field) }\n\t\t\t\t: { key: field.key, type: field.type === 'text' ? 'text' : 'custom', label: field.type === 'checkbox' ? '' : field.label }))\n\t\t},\n\n\t\t/** The fields drawn through a `field-<key>` slot: a reference or a checkbox. */\n\t\tslotFields() {\n\t\t\treturn this.fields.filter((field) => field.type === 'reference' || field.type === 'checkbox')\n\t\t},\n\n\t\tworkspace() {\n\t\t\tconst c = this.cnWorkspaceContext\n\t\t\tconst bag = c && typeof c === 'object' && 'value' in c ? c.value : c\n\t\t\treturn bag && typeof bag === 'object' ? bag : {}\n\t\t},\n\n\t\t/** The defaults, `@workspace.<key>` resolved; recomputed when a page filter changes. */\n\t\tdefaults() {\n\t\t\tconst out = {}\n\t\t\tfor (const field of this.fields) {\n\t\t\t\tconst raw = field.default !== undefined ? field.default : (field.type === 'checkbox' ? false : '')\n\t\t\t\tconst value = resolveFilterValue(raw, { workspace: this.workspace })\n\t\t\t\tout[field.key] = typeof value === 'string' && value.startsWith('@') ? '' : value\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\n\t\tcanSubmit() {\n\t\t\treturn this.fields.every((field) => {\n\t\t\t\tif (field.required !== true) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\treturn field.type === 'checkbox' ? value === true : value !== undefined && value !== null && value !== ''\n\t\t\t})\n\t\t},\n\n\t\tsubmitLabel() {\n\t\t\treturn this.copy(this.content.submitLabel) || t('nextcloud-vue', 'Create')\n\t\t},\n\n\t\tsavingLabel() {\n\t\t\treturn t('nextcloud-vue', 'Creating…')\n\t\t},\n\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\t},\n\n\twatch: {\n\t\tdefaults: {\n\t\t\timmediate: true,\n\t\t\thandler(next, previous) {\n\t\t\t\tfor (const [key, value] of Object.entries(next)) {\n\t\t\t\t\t// A default that moved (the page filter changed) follows into\n\t\t\t\t\t// a field the reader left at the previous default.\n\t\t\t\t\tif (this.form[key] === undefined || (previous && this.form[key] === previous[key])) {\n\t\t\t\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.loadOptions()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the host's translate, else the library's.\n\t\t *\n\t\t * @param {string} key The string.\n\t\t * @return {string}\n\t\t */\n\t\tcopy(key) {\n\t\t\tif (typeof key !== 'string' || key === '') {\n\t\t\t\treturn key\n\t\t\t}\n\t\t\tconst host = typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : key\n\t\t\treturn typeof host === 'string' && host !== '' ? host : key\n\t\t},\n\n\t\t/**\n\t\t * @param {object} field A select field.\n\t\t * @return {Array<{value: (string|number), label: string}>}\n\t\t */\n\t\tselectOptions(field) {\n\t\t\treturn (this.optionsByField[field.key] || []).map((o) => ({ value: o.id, label: o.label }))\n\t\t},\n\n\t\t/**\n\t\t * The href of a field's link: the value at `link.from.path` of the option\n\t\t * chosen in the select `link.from.field`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string} The href, or '' when there is none.\n\t\t */\n\t\tlinkHref(field) {\n\t\t\tconst from = field.link?.from\n\t\t\tif (!from || !from.field || !from.path) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst chosen = (this.optionsByField[from.field] || []).find((o) => String(o.id) === String(this.form[from.field]))\n\t\t\tconst href = chosen?.data?.[from.path]\n\t\t\treturn typeof href === 'string' && /^https?:\\/\\//i.test(href) ? href : ''\n\t\t},\n\n\t\tasync loadOptions() {\n\t\t\tconst ctx = { workspace: this.workspace }\n\t\t\tawait Promise.all(this.fields\n\t\t\t\t.filter((field) => field.type === 'select' && isOptionsFrom(field.optionsFrom))\n\t\t\t\t.map(async (field) => {\n\t\t\t\t\tlet options\n\t\t\t\t\ttry {\n\t\t\t\t\t\toptions = await loadOptionsFrom(field.optionsFrom, ctx)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\toptions = []\n\t\t\t\t\t}\n\t\t\t\t\tthis.optionsByField = { ...this.optionsByField, [field.key]: options }\n\t\t\t\t\tif ((this.form[field.key] === '' || this.form[field.key] === undefined) && options.length > 0) {\n\t\t\t\t\t\tthis.form = { ...this.form, [field.key]: options[0].id }\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t},\n\n\t\tonFieldUpdate({ key, value }) {\n\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\tthis.errorMessage = ''\n\t\t},\n\n\t\t/**\n\t\t * Create the object from the fields and the declared `values`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.canSubmit || this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst store = (() => {\n\t\t\t\ttry {\n\t\t\t\t\treturn useObjectStore()\n\t\t\t\t} catch {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})()\n\t\t\tif (!store || !this.register || !this.schema) {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.errorMessage = ''\n\t\t\ttry {\n\t\t\t\tconst values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace })\n\t\t\t\tconst payload = { ...values }\n\t\t\t\tfor (const field of this.fields) {\n\t\t\t\t\tpayload[field.key] = this.form[field.key]\n\t\t\t\t}\n\t\t\t\tif (typeof store.registerObjectType === 'function' && !store.objectTypeRegistry?.[this.typeSlug]) {\n\t\t\t\t\tstore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t}\n\t\t\t\tconst result = await store.saveObject(this.typeSlug, payload)\n\t\t\t\tif (!result) {\n\t\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.form = { ...this.form, ...this.defaults }\n\t\t\t\t/**\n\t\t\t\t * @event saved The object was created. Payload: what the store answered.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', result)\n\t\t\t} catch {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-create-form-widget__link {\n\tdisplay: inline-block;\n\tmargin-top: 8px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["_createVNode","_createTextVNode","_renderList","_createBlock","_toDisplayString","_createElementBlock"],"mappings":";;;;;;;;;;;0EAUU,SAAS,CAAA,SAAA,EAAA;AACjB,IAAA,UAAU,EAAC,uBAAQ;AAClB,IAAA,MAAM,EAAE,QAAU,CAAA,UAAA;AAClB,IAAA,KAAK,EAAE,KAAI,CAAA,IAAA;AACX,IAAA,SAAS,EAAE,QAAS,CAAA,SAAA;AACpB,IAAA,UAAU,EAAE,KAAM,CAAA,MAAA;AAClB,IAAA,WAAW,EAAE,QAAI,CAAA,WAAA;AACjB,IAAA,eAAe,EAAE,QAAW,CAAA,WAAA;AAC5B,IAAA,YAAY,EAAE,KAAE,CAAA,YAAA;AACf,IAAA,gB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,CAAA,GAAA,EAAA,KAAA,EAAA,EAAA,IAAA,EAAA,EAAA,CAAA;;AAEzC,cAAA,CAAA,KAAK,CAAA,IAAA,KAAA,UAAA;8BADhBA,WAMsB,CAAA,gCAAA,EAAA;;AAJrB,kBAAA,UAAU,EAAE,KAAA,CAAA,IAAI,CAAC,KAAI,CAAA,GAAA,CAAA,KAAA,IAAA;kBACtB,aAAA,EAAA,CAAA,wBAAA,EAAA,KAAA,CAAA,GAAA,CAAA,CAAA;kBACC,qBAAiB,EAAA,CAAG,CAAA,KAAA,QAAA,CAAA,aAAA,QAAA,KAAA,CAAA,GAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA;;mCACrB,MAAiB;AAAd,oBAAAF,eAAA,CAAAG,eAAA,CAAA,KAAK,CAAC,KAAK,CAAA,EAAA,CAAA,YAAA;;;;;AAGR,UAAA,CAAA,QAAA,CAAA,QAAQ,CAAC,KAAK,CAAA;4BADpBC,kBAQG,CAAA,GAAA,EAAA;;AANH,gBAAA,KAAK,EAAC,6BAA6B;gBAClC,IAAI,EAAE,QAAQ,CAAA,QAAA,CAAC,KAAI,CAAA;AACpB,gBAAA,MAAE,EAAA,QAAA;AACF,gBAAA,GAAG,EAAC,qBAAI;;AAEL,eAAA,EAAAD,eAAA,CAAA,KAAK,CAAC,SAAO,CAAA,EAAA,CAAA,oBAAA,UAAA,CAAA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnCreateFormWidget.vue3.js","sources":["../../../../src/components/CnCreateFormWidget/CnCreateFormWidget.vue?vue&type=template&id=a55360d8&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnFormWidgetBase\n\t\tv-bind=\"rootAttrs\"\n\t\tblockClass=\"cn-create-form-widget\"\n\t\t:fields=\"formFields\"\n\t\t:model=\"form\"\n\t\t:canSubmit=\"canSubmit\"\n\t\t:submitting=\"saving\"\n\t\t:submitLabel=\"submitLabel\"\n\t\t:submittingLabel=\"savingLabel\"\n\t\t:errorMessage=\"errorMessage\"\n\t\t@update:field=\"onFieldUpdate\"\n\t\t@submit=\"onSubmit\">\n\t\t<template v-for=\"field in slotFields\" #[`field-${field.key}`] :key=\"field.key\">\n\t\t\t<CnResourceSelect\n\t\t\t\tv-if=\"field.type === 'reference'\"\n\t\t\t\t:register=\"field.register || register\"\n\t\t\t\t:schema=\"field.schema\"\n\t\t\t\t:labelField=\"field.labelField || 'name'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:inputLabel=\"field.label\"\n\t\t\t\t:preload=\"true\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t:allowCreate=\"false\"\n\t\t\t\t@update:modelValue=\"(id) => onFieldUpdate({ key: field.key, value: id || '' })\" />\n\t\t\t<NcTextField\n\t\t\t\tv-else-if=\"field.type === 'date' || field.type === 'number'\"\n\t\t\t\t:modelValue=\"form[field.key]\"\n\t\t\t\t:type=\"field.type\"\n\t\t\t\t:label=\"field.label\"\n\t\t\t\t:step=\"field.type === 'number' ? (field.step || 'any') : undefined\"\n\t\t\t\t:min=\"field.min\"\n\t\t\t\t:max=\"field.max\"\n\t\t\t\t:data-testid=\"`cn-create-form-input-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\" />\n\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\tv-else-if=\"field.type === 'checkbox'\"\n\t\t\t\t:modelValue=\"form[field.key] === true\"\n\t\t\t\t:data-testid=\"`cn-create-form-checkbox-${field.key}`\"\n\t\t\t\t@update:modelValue=\"(v) => onFieldUpdate({ key: field.key, value: v })\">\n\t\t\t\t{{ field.label }}\n\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t<a\n\t\t\t\tv-if=\"linkHref(field)\"\n\t\t\t\tclass=\"cn-create-form-widget__link\"\n\t\t\t\t:href=\"linkHref(field)\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t:data-testid=\"`cn-create-form-link-${field.key}`\">\n\t\t\t\t{{ field.linkLabel }}\n\t\t\t</a>\n\t\t</template>\n\n\t\t<template #actions>\n\t\t\t<span v-if=\"timerConfig && timerStartedAt !== null\"\n\t\t\t\tclass=\"cn-create-form-widget__elapsed\"\n\t\t\t\trole=\"timer\"\n\t\t\t\tdata-testid=\"cn-create-form-elapsed\">{{ elapsedText }}</span>\n\t\t\t<NcButton\n\t\t\t\tv-if=\"timerConfig\"\n\t\t\t\tdata-testid=\"cn-create-form-timer\"\n\t\t\t\t@click=\"toggleTimer\">\n\t\t\t\t{{ timerStartedAt === null ? timerStartLabel : timerStopLabel }}\n\t\t\t</NcButton>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:wide=\"content.wideSubmit !== false\"\n\t\t\t\t:disabled=\"saving || !canSubmit\"\n\t\t\t\tdata-testid=\"cn-create-form-submit\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t<template v-if=\"content.submitIcon\" #icon>\n\t\t\t\t\t<CnIcon :name=\"content.submitIcon\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ saving ? savingLabel : submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnFormWidgetBase>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcTextField } from '@nextcloud/vue'\nimport { camelize } from 'vue'\nimport CnFormWidgetBase from '../CnFormWidgetBase/CnFormWidgetBase.vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnResourceSelect from '../CnResourceSelect/CnResourceSelect.vue'\nimport { useObjectStore } from '../../store/index.js'\nimport { isOptionsFrom, loadOptionsFrom } from '../../utils/optionsFrom.js'\nimport { resolveDeepTokens, resolveFilterValue } from '../../utils/resolveFilterTokens.js'\n\n/**\n * CnCreateFormWidget — the `create-form` dashboard widget: a card that creates\n * one OpenRegister object from the fields its manifest declares (PqLoyaliteit\n * \"Aanmelding loyaliteit\").\n *\n * `content`: `{ register, schema, fields, values?, submitLabel?, submitIcon?,\n * successMessage?, wideSubmit? }`. Each field is `{ key, label, type?, required?,\n * default?, optionsFrom?, schema?, labelField?, link? }`:\n *\n * - `type`: `text` (default), `select` (options from `optionsFrom`, the shape a\n * page filter takes), `reference` (a search over `schema`, labelled by\n * `labelField`) or `checkbox`. A required checkbox must be ticked, any other\n * required field filled, before the create is allowed.\n * - `default` seeds the field and may be a `@workspace.<key>` token, so a page\n * filter preselects it.\n * - `link` (`{ label, from: { field, path } }`, on a checkbox or reference\n * field) draws a link under it to the value at `path` of the option chosen in\n * the select `field`, such as a programme's terms (`optionsFrom.keepFields`\n * keeps that value on the option).\n *\n * `values` are written with every create, after token resolution (`@now`,\n * `@workspace.<key>`). After a create the fields return to their defaults.\n *\n * @spec openspec/changes/create-form-widget/specs/create-form-widget/spec.md#requirement-a-dashboard-card-can-create-an-object-from-declared-fields\n */\nexport default {\n\tname: 'CnCreateFormWidget',\n\n\tcomponents: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch, NcTextField },\n\n\tinject: {\n\t\t/** Page-level workspace context from CnDashboardPage, for `@workspace.<key>` defaults. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host app's translate function. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\t// A dashboard binds the widget's `content` keys as attributes too; they must\n\t// not reach CnFormWidgetBase's own props.\n\tinheritAttrs: false,\n\n\tprops: {\n\t\t/**\n\t\t * The widget config, see the component description.\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The record of a detail page, for `@objectId` in `values`. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The record of a detail page, for `@object.<field>` in `values`. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: ['saved'],\n\n\tdata() {\n\t\treturn {\n\t\t\tform: {},\n\t\t\toptionsByField: {},\n\t\t\tsaving: false,\n\t\t\terrorMessage: '',\n\t\t\ttimerStartedAt: null,\n\t\t\ttimerNow: 0,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\trootAttrs() {\n\t\t\tconst own = new Set(Object.keys(CnFormWidgetBase.props || {}))\n\t\t\treturn Object.fromEntries(Object.entries(this.$attrs).filter(([key]) => !own.has(camelize(key))))\n\t\t},\n\n\t\tregister() {\n\t\t\treturn this.content.register || ''\n\t\t},\n\n\t\tschema() {\n\t\t\treturn this.content.schema || ''\n\t\t},\n\n\t\tfields() {\n\t\t\treturn (Array.isArray(this.content.fields) ? this.content.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\ttype: field.type || 'text',\n\t\t\t\t\tlabel: this.copy(field.label || ''),\n\t\t\t\t\tlinkLabel: this.copy(field.link?.label || ''),\n\t\t\t\t}))\n\t\t},\n\n\t\t/** The descriptors CnFormWidgetBase draws; reference and checkbox fields come from slots. */\n\t\tformFields() {\n\t\t\treturn this.fields.map((field) => (field.type === 'select'\n\t\t\t\t? { key: field.key, type: 'select', label: field.label, options: this.selectOptions(field) }\n\t\t\t\t: { key: field.key, type: field.type === 'text' ? 'text' : 'custom', label: field.type === 'checkbox' ? '' : field.label }))\n\t\t},\n\n\t\t/** The fields drawn through a `field-<key>` slot. */\n\t\tslotFields() {\n\t\t\treturn this.fields.filter((field) => ['reference', 'checkbox', 'date', 'number'].includes(field.type))\n\t\t},\n\n\t\tworkspace() {\n\t\t\tconst c = this.cnWorkspaceContext\n\t\t\tconst bag = c && typeof c === 'object' && 'value' in c ? c.value : c\n\t\t\treturn bag && typeof bag === 'object' ? bag : {}\n\t\t},\n\n\t\t/** The defaults, `@workspace.<key>` resolved; recomputed when a page filter changes. */\n\t\tdefaults() {\n\t\t\tconst out = {}\n\t\t\tfor (const field of this.fields) {\n\t\t\t\tconst raw = field.default !== undefined ? field.default : (field.type === 'checkbox' ? false : '')\n\t\t\t\tconst value = resolveFilterValue(raw, { workspace: this.workspace })\n\t\t\t\tout[field.key] = typeof value === 'string' && value.startsWith('@') ? '' : value\n\t\t\t}\n\t\t\treturn out\n\t\t},\n\n\t\tcanSubmit() {\n\t\t\treturn this.fields.every((field) => {\n\t\t\t\tif (field.required !== true) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = this.form[field.key]\n\t\t\t\treturn field.type === 'checkbox' ? value === true : value !== undefined && value !== null && value !== ''\n\t\t\t})\n\t\t},\n\n\t\tsubmitLabel() {\n\t\t\treturn this.copy(this.content.submitLabel) || t('nextcloud-vue', 'Create')\n\t\t},\n\n\t\tsavingLabel() {\n\t\t\treturn t('nextcloud-vue', 'Creating…')\n\t\t},\n\n\t\t/** `content.timer` when it names a field of this form, else null. */\n\t\ttimerConfig() {\n\t\t\tconst timer = this.content.timer\n\t\t\treturn timer && this.fields.some((field) => field.key === timer.field) ? timer : null\n\t\t},\n\n\t\ttimerStartLabel() {\n\t\t\treturn this.copy(this.timerConfig?.startLabel) || t('nextcloud-vue', 'Start timer')\n\t\t},\n\n\t\ttimerStopLabel() {\n\t\t\treturn this.copy(this.timerConfig?.stopLabel) || t('nextcloud-vue', 'Stop timer')\n\t\t},\n\n\t\t/** The running timer as h:mm:ss. */\n\t\telapsedText() {\n\t\t\tconst seconds = Math.max(0, Math.floor((this.timerNow - this.timerStartedAt) / 1000))\n\t\t\tconst minutes = String(Math.floor(seconds / 60) % 60).padStart(2, '0')\n\t\t\treturn `${Math.floor(seconds / 3600)}:${minutes}:${String(seconds % 60).padStart(2, '0')}`\n\t\t},\n\n\t\ttypeSlug() {\n\t\t\treturn `${this.register}-${this.schema}`\n\t\t},\n\t},\n\n\twatch: {\n\t\tdefaults: {\n\t\t\timmediate: true,\n\t\t\thandler(next, previous) {\n\t\t\t\tfor (const [key, value] of Object.entries(next)) {\n\t\t\t\t\t// A default that moved (the page filter changed) follows into\n\t\t\t\t\t// a field the reader left at the previous default.\n\t\t\t\t\tif (this.form[key] === undefined || (previous && this.form[key] === previous[key])) {\n\t\t\t\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.loadOptions()\n\t},\n\n\tbeforeUnmount() {\n\t\tclearInterval(this.timerInterval)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Start the timer, or stop it and write the time into its field: hours\n\t\t * with two decimals, minutes with `unit: \"minutes\"`, never less than the\n\t\t * smallest step so a short run does not read as nothing.\n\t\t *\n\t\t * @spec openspec/changes/create-form-date-number-timer/specs/create-form-date-number-timer/spec.md#requirement-a-timer-fills-a-field\n\t\t * @return {void}\n\t\t */\n\t\ttoggleTimer() {\n\t\t\tif (this.timerStartedAt === null) {\n\t\t\t\tthis.timerStartedAt = Date.now()\n\t\t\t\tthis.timerNow = this.timerStartedAt\n\t\t\t\tthis.timerInterval = setInterval(() => {\n\t\t\t\t\tthis.timerNow = Date.now()\n\t\t\t\t}, 1000)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tclearInterval(this.timerInterval)\n\t\t\tconst milliseconds = Date.now() - this.timerStartedAt\n\t\t\tthis.timerStartedAt = null\n\t\t\tconst value = this.timerConfig.unit === 'minutes'\n\t\t\t\t? Math.max(1, Math.round(milliseconds / 60000))\n\t\t\t\t: Math.max(0.01, Math.round(milliseconds / 36000) / 100)\n\t\t\tthis.onFieldUpdate({ key: this.timerConfig.field, value: String(value) })\n\t\t},\n\n\t\t/**\n\t\t * A manifest string through the host's translate, else the library's.\n\t\t *\n\t\t * @param {string} key The string.\n\t\t * @return {string}\n\t\t */\n\t\tcopy(key) {\n\t\t\tif (typeof key !== 'string' || key === '') {\n\t\t\t\treturn key\n\t\t\t}\n\t\t\tconst host = typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : key\n\t\t\treturn typeof host === 'string' && host !== '' ? host : key\n\t\t},\n\n\t\t/**\n\t\t * @param {object} field A select field.\n\t\t * @return {Array<{value: (string|number), label: string}>}\n\t\t */\n\t\tselectOptions(field) {\n\t\t\treturn (this.optionsByField[field.key] || []).map((o) => ({ value: o.id, label: o.label }))\n\t\t},\n\n\t\t/**\n\t\t * The href of a field's link: the value at `link.from.path` of the option\n\t\t * chosen in the select `link.from.field`.\n\t\t *\n\t\t * @param {object} field The field.\n\t\t * @return {string} The href, or '' when there is none.\n\t\t */\n\t\tlinkHref(field) {\n\t\t\tconst from = field.link?.from\n\t\t\tif (!from || !from.field || !from.path) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst chosen = (this.optionsByField[from.field] || []).find((o) => String(o.id) === String(this.form[from.field]))\n\t\t\tconst href = chosen?.data?.[from.path]\n\t\t\treturn typeof href === 'string' && /^https?:\\/\\//i.test(href) ? href : ''\n\t\t},\n\n\t\tasync loadOptions() {\n\t\t\tconst ctx = { workspace: this.workspace }\n\t\t\tawait Promise.all(this.fields\n\t\t\t\t.filter((field) => field.type === 'select' && isOptionsFrom(field.optionsFrom))\n\t\t\t\t.map(async (field) => {\n\t\t\t\t\tlet options\n\t\t\t\t\ttry {\n\t\t\t\t\t\toptions = await loadOptionsFrom(field.optionsFrom, ctx)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\toptions = []\n\t\t\t\t\t}\n\t\t\t\t\tthis.optionsByField = { ...this.optionsByField, [field.key]: options }\n\t\t\t\t\tif ((this.form[field.key] === '' || this.form[field.key] === undefined) && options.length > 0) {\n\t\t\t\t\t\tthis.form = { ...this.form, [field.key]: options[0].id }\n\t\t\t\t\t}\n\t\t\t\t}))\n\t\t},\n\n\t\tonFieldUpdate({ key, value }) {\n\t\t\tthis.form = { ...this.form, [key]: value }\n\t\t\tthis.errorMessage = ''\n\t\t},\n\n\t\t/**\n\t\t * Create the object from the fields and the declared `values`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.canSubmit || this.saving) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst store = (() => {\n\t\t\t\ttry {\n\t\t\t\t\treturn useObjectStore()\n\t\t\t\t} catch {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})()\n\t\t\tif (!store || !this.register || !this.schema) {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.errorMessage = ''\n\t\t\ttry {\n\t\t\t\tconst values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace, objectId: this.objectId, object: this.objectData })\n\t\t\t\tconst payload = { ...values }\n\t\t\t\tfor (const field of this.fields) {\n\t\t\t\t\tconst value = this.form[field.key]\n\t\t\t\t\tpayload[field.key] = field.type === 'number' && value !== '' && value !== null && value !== undefined ? Number(value) : value\n\t\t\t\t}\n\t\t\t\tif (typeof store.registerObjectType === 'function' && !store.objectTypeRegistry?.[this.typeSlug]) {\n\t\t\t\t\tstore.registerObjectType(this.typeSlug, this.schema, this.register)\n\t\t\t\t}\n\t\t\t\tconst result = await store.saveObject(this.typeSlug, payload)\n\t\t\t\tif (!result) {\n\t\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.form = { ...this.form, ...this.defaults }\n\t\t\t\t/**\n\t\t\t\t * @event saved The object was created. Payload: what the store answered.\n\t\t\t\t */\n\t\t\t\tthis.$emit('saved', result)\n\t\t\t} catch {\n\t\t\t\tthis.errorMessage = this.copy(this.content.errorMessage) || t('nextcloud-vue', 'Could not create the item')\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-create-form-widget__link {\n\tdisplay: inline-block;\n\tmargin-top: 8px;\n\tcolor: var(--color-primary-element);\n\tfont-weight: 600;\n\ttext-decoration: underline;\n}\n\n.cn-create-form-widget__elapsed {\n\talign-self: center;\n\tfont-variant-numeric: tabular-nums;\n}\n</style>\n"],"names":["_createElementBlock","_toDisplayString","_createVNode","_createTextVNode","_renderList","_createBlock"],"mappings":";;;;;AA+DI,EAAA,KAAK,EAAC,gCAAW;AACjB,EAAA,IAAI,EAAC,OAAO;AACZ,EAAA,aAAW,EAAC,wBAAQ;;;;;;;;;;;0EAvDd,SAAS,CAAA,SAAA,EAAA;AACjB,IAAA,UAAU,EAAC,uBAAQ;AAClB,IAAA,MAAM,EAAE,QAAU,CAAA,UAAA;AAClB,IAAA,KAAK,EAAE,KAAI,CAAA,IAAA;AACX,IAAA,SAAS,EAAE,QAAS,CAAA,SAAA;AACpB,IAAA,UAAU,EAAE,KAAM,CAAA,MAAA;AAClB,IAAA,WAAW,EAAE,QAAI,CAAA,WAAA;AACjB,IAAA,eAAe,EAAE,QAAW,CAAA,WAAA;AAC5B,IAAA,YAAY,EAAE,KAAE,CAAA,YAAA;AACf,IAAA,gBAAW,EAAE,QAAa,CAAA,aAAA;AAC1B,IAAA,QAAK,EAAE,QAAQ,CAAA,QAAA;;AAyCN,IAAA,OAAO,UACjB,MAGqB;AAHb,MAAA,CAAA,QAAA,CAAA,WAAA,IAAA,KAAA,CAAA,cAAA,KAAA,IAAA;wBAARA,kBAGqB,CAAA,MAAA,EAHrB,UAGqB,EAAAC,eAAA,CAAA,QAAA,CAAA,WAAA,CAAA,EAAA,CAAA,YAAA;;OAEd,QAAG,CAAA,WAAA;mCAIC,CAAA,mBAAA,EAAA;;AAHV,YAAA,aAAO,EAAA,sBAAA;AACN,YAAA,OAAK,EAAE,QAAQ,CAAA,WAAA;;6BAChB,MAAmC;8CAAhC,KAAc,CAAA,cAAA,KAAA,IAAA,GAAa,QAAK,CAAA,eAAA,GAAA,QA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CAAA,QAAA,CAAC,KAAI,CAAA;AACpB,gBAAA,MAAE,EAAA,QAAA;AACF,gBAAA,GAAG,EAAC,qBAAI;;AAEL,eAAA,EAAAC,eAAA,CAAA,KAAK,CAAC,SAAO,CAAA,EAAA,CAAA,oBAAA,UAAA,CAAA;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnDataMatrix.vue2.js';
|
|
|
2
2
|
import { render } from './CnDataMatrix.vue3.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-401dc886";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
import { evalFormula } from '../../utils/evalFormula.js';
|
|
1
3
|
import { userLocale } from '../../utils/userLocale.js';
|
|
2
4
|
|
|
5
|
+
const ROUNDERS = Object.freeze({ round: Math.round, ceil: Math.ceil, floor: Math.floor });
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The number a cell holds; an empty cell is no number, rather than zero.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} raw The cell.
|
|
11
|
+
* @return {number|null} The number, or null.
|
|
12
|
+
*/
|
|
13
|
+
function numberIn(raw) {
|
|
14
|
+
return raw === null || raw === undefined || raw === '' || !Number.isFinite(Number(raw)) ? null : Number(raw)
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* CnDataMatrix — Inline-edit data grid for matrix-shaped data
|
|
5
19
|
* (rows × columns). Each cell is click-to-edit; commits emit
|
|
@@ -11,8 +25,19 @@ import { userLocale } from '../../utils/userLocale.js';
|
|
|
11
25
|
* rubrics — the "spreadsheet" shape where cells are independently
|
|
12
26
|
* editable values rather than a row/object form.
|
|
13
27
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
28
|
+
* A column with `formula` computes its cells from the other columns and is
|
|
29
|
+
* read only: `now*(rate/100)`, with `prev_now` for the row above and `round`
|
|
30
|
+
* set to `round`, `ceil` or `floor`. A row where the formula has no answer shows
|
|
31
|
+
* its own stored value. Formulas are arithmetic only, through `evalFormula`.
|
|
32
|
+
*
|
|
33
|
+
* A scoring matrix weighs its columns: give each column a `weight` (and an
|
|
34
|
+
* optional `weightLabel` such as "40%"), set `rowTotalsMode="weighted"` and
|
|
35
|
+
* the row total is the weighted mean of the row's scores. `showRank` ranks
|
|
36
|
+
* the rows by that total, highest first, and `highlightTopRank` tints the
|
|
37
|
+
* leading row.
|
|
38
|
+
*
|
|
39
|
+
* Not a full spreadsheet engine — there are no cell-range references, no
|
|
40
|
+
* charts. Consumers wanting that should
|
|
16
41
|
* embed a dedicated library (e.g. handsontable) and use this for
|
|
17
42
|
* the simpler cases.
|
|
18
43
|
*
|
|
@@ -44,7 +69,7 @@ var script = {
|
|
|
44
69
|
/**
|
|
45
70
|
* Column declarations.
|
|
46
71
|
*
|
|
47
|
-
* @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string}>}
|
|
72
|
+
* @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formula?:string,round?:'round'|'ceil'|'floor',formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string,weight?:number,weightLabel?:string}>}
|
|
48
73
|
*/
|
|
49
74
|
columns: { type: Array, default: () => [] },
|
|
50
75
|
/** Field on each row carrying its id. */
|
|
@@ -69,6 +94,22 @@ var script = {
|
|
|
69
94
|
rowTotalsLabel: { type: String, default: 'Total' },
|
|
70
95
|
/** Label preceding the column-totals row. */
|
|
71
96
|
columnTotalsLabel: { type: String, default: 'Total' },
|
|
97
|
+
/**
|
|
98
|
+
* How a row total is computed: `sum` adds the number columns,
|
|
99
|
+
* `weighted` takes the mean of the number columns weighted by each
|
|
100
|
+
* column's `weight`, leaving out a cell without a value.
|
|
101
|
+
*/
|
|
102
|
+
rowTotalsMode: { type: String, default: 'sum', validator: (v) => ['sum', 'weighted'].includes(v) },
|
|
103
|
+
/** Fraction digits of the totals; null keeps the locale default. */
|
|
104
|
+
totalsFractionDigits: { type: Number, default: null },
|
|
105
|
+
/** Render a rank column: the rows ranked by their row total, highest first, ties sharing a rank. */
|
|
106
|
+
showRank: { type: Boolean, default: false },
|
|
107
|
+
/** Header of the rank column, already translated; the library default is "Rank". */
|
|
108
|
+
rankLabel: { type: String, default: '' },
|
|
109
|
+
/** Tint the row ranked first. */
|
|
110
|
+
highlightTopRank: { type: Boolean, default: false },
|
|
111
|
+
/** Field on each row with a second line under its label, such as a price. */
|
|
112
|
+
rowSublabelKey: { type: String, default: '' },
|
|
72
113
|
},
|
|
73
114
|
|
|
74
115
|
emits: ['cell-edit'],
|
|
@@ -79,6 +120,69 @@ var script = {
|
|
|
79
120
|
},
|
|
80
121
|
|
|
81
122
|
computed: {
|
|
123
|
+
/** @return {string} The rank column header. */
|
|
124
|
+
resolvedRankLabel() {
|
|
125
|
+
return this.rankLabel || translate('nextcloud-vue', 'Rank')
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The rank of every row with a row total: highest total first, rows
|
|
130
|
+
* with an equal total sharing a rank (1, 2, 2, 4).
|
|
131
|
+
*
|
|
132
|
+
* @return {Map<unknown, number>} Rank per row id.
|
|
133
|
+
*/
|
|
134
|
+
ranks() {
|
|
135
|
+
const totals = this.rows
|
|
136
|
+
.map((row) => ({ id: row[this.rowIdKey], total: this.rowTotal(row) }))
|
|
137
|
+
.filter((entry) => Number.isFinite(entry.total))
|
|
138
|
+
.sort((a, b) => b.total - a.total);
|
|
139
|
+
const ranks = new Map();
|
|
140
|
+
totals.forEach((entry, index) => {
|
|
141
|
+
const previous = totals[index - 1];
|
|
142
|
+
ranks.set(entry.id, previous && previous.total === entry.total ? ranks.get(previous.id) : index + 1);
|
|
143
|
+
});
|
|
144
|
+
return ranks
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The computed cells of every row, in order. A formula reads the row's
|
|
149
|
+
* numbers by column key and the previous row's as `prev_<key>`, and sees
|
|
150
|
+
* formula columns to its left. A formula without an answer has no entry
|
|
151
|
+
* here, so the cell shows what the row itself holds.
|
|
152
|
+
*
|
|
153
|
+
* @return {Map<object, Record<string, number>>} Computed values per row.
|
|
154
|
+
*/
|
|
155
|
+
formulaValues() {
|
|
156
|
+
const values = new Map();
|
|
157
|
+
if (!this.columns.some((col) => col.formula)) {
|
|
158
|
+
return values
|
|
159
|
+
}
|
|
160
|
+
let previous = {};
|
|
161
|
+
for (const row of this.rows) {
|
|
162
|
+
const vars = { ...previous };
|
|
163
|
+
for (const col of this.columns) {
|
|
164
|
+
if (!col.formula && numberIn(row[col.key]) !== null) {
|
|
165
|
+
vars[col.key] = numberIn(row[col.key]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const computed = {};
|
|
169
|
+
for (const col of this.columns) {
|
|
170
|
+
if (col.formula) {
|
|
171
|
+
const answer = evalFormula(col.formula, vars);
|
|
172
|
+
if (answer !== null) {
|
|
173
|
+
computed[col.key] = (ROUNDERS[col.round] ?? Number)(answer);
|
|
174
|
+
vars[col.key] = computed[col.key];
|
|
175
|
+
} else if (numberIn(row[col.key]) !== null) {
|
|
176
|
+
vars[col.key] = numberIn(row[col.key]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
values.set(row, computed);
|
|
181
|
+
previous = Object.fromEntries(Object.entries(vars).filter(([key]) => !key.startsWith('prev_')).map(([key, value]) => [`prev_${key}`, value]));
|
|
182
|
+
}
|
|
183
|
+
return values
|
|
184
|
+
},
|
|
185
|
+
|
|
82
186
|
/**
|
|
83
187
|
* Grand total (sum of every numeric cell). Shown in the
|
|
84
188
|
* bottom-right corner when both totals are enabled.
|
|
@@ -90,7 +194,7 @@ var script = {
|
|
|
90
194
|
for (const row of this.rows) {
|
|
91
195
|
for (const col of this.columns) {
|
|
92
196
|
if (col.type === 'number') {
|
|
93
|
-
const v = Number(row
|
|
197
|
+
const v = Number(this.cellValue(row, col));
|
|
94
198
|
if (Number.isFinite(v)) {
|
|
95
199
|
total += v;
|
|
96
200
|
}
|
|
@@ -121,7 +225,7 @@ var script = {
|
|
|
121
225
|
* @return {boolean}
|
|
122
226
|
*/
|
|
123
227
|
isCellReadOnly(row, col) {
|
|
124
|
-
return Boolean(col.readOnly)
|
|
228
|
+
return Boolean(col.readOnly || col.formula)
|
|
125
229
|
},
|
|
126
230
|
|
|
127
231
|
/**
|
|
@@ -132,6 +236,9 @@ var script = {
|
|
|
132
236
|
* @return {unknown} The raw value.
|
|
133
237
|
*/
|
|
134
238
|
cellValue(row, col) {
|
|
239
|
+
if (col.formula && this.formulaValues.get(row)?.[col.key] !== undefined) {
|
|
240
|
+
return this.formulaValues.get(row)[col.key]
|
|
241
|
+
}
|
|
135
242
|
return row[col.key]
|
|
136
243
|
},
|
|
137
244
|
|
|
@@ -237,16 +344,62 @@ var script = {
|
|
|
237
344
|
},
|
|
238
345
|
|
|
239
346
|
/**
|
|
240
|
-
*
|
|
347
|
+
* The weight shown beside a column label: `weightLabel`, else the
|
|
348
|
+
* `weight` itself, or '' for an unweighted column.
|
|
349
|
+
*
|
|
350
|
+
* @param {object} col Column definition.
|
|
351
|
+
* @return {string} The weight text.
|
|
352
|
+
*/
|
|
353
|
+
weightText(col) {
|
|
354
|
+
if (typeof col.weightLabel === 'string' && col.weightLabel !== '') {
|
|
355
|
+
return col.weightLabel
|
|
356
|
+
}
|
|
357
|
+
return Number.isFinite(col.weight) ? String(col.weight) : ''
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Format a total with `totalsFractionDigits` when set.
|
|
362
|
+
*
|
|
363
|
+
* @param {number|null} value The total.
|
|
364
|
+
* @return {string} The display string.
|
|
365
|
+
*/
|
|
366
|
+
formatTotal(value) {
|
|
367
|
+
if (!Number.isFinite(value)) {
|
|
368
|
+
return ''
|
|
369
|
+
}
|
|
370
|
+
if (this.totalsFractionDigits === null) {
|
|
371
|
+
return this.formatCell(value, { type: 'number' })
|
|
372
|
+
}
|
|
373
|
+
const digits = this.totalsFractionDigits;
|
|
374
|
+
return value.toLocaleString(userLocale(), { minimumFractionDigits: digits, maximumFractionDigits: digits })
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Per-row total: the sum of every numeric column, or in `weighted`
|
|
379
|
+
* mode the weighted mean over the weighted columns that hold a value
|
|
380
|
+
* (null when none does).
|
|
241
381
|
*
|
|
242
382
|
* @param {object} row Row record.
|
|
243
|
-
* @return {number}
|
|
383
|
+
* @return {number|null}
|
|
244
384
|
*/
|
|
245
385
|
rowTotal(row) {
|
|
386
|
+
if (this.rowTotalsMode === 'weighted') {
|
|
387
|
+
let weighted = 0;
|
|
388
|
+
let weights = 0;
|
|
389
|
+
for (const col of this.columns) {
|
|
390
|
+
const raw = this.cellValue(row, col);
|
|
391
|
+
const v = Number(raw);
|
|
392
|
+
if (col.type === 'number' && Number.isFinite(col.weight) && col.weight > 0 && raw !== null && raw !== undefined && raw !== '' && Number.isFinite(v)) {
|
|
393
|
+
weighted += v * col.weight;
|
|
394
|
+
weights += col.weight;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return weights > 0 ? weighted / weights : null
|
|
398
|
+
}
|
|
246
399
|
let total = 0;
|
|
247
400
|
for (const col of this.columns) {
|
|
248
401
|
if (col.type === 'number') {
|
|
249
|
-
const v = Number(row
|
|
402
|
+
const v = Number(this.cellValue(row, col));
|
|
250
403
|
if (Number.isFinite(v)) {
|
|
251
404
|
total += v;
|
|
252
405
|
}
|
|
@@ -274,7 +427,7 @@ var script = {
|
|
|
274
427
|
// `Number(null)` is `0`, which would otherwise be counted and
|
|
275
428
|
// summed as a real zero value.
|
|
276
429
|
const values = this.rows
|
|
277
|
-
.map((r) => r
|
|
430
|
+
.map((r) => this.cellValue(r, col))
|
|
278
431
|
.filter((v) => v !== null && v !== undefined && v !== '')
|
|
279
432
|
.map((v) => Number(v))
|
|
280
433
|
.filter((v) => Number.isFinite(v));
|