@conduction/nextcloud-vue 2.139.0 → 2.140.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/CnAppRoot/CnAppRoot.vue2.js +9 -2
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js.map +1 -1
- package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +17 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +2 -2
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue2.js +52 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue3.js +23 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnConversationThread/CnConversationWidget.vue.js +1 -1
- package/dist/esm/components/CnConversationThread/CnConversationWidget.vue2.js +106 -0
- package/dist/esm/components/CnConversationThread/CnConversationWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnConversationThread/CnConversationWidget.vue3.js +30 -7
- package/dist/esm/components/CnConversationThread/CnConversationWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +59 -3
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js +44 -34
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +28 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js +7 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js +5 -0
- package/dist/esm/components/CnFilesBrowser/filesBrowserColumns.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +30 -2
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js +28 -3
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue2.js +10 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue3.js.map +1 -1
- package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue.js +1 -1
- package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue2.js +12 -1
- package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue3.js +1 -1
- package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransitionInputFields/CnTransitionInputFields.vue.js +1 -1
- package/dist/esm/components/CnTransitionInputFields/CnTransitionInputFields.vue2.js +23 -1
- package/dist/esm/components/CnTransitionInputFields/CnTransitionInputFields.vue2.js.map +1 -1
- package/dist/esm/components/CnTransitionInputFields/CnTransitionInputFields.vue3.js +43 -13
- package/dist/esm/components/CnTransitionInputFields/CnTransitionInputFields.vue3.js.map +1 -1
- package/dist/esm/composables/indexSources.js +5 -2
- package/dist/esm/composables/indexSources.js.map +1 -1
- package/dist/esm/composables/useTaskInboxStore.js +4 -3
- package/dist/esm/composables/useTaskInboxStore.js.map +1 -1
- package/dist/esm/l10n/en.json.js +2 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +5 -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 +466 -371
- package/dist/esm/utils/builtInFormatters.js +23 -1
- package/dist/esm/utils/builtInFormatters.js.map +1 -1
- package/dist/esm/utils/fillTemplate.js +7 -1
- package/dist/esm/utils/fillTemplate.js.map +1 -1
- package/dist/esm/utils/myTeam.js +24 -4
- package/dist/esm/utils/myTeam.js.map +1 -1
- package/dist/esm/utils/resolveFilterTokens.js +5 -4
- package/dist/esm/utils/resolveFilterTokens.js.map +1 -1
- package/dist/esm/utils/transitionInputs.js +43 -2
- package/dist/esm/utils/transitionInputs.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +771 -222
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +466 -371
- package/l10n/en.json +2 -1
- package/l10n/nl.json +5 -1
- package/package.json +1 -1
- package/src/components/CnAppRoot/CnAppRoot.vue +9 -2
- package/src/components/CnCellRenderer/CnCellRenderer.vue +19 -3
- package/src/components/CnChartWidget/CnChartWidget.md +1 -0
- package/src/components/CnChartWidget/CnChartWidget.vue +72 -1
- package/src/components/CnConversationThread/CnConversationWidget.vue +126 -1
- package/src/components/CnFactsWidget/CnFactsWidget.vue +72 -5
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +28 -1
- package/src/components/CnFilesBrowser/filesBrowser.js +7 -1
- package/src/components/CnFilesBrowser/filesBrowserColumns.js +5 -0
- package/src/components/CnIndexPage/CnIndexPage.vue +30 -2
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +28 -3
- package/src/components/CnRecordListWidget/CnRecordNoteRows.vue +10 -0
- package/src/components/CnStackedBarWidget/CnStackedBarWidget.vue +68 -2
- package/src/components/CnTransitionInputFields/CnTransitionInputFields.vue +43 -1
- package/src/composables/indexSources.js +5 -2
- package/src/composables/useTaskInboxStore.js +4 -3
- package/src/css/look-board.css +10 -2
- package/src/css/table.css +13 -0
- package/src/utils/builtInFormatters.js +22 -0
- package/src/utils/fillTemplate.js +7 -1
- package/src/utils/myTeam.js +24 -4
- package/src/utils/resolveFilterTokens.js +5 -4
- package/src/utils/transitionInputs.js +42 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnConversationWidget.vue3.js","sources":["../../../../src/components/CnConversationThread/CnConversationWidget.vue?vue&type=template&id=c7d9637a&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-case-widget-card\">\n\t\t<CnConversationThread\n\t\t\t:messages=\"messages\"\n\t\t\t:title=\"tr(content.title || '')\"\n\t\t\t:subtitle=\"tr(content.subtitle || '')\"\n\t\t\t:showDirection=\"content.showDirection === true\"\n\t\t\t:allowReply=\"content.allowReply !== false\"\n\t\t\t:replyLabel=\"content.replyLabel ? tr(content.replyLabel) : undefined\"\n\t\t\t:placeholder=\"tr(content.placeholder || '')\"\n\t\t\t:sendLabel=\"content.sendLabel ? tr(content.sendLabel) : undefined\"\n\t\t\t:replyHint=\"tr(content.replyHint || '')\"\n\t\t\t:replyOption=\"replyOption\"\n\t\t\t:usLabel=\"content.usLabel ? tr(content.usLabel) : undefined\"\n\t\t\t:endpoint=\"replyAction ? '' : endpoint\"\n\t\t\t:loading=\"loading\"\n\t\t\t:emptyText=\"content.emptyText ? tr(content.emptyText) : undefined\"\n\t\t\t:channelFilter=\"content.channelChips === true\"\n\t\t\t:channels=\"channelLabels\"\n\t\t\t:payload=\"replyValues\"\n\t\t\t@send=\"onSend\"\n\t\t\t@sent=\"onSent\"\n\t\t\t@messageAction=\"onMessageAction\">\n\t\t\t<template v-if=\"templates\" #reply-tools=\"{ setDraft }\">\n\t\t\t\t<CnTemplateSelect\n\t\t\t\t\t:url=\"templates.url\"\n\t\t\t\t\t:params=\"templateParams\"\n\t\t\t\t\t:inputLabel=\"tr(templates.inputLabel || 'Template')\"\n\t\t\t\t\tdata-testid=\"cn-conversation-templates\"\n\t\t\t\t\t@apply=\"applyTemplate($event, setDraft)\" />\n\t\t\t</template>\n\t\t\t<template v-if=\"replyOptions.length > 0\" #reply-actions>\n\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\tv-for=\"option in replyOptions\"\n\t\t\t\t\t:key=\"option.key\"\n\t\t\t\t\tv-model=\"replyValues[option.key]\"\n\t\t\t\t\t:data-testid=\"`cn-conversation-option-${option.key}`\">\n\t\t\t\t\t{{ tr(option.label) }}\n\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t</template>\n\t\t\t<template v-if=\"headerAction || statusBadgeText\" #header-actions>\n\t\t\t\t<span v-if=\"statusBadgeText\"\n\t\t\t\t\tclass=\"cn-conversation-widget__badge\"\n\t\t\t\t\tdata-testid=\"cn-conversation-status-badge\">\n\t\t\t\t\t{{ statusBadgeText }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tv-if=\"headerAction\"\n\t\t\t\t\tdata-testid=\"cn-conversation-header-action\"\n\t\t\t\t\t@click=\"onHeaderAction\">\n\t\t\t\t\t<template v-if=\"headerAction.icon\" #icon>\n\t\t\t\t\t\t<CnIcon :name=\"headerAction.icon\" :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ tr(headerAction.label) }}\n\t\t\t\t</NcButton>\n\t\t\t</template>\n\t\t</CnConversationThread>\n\t\t<p v-if=\"actionError\"\n\t\t\tclass=\"cn-conversation-widget__error\"\n\t\t\trole=\"alert\"\n\t\t\tdata-testid=\"cn-conversation-action-error\">\n\t\t\t{{ actionError }}\n\t\t</p>\n\t</div>\n</template>\n\n<script>\nimport { subscribe, unsubscribe } from '@nextcloud/event-bus'\nimport { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnTemplateSelect from '../CnTemplateSelect/CnTemplateSelect.vue'\nimport CnConversationThread from './CnConversationThread.vue'\nimport { dispatchAction } from '../../utils/actionsDispatcher.js'\nimport { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { hasUnresolvedDeepTokens, resolveDeepTokens } from '../../utils/resolveFilterTokens.js'\nimport { userDisplayName } from '../../utils/userDisplayName.js'\n\n/**\n * CnConversationWidget: the `conversation` detail widget type.\n *\n * Renders CnConversationThread from the messages of a record, oldest first.\n * The messages are a list on the bound record (`field`), or the objects of a\n * register list (`source: { register, schema, filter?, limit? }`, the filter\n * token-resolved like a record-list's: `{ \"case\": \"@objectId\" }`).\n *\n * Mapping keys name where each message keeps its parts: `textField` (alias\n * `bodyField`), `timeField` (alias `timestampField`), `authorField` (alias\n * `senderField`), `sideField` (alias `directionField`) with `usValue` (alias\n * `outValue`) for the messages the organisation sent, and `channelField` with\n * an optional `channelMap` from stored value to label (\"email\" to \"E-mail\").\n *\n * The reply box posts to `endpoint` (`@objectId` filled in), or runs\n * `replyAction`, an action descriptor the app decides the meaning of: it is\n * dispatched with `args: [{ text, objectId }]` and `props.text`. After a send\n * the source is read again.\n *\n * `fields: [{ field, side }]` merges several lists of the record by time,\n * each on its side (a ticket's `portalReplies` and `portalAnswers`).\n * `templates` (`{ url, params?, inputLabel, textField? }`) puts a\n * CnTemplateSelect above the reply box; picking one fills the box with the\n * option's `values[textField]` (default `text`). `replyOptions`\n * (`[{ key, label, default? }]`) are checkboxes sent with the reply: in the\n * endpoint's body and as `options` in a `replyAction`'s argument.\n * `statusField` with `statusMap` shows each message's status, and\n * `messageActions` (`[{ id, label, endpoint, method?, when?, errorText? }]`)\n * are buttons on the messages that match `when` (`{ field, in }`,\n * `{ field, equals }`, `{ field, empty: true }`, or a list of them that must\n * all hold); `{field}` in the endpoint is read from the message. `errors`\n * (`{ path, map, default, ok? }`) names an answer's refusal by its status.\n *\n * `channelChips: true` draws a chip per channel above the thread (every\n * `channelMap` label, in map order, then any other channel a message uses).\n * `headerAction` is a button beside the title (`{ label, icon?, ...action }`,\n * DqZaakContact's \"Contact vastleggen\"), dispatched like `replyAction` with\n * `args: [{ objectId }]`; after it the source is read again.\n */\nexport default {\n\tname: 'CnConversationWidget',\n\n\tcomponents: {\n\t\tCnConversationThread,\n\t\tCnIcon,\n\t\tCnTemplateSelect,\n\t\tNcButton,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t\t/** Pre-bound action dispatcher of the page, for `replyAction`. */\n\t\tcnDispatchAction: { default: null },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget's content: `field` (the dot-path to the messages on the\n\t\t * record) or `source`, the mapping keys, `endpoint` or `replyAction`,\n\t\t * and the texts (`title`, `replyLabel`, `placeholder`, `sendLabel`,\n\t\t * `usLabel`, `emptyText`, translated).\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The bound record. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The bound record's id. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t/** Replies sent from this widget that the record does not hold yet. */\n\t\t\tsentHere: [],\n\t\t\t/** The messages read from `source`. */\n\t\t\tlisted: [],\n\t\t\t/** Whether `source` is being read. */\n\t\t\tloading: false,\n\t\t\t/** The reply options' values, by key. */\n\t\t\treplyValues: this.initialReplyValues(),\n\t\t\t/** Why the last message action failed. */\n\t\t\tactionError: '',\n\t\t\t/** The action running, as `<action>|<message>`. */\n\t\t\tacting: '',\n\t\t\t/** The threads `statusBadge` reads. */\n\t\t\tbadgeRows: [],\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object|null} The register list the messages come from, or null. */\n\t\tsource() {\n\t\t\tconst source = this.content?.source\n\t\t\treturn source && typeof source === 'object' && source.register && source.schema ? source : null\n\t\t},\n\n\t\t/** @return {object|null} The header action, or null without a label. */\n\t\t/** @return {string} The latest thread's status (`statusBadge`), mapped and translated; '' for none. */\n\t\tstatusBadgeText() {\n\t\t\tconst badge = this.content?.statusBadge\n\t\t\tif (!badge || this.badgeRows.length === 0) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst sortField = badge.sortField || ''\n\t\t\tconst time = (row) => {\n\t\t\t\tconst value = sortField ? Date.parse(readPath(row, sortField)) : NaN\n\t\t\t\treturn Number.isNaN(value) ? 0 : value\n\t\t\t}\n\t\t\tconst latest = [...this.badgeRows].sort((a, b) => time(b) - time(a))[0]\n\t\t\tconst raw = readPath(latest, badge.path || 'status')\n\t\t\tif (raw === undefined || raw === null || raw === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst map = badge.map && typeof badge.map === 'object' ? badge.map : {}\n\t\t\treturn this.tr(Object.hasOwn(map, String(raw)) ? map[String(raw)] : String(raw))\n\t\t},\n\n\t\theaderAction() {\n\t\t\tconst action = this.content?.headerAction\n\t\t\treturn action && typeof action === 'object' && typeof action.label === 'string' && action.label !== '' ? action : null\n\t\t},\n\n\t\t/** @return {Array<string>} The `channelMap` labels, translated, each once. */\n\t\tchannelLabels() {\n\t\t\tconst map = this.content?.channelMap && typeof this.content.channelMap === 'object' ? this.content.channelMap : {}\n\t\t\treturn [...new Set(Object.values(map).filter((label) => typeof label === 'string' && label !== '').map((label) => this.tr(label)))]\n\t\t},\n\n\t\t/**\n\t\t * `content.replyOption` with its label translated, or null.\n\t\t *\n\t\t * @return {{label: string, key: string, value?: boolean}|null}\n\t\t * @spec openspec/changes/conversation-reply-option/specs/conversation-source/spec.md#requirement-a-reply-can-carry-a-hint-and-an-option\n\t\t */\n\t\treplyOption() {\n\t\t\tconst option = this.content?.replyOption\n\t\t\treturn option && typeof option === 'object' && option.label && option.key\n\t\t\t\t? { ...option, label: this.tr(option.label) }\n\t\t\t\t: null\n\t\t},\n\n\t\t/** @return {object|null} The template picker config, or null. */\n\t\ttemplates() {\n\t\t\tconst templates = this.content?.templates\n\t\t\treturn templates && typeof templates === 'object' && typeof templates.url === 'string' && templates.url !== '' ? templates : null\n\t\t},\n\n\t\t/** @return {object} The template list's params with tokens resolved. */\n\t\ttemplateParams() {\n\t\t\treturn resolveDeepTokens(this.templates?.params || {}, this.tokenCtx)\n\t\t},\n\n\t\t/** @return {Array<object>} The reply options with a key and a label. */\n\t\treplyOptions() {\n\t\t\tconst list = Array.isArray(this.content?.replyOptions) ? this.content.replyOptions : []\n\t\t\treturn list.filter((option) => option && typeof option.key === 'string' && option.key !== '' && typeof option.label === 'string')\n\t\t},\n\n\t\t/** @return {Array<object>} The message actions with an id, a label and an endpoint. */\n\t\tmessageActions() {\n\t\t\tconst list = Array.isArray(this.content?.messageActions) ? this.content.messageActions : []\n\t\t\treturn list.filter((action) => action && action.id && action.label && typeof action.endpoint === 'string')\n\t\t},\n\n\t\t/** @return {object|null} The reply action, or null. */\n\t\treplyAction() {\n\t\t\tconst action = this.content?.replyAction\n\t\t\treturn action && typeof action === 'object' ? action : null\n\t\t},\n\n\t\t/**\n\t\t * The messages in the thread's shape, oldest first, plus the replies\n\t\t * sent here.\n\t\t *\n\t\t * @return {Array<object>} The messages.\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-conversation-reads-its-messages-from-a-list-and-maps-their-parts\n\t\t */\n\t\tmessages() {\n\t\t\tconst c = this.content || {}\n\t\t\tconst usValue = String(c.outValue ?? c.usValue ?? 'us')\n\t\t\tconst channelMap = c.channelMap && typeof c.channelMap === 'object' ? c.channelMap : {}\n\t\t\tconst statusMap = c.statusMap && typeof c.statusMap === 'object' ? c.statusMap : {}\n\t\t\tconst stored = this.rawMessages()\n\t\t\t\t.map(({ message, side, key }, index) => {\n\t\t\t\t\tconst channel = c.channelField ? readPath(message, c.channelField) : undefined\n\t\t\t\t\tconst channelKey = channel === undefined || channel === null ? '' : String(channel)\n\t\t\t\t\tconst status = c.statusField ? readPath(message, c.statusField) : undefined\n\t\t\t\t\tconst statusKey = status === undefined || status === null ? '' : String(status)\n\t\t\t\t\tconst sideOf = side || (String(readPath(message, c.directionField || c.sideField || 'side')) === usValue ? 'us' : 'them')\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: key,\n\t\t\t\t\t\tauthor: this.authorOf(message, sideOf),\n\t\t\t\t\t\tnote: c.noteField ? this.textOf(readPath(message, c.noteField)) : '',\n\t\t\t\t\t\ttime: readPath(message, c.timestampField || c.timeField || 'time'),\n\t\t\t\t\t\ttext: readPath(message, c.bodyField || c.textField || 'text'),\n\t\t\t\t\t\tside: sideOf,\n\t\t\t\t\t\tchannel: channelKey === '' ? '' : this.tr(Object.hasOwn(channelMap, channelKey) ? channelMap[channelKey] : channelKey),\n\t\t\t\t\t\tstatus: statusKey === '' ? '' : this.tr(Object.hasOwn(statusMap, statusKey) ? statusMap[statusKey] : statusKey),\n\t\t\t\t\t\tactions: this.messageActions\n\t\t\t\t\t\t\t.filter((action) => this.actionApplies(action, message))\n\t\t\t\t\t\t\t.map((action) => ({ id: action.id, label: this.tr(action.label), disabled: this.acting === `${action.id}|${key}` })),\n\t\t\t\t\t\torder: index,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst at = (message) => {\n\t\t\t\tconst ms = Date.parse(message.time)\n\t\t\t\treturn Number.isNaN(ms) ? null : ms\n\t\t\t}\n\t\t\tstored.sort((a, b) => {\n\t\t\t\tconst ta = at(a)\n\t\t\t\tconst tb = at(b)\n\t\t\t\treturn (ta === null || tb === null || ta === tb) ? a.order - b.order : ta - tb\n\t\t\t})\n\t\t\treturn [...stored, ...this.sentHere]\n\t\t},\n\n\t\t/**\n\t\t * The endpoint with the record's id filled in.\n\t\t *\n\t\t * @return {string} The URL, or '' when the content names none.\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t */\n\t\tendpoint() {\n\t\t\tconst url = this.content.endpoint\n\t\t\tif (typeof url !== 'string' || url === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn url.replace(/@objectId/g, encodeURIComponent(String(this.objectId ?? '')))\n\t\t},\n\n\t\t/** @return {object} The token context for `source.filter` and `replyAction`. */\n\t\ttokenCtx() {\n\t\t\treturn { objectId: this.objectId, object: this.objectData || {} }\n\t\t},\n\t},\n\n\twatch: {\n\t\t// The record was read again, so it now holds what was sent from here.\n\t\tobjectData() {\n\t\t\tthis.sentHere = []\n\t\t},\n\n\t\tobjectId: {\n\t\t\timmediate: true,\n\t\t\thandler() {\n\t\t\t\tthis.loadSource()\n\t\t\t\tthis.loadBadge()\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tsubscribe('cn:page:refresh', this.onPageRefresh)\n\t},\n\n\tbeforeUnmount() {\n\t\tunsubscribe('cn:page:refresh', this.onPageRefresh)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Read the messages again when the page refreshes (a dialog sent one).\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onPageRefresh() {\n\t\t\tawait Promise.all([this.loadSource(), this.loadBadge()])\n\t\t},\n\n\t\t/**\n\t\t * Read the threads whose latest status `statusBadge` shows\n\t\t * (`{ source: { register, schema, filter?, limit? }, sortField?, path?, map? }`).\n\t\t * A filter whose token does not resolve, or a failed read, shows no badge.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-shows-the-latest-thread-status-and-a-status-can-open-a-follow-up\n\t\t */\n\t\tasync loadBadge() {\n\t\t\tconst source = this.content?.statusBadge?.source\n\t\t\tif (!source || !source.register || !source.schema) {\n\t\t\t\tthis.badgeRows = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst filter = resolveDeepTokens(source.filter || {}, this.tokenCtx)\n\t\t\tif (hasUnresolvedDeepTokens(filter) || Object.values(filter).some((value) => value === '' || value === null || value === undefined)) {\n\t\t\t\tthis.badgeRows = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst rows = await fetchReferenceObjects({ register: source.register, schema: source.schema, filter, limit: source.limit || 50 })\n\t\t\t\tthis.badgeRows = Array.isArray(rows) ? rows : []\n\t\t\t} catch {\n\t\t\t\tthis.badgeRows = []\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The stored messages with the side their list gives them: one list\n\t\t * (`field` or `source`), or several merged (`fields`).\n\t\t *\n\t\t * @return {Array<{message: object, side: string, key: string}>} The messages.\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-merges-several-lists-of-the-record\n\t\t */\n\t\trawMessages() {\n\t\t\tconst c = this.content || {}\n\t\t\tconst lists = !this.source && Array.isArray(c.fields) && c.fields.length > 0\n\t\t\t\t? c.fields.filter((entry) => entry && typeof entry.field === 'string').map((entry) => ({ list: readPath(this.objectData || {}, entry.field), side: entry.side === 'us' ? 'us' : 'them', prefix: entry.field }))\n\t\t\t\t: [{ list: this.source ? this.listed : readPath(this.objectData || {}, c.field || 'messages'), side: '', prefix: 'message' }]\n\t\t\treturn lists.flatMap(({ list, side, prefix }) => (Array.isArray(list) ? list : [])\n\t\t\t\t.filter((message) => message && typeof message === 'object')\n\t\t\t\t.map((message, index) => ({ message, side, key: String(message.id ?? `${prefix}-${index}`) })))\n\t\t},\n\n\t\t/**\n\t\t * Whether a message action applies to a message (`when`).\n\t\t *\n\t\t * @param {object} action The action.\n\t\t * @param {object} message The stored message.\n\t\t * @return {boolean}\n\t\t */\n\t\tactionApplies(action, message) {\n\t\t\tconst conditions = [].concat(action.when || [])\n\t\t\treturn conditions.every((when) => {\n\t\t\t\tif (!when || typeof when !== 'object' || typeof when.field !== 'string') {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = readPath(message, when.field)\n\t\t\t\tif (when.empty === true) {\n\t\t\t\t\treturn value === undefined || value === null || value === ''\n\t\t\t\t}\n\t\t\t\tif (Array.isArray(when.in)) {\n\t\t\t\t\treturn when.in.map(String).includes(String(value))\n\t\t\t\t}\n\t\t\t\treturn String(value) === String(when.equals)\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The reply options at their defaults.\n\t\t *\n\t\t * @return {object} Values by key.\n\t\t */\n\t\tinitialReplyValues() {\n\t\t\tconst list = Array.isArray(this.content?.replyOptions) ? this.content.replyOptions : []\n\t\t\treturn Object.fromEntries(list.filter((option) => option && option.key).map((option) => [option.key, option.default === true]))\n\t\t},\n\n\t\t/**\n\t\t * Put a picked template's text in the reply box.\n\t\t *\n\t\t * @param {object|null} option The template option.\n\t\t * @param {(text: string) => void} setDraft The thread's draft setter.\n\t\t * @return {void}\n\t\t */\n\t\tapplyTemplate(option, setDraft) {\n\t\t\tif (!option || !option.values) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst text = option.values[this.templates.textField || 'text']\n\t\t\tif (typeof text === 'string') {\n\t\t\t\tsetDraft(text)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run a message action: call its endpoint with the message's fields,\n\t\t * then read the messages again.\n\t\t *\n\t\t * @param {{action: string, message: string}} event Which action on which message.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-message-carries-its-status-and-actions\n\t\t */\n\t\tasync onMessageAction({ action: actionId, message: key }) {\n\t\t\tconst action = this.messageActions.find((entry) => entry.id === actionId)\n\t\t\tconst stored = this.rawMessages().find((entry) => entry.key === key)\n\t\t\tif (!action || !stored || this.acting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.actionError = ''\n\t\t\tthis.acting = `${actionId}|${key}`\n\t\t\ttry {\n\t\t\t\tconst [{ default: axios }, { generateUrl }] = await Promise.all([import('@nextcloud/axios'), import('@nextcloud/router')])\n\t\t\t\tconst path = action.endpoint\n\t\t\t\t\t.replace(/@objectId/g, encodeURIComponent(String(this.objectId ?? '')))\n\t\t\t\t\t.replace(/\\{([\\w.]+)\\}/g, (_m, field) => encodeURIComponent(String(readPath(stored.message, field) ?? '')))\n\t\t\t\tconst response = await axios.request({ method: String(action.method || 'POST').toLowerCase(), url: generateUrl(path) })\n\t\t\t\tif (await this.followUp(action, response?.data)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst refusal = this.actionRefusal(action, response?.data)\n\t\t\t\tif (refusal) {\n\t\t\t\t\tthis.actionError = refusal\n\t\t\t\t}\n\t\t\t\tawait this.loadSource()\n\t\t\t} catch (error) {\n\t\t\t\tif (await this.followUp(action, error?.response?.data)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.actionError = this.actionRefusal(action, error?.response?.data) || this.tr(action.errorText || 'The action failed.')\n\t\t\t} finally {\n\t\t\t\tthis.acting = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run the follow-up action a message action's answer asks for: the\n\t\t * status at `errors.path` (default `status`) looked up in `onStatus`,\n\t\t * dispatched like `headerAction`, tokens resolved against the record.\n\t\t *\n\t\t * @param {object} action The message action.\n\t\t * @param {object|undefined} answer The response body.\n\t\t * @return {Promise<boolean>} True when a follow-up ran.\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-shows-the-latest-thread-status-and-a-status-can-open-a-follow-up\n\t\t */\n\t\tasync followUp(action, answer) {\n\t\t\tconst map = action.onStatus\n\t\t\tif (!map || typeof map !== 'object' || !answer || typeof answer !== 'object') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst status = readPath(answer, action.errors?.path || 'status')\n\t\t\tconst next = status === undefined || status === null ? null : map[String(status)]\n\t\t\tif (!next || typeof next !== 'object') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst resolved = resolveDeepTokens(next, this.tokenCtx)\n\t\t\ttry {\n\t\t\t\tawait (typeof this.cnDispatchAction === 'function'\n\t\t\t\t\t? this.cnDispatchAction(resolved)\n\t\t\t\t\t: dispatchAction(resolved, { router: this.$router || null }))\n\t\t\t} catch {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The text a message action's answer names, by `errors` (`{ path, map,\n\t\t * ok? }`): the status at `path` mapped to a text. A status listed in `ok`\n\t\t * (default `[\"sent\", \"ok\"]`) is no refusal.\n\t\t *\n\t\t * @param {object} action The action.\n\t\t * @param {object|undefined} answer The response body.\n\t\t * @return {string} The text, '' for none.\n\t\t */\n\t\tactionRefusal(action, answer) {\n\t\t\tconst errors = action.errors\n\t\t\tif (!errors || typeof errors !== 'object' || !answer || typeof answer !== 'object') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst status = readPath(answer, errors.path || 'status')\n\t\t\tif (status === undefined || status === null || (errors.ok || ['sent', 'ok']).map(String).includes(String(status))) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst text = (errors.map || {})[String(status)] || errors.default\n\t\t\treturn text ? this.tr(text) : ''\n\t\t},\n\n\t\t/**\n\t\t * Who wrote a message: `usAuthorField` / `themAuthorField` for its\n\t\t * side, else `senderField` (`authorField`). A field written\n\t\t * `@object.<path>` reads the bound record (the case's requester on an\n\t\t * incoming message). With `usAuthorFormat` / `themAuthorFormat` set to\n\t\t * `user` the value is a user id, shown by its display name.\n\t\t *\n\t\t * @param {object} message The message.\n\t\t * @param {string} side `us` or `them`.\n\t\t * @return {string} The author, or '' when the message names none.\n\t\t * @spec openspec/changes/conversation-board-bubble/specs/conversation-source/spec.md#requirement-a-message-names-its-author-per-side-its-direction-and-a-note\n\t\t */\n\t\tauthorOf(message, side) {\n\t\t\tconst c = this.content || {}\n\t\t\tconst field = (side === 'us' ? c.usAuthorField : c.themAuthorField) || c.senderField || c.authorField || 'author'\n\t\t\tconst value = typeof field === 'string' && field.startsWith('@object.')\n\t\t\t\t? readPath(this.objectData || {}, field.slice('@object.'.length))\n\t\t\t\t: readPath(message, field)\n\t\t\tconst text = this.textOf(value)\n\t\t\tconst format = side === 'us' ? c.usAuthorFormat : c.themAuthorFormat\n\t\t\treturn format === 'user' && text !== '' ? (userDisplayName(text) || text) : text\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} value A stored value.\n\t\t * @return {string} It as text, or '' for none.\n\t\t */\n\t\ttextOf(value) {\n\t\t\treturn value === undefined || value === null || typeof value === 'object' ? '' : String(value)\n\t\t},\n\n\t\t/**\n\t\t * Translate through the app's translate.\n\t\t *\n\t\t * @param {string} key The source string.\n\t\t * @return {string}\n\t\t */\n\t\ttr(key) {\n\t\t\treturn key && typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : (key || '')\n\t\t},\n\n\t\t/**\n\t\t * Read the messages from `source`. A filter whose token does not\n\t\t * resolve sends no request; a failed read leaves the thread empty.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-conversation-reads-its-messages-from-a-list-and-maps-their-parts\n\t\t */\n\t\tasync loadSource() {\n\t\t\tif (!this.source) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst raw = this.source.filter || {}\n\t\t\tconst filter = resolveDeepTokens(raw, this.tokenCtx)\n\t\t\tconst emptied = Object.keys(raw).some((key) => typeof raw[key] === 'string' && raw[key].startsWith('@') && (filter[key] === '' || filter[key] === null || filter[key] === undefined))\n\t\t\tif (emptied || hasUnresolvedDeepTokens(filter)) {\n\t\t\t\tthis.listed = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.listed = await fetchReferenceObjects({ register: this.source.register, schema: this.source.schema, filter, limit: this.source.limit || 200 })\n\t\t\t\tthis.sentHere = []\n\t\t\t} catch {\n\t\t\t\tthis.listed = []\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 * Run `replyAction` with the reply, when there is one; the endpoint\n\t\t * path is the thread's own.\n\t\t *\n\t\t * @param {string} text The reply.\n\t\t * @param {object} [extras] The reply option's state, `{ [key]: boolean }`.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-reply-can-run-an-app-action\n\t\t * @spec openspec/changes/conversation-reply-option/specs/conversation-source/spec.md#requirement-a-reply-can-carry-a-hint-and-an-option\n\t\t */\n\t\tasync onSend(text, extras = {}) {\n\t\t\tif (!this.replyAction) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst resolved = resolveDeepTokens(this.replyAction, this.tokenCtx)\n\t\t\tconst options = this.replyOptions.length > 0 ? { options: { ...this.replyValues } } : {}\n\t\t\tconst action = { ...resolved, args: [{ text, objectId: this.objectId, ...extras, ...options }], props: { ...(resolved.props || {}), text, ...extras, ...options } }\n\t\t\tconst result = typeof this.cnDispatchAction === 'function'\n\t\t\t\t? this.cnDispatchAction(action)\n\t\t\t\t: dispatchAction(action, { router: this.$router || null })\n\t\t\ttry {\n\t\t\t\tconst outcome = await result\n\t\t\t\tif (outcome === false) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.source) {\n\t\t\t\tawait this.loadSource()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onSent({ text })\n\t\t},\n\n\t\t/**\n\t\t * Run `headerAction` with the record id, then read the source again.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onHeaderAction() {\n\t\t\tif (!this.headerAction) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst { label, icon, ...rest } = resolveDeepTokens(this.headerAction, this.tokenCtx)\n\t\t\tconst action = { ...rest, args: [{ objectId: this.objectId }] }\n\t\t\ttry {\n\t\t\t\tconst outcome = await (typeof this.cnDispatchAction === 'function'\n\t\t\t\t\t? this.cnDispatchAction(action)\n\t\t\t\t\t: dispatchAction(action, { router: this.$router || null }))\n\t\t\t\tif (outcome === false) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tawait this.loadSource()\n\t\t},\n\n\t\t/**\n\t\t * Show an accepted reply at once, without waiting for the record.\n\t\t *\n\t\t * @param {object} data The endpoint's response.\n\t\t * @return {void}\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t */\n\t\tonSent(data) {\n\t\t\tconst text = data?.message ?? data?.text\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.sentHere.push({\n\t\t\t\tid: `sent-${this.sentHere.length}`,\n\t\t\t\ttime: new Date().toISOString(),\n\t\t\t\ttext,\n\t\t\t\tside: 'us',\n\t\t\t})\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-conversation-widget__badge {\n\tpadding: 2px 10px;\n\tborder-radius: var(--border-radius-pill);\n\tbackground: var(--color-background-dark);\n\tcolor: var(--color-main-text);\n\tfont-size: var(--font-size-small, 13px);\n}\n\n.cn-conversation-widget__error {\n\tcolor: var(--color-error-text, var(--color-error));\n\tmargin: calc(2 * var(--default-grid-baseline)) 0 0;\n}\n\n.cn-case-widget-card {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large);\n\tpadding: calc(5 * var(--default-grid-baseline));\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_withCtx","_Fragment","_renderList","_createBlock","_toDisplayString","_createTextVNode"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"CnConversationWidget.vue3.js","sources":["../../../../src/components/CnConversationThread/CnConversationWidget.vue?vue&type=template&id=63984d97&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-case-widget-card\">\n\t\t<CnConversationThread\n\t\t\tref=\"thread\"\n\t\t\t:messages=\"messages\"\n\t\t\t:title=\"tr(content.title || '')\"\n\t\t\t:subtitle=\"tr(content.subtitle || '')\"\n\t\t\t:showDirection=\"content.showDirection === true\"\n\t\t\t:allowReply=\"content.allowReply !== false\"\n\t\t\t:replyLabel=\"content.replyLabel ? tr(content.replyLabel) : undefined\"\n\t\t\t:placeholder=\"tr(content.placeholder || '')\"\n\t\t\t:sendLabel=\"content.sendLabel ? tr(content.sendLabel) : undefined\"\n\t\t\t:replyHint=\"tr(content.replyHint || '')\"\n\t\t\t:replyOption=\"replyOption\"\n\t\t\t:usLabel=\"content.usLabel ? tr(content.usLabel) : undefined\"\n\t\t\t:endpoint=\"replyAction ? '' : endpoint\"\n\t\t\t:loading=\"loading\"\n\t\t\t:emptyText=\"content.emptyText ? tr(content.emptyText) : undefined\"\n\t\t\t:channelFilter=\"content.channelChips === true\"\n\t\t\t:channels=\"channelLabels\"\n\t\t\t:payload=\"replyValues\"\n\t\t\t@send=\"onSend\"\n\t\t\t@sent=\"onSent\"\n\t\t\t@messageAction=\"onMessageAction\">\n\t\t\t<template v-if=\"templates\" #reply-tools=\"{ setDraft }\">\n\t\t\t\t<CnTemplateSelect\n\t\t\t\t\t:url=\"templates.url\"\n\t\t\t\t\t:params=\"templateParams\"\n\t\t\t\t\t:inputLabel=\"tr(templates.inputLabel || 'Template')\"\n\t\t\t\t\tdata-testid=\"cn-conversation-templates\"\n\t\t\t\t\t@apply=\"applyTemplate($event, setDraft)\" />\n\t\t\t</template>\n\t\t\t<template v-if=\"replyOptions.length > 0 || draftUrl\" #reply-actions=\"{ draft }\">\n\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\tv-for=\"option in replyOptions\"\n\t\t\t\t\t:key=\"option.key\"\n\t\t\t\t\tv-model=\"replyValues[option.key]\"\n\t\t\t\t\t:data-testid=\"`cn-conversation-option-${option.key}`\">\n\t\t\t\t\t{{ tr(option.label) }}\n\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t<span v-if=\"draftUrl && draftStatus\"\n\t\t\t\t\tclass=\"cn-conversation-widget__draft-status\"\n\t\t\t\t\trole=\"status\"\n\t\t\t\t\tdata-testid=\"cn-conversation-draft-status\">\n\t\t\t\t\t{{ draftStatus }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tv-if=\"draftUrl\"\n\t\t\t\t\tdata-testid=\"cn-conversation-save-draft\"\n\t\t\t\t\t:disabled=\"savingDraft\"\n\t\t\t\t\t@click=\"saveDraft(draft)\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Save as draft') }}\n\t\t\t\t</NcButton>\n\t\t\t</template>\n\t\t\t<template v-if=\"headerAction || statusBadgeText\" #header-actions>\n\t\t\t\t<span v-if=\"statusBadgeText\"\n\t\t\t\t\tclass=\"cn-conversation-widget__badge\"\n\t\t\t\t\tdata-testid=\"cn-conversation-status-badge\">\n\t\t\t\t\t{{ statusBadgeText }}\n\t\t\t\t</span>\n\t\t\t\t<NcButton\n\t\t\t\t\tv-if=\"headerAction\"\n\t\t\t\t\tdata-testid=\"cn-conversation-header-action\"\n\t\t\t\t\t@click=\"onHeaderAction\">\n\t\t\t\t\t<template v-if=\"headerAction.icon\" #icon>\n\t\t\t\t\t\t<CnIcon :name=\"headerAction.icon\" :size=\"20\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ tr(headerAction.label) }}\n\t\t\t\t</NcButton>\n\t\t\t</template>\n\t\t</CnConversationThread>\n\t\t<p v-if=\"actionError\"\n\t\t\tclass=\"cn-conversation-widget__error\"\n\t\t\trole=\"alert\"\n\t\t\tdata-testid=\"cn-conversation-action-error\">\n\t\t\t{{ actionError }}\n\t\t</p>\n\t</div>\n</template>\n\n<script>\nimport { subscribe, unsubscribe } from '@nextcloud/event-bus'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport CnTemplateSelect from '../CnTemplateSelect/CnTemplateSelect.vue'\nimport CnConversationThread from './CnConversationThread.vue'\nimport { dispatchAction } from '../../utils/actionsDispatcher.js'\nimport { formatTimeOfDay } from '../../utils/boardDate.js'\nimport { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { hasUnresolvedDeepTokens, resolveDeepTokens } from '../../utils/resolveFilterTokens.js'\nimport { userDisplayName } from '../../utils/userDisplayName.js'\n\n/**\n * CnConversationWidget: the `conversation` detail widget type.\n *\n * Renders CnConversationThread from the messages of a record, oldest first.\n * The messages are a list on the bound record (`field`), or the objects of a\n * register list (`source: { register, schema, filter?, limit? }`, the filter\n * token-resolved like a record-list's: `{ \"case\": \"@objectId\" }`).\n *\n * Mapping keys name where each message keeps its parts: `textField` (alias\n * `bodyField`), `timeField` (alias `timestampField`), `authorField` (alias\n * `senderField`), `sideField` (alias `directionField`) with `usValue` (alias\n * `outValue`) for the messages the organisation sent, and `channelField` with\n * an optional `channelMap` from stored value to label (\"email\" to \"E-mail\").\n *\n * The reply box posts to `endpoint` (`@objectId` filled in), or runs\n * `replyAction`, an action descriptor the app decides the meaning of: it is\n * dispatched with `args: [{ text, objectId }]` and `props.text`. After a send\n * the source is read again.\n *\n * `fields: [{ field, side }]` merges several lists of the record by time,\n * each on its side (a ticket's `portalReplies` and `portalAnswers`).\n * `templates` (`{ url, params?, inputLabel, textField? }`) puts a\n * CnTemplateSelect above the reply box; picking one fills the box with the\n * option's `values[textField]` (default `text`). `replyOptions`\n * (`[{ key, label, default? }]`) are checkboxes sent with the reply: in the\n * endpoint's body and as `options` in a `replyAction`'s argument.\n * `statusField` with `statusMap` shows each message's status, and\n * `messageActions` (`[{ id, label, endpoint, method?, when?, errorText? }]`)\n * are buttons on the messages that match `when` (`{ field, in }`,\n * `{ field, equals }`, `{ field, empty: true }`, or a list of them that must\n * all hold); `{field}` in the endpoint is read from the message. `errors`\n * (`{ path, map, default, ok? }`) names an answer's refusal by its status.\n *\n * `channelChips: true` draws a chip per channel above the thread (every\n * `channelMap` label, in map order, then any other channel a message uses).\n * `headerAction` is a button beside the title (`{ label, icon?, ...action }`,\n * DqZaakContact's \"Contact vastleggen\"), dispatched like `replyAction` with\n * `args: [{ objectId }]`; after it the source is read again.\n */\nexport default {\n\tname: 'CnConversationWidget',\n\n\tcomponents: {\n\t\tCnConversationThread,\n\t\tCnIcon,\n\t\tCnTemplateSelect,\n\t\tNcButton,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t\t/** Pre-bound action dispatcher of the page, for `replyAction`. */\n\t\tcnDispatchAction: { default: null },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget's content: `field` (the dot-path to the messages on the\n\t\t * record) or `source`, the mapping keys, `endpoint` or `replyAction`,\n\t\t * and the texts (`title`, `replyLabel`, `placeholder`, `sendLabel`,\n\t\t * `usLabel`, `emptyText`, translated).\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The bound record. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The bound record's id. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t/** Replies sent from this widget that the record does not hold yet. */\n\t\t\tsentHere: [],\n\t\t\t/** The messages read from `source`. */\n\t\t\tlisted: [],\n\t\t\t/** Whether `source` is being read. */\n\t\t\tloading: false,\n\t\t\t/** The reply options' values, by key. */\n\t\t\treplyValues: this.initialReplyValues(),\n\t\t\t/** Why the last message action failed. */\n\t\t\tactionError: '',\n\t\t\t/** The action running, as `<action>|<message>`. */\n\t\t\tacting: '',\n\t\t\t/** The threads `statusBadge` reads. */\n\t\t\tbadgeRows: [],\n\t\t\t/** What the last draft save said: when it was saved, or that it failed. */\n\t\t\tdraftStatus: '',\n\t\t\t/** Whether a draft is being saved. */\n\t\t\tsavingDraft: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object|null} The register list the messages come from, or null. */\n\t\tsource() {\n\t\t\tconst source = this.content?.source\n\t\t\treturn source && typeof source === 'object' && source.register && source.schema ? source : null\n\t\t},\n\n\t\t/** @return {object|null} The header action, or null without a label. */\n\t\t/** @return {string} The latest thread's status (`statusBadge`), mapped and translated; '' for none. */\n\t\tstatusBadgeText() {\n\t\t\tconst badge = this.content?.statusBadge\n\t\t\tif (!badge || this.badgeRows.length === 0) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst sortField = badge.sortField || ''\n\t\t\tconst time = (row) => {\n\t\t\t\tconst value = sortField ? Date.parse(readPath(row, sortField)) : NaN\n\t\t\t\treturn Number.isNaN(value) ? 0 : value\n\t\t\t}\n\t\t\tconst latest = [...this.badgeRows].sort((a, b) => time(b) - time(a))[0]\n\t\t\tconst raw = readPath(latest, badge.path || 'status')\n\t\t\tif (raw === undefined || raw === null || raw === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst map = badge.map && typeof badge.map === 'object' ? badge.map : {}\n\t\t\treturn this.tr(Object.hasOwn(map, String(raw)) ? map[String(raw)] : String(raw))\n\t\t},\n\n\t\theaderAction() {\n\t\t\tconst action = this.content?.headerAction\n\t\t\treturn action && typeof action === 'object' && typeof action.label === 'string' && action.label !== '' ? action : null\n\t\t},\n\n\t\t/** @return {Array<string>} The `channelMap` labels, translated, each once. */\n\t\tchannelLabels() {\n\t\t\tconst map = this.content?.channelMap && typeof this.content.channelMap === 'object' ? this.content.channelMap : {}\n\t\t\treturn [...new Set(Object.values(map).filter((label) => typeof label === 'string' && label !== '').map((label) => this.tr(label)))]\n\t\t},\n\n\t\t/**\n\t\t * `content.replyOption` with its label translated, or null.\n\t\t *\n\t\t * @return {{label: string, key: string, value?: boolean}|null}\n\t\t * @spec openspec/changes/conversation-reply-option/specs/conversation-source/spec.md#requirement-a-reply-can-carry-a-hint-and-an-option\n\t\t */\n\t\treplyOption() {\n\t\t\tconst option = this.content?.replyOption\n\t\t\treturn option && typeof option === 'object' && option.label && option.key\n\t\t\t\t? { ...option, label: this.tr(option.label) }\n\t\t\t\t: null\n\t\t},\n\n\t\t/** @return {object|null} The template picker config, or null. */\n\t\ttemplates() {\n\t\t\tconst templates = this.content?.templates\n\t\t\treturn templates && typeof templates === 'object' && typeof templates.url === 'string' && templates.url !== '' ? templates : null\n\t\t},\n\n\t\t/** @return {object} The template list's params with tokens resolved. */\n\t\ttemplateParams() {\n\t\t\treturn resolveDeepTokens(this.templates?.params || {}, this.tokenCtx)\n\t\t},\n\n\t\t/** @return {Array<object>} The reply options with a key and a label. */\n\t\treplyOptions() {\n\t\t\tconst list = Array.isArray(this.content?.replyOptions) ? this.content.replyOptions : []\n\t\t\treturn list.filter((option) => option && typeof option.key === 'string' && option.key !== '' && typeof option.label === 'string')\n\t\t},\n\n\t\t/** @return {Array<object>} The message actions with an id, a label and an endpoint. */\n\t\tmessageActions() {\n\t\t\tconst list = Array.isArray(this.content?.messageActions) ? this.content.messageActions : []\n\t\t\treturn list.filter((action) => action && action.id && action.label && typeof action.endpoint === 'string')\n\t\t},\n\n\t\t/** @return {object|null} The reply action, or null. */\n\t\treplyAction() {\n\t\t\tconst action = this.content?.replyAction\n\t\t\treturn action && typeof action === 'object' ? action : null\n\t\t},\n\n\t\t/**\n\t\t * The messages in the thread's shape, oldest first, plus the replies\n\t\t * sent here.\n\t\t *\n\t\t * @return {Array<object>} The messages.\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-conversation-reads-its-messages-from-a-list-and-maps-their-parts\n\t\t */\n\t\tmessages() {\n\t\t\tconst c = this.content || {}\n\t\t\tconst usValue = String(c.outValue ?? c.usValue ?? 'us')\n\t\t\tconst channelMap = c.channelMap && typeof c.channelMap === 'object' ? c.channelMap : {}\n\t\t\tconst statusMap = c.statusMap && typeof c.statusMap === 'object' ? c.statusMap : {}\n\t\t\tconst stored = this.rawMessages()\n\t\t\t\t.map(({ message, side, key }, index) => {\n\t\t\t\t\tconst channel = c.channelField ? readPath(message, c.channelField) : undefined\n\t\t\t\t\tconst channelKey = channel === undefined || channel === null ? '' : String(channel)\n\t\t\t\t\tconst status = c.statusField ? readPath(message, c.statusField) : undefined\n\t\t\t\t\tconst statusKey = status === undefined || status === null ? '' : String(status)\n\t\t\t\t\tconst sideOf = side || (String(readPath(message, c.directionField || c.sideField || 'side')) === usValue ? 'us' : 'them')\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: key,\n\t\t\t\t\t\tauthor: this.authorOf(message, sideOf),\n\t\t\t\t\t\tnote: c.noteField ? this.textOf(readPath(message, c.noteField)) : '',\n\t\t\t\t\t\ttime: readPath(message, c.timestampField || c.timeField || 'time'),\n\t\t\t\t\t\ttext: readPath(message, c.bodyField || c.textField || 'text'),\n\t\t\t\t\t\tside: sideOf,\n\t\t\t\t\t\tchannel: channelKey === '' ? '' : this.tr(Object.hasOwn(channelMap, channelKey) ? channelMap[channelKey] : channelKey),\n\t\t\t\t\t\tstatus: statusKey === '' ? '' : this.tr(Object.hasOwn(statusMap, statusKey) ? statusMap[statusKey] : statusKey),\n\t\t\t\t\t\tactions: this.messageActions\n\t\t\t\t\t\t\t.filter((action) => this.actionApplies(action, message))\n\t\t\t\t\t\t\t.map((action) => ({ id: action.id, label: this.tr(action.label), disabled: this.acting === `${action.id}|${key}` })),\n\t\t\t\t\t\torder: index,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst at = (message) => {\n\t\t\t\tconst ms = Date.parse(message.time)\n\t\t\t\treturn Number.isNaN(ms) ? null : ms\n\t\t\t}\n\t\t\tstored.sort((a, b) => {\n\t\t\t\tconst ta = at(a)\n\t\t\t\tconst tb = at(b)\n\t\t\t\treturn (ta === null || tb === null || ta === tb) ? a.order - b.order : ta - tb\n\t\t\t})\n\t\t\treturn [...stored, ...this.sentHere]\n\t\t},\n\n\t\t/**\n\t\t * The endpoint with the record's id filled in.\n\t\t *\n\t\t * @return {string} The URL, or '' when the content names none.\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t */\n\t\t/**\n\t\t * The reply draft's url (`content.draft.url`, `@objectId` filled in),\n\t\t * or '' without one.\n\t\t *\n\t\t * @return {string}\n\t\t * @spec openspec/changes/conversation-reply-draft/specs/conversation-reply-draft/spec.md#requirement-a-reply-can-be-saved-as-a-draft-and-comes-back\n\t\t */\n\t\tdraftUrl() {\n\t\t\tconst url = this.content.draft && this.content.draft.url\n\t\t\tif (typeof url !== 'string' || url === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn url.replace(/@objectId/g, encodeURIComponent(String(this.objectId ?? '')))\n\t\t},\n\n\t\tendpoint() {\n\t\t\tconst url = this.content.endpoint\n\t\t\tif (typeof url !== 'string' || url === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn url.replace(/@objectId/g, encodeURIComponent(String(this.objectId ?? '')))\n\t\t},\n\n\t\t/** @return {object} The token context for `source.filter` and `replyAction`. */\n\t\ttokenCtx() {\n\t\t\treturn { objectId: this.objectId, object: this.objectData || {} }\n\t\t},\n\t},\n\n\twatch: {\n\t\t// The record was read again, so it now holds what was sent from here.\n\t\tobjectData() {\n\t\t\tthis.sentHere = []\n\t\t},\n\n\t\tobjectId: {\n\t\t\timmediate: true,\n\t\t\thandler() {\n\t\t\t\tthis.loadSource()\n\t\t\t\tthis.loadBadge()\n\t\t\t\tthis.loadDraft()\n\t\t\t},\n\t\t},\n\t},\n\n\tmounted() {\n\t\tsubscribe('cn:page:refresh', this.onPageRefresh)\n\t\tsubscribe('cn:conversation:reply-sent', this.onReplySentElsewhere)\n\t},\n\n\tbeforeUnmount() {\n\t\tunsubscribe('cn:page:refresh', this.onPageRefresh)\n\t\tunsubscribe('cn:conversation:reply-sent', this.onReplySentElsewhere)\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Read the saved reply draft into the reply box.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-draft/specs/conversation-reply-draft/spec.md#requirement-a-reply-can-be-saved-as-a-draft-and-comes-back\n\t\t */\n\t\tasync loadDraft() {\n\t\t\tif (!this.draftUrl) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst { default: axios } = await import('@nextcloud/axios')\n\t\t\t\tconst { generateUrl } = await import('@nextcloud/router')\n\t\t\t\tconst { data } = await axios.get(generateUrl(this.draftUrl))\n\t\t\t\tconst text = data && typeof data.text === 'string' ? data.text : ''\n\t\t\t\tif (text !== '' && this.$refs.thread) {\n\t\t\t\t\tthis.$refs.thread.setDraft(text)\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// No saved draft to read leaves the box empty.\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Store the reply box as the draft and say when it was saved.\n\t\t *\n\t\t * @param {string} text The reply box's text.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync saveDraft(text) {\n\t\t\tthis.savingDraft = true\n\t\t\ttry {\n\t\t\t\tawait this.storeDraft(String(text ?? ''))\n\t\t\t\tthis.draftStatus = t('nextcloud-vue', 'Draft saved at {time}', { time: formatTimeOfDay(new Date()) })\n\t\t\t} catch {\n\t\t\t\tthis.draftStatus = t('nextcloud-vue', 'The draft could not be saved')\n\t\t\t} finally {\n\t\t\t\tthis.savingDraft = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * A reply on this record went out through a dialog or another surface\n\t\t * (`cn:conversation:reply-sent` with `{ objectId }`): the saved draft\n\t\t * and the reply box are cleared.\n\t\t *\n\t\t * @param {{objectId?: string}} payload The record the reply was on.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-draft/specs/conversation-reply-draft/spec.md#requirement-a-reply-can-be-saved-as-a-draft-and-comes-back\n\t\t */\n\t\tasync onReplySentElsewhere(payload) {\n\t\t\tif (!this.draftUrl || String(payload?.objectId ?? '') !== String(this.objectId ?? '')) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.$refs.thread) {\n\t\t\t\tthis.$refs.thread.setDraft('')\n\t\t\t}\n\t\t\tthis.draftStatus = ''\n\t\t\ttry {\n\t\t\t\tawait this.storeDraft('')\n\t\t\t} catch {\n\t\t\t\t// The next save overwrites a draft that could not be cleared.\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * PUT the draft text.\n\t\t *\n\t\t * @param {string} text The text; '' clears the draft.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync storeDraft(text) {\n\t\t\tconst { default: axios } = await import('@nextcloud/axios')\n\t\t\tconst { generateUrl } = await import('@nextcloud/router')\n\t\t\tawait axios.put(generateUrl(this.draftUrl), { text })\n\t\t},\n\n\t\t/**\n\t\t * Read the messages again when the page refreshes (a dialog sent one).\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onPageRefresh() {\n\t\t\tawait Promise.all([this.loadSource(), this.loadBadge()])\n\t\t},\n\n\t\t/**\n\t\t * Read the threads whose latest status `statusBadge` shows\n\t\t * (`{ source: { register, schema, filter?, limit? }, sortField?, path?, map? }`).\n\t\t * A filter whose token does not resolve, or a failed read, shows no badge.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-shows-the-latest-thread-status-and-a-status-can-open-a-follow-up\n\t\t */\n\t\tasync loadBadge() {\n\t\t\tconst source = this.content?.statusBadge?.source\n\t\t\tif (!source || !source.register || !source.schema) {\n\t\t\t\tthis.badgeRows = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst filter = resolveDeepTokens(source.filter || {}, this.tokenCtx)\n\t\t\tif (hasUnresolvedDeepTokens(filter) || Object.values(filter).some((value) => value === '' || value === null || value === undefined)) {\n\t\t\t\tthis.badgeRows = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst rows = await fetchReferenceObjects({ register: source.register, schema: source.schema, filter, limit: source.limit || 50 })\n\t\t\t\tthis.badgeRows = Array.isArray(rows) ? rows : []\n\t\t\t} catch {\n\t\t\t\tthis.badgeRows = []\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The stored messages with the side their list gives them: one list\n\t\t * (`field` or `source`), or several merged (`fields`).\n\t\t *\n\t\t * @return {Array<{message: object, side: string, key: string}>} The messages.\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-merges-several-lists-of-the-record\n\t\t */\n\t\trawMessages() {\n\t\t\tconst c = this.content || {}\n\t\t\tconst lists = !this.source && Array.isArray(c.fields) && c.fields.length > 0\n\t\t\t\t? c.fields.filter((entry) => entry && typeof entry.field === 'string').map((entry) => ({ list: readPath(this.objectData || {}, entry.field), side: entry.side === 'us' ? 'us' : 'them', prefix: entry.field }))\n\t\t\t\t: [{ list: this.source ? this.listed : readPath(this.objectData || {}, c.field || 'messages'), side: '', prefix: 'message' }]\n\t\t\treturn lists.flatMap(({ list, side, prefix }) => (Array.isArray(list) ? list : [])\n\t\t\t\t.filter((message) => message && typeof message === 'object')\n\t\t\t\t.map((message, index) => ({ message, side, key: String(message.id ?? `${prefix}-${index}`) })))\n\t\t},\n\n\t\t/**\n\t\t * Whether a message action applies to a message (`when`).\n\t\t *\n\t\t * @param {object} action The action.\n\t\t * @param {object} message The stored message.\n\t\t * @return {boolean}\n\t\t */\n\t\tactionApplies(action, message) {\n\t\t\tconst conditions = [].concat(action.when || [])\n\t\t\treturn conditions.every((when) => {\n\t\t\t\tif (!when || typeof when !== 'object' || typeof when.field !== 'string') {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tconst value = readPath(message, when.field)\n\t\t\t\tif (when.empty === true) {\n\t\t\t\t\treturn value === undefined || value === null || value === ''\n\t\t\t\t}\n\t\t\t\tif (Array.isArray(when.in)) {\n\t\t\t\t\treturn when.in.map(String).includes(String(value))\n\t\t\t\t}\n\t\t\t\treturn String(value) === String(when.equals)\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The reply options at their defaults.\n\t\t *\n\t\t * @return {object} Values by key.\n\t\t */\n\t\tinitialReplyValues() {\n\t\t\tconst list = Array.isArray(this.content?.replyOptions) ? this.content.replyOptions : []\n\t\t\treturn Object.fromEntries(list.filter((option) => option && option.key).map((option) => [option.key, option.default === true]))\n\t\t},\n\n\t\t/**\n\t\t * Put a picked template's text in the reply box.\n\t\t *\n\t\t * @param {object|null} option The template option.\n\t\t * @param {(text: string) => void} setDraft The thread's draft setter.\n\t\t * @return {void}\n\t\t */\n\t\tapplyTemplate(option, setDraft) {\n\t\t\tif (!option || !option.values) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst text = option.values[this.templates.textField || 'text']\n\t\t\tif (typeof text === 'string') {\n\t\t\t\tsetDraft(text)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run a message action: call its endpoint with the message's fields,\n\t\t * then read the messages again.\n\t\t *\n\t\t * @param {{action: string, message: string}} event Which action on which message.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-message-carries-its-status-and-actions\n\t\t */\n\t\tasync onMessageAction({ action: actionId, message: key }) {\n\t\t\tconst action = this.messageActions.find((entry) => entry.id === actionId)\n\t\t\tconst stored = this.rawMessages().find((entry) => entry.key === key)\n\t\t\tif (!action || !stored || this.acting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.actionError = ''\n\t\t\tthis.acting = `${actionId}|${key}`\n\t\t\ttry {\n\t\t\t\tconst [{ default: axios }, { generateUrl }] = await Promise.all([import('@nextcloud/axios'), import('@nextcloud/router')])\n\t\t\t\tconst path = action.endpoint\n\t\t\t\t\t.replace(/@objectId/g, encodeURIComponent(String(this.objectId ?? '')))\n\t\t\t\t\t.replace(/\\{([\\w.]+)\\}/g, (_m, field) => encodeURIComponent(String(readPath(stored.message, field) ?? '')))\n\t\t\t\tconst response = await axios.request({ method: String(action.method || 'POST').toLowerCase(), url: generateUrl(path) })\n\t\t\t\tif (await this.followUp(action, response?.data)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst refusal = this.actionRefusal(action, response?.data)\n\t\t\t\tif (refusal) {\n\t\t\t\t\tthis.actionError = refusal\n\t\t\t\t}\n\t\t\t\tawait this.loadSource()\n\t\t\t} catch (error) {\n\t\t\t\tif (await this.followUp(action, error?.response?.data)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.actionError = this.actionRefusal(action, error?.response?.data) || this.tr(action.errorText || 'The action failed.')\n\t\t\t} finally {\n\t\t\t\tthis.acting = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run the follow-up action a message action's answer asks for: the\n\t\t * status at `errors.path` (default `status`) looked up in `onStatus`,\n\t\t * dispatched like `headerAction`, tokens resolved against the record.\n\t\t *\n\t\t * @param {object} action The message action.\n\t\t * @param {object|undefined} answer The response body.\n\t\t * @return {Promise<boolean>} True when a follow-up ran.\n\t\t * @spec openspec/changes/conversation-reply-tools/specs/conversation/spec.md#requirement-a-conversation-shows-the-latest-thread-status-and-a-status-can-open-a-follow-up\n\t\t */\n\t\tasync followUp(action, answer) {\n\t\t\tconst map = action.onStatus\n\t\t\tif (!map || typeof map !== 'object' || !answer || typeof answer !== 'object') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst status = readPath(answer, action.errors?.path || 'status')\n\t\t\tconst next = status === undefined || status === null ? null : map[String(status)]\n\t\t\tif (!next || typeof next !== 'object') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst resolved = resolveDeepTokens(next, this.tokenCtx)\n\t\t\ttry {\n\t\t\t\tawait (typeof this.cnDispatchAction === 'function'\n\t\t\t\t\t? this.cnDispatchAction(resolved)\n\t\t\t\t\t: dispatchAction(resolved, { router: this.$router || null }))\n\t\t\t} catch {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The text a message action's answer names, by `errors` (`{ path, map,\n\t\t * ok? }`): the status at `path` mapped to a text. A status listed in `ok`\n\t\t * (default `[\"sent\", \"ok\"]`) is no refusal.\n\t\t *\n\t\t * @param {object} action The action.\n\t\t * @param {object|undefined} answer The response body.\n\t\t * @return {string} The text, '' for none.\n\t\t */\n\t\tactionRefusal(action, answer) {\n\t\t\tconst errors = action.errors\n\t\t\tif (!errors || typeof errors !== 'object' || !answer || typeof answer !== 'object') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst status = readPath(answer, errors.path || 'status')\n\t\t\tif (status === undefined || status === null || (errors.ok || ['sent', 'ok']).map(String).includes(String(status))) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst text = (errors.map || {})[String(status)] || errors.default\n\t\t\treturn text ? this.tr(text) : ''\n\t\t},\n\n\t\t/**\n\t\t * Who wrote a message: `usAuthorField` / `themAuthorField` for its\n\t\t * side, else `senderField` (`authorField`). A field written\n\t\t * `@object.<path>` reads the bound record (the case's requester on an\n\t\t * incoming message). With `usAuthorFormat` / `themAuthorFormat` set to\n\t\t * `user` the value is a user id, shown by its display name.\n\t\t *\n\t\t * @param {object} message The message.\n\t\t * @param {string} side `us` or `them`.\n\t\t * @return {string} The author, or '' when the message names none.\n\t\t * @spec openspec/changes/conversation-board-bubble/specs/conversation-source/spec.md#requirement-a-message-names-its-author-per-side-its-direction-and-a-note\n\t\t */\n\t\tauthorOf(message, side) {\n\t\t\tconst c = this.content || {}\n\t\t\tconst field = (side === 'us' ? c.usAuthorField : c.themAuthorField) || c.senderField || c.authorField || 'author'\n\t\t\tconst value = typeof field === 'string' && field.startsWith('@object.')\n\t\t\t\t? readPath(this.objectData || {}, field.slice('@object.'.length))\n\t\t\t\t: readPath(message, field)\n\t\t\tconst text = this.textOf(value)\n\t\t\tconst format = side === 'us' ? c.usAuthorFormat : c.themAuthorFormat\n\t\t\treturn format === 'user' && text !== '' ? (userDisplayName(text) || text) : text\n\t\t},\n\n\t\t/**\n\t\t * @param {unknown} value A stored value.\n\t\t * @return {string} It as text, or '' for none.\n\t\t */\n\t\ttextOf(value) {\n\t\t\treturn value === undefined || value === null || typeof value === 'object' ? '' : String(value)\n\t\t},\n\n\t\t/**\n\t\t * Translate through the app's translate.\n\t\t *\n\t\t * @param {string} key The source string.\n\t\t * @return {string}\n\t\t */\n\t\ttr(key) {\n\t\t\treturn key && typeof this.cnTranslate === 'function' ? this.cnTranslate(key) : (key || '')\n\t\t},\n\n\t\t/**\n\t\t * Read the messages from `source`. A filter whose token does not\n\t\t * resolve sends no request; a failed read leaves the thread empty.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-conversation-reads-its-messages-from-a-list-and-maps-their-parts\n\t\t */\n\t\tasync loadSource() {\n\t\t\tif (!this.source) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst raw = this.source.filter || {}\n\t\t\tconst filter = resolveDeepTokens(raw, this.tokenCtx)\n\t\t\tconst emptied = Object.keys(raw).some((key) => typeof raw[key] === 'string' && raw[key].startsWith('@') && (filter[key] === '' || filter[key] === null || filter[key] === undefined))\n\t\t\tif (emptied || hasUnresolvedDeepTokens(filter)) {\n\t\t\t\tthis.listed = []\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\ttry {\n\t\t\t\tthis.listed = await fetchReferenceObjects({ register: this.source.register, schema: this.source.schema, filter, limit: this.source.limit || 200 })\n\t\t\t\tthis.sentHere = []\n\t\t\t} catch {\n\t\t\t\tthis.listed = []\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 * Run `replyAction` with the reply, when there is one; the endpoint\n\t\t * path is the thread's own.\n\t\t *\n\t\t * @param {string} text The reply.\n\t\t * @param {object} [extras] The reply option's state, `{ [key]: boolean }`.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/conversation-source/specs/conversation-source/spec.md#requirement-a-reply-can-run-an-app-action\n\t\t * @spec openspec/changes/conversation-reply-option/specs/conversation-source/spec.md#requirement-a-reply-can-carry-a-hint-and-an-option\n\t\t */\n\t\tasync onSend(text, extras = {}) {\n\t\t\tif (!this.replyAction) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst resolved = resolveDeepTokens(this.replyAction, this.tokenCtx)\n\t\t\tconst options = this.replyOptions.length > 0 ? { options: { ...this.replyValues } } : {}\n\t\t\tconst action = { ...resolved, args: [{ text, objectId: this.objectId, ...extras, ...options }], props: { ...(resolved.props || {}), text, ...extras, ...options } }\n\t\t\tconst result = typeof this.cnDispatchAction === 'function'\n\t\t\t\t? this.cnDispatchAction(action)\n\t\t\t\t: dispatchAction(action, { router: this.$router || null })\n\t\t\ttry {\n\t\t\t\tconst outcome = await result\n\t\t\t\tif (outcome === false) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.source) {\n\t\t\t\tawait this.loadSource()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onSent({ text })\n\t\t},\n\n\t\t/**\n\t\t * Run `headerAction` with the record id, then read the source again.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync onHeaderAction() {\n\t\t\tif (!this.headerAction) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst { label, icon, ...rest } = resolveDeepTokens(this.headerAction, this.tokenCtx)\n\t\t\tconst action = { ...rest, args: [{ objectId: this.objectId }] }\n\t\t\ttry {\n\t\t\t\tconst outcome = await (typeof this.cnDispatchAction === 'function'\n\t\t\t\t\t? this.cnDispatchAction(action)\n\t\t\t\t\t: dispatchAction(action, { router: this.$router || null }))\n\t\t\t\tif (outcome === false) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tawait this.loadSource()\n\t\t},\n\n\t\t/**\n\t\t * Show an accepted reply at once, without waiting for the record.\n\t\t *\n\t\t * @param {object} data The endpoint's response.\n\t\t * @return {void}\n\t\t * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-conversation-thread\n\t\t */\n\t\tonSent(data) {\n\t\t\tconst text = data?.message ?? data?.text\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.draftUrl) {\n\t\t\t\tthis.storeDraft('')\n\t\t\t}\n\t\t\tthis.sentHere.push({\n\t\t\t\tid: `sent-${this.sentHere.length}`,\n\t\t\t\ttime: new Date().toISOString(),\n\t\t\t\ttext,\n\t\t\t\tside: 'us',\n\t\t\t})\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-conversation-widget__badge {\n\tpadding: 2px 10px;\n\tborder-radius: var(--border-radius-pill);\n\tbackground: var(--color-background-dark);\n\tcolor: var(--color-main-text);\n\tfont-size: var(--font-size-small, 13px);\n}\n\n.cn-conversation-widget__error {\n\tcolor: var(--color-error-text, var(--color-error));\n\tmargin: calc(2 * var(--default-grid-baseline)) 0 0;\n}\n\n.cn-case-widget-card {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large);\n\tpadding: calc(5 * var(--default-grid-baseline));\n}\n\n.cn-conversation-widget__draft-status {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-size: 13px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_withCtx","_Fragment","_renderList","_createBlock","_toDisplayString","_createTextVNode"],"mappings":"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"}
|
|
@@ -3,7 +3,7 @@ export { FACTS_REVEAL_CHANNEL } from './CnFactsWidget.vue2.js';
|
|
|
3
3
|
import { render } from './CnFactsWidget.vue3.js';
|
|
4
4
|
|
|
5
5
|
script.render = render;
|
|
6
|
-
script.__scopeId = "data-v-
|
|
6
|
+
script.__scopeId = "data-v-1b8f8e6f";
|
|
7
7
|
const __sfc_main = script;
|
|
8
8
|
|
|
9
9
|
export { __sfc_main as default };
|
|
@@ -195,7 +195,7 @@ var script = {
|
|
|
195
195
|
* `as` is `row` (default when `label` or `icon` is set), `title`, `line`, `text` (a line in the normal ink), `lead` (an icon tile or initials beside `title` and `subtitle`), `pill` or `meter`.
|
|
196
196
|
* `countFrom` (`{ register, schema, filter? }`, `@objectId` / `@object.<field>` in the filter) shows how many records that list holds ("Lopende zaken 43"); the row is left out while the count cannot be read.
|
|
197
197
|
* A `meter` shows the amount at `path` against the limit at `limitPath` (or a constant `limit`) as "12 of 50" with a bar; past the limit the bar turns red and the text says "over the limit"; without a positive limit it shows the amount and no bar.
|
|
198
|
-
* A row's `format` may also be `email`, `phone` or `url` (a link) or `masked` (the last four characters; `reveal: true` adds Show). `copy: true` adds a copy button; `icon` replaces the label.
|
|
198
|
+
* A row's `format` may also be `email`, `phone` or `url` (a link) or `masked` (the last four characters; `reveal: true` adds Show, which unmasks the record's value; `reveal: { url, path? }` makes Show ask the server for the value at `url` (tokens resolved), read at `path` (else the entry's path), so a server that answers the mask can check and record the reveal). `copy: true` adds a copy button; `icon` replaces the label.
|
|
199
199
|
* A part may be `{ text }`, a constant; a `line` or `text` entry without `path` or `parts` shows its `text`.
|
|
200
200
|
* `resolve: { register, schema, labelField? }` on an entry or a part turns a value that is a reference (an id, or a list of ids) into the label of the referenced object (`labelField`, else `title`, then `name`): the case type or status of a task shows its name, not its uuid. The ids are fetched once per register and schema through the object store and shared by every facts widget on the page; the entry stays empty until its label is known, and when no label can be read. A resolved value works as a pill too: `map` is applied to the resolved label, and `variantMap` / `colorMap` look the tone up by the value of `resolve.toneField` on the referenced object when that is set (a status named by its `name`, coloured by its `state`), then by the resolved label, then by the stored value.
|
|
201
201
|
* `route` (`{ name, params?, query? }`, `@source.<path>` in a param) on a `title` or a `row` links its value to that route; a param that does not fill leaves it plain.
|
|
@@ -249,6 +249,9 @@ var script = {
|
|
|
249
249
|
error: false,
|
|
250
250
|
/** Keys of the masked rows the reader chose to show. */
|
|
251
251
|
revealed: {},
|
|
252
|
+
revealedValues: {},
|
|
253
|
+
revealErrors: {},
|
|
254
|
+
revealing: '',
|
|
252
255
|
/** Key of the row whose value was just copied. */
|
|
253
256
|
copied: '',
|
|
254
257
|
/** Labels of the referenced objects read so far, by `refKey`. */
|
|
@@ -1096,7 +1099,12 @@ var script = {
|
|
|
1096
1099
|
extras.external = true;
|
|
1097
1100
|
} else if (field.format === 'masked') {
|
|
1098
1101
|
extras.masked = value.length > 4 ? '*'.repeat(Math.min(value.length - 4, 5)) + value.slice(-4) : value;
|
|
1099
|
-
|
|
1102
|
+
const server = field.reveal && typeof field.reveal === 'object' && typeof field.reveal.url === 'string' && field.reveal.url !== '';
|
|
1103
|
+
extras.reveal = (field.reveal === true || server) && value.length > 4;
|
|
1104
|
+
if (server) {
|
|
1105
|
+
extras.revealUrl = field.reveal.url;
|
|
1106
|
+
extras.revealPath = typeof field.reveal.path === 'string' && field.reveal.path !== '' ? field.reveal.path : (field.path || '');
|
|
1107
|
+
}
|
|
1100
1108
|
}
|
|
1101
1109
|
return extras
|
|
1102
1110
|
},
|
|
@@ -1108,7 +1116,14 @@ var script = {
|
|
|
1108
1116
|
* @param {object} row The row.
|
|
1109
1117
|
* @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-the-facts-card-draws-contact-details-identity-and-a-lead
|
|
1110
1118
|
*/
|
|
1111
|
-
reveal(row) {
|
|
1119
|
+
async reveal(row) {
|
|
1120
|
+
if (row.revealUrl) {
|
|
1121
|
+
const value = await this.fetchRevealed(row);
|
|
1122
|
+
if (value === null) {
|
|
1123
|
+
return
|
|
1124
|
+
}
|
|
1125
|
+
this.revealedValues = { ...this.revealedValues, [row.key]: value };
|
|
1126
|
+
}
|
|
1112
1127
|
this.revealed = { ...this.revealed, [row.key]: true };
|
|
1113
1128
|
const detail = { path: row.path };
|
|
1114
1129
|
/**
|
|
@@ -1119,6 +1134,47 @@ var script = {
|
|
|
1119
1134
|
emit(FACTS_REVEAL_CHANNEL, { ...detail, objectId: this.tokenCtx.objectId, register: this.tokenCtx.register || null, schema: this.tokenCtx.schema || null });
|
|
1120
1135
|
},
|
|
1121
1136
|
|
|
1137
|
+
/**
|
|
1138
|
+
* The text a row shows: its mask until revealed, then the value the
|
|
1139
|
+
* server answered (a server reveal) or the value the record holds.
|
|
1140
|
+
*
|
|
1141
|
+
* @param {object} row The row.
|
|
1142
|
+
* @return {string}
|
|
1143
|
+
* @spec openspec/changes/facts-reveal-from-server/specs/facts-widget/spec.md#requirement-a-masked-fact-can-be-revealed-by-the-server
|
|
1144
|
+
*/
|
|
1145
|
+
shownValue(row) {
|
|
1146
|
+
if (!row.masked || !this.revealed[row.key]) {
|
|
1147
|
+
return row.masked || row.value
|
|
1148
|
+
}
|
|
1149
|
+
return Object.hasOwn(this.revealedValues, row.key) ? this.revealedValues[row.key] : row.value
|
|
1150
|
+
},
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Ask the server for a masked value (`reveal.url`, tokens resolved,
|
|
1154
|
+
* read at `reveal.path`), never from a cache: each show is a request
|
|
1155
|
+
* the server can check and record.
|
|
1156
|
+
*
|
|
1157
|
+
* @param {object} row The row.
|
|
1158
|
+
* @return {Promise<string|null>} The value, or null when it could not be read.
|
|
1159
|
+
* @spec openspec/changes/facts-reveal-from-server/specs/facts-widget/spec.md#requirement-a-masked-fact-can-be-revealed-by-the-server
|
|
1160
|
+
*/
|
|
1161
|
+
async fetchRevealed(row) {
|
|
1162
|
+
this.revealing = row.key;
|
|
1163
|
+
this.revealErrors = { ...this.revealErrors, [row.key]: '' };
|
|
1164
|
+
try {
|
|
1165
|
+
const payload = await fetchEndpointSource({ url: row.revealUrl, responsePath: row.revealPath }, this.tokenCtx, { force: true });
|
|
1166
|
+
if (payload === null || payload === undefined || payload === '' || typeof payload === 'object') {
|
|
1167
|
+
throw new Error('no value')
|
|
1168
|
+
}
|
|
1169
|
+
return String(payload)
|
|
1170
|
+
} catch {
|
|
1171
|
+
this.revealErrors = { ...this.revealErrors, [row.key]: translate('nextcloud-vue', 'The value could not be shown.') };
|
|
1172
|
+
return null
|
|
1173
|
+
} finally {
|
|
1174
|
+
this.revealing = '';
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
|
|
1122
1178
|
/**
|
|
1123
1179
|
* Copy a row's value to the clipboard.
|
|
1124
1180
|
*
|