@conduction/nextcloud-vue 2.156.0 → 2.157.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/CnBannerWidget/CnBannerWidget.vue.js +1 -1
- package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue.js +1 -1
- package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDuplicateWarning/CnDuplicateWarning.vue.js +1 -1
- package/dist/esm/components/CnDuplicateWarning/CnDuplicateWarning.vue2.js +2 -1
- package/dist/esm/components/CnDuplicateWarning/CnDuplicateWarning.vue2.js.map +1 -1
- package/dist/esm/components/CnDuplicateWarning/CnDuplicateWarning.vue3.js +10 -3
- package/dist/esm/components/CnDuplicateWarning/CnDuplicateWarning.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +14 -4
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js +3 -3
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue.js +1 -1
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFeaturesBoard/CnFeaturesBoard.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 +2 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnMailTab/CnMailTab.vue.js +1 -1
- package/dist/esm/components/CnMailTab/CnMailTab.vue2.js +4 -4
- package/dist/esm/components/CnMailTab/CnMailTab.vue2.js.map +1 -1
- package/dist/esm/components/CnMailTab/CnMailTab.vue3.js.map +1 -1
- package/dist/esm/components/CnNotificationMatrix/CnNotificationMatrix.vue.js +1 -1
- package/dist/esm/components/CnNotificationMatrix/CnNotificationMatrix.vue2.js +3 -0
- package/dist/esm/components/CnNotificationMatrix/CnNotificationMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnNotificationMatrix/CnNotificationMatrix.vue3.js +10 -2
- package/dist/esm/components/CnNotificationMatrix/CnNotificationMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue.js +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue2.js +6 -0
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue2.js.map +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue3.js +2 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue3.js.map +1 -1
- package/dist/esm/components/CnSavedViewLookFields/CnSavedViewLookFields.vue.js +1 -1
- package/dist/esm/components/CnSavedViewLookFields/CnSavedViewLookFields.vue2.js.map +1 -1
- package/dist/esm/components/CnSavedViewLookFields/CnSavedViewLookFields.vue3.js +27 -24
- package/dist/esm/components/CnSavedViewLookFields/CnSavedViewLookFields.vue3.js.map +1 -1
- package/dist/esm/components/CnSearchSelect/CnSearchSelect.vue.js +1 -1
- package/dist/esm/components/CnSearchSelect/CnSearchSelect.vue2.js.map +1 -1
- package/dist/esm/components/CnSearchSelect/CnSearchSelect.vue3.js.map +1 -1
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue.js +1 -1
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js +4 -1
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnStagesWidget/stagesModel.js +10 -2
- package/dist/esm/components/CnStagesWidget/stagesModel.js.map +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineManage.vue.js +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineManage.vue2.js +61 -2
- package/dist/esm/components/CnTimelineWidget/CnTimelineManage.vue2.js.map +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineManage.vue3.js +68 -44
- package/dist/esm/components/CnTimelineWidget/CnTimelineManage.vue3.js.map +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue.js +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue2.js +13 -3
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue3.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +667 -375
- package/dist/esm/utils/dynamicProperties.js +14 -2
- package/dist/esm/utils/dynamicProperties.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +829 -678
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +667 -375
- package/package.json +1 -1
- package/src/components/CnBannerWidget/CnBannerWidget.vue +5 -1
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +12 -5
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +12 -0
- package/src/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue +1 -0
- package/src/components/CnDuplicateWarning/CnDuplicateWarning.vue +8 -4
- package/src/components/CnFactsWidget/CnFactsWidget.vue +31 -6
- package/src/components/CnFeaturesBoard/CnFeaturesBoard.vue +4 -2
- package/src/components/CnFormDialog/CnFormDialog.vue +1 -0
- package/src/components/CnMailTab/CnMailTab.vue +4 -4
- package/src/components/CnNotificationMatrix/CnNotificationMatrix.vue +20 -0
- package/src/components/CnPartyPicker/CnPartyPicker.vue +7 -0
- package/src/components/CnSavedViewLookFields/CnSavedViewLookFields.vue +27 -20
- package/src/components/CnSearchSelect/CnSearchSelect.vue +3 -1
- package/src/components/CnStagesWidget/CnStagesWidget.vue +4 -1
- package/src/components/CnStagesWidget/stagesModel.js +10 -2
- package/src/components/CnTimelineWidget/CnTimelineManage.vue +69 -4
- package/src/css/dialog.css +33 -0
- package/src/css/look-board-detail.css +4 -3
- package/src/css/look-board-index.css +34 -3
- package/src/css/look-board.css +170 -4
- package/src/integrations/builtin/email/CnEmailTab.vue +13 -3
- package/src/utils/dynamicProperties.js +13 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnDeviceFramesWidget.vue2.js","sources":["../../../../src/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-device-frames-widget\" data-testid=\"cn-device-frames-widget\">\n\t\t<section\n\t\t\tv-for=\"frame in frames\"\n\t\t\t:key=\"frame.key\"\n\t\t\tclass=\"cn-device-frames-widget__frame\"\n\t\t\t:style=\"frameStyle\"\n\t\t\t:aria-labelledby=\"headingId(frame.key)\"\n\t\t\t:data-testid=\"`cn-device-frame-${frame.key}`\">\n\t\t\t<header class=\"cn-device-frames-widget__head\">\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"frame.status\"\n\t\t\t\t\tclass=\"cn-device-frames-widget__status\"\n\t\t\t\t\t:class=\"`cn-device-frames-widget__status--${frame.status.tone}`\"\n\t\t\t\t\tdata-testid=\"cn-device-frame-status\">\n\t\t\t\t\t<component :is=\"frame.status.icon\" :size=\"16\" aria-hidden=\"true\" />\n\t\t\t\t\t{{ frame.status.text }}\n\t\t\t\t</span>\n\t\t\t\t<h3 :id=\"headingId(frame.key)\" class=\"cn-device-frames-widget__title\">\n\t\t\t\t\t{{ frame.title }}\n\t\t\t\t</h3>\n\t\t\t</header>\n\t\t\t<div class=\"cn-device-frames-widget__body\">\n\t\t\t\t<CnSectionsWidget\n\t\t\t\t\t:content=\"{ sections: frame.sections, cards: false, hideEmpty: true }\"\n\t\t\t\t\t:availableWidgets=\"availableWidgets\"\n\t\t\t\t\t:objectId=\"objectId\"\n\t\t\t\t\t:objectData=\"objectData\"\n\t\t\t\t\t:objectType=\"objectType\"\n\t\t\t\t\t:schemaObject=\"schemaObject\"\n\t\t\t\t\t:register=\"register\"\n\t\t\t\t\t:schema=\"schema\"\n\t\t\t\t\t:store=\"store\"\n\t\t\t\t\t:surface=\"surface\"\n\t\t\t\t\t:integrationContext=\"integrationContext\"\n\t\t\t\t\t:cnRegistry=\"cnRegistry\" />\n\t\t\t</div>\n\t\t</section>\n\t</div>\n</template>\n\n<script>\nimport { markRaw } from 'vue'\nimport CloudCheckOutline from 'vue-material-design-icons/CloudCheckOutline.vue'\nimport CloudOffOutline from 'vue-material-design-icons/CloudOffOutline.vue'\nimport InformationOutline from 'vue-material-design-icons/InformationOutline.vue'\nimport CnSectionsWidget from '../CnSectionsWidget/CnSectionsWidget.vue'\n\n/** Counter for unique heading ids across instances. */\nlet instanceCounter = 0\n\n/**\n * CnDeviceFramesWidget - the `device-frames` widget: several small pages side\n * by side, each in a phone frame with its own header (board DqInspectie,\n * \"Inspectie in het veld\": the day offline, a checklist question with a\n * photo, and the sync queue).\n *\n * Each frame stacks widgets of the surface, as the `sections` widget does,\n * under a header with the frame's title and an optional status line. The\n * status can follow the connection (\"Offline · synced at 07:42\" while the\n * device is offline). The frames wrap onto the next row when the page is\n * narrower, and a frame takes the full width on a phone.\n *\n * ```json\n * {\n * \"type\": \"device-frames\",\n * \"content\": {\n * \"width\": 350,\n * \"status\": { \"followConnection\": true, \"offlineText\": \"Offline · synced at 07:42\", \"onlineText\": \"Online\" },\n * \"frames\": [\n * { \"key\": \"today\", \"title\": \"Today\", \"widgetIds\": [\"today-runs\", \"offline-note\"] },\n * { \"key\": \"question\", \"title\": \"Kerkplein 7\", \"widgetIds\": [\"checklist-run\"] },\n * { \"key\": \"sync\", \"title\": \"Synchronise\", \"widgetIds\": [\"sync-queue\"] }\n * ]\n * }\n * }\n * ```\n *\n * @spec openspec/changes/device-frames-widget/specs/device-frames-widget/spec.md#requirement-a-page-can-show-several-small-pages-as-phone-frames\n */\nexport default {\n\tname: 'CnDeviceFramesWidget',\n\n\tcomponents: { CnSectionsWidget },\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget configuration.\n\t\t *\n\t\t * - `frames` — `[{ key?, title, widgetIds? | sections?, status? }]`, in order. `widgetIds` names\n\t\t * widgets of the surface, stacked; `sections` takes the `sections` widget's entries instead.\n\t\t * - `status` — the status line of every frame (a frame's own `status` wins): `{ text?, tone?,\n\t\t * followConnection?, onlineText?, offlineText? }`. With `followConnection` the line reads\n\t\t * `offlineText` while the device is offline and `onlineText` otherwise. `tone` is `warning`\n\t\t * (default while offline), `success` or `info`.\n\t\t * - `width` — the frame width in pixels (default 350).\n\t\t * - `height` — the frame height in pixels (at least 400); what does not fit scrolls inside it. Without it the frame grows with its content.\n\t\t *\n\t\t * @type {{frames?: Array<object>, status?: object, width?: number}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** Sibling widget definitions on the surface, for `widgetIds`. */\n\t\tavailableWidgets: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** The bound record's id, forwarded to the children. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The loaded record, forwarded to the children. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The resolved object-type slug. */\n\t\tobjectType: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The resolved JSON Schema object. */\n\t\tschemaObject: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** OpenRegister register slug of the surface. */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** OpenRegister schema slug of the surface. */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The effective object store. */\n\t\tstore: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Rendering surface forwarded to the children. */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/** Object context forwarded to integration children. */\n\t\tintegrationContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The consumer's component registry, for custom child widget types. */\n\t\tcnRegistry: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: instanceCounter,\n\t\t\tonline: typeof navigator === 'undefined' || navigator.onLine !== false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The frame width. */\n\t\tframeStyle() {\n\t\t\tconst width = Number(this.content?.width)\n\t\t\tconst height = Number(this.content?.height)\n\t\t\tconst style = { '--cn-device-frame-width': `${Number.isFinite(width) && width >= 240 ? width : 350}px` }\n\t\t\tif (Number.isFinite(height) && height >= 400) {\n\t\t\t\tstyle['--cn-device-frame-height'] = `${height}px`\n\t\t\t}\n\t\t\treturn style\n\t\t},\n\n\t\t/**\n\t\t * The frames to draw: a key, a translated title, the sections and the\n\t\t * status line.\n\t\t *\n\t\t * @return {Array<{key: string, title: string, sections: Array<object>, status: object|null}>}\n\t\t */\n\t\tframes() {\n\t\t\tconst list = Array.isArray(this.content?.frames) ? this.content.frames : []\n\t\t\treturn list\n\t\t\t\t.filter((frame) => frame && typeof frame === 'object')\n\t\t\t\t.map((frame, index) => {\n\t\t\t\t\tconst sections = Array.isArray(frame.sections)\n\t\t\t\t\t\t? frame.sections\n\t\t\t\t\t\t: (Array.isArray(frame.widgetIds) ? frame.widgetIds : []).filter((id) => typeof id === 'string' && id !== '').map((widgetId) => ({ widgetId }))\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: String(frame.key || `frame-${index}`).replace(/[^\\w-]/g, '-'),\n\t\t\t\t\t\ttitle: this.tr(frame.title || ''),\n\t\t\t\t\t\tsections,\n\t\t\t\t\t\tstatus: this.statusOf(frame.status || this.content?.status || null),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.addEventListener('online', this.onConnection)\n\t\t\twindow.addEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.removeEventListener('online', this.onConnection)\n\t\t\twindow.removeEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tmethods: {\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 * The status line of a frame, or null.\n\t\t *\n\t\t * @param {object|null} status The configured status.\n\t\t * @return {{text: string, tone: string, icon: object}|null}\n\t\t */\n\t\tstatusOf(status) {\n\t\t\tif (!status || typeof status !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tlet text = status.text\n\t\t\tlet tone = status.tone\n\t\t\tif (status.followConnection === true) {\n\t\t\t\ttext = this.online ? status.onlineText : status.offlineText\n\t\t\t\ttone = tone || (this.online ? 'success' : 'warning')\n\t\t\t}\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst known = ['warning', 'success', 'info'].includes(tone) ? tone : 'info'\n\t\t\tconst icon = known === 'warning' ? CloudOffOutline : (known === 'success' ? CloudCheckOutline : InformationOutline)\n\t\t\treturn { text: this.tr(text), tone: known, icon: markRaw(icon) }\n\t\t},\n\n\t\t/** Follow the browser's connection state. */\n\t\tonConnection() {\n\t\t\tthis.online = typeof navigator === 'undefined' || navigator.onLine !== false\n\t\t},\n\n\t\t/**\n\t\t * The id of a frame's heading.\n\t\t *\n\t\t * @param {string} key The frame key.\n\t\t * @return {string}\n\t\t */\n\t\theadingId(key) {\n\t\t\treturn `cn-device-frame-${this.uid}-${key}`\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-device-frames-widget {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: flex-start;\n\tgap: 20px;\n}\n\n.cn-device-frames-widget__frame {\n\tdisplay: flex;\n\tflex: none;\n\tflex-direction: column;\n\twidth: var(--cn-device-frame-width, 350px);\n\tmax-width: 100%;\n\tmin-height: 600px;\n\theight: var(--cn-device-frame-height, auto);\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tborder: 10px solid var(--color-main-text);\n\tborder-radius: 36px;\n\tbackground: var(--color-background-hover);\n}\n\n.cn-device-frames-widget__head {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n\tpadding: 14px 18px 10px;\n\tborder-bottom: 1px solid var(--color-border);\n\tbackground: var(--color-main-background);\n}\n\n.cn-device-frames-widget__status {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tfont-size: 13px;\n\tfont-weight: 600;\n}\n\n.cn-device-frames-widget__status--warning {\n\tcolor: var(--color-warning-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--success {\n\tcolor: var(--color-success-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--info {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-device-frames-widget__title {\n\tmargin: 0;\n\tfont-size: 20px;\n\tfont-weight: 700;\n\tline-height: 1.2;\n}\n\n.cn-device-frames-widget__body {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 14px;\n}\n\n/* `height` (DqInspectie: 700) makes every frame a phone of that height;\n what does not fit scrolls inside the screen. */\n.cn-device-frames-widget__frame[style*='--cn-device-frame-height'] .cn-device-frames-widget__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n\toverflow-y: auto;\n}\n\n/* On a phone the frame is the screen: no bezel, the full width. */\n@media (max-width: 640px) {\n\t.cn-device-frames-widget__frame {\n\t\twidth: 100%;\n\t\tmin-height: 0;\n\t\tborder-width: 0;\n\t\tborder-radius: var(--cn-board-card-radius, 12px);\n\t}\n}\n</style>\n"],"names":["CnSectionsWidget"],"mappings":";;;;;;AAqDA;AACA,IAAI,kBAAkB,EAAA;;AAEtB;AACC;;;;AAIA;;;;;AAKA;AACA;AACA;;;;;;;AAOA;AACA;AACA;;;;AAIA;AACA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,sBAAsB;;CAE5B,UAAU,EAAE,oBAAEA,UAAe,EAAG;;AAEhC,CAAA,MAAM,EAAE;AACP,EAAA,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,KAAK;EAC5C;;AAED,CAAA,KAAK,EAAE;AACN;;AAEC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGD,E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DeviceFramesWidget/CnDeviceFramesWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-device-frames-widget\" data-testid=\"cn-device-frames-widget\">\n\t\t<section\n\t\t\tv-for=\"frame in frames\"\n\t\t\t:key=\"frame.key\"\n\t\t\tclass=\"cn-device-frames-widget__frame\"\n\t\t\t:style=\"frameStyle\"\n\t\t\t:aria-labelledby=\"headingId(frame.key)\"\n\t\t\t:data-testid=\"`cn-device-frame-${frame.key}`\">\n\t\t\t<header class=\"cn-device-frames-widget__head\">\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"frame.status\"\n\t\t\t\t\tclass=\"cn-device-frames-widget__status\"\n\t\t\t\t\t:class=\"`cn-device-frames-widget__status--${frame.status.tone}`\"\n\t\t\t\t\tdata-testid=\"cn-device-frame-status\">\n\t\t\t\t\t<component :is=\"frame.status.icon\" :size=\"16\" aria-hidden=\"true\" />\n\t\t\t\t\t{{ frame.status.text }}\n\t\t\t\t</span>\n\t\t\t\t<h3 :id=\"headingId(frame.key)\" class=\"cn-device-frames-widget__title\">\n\t\t\t\t\t{{ frame.title }}\n\t\t\t\t</h3>\n\t\t\t</header>\n\t\t\t<div class=\"cn-device-frames-widget__body\">\n\t\t\t\t<CnSectionsWidget\n\t\t\t\t\t:content=\"{ sections: frame.sections, cards: false, hideEmpty: true }\"\n\t\t\t\t\t:availableWidgets=\"availableWidgets\"\n\t\t\t\t\t:objectId=\"objectId\"\n\t\t\t\t\t:objectData=\"objectData\"\n\t\t\t\t\t:objectType=\"objectType\"\n\t\t\t\t\t:schemaObject=\"schemaObject\"\n\t\t\t\t\t:register=\"register\"\n\t\t\t\t\t:schema=\"schema\"\n\t\t\t\t\t:store=\"store\"\n\t\t\t\t\t:surface=\"surface\"\n\t\t\t\t\t:integrationContext=\"integrationContext\"\n\t\t\t\t\t:cnRegistry=\"cnRegistry\" />\n\t\t\t</div>\n\t\t</section>\n\t</div>\n</template>\n\n<script>\nimport { markRaw } from 'vue'\nimport CloudCheckOutline from 'vue-material-design-icons/CloudCheckOutline.vue'\nimport CloudOffOutline from 'vue-material-design-icons/CloudOffOutline.vue'\nimport InformationOutline from 'vue-material-design-icons/InformationOutline.vue'\nimport CnSectionsWidget from '../CnSectionsWidget/CnSectionsWidget.vue'\n\n/** Counter for unique heading ids across instances. */\nlet instanceCounter = 0\n\n/**\n * CnDeviceFramesWidget - the `device-frames` widget: several small pages side\n * by side, each in a phone frame with its own header (board DqInspectie,\n * \"Inspectie in het veld\": the day offline, a checklist question with a\n * photo, and the sync queue).\n *\n * Each frame stacks widgets of the surface, as the `sections` widget does,\n * under a header with the frame's title and an optional status line. The\n * status can follow the connection (\"Offline · synced at 07:42\" while the\n * device is offline). The frames wrap onto the next row when the page is\n * narrower, and a frame takes the full width on a phone.\n *\n * ```json\n * {\n * \"type\": \"device-frames\",\n * \"content\": {\n * \"width\": 350,\n * \"status\": { \"followConnection\": true, \"offlineText\": \"Offline · synced at 07:42\", \"onlineText\": \"Online\" },\n * \"frames\": [\n * { \"key\": \"today\", \"title\": \"Today\", \"widgetIds\": [\"today-runs\", \"offline-note\"] },\n * { \"key\": \"question\", \"title\": \"Kerkplein 7\", \"widgetIds\": [\"checklist-run\"] },\n * { \"key\": \"sync\", \"title\": \"Synchronise\", \"widgetIds\": [\"sync-queue\"] }\n * ]\n * }\n * }\n * ```\n *\n * @spec openspec/changes/device-frames-widget/specs/device-frames-widget/spec.md#requirement-a-page-can-show-several-small-pages-as-phone-frames\n */\nexport default {\n\tname: 'CnDeviceFramesWidget',\n\n\tcomponents: { CnSectionsWidget },\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget configuration.\n\t\t *\n\t\t * - `frames` — `[{ key?, title, widgetIds? | sections?, status? }]`, in order. `widgetIds` names\n\t\t * widgets of the surface, stacked; `sections` takes the `sections` widget's entries instead.\n\t\t * - `status` — the status line of every frame (a frame's own `status` wins): `{ text?, tone?,\n\t\t * followConnection?, onlineText?, offlineText? }`. With `followConnection` the line reads\n\t\t * `offlineText` while the device is offline and `onlineText` otherwise. `tone` is `warning`\n\t\t * (default while offline), `success` or `info`.\n\t\t * - `width` — the frame width in pixels (default 350).\n\t\t * - `height` — the frame height in pixels (at least 400); what does not fit scrolls inside it. Without it the frame grows with its content.\n\t\t *\n\t\t * @type {{frames?: Array<object>, status?: object, width?: number}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** Sibling widget definitions on the surface, for `widgetIds`. */\n\t\tavailableWidgets: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** The bound record's id, forwarded to the children. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The loaded record, forwarded to the children. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The resolved object-type slug. */\n\t\tobjectType: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The resolved JSON Schema object. */\n\t\tschemaObject: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** OpenRegister register slug of the surface. */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** OpenRegister schema slug of the surface. */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The effective object store. */\n\t\tstore: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Rendering surface forwarded to the children. */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/** Object context forwarded to integration children. */\n\t\tintegrationContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The consumer's component registry, for custom child widget types. */\n\t\tcnRegistry: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: instanceCounter,\n\t\t\tonline: typeof navigator === 'undefined' || navigator.onLine !== false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The frame width. */\n\t\tframeStyle() {\n\t\t\tconst width = Number(this.content?.width)\n\t\t\tconst height = Number(this.content?.height)\n\t\t\tconst style = { '--cn-device-frame-width': `${Number.isFinite(width) && width >= 240 ? width : 350}px` }\n\t\t\tif (Number.isFinite(height) && height >= 400) {\n\t\t\t\tstyle['--cn-device-frame-height'] = `${height}px`\n\t\t\t}\n\t\t\treturn style\n\t\t},\n\n\t\t/**\n\t\t * The frames to draw: a key, a translated title, the sections and the\n\t\t * status line.\n\t\t *\n\t\t * @return {Array<{key: string, title: string, sections: Array<object>, status: object|null}>}\n\t\t */\n\t\tframes() {\n\t\t\tconst list = Array.isArray(this.content?.frames) ? this.content.frames : []\n\t\t\treturn list\n\t\t\t\t.filter((frame) => frame && typeof frame === 'object')\n\t\t\t\t.map((frame, index) => {\n\t\t\t\t\tconst sections = Array.isArray(frame.sections)\n\t\t\t\t\t\t? frame.sections\n\t\t\t\t\t\t: (Array.isArray(frame.widgetIds) ? frame.widgetIds : []).filter((id) => typeof id === 'string' && id !== '').map((widgetId) => ({ widgetId }))\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: String(frame.key || `frame-${index}`).replace(/[^\\w-]/g, '-'),\n\t\t\t\t\t\ttitle: this.tr(frame.title || ''),\n\t\t\t\t\t\tsections,\n\t\t\t\t\t\tstatus: this.statusOf(frame.status || this.content?.status || null),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.addEventListener('online', this.onConnection)\n\t\t\twindow.addEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.removeEventListener('online', this.onConnection)\n\t\t\twindow.removeEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tmethods: {\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 * The status line of a frame, or null.\n\t\t *\n\t\t * @param {object|null} status The configured status.\n\t\t * @return {{text: string, tone: string, icon: object}|null}\n\t\t */\n\t\tstatusOf(status) {\n\t\t\tif (!status || typeof status !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tlet text = status.text\n\t\t\tlet tone = status.tone\n\t\t\tif (status.followConnection === true) {\n\t\t\t\ttext = this.online ? status.onlineText : status.offlineText\n\t\t\t\ttone = tone || (this.online ? 'success' : 'warning')\n\t\t\t}\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst known = ['warning', 'success', 'info'].includes(tone) ? tone : 'info'\n\t\t\tconst icon = known === 'warning' ? CloudOffOutline : (known === 'success' ? CloudCheckOutline : InformationOutline)\n\t\t\treturn { text: this.tr(text), tone: known, icon: markRaw(icon) }\n\t\t},\n\n\t\t/** Follow the browser's connection state. */\n\t\tonConnection() {\n\t\t\tthis.online = typeof navigator === 'undefined' || navigator.onLine !== false\n\t\t},\n\n\t\t/**\n\t\t * The id of a frame's heading.\n\t\t *\n\t\t * @param {string} key The frame key.\n\t\t * @return {string}\n\t\t */\n\t\theadingId(key) {\n\t\t\treturn `cn-device-frame-${this.uid}-${key}`\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-device-frames-widget {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: flex-start;\n\tgap: 20px;\n}\n\n.cn-device-frames-widget__frame {\n\tdisplay: flex;\n\tflex: none;\n\tflex-direction: column;\n\twidth: var(--cn-device-frame-width, 350px);\n\tmax-width: 100%;\n\tmin-height: 600px;\n\theight: var(--cn-device-frame-height, auto);\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tborder: 10px solid var(--color-main-text);\n\tborder-radius: 36px;\n\tbackground: var(--color-background-hover);\n}\n\n.cn-device-frames-widget__head {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n\tpadding: 14px 18px 10px;\n\tborder-bottom: 1px solid var(--color-border);\n\tbackground: var(--color-main-background);\n}\n\n.cn-device-frames-widget__status {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tline-height: normal;\n}\n\n.cn-device-frames-widget__status--warning {\n\tcolor: var(--color-warning-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--success {\n\tcolor: var(--color-success-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--info {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-device-frames-widget__title {\n\tmargin: 0;\n\tfont-size: 20px;\n\tfont-weight: 700;\n\tline-height: 1.2;\n}\n\n.cn-device-frames-widget__body {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 14px;\n}\n\n/* `height` (DqInspectie: 700) makes every frame a phone of that height;\n what does not fit scrolls inside the screen. */\n.cn-device-frames-widget__frame[style*='--cn-device-frame-height'] .cn-device-frames-widget__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n\toverflow-y: auto;\n}\n\n/* On a phone the frame is the screen: no bezel, the full width. */\n@media (max-width: 640px) {\n\t.cn-device-frames-widget__frame {\n\t\twidth: 100%;\n\t\tmin-height: 0;\n\t\tborder-width: 0;\n\t\tborder-radius: var(--cn-board-card-radius, 12px);\n\t}\n}\n</style>\n"],"names":["CnSectionsWidget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AAO,CAAC,IAAI,CAAE,EAAA;GAC/D;;AAED;AACA,EAAA,YAAY,GAAG;AACd,GAAA,IAAI,CAAC,MAAK,GAAI,OAAO,SAAU,KAAI,WAAU,IAAK,SAAS,CAAC,MAAO,KAAI,MAAI;GAC3E;;AAED;;AAEC;;AAEA;;AAED,EAAA,SAAS,CAAC,GAAG,EAAE;AACd,GAAA,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;GAC1C;EACD;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnDeviceFramesWidget.vue3.js","sources":["../../../../src/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue?vue&type=template&id=9442557e&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-device-frames-widget\" data-testid=\"cn-device-frames-widget\">\n\t\t<section\n\t\t\tv-for=\"frame in frames\"\n\t\t\t:key=\"frame.key\"\n\t\t\tclass=\"cn-device-frames-widget__frame\"\n\t\t\t:style=\"frameStyle\"\n\t\t\t:aria-labelledby=\"headingId(frame.key)\"\n\t\t\t:data-testid=\"`cn-device-frame-${frame.key}`\">\n\t\t\t<header class=\"cn-device-frames-widget__head\">\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"frame.status\"\n\t\t\t\t\tclass=\"cn-device-frames-widget__status\"\n\t\t\t\t\t:class=\"`cn-device-frames-widget__status--${frame.status.tone}`\"\n\t\t\t\t\tdata-testid=\"cn-device-frame-status\">\n\t\t\t\t\t<component :is=\"frame.status.icon\" :size=\"16\" aria-hidden=\"true\" />\n\t\t\t\t\t{{ frame.status.text }}\n\t\t\t\t</span>\n\t\t\t\t<h3 :id=\"headingId(frame.key)\" class=\"cn-device-frames-widget__title\">\n\t\t\t\t\t{{ frame.title }}\n\t\t\t\t</h3>\n\t\t\t</header>\n\t\t\t<div class=\"cn-device-frames-widget__body\">\n\t\t\t\t<CnSectionsWidget\n\t\t\t\t\t:content=\"{ sections: frame.sections, cards: false, hideEmpty: true }\"\n\t\t\t\t\t:availableWidgets=\"availableWidgets\"\n\t\t\t\t\t:objectId=\"objectId\"\n\t\t\t\t\t:objectData=\"objectData\"\n\t\t\t\t\t:objectType=\"objectType\"\n\t\t\t\t\t:schemaObject=\"schemaObject\"\n\t\t\t\t\t:register=\"register\"\n\t\t\t\t\t:schema=\"schema\"\n\t\t\t\t\t:store=\"store\"\n\t\t\t\t\t:surface=\"surface\"\n\t\t\t\t\t:integrationContext=\"integrationContext\"\n\t\t\t\t\t:cnRegistry=\"cnRegistry\" />\n\t\t\t</div>\n\t\t</section>\n\t</div>\n</template>\n\n<script>\nimport { markRaw } from 'vue'\nimport CloudCheckOutline from 'vue-material-design-icons/CloudCheckOutline.vue'\nimport CloudOffOutline from 'vue-material-design-icons/CloudOffOutline.vue'\nimport InformationOutline from 'vue-material-design-icons/InformationOutline.vue'\nimport CnSectionsWidget from '../CnSectionsWidget/CnSectionsWidget.vue'\n\n/** Counter for unique heading ids across instances. */\nlet instanceCounter = 0\n\n/**\n * CnDeviceFramesWidget - the `device-frames` widget: several small pages side\n * by side, each in a phone frame with its own header (board DqInspectie,\n * \"Inspectie in het veld\": the day offline, a checklist question with a\n * photo, and the sync queue).\n *\n * Each frame stacks widgets of the surface, as the `sections` widget does,\n * under a header with the frame's title and an optional status line. The\n * status can follow the connection (\"Offline · synced at 07:42\" while the\n * device is offline). The frames wrap onto the next row when the page is\n * narrower, and a frame takes the full width on a phone.\n *\n * ```json\n * {\n * \"type\": \"device-frames\",\n * \"content\": {\n * \"width\": 350,\n * \"status\": { \"followConnection\": true, \"offlineText\": \"Offline · synced at 07:42\", \"onlineText\": \"Online\" },\n * \"frames\": [\n * { \"key\": \"today\", \"title\": \"Today\", \"widgetIds\": [\"today-runs\", \"offline-note\"] },\n * { \"key\": \"question\", \"title\": \"Kerkplein 7\", \"widgetIds\": [\"checklist-run\"] },\n * { \"key\": \"sync\", \"title\": \"Synchronise\", \"widgetIds\": [\"sync-queue\"] }\n * ]\n * }\n * }\n * ```\n *\n * @spec openspec/changes/device-frames-widget/specs/device-frames-widget/spec.md#requirement-a-page-can-show-several-small-pages-as-phone-frames\n */\nexport default {\n\tname: 'CnDeviceFramesWidget',\n\n\tcomponents: { CnSectionsWidget },\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget configuration.\n\t\t *\n\t\t * - `frames` — `[{ key?, title, widgetIds? | sections?, status? }]`, in order. `widgetIds` names\n\t\t * widgets of the surface, stacked; `sections` takes the `sections` widget's entries instead.\n\t\t * - `status` — the status line of every frame (a frame's own `status` wins): `{ text?, tone?,\n\t\t * followConnection?, onlineText?, offlineText? }`. With `followConnection` the line reads\n\t\t * `offlineText` while the device is offline and `onlineText` otherwise. `tone` is `warning`\n\t\t * (default while offline), `success` or `info`.\n\t\t * - `width` — the frame width in pixels (default 350).\n\t\t * - `height` — the frame height in pixels (at least 400); what does not fit scrolls inside it. Without it the frame grows with its content.\n\t\t *\n\t\t * @type {{frames?: Array<object>, status?: object, width?: number}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** Sibling widget definitions on the surface, for `widgetIds`. */\n\t\tavailableWidgets: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** The bound record's id, forwarded to the children. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The loaded record, forwarded to the children. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The resolved object-type slug. */\n\t\tobjectType: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The resolved JSON Schema object. */\n\t\tschemaObject: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** OpenRegister register slug of the surface. */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** OpenRegister schema slug of the surface. */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The effective object store. */\n\t\tstore: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Rendering surface forwarded to the children. */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/** Object context forwarded to integration children. */\n\t\tintegrationContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The consumer's component registry, for custom child widget types. */\n\t\tcnRegistry: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: instanceCounter,\n\t\t\tonline: typeof navigator === 'undefined' || navigator.onLine !== false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The frame width. */\n\t\tframeStyle() {\n\t\t\tconst width = Number(this.content?.width)\n\t\t\tconst height = Number(this.content?.height)\n\t\t\tconst style = { '--cn-device-frame-width': `${Number.isFinite(width) && width >= 240 ? width : 350}px` }\n\t\t\tif (Number.isFinite(height) && height >= 400) {\n\t\t\t\tstyle['--cn-device-frame-height'] = `${height}px`\n\t\t\t}\n\t\t\treturn style\n\t\t},\n\n\t\t/**\n\t\t * The frames to draw: a key, a translated title, the sections and the\n\t\t * status line.\n\t\t *\n\t\t * @return {Array<{key: string, title: string, sections: Array<object>, status: object|null}>}\n\t\t */\n\t\tframes() {\n\t\t\tconst list = Array.isArray(this.content?.frames) ? this.content.frames : []\n\t\t\treturn list\n\t\t\t\t.filter((frame) => frame && typeof frame === 'object')\n\t\t\t\t.map((frame, index) => {\n\t\t\t\t\tconst sections = Array.isArray(frame.sections)\n\t\t\t\t\t\t? frame.sections\n\t\t\t\t\t\t: (Array.isArray(frame.widgetIds) ? frame.widgetIds : []).filter((id) => typeof id === 'string' && id !== '').map((widgetId) => ({ widgetId }))\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: String(frame.key || `frame-${index}`).replace(/[^\\w-]/g, '-'),\n\t\t\t\t\t\ttitle: this.tr(frame.title || ''),\n\t\t\t\t\t\tsections,\n\t\t\t\t\t\tstatus: this.statusOf(frame.status || this.content?.status || null),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.addEventListener('online', this.onConnection)\n\t\t\twindow.addEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.removeEventListener('online', this.onConnection)\n\t\t\twindow.removeEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tmethods: {\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 * The status line of a frame, or null.\n\t\t *\n\t\t * @param {object|null} status The configured status.\n\t\t * @return {{text: string, tone: string, icon: object}|null}\n\t\t */\n\t\tstatusOf(status) {\n\t\t\tif (!status || typeof status !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tlet text = status.text\n\t\t\tlet tone = status.tone\n\t\t\tif (status.followConnection === true) {\n\t\t\t\ttext = this.online ? status.onlineText : status.offlineText\n\t\t\t\ttone = tone || (this.online ? 'success' : 'warning')\n\t\t\t}\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst known = ['warning', 'success', 'info'].includes(tone) ? tone : 'info'\n\t\t\tconst icon = known === 'warning' ? CloudOffOutline : (known === 'success' ? CloudCheckOutline : InformationOutline)\n\t\t\treturn { text: this.tr(text), tone: known, icon: markRaw(icon) }\n\t\t},\n\n\t\t/** Follow the browser's connection state. */\n\t\tonConnection() {\n\t\t\tthis.online = typeof navigator === 'undefined' || navigator.onLine !== false\n\t\t},\n\n\t\t/**\n\t\t * The id of a frame's heading.\n\t\t *\n\t\t * @param {string} key The frame key.\n\t\t * @return {string}\n\t\t */\n\t\theadingId(key) {\n\t\t\treturn `cn-device-frame-${this.uid}-${key}`\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-device-frames-widget {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: flex-start;\n\tgap: 20px;\n}\n\n.cn-device-frames-widget__frame {\n\tdisplay: flex;\n\tflex: none;\n\tflex-direction: column;\n\twidth: var(--cn-device-frame-width, 350px);\n\tmax-width: 100%;\n\tmin-height: 600px;\n\theight: var(--cn-device-frame-height, auto);\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tborder: 10px solid var(--color-main-text);\n\tborder-radius: 36px;\n\tbackground: var(--color-background-hover);\n}\n\n.cn-device-frames-widget__head {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n\tpadding: 14px 18px 10px;\n\tborder-bottom: 1px solid var(--color-border);\n\tbackground: var(--color-main-background);\n}\n\n.cn-device-frames-widget__status {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tfont-size: 13px;\n\tfont-weight: 600;\n}\n\n.cn-device-frames-widget__status--warning {\n\tcolor: var(--color-warning-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--success {\n\tcolor: var(--color-success-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--info {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-device-frames-widget__title {\n\tmargin: 0;\n\tfont-size: 20px;\n\tfont-weight: 700;\n\tline-height: 1.2;\n}\n\n.cn-device-frames-widget__body {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 14px;\n}\n\n/* `height` (DqInspectie: 700) makes every frame a phone of that height;\n what does not fit scrolls inside the screen. */\n.cn-device-frames-widget__frame[style*='--cn-device-frame-height'] .cn-device-frames-widget__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n\toverflow-y: auto;\n}\n\n/* On a phone the frame is the screen: no bezel, the full width. */\n@media (max-width: 640px) {\n\t.cn-device-frames-widget__frame {\n\t\twidth: 100%;\n\t\tmin-height: 0;\n\t\tborder-width: 0;\n\t\tborder-radius: var(--cn-board-card-radius, 12px);\n\t}\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","_resolveDynamicComponent","_createTextVNode","_toDisplayString"],"mappings":";;;AAWM,EAAA,KAAK,EAAC,yBAAS;AAAA,EAAA,aAAA,EAAA,yBAAA;;;AAQV,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,+BAAwB,GAAA;;AAajC,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,+BAAc,GAAA;;;;;AArBzB,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;sBACAA,8CACgB,QAAM,CAAA,MAAA,EAAA,CAAf,KAAK,KAAA;2BADZA;QAEC,GAAG,EAAE,KAAK,CAAC,GAAG;aACV,EAAA,gCAAA;AACH,QAAA,KAAI,iBAAE,QAAU,CAAA,UAAA,CAAA;AAChB,QAAA,iBAAc,EAAE,QAAA,CAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAA;QACnC,aAAU,EAAA,CAAA,gBAAA,EAAqB,KAAK,CAAC,GAAG,CAAA,CAAA;;AACxC,QAAAC,kBAAA,CAYO,UAZP,UAYO,EAAA;AAVD,UAAA,CAAA,KAAK,CAAC,MAAM;4BADlBD,kBAOM,CAAA,MAAA,EAAA;;AALN,gBAAA,KAAK,kBAAA,iCAAA,EAAA,CAAA,iCAAA,EACuC,KAAK,CAAC,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X-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-device-frames-widget\" data-testid=\"cn-device-frames-widget\">\n\t\t<section\n\t\t\tv-for=\"frame in frames\"\n\t\t\t:key=\"frame.key\"\n\t\t\tclass=\"cn-device-frames-widget__frame\"\n\t\t\t:style=\"frameStyle\"\n\t\t\t:aria-labelledby=\"headingId(frame.key)\"\n\t\t\t:data-testid=\"`cn-device-frame-${frame.key}`\">\n\t\t\t<header class=\"cn-device-frames-widget__head\">\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"frame.status\"\n\t\t\t\t\tclass=\"cn-device-frames-widget__status\"\n\t\t\t\t\t:class=\"`cn-device-frames-widget__status--${frame.status.tone}`\"\n\t\t\t\t\tdata-testid=\"cn-device-frame-status\">\n\t\t\t\t\t<component :is=\"frame.status.icon\" :size=\"16\" aria-hidden=\"true\" />\n\t\t\t\t\t{{ frame.status.text }}\n\t\t\t\t</span>\n\t\t\t\t<h3 :id=\"headingId(frame.key)\" class=\"cn-device-frames-widget__title\">\n\t\t\t\t\t{{ frame.title }}\n\t\t\t\t</h3>\n\t\t\t</header>\n\t\t\t<div class=\"cn-device-frames-widget__body\">\n\t\t\t\t<CnSectionsWidget\n\t\t\t\t\t:content=\"{ sections: frame.sections, cards: false, hideEmpty: true }\"\n\t\t\t\t\t:availableWidgets=\"availableWidgets\"\n\t\t\t\t\t:objectId=\"objectId\"\n\t\t\t\t\t:objectData=\"objectData\"\n\t\t\t\t\t:objectType=\"objectType\"\n\t\t\t\t\t:schemaObject=\"schemaObject\"\n\t\t\t\t\t:register=\"register\"\n\t\t\t\t\t:schema=\"schema\"\n\t\t\t\t\t:store=\"store\"\n\t\t\t\t\t:surface=\"surface\"\n\t\t\t\t\t:integrationContext=\"integrationContext\"\n\t\t\t\t\t:cnRegistry=\"cnRegistry\" />\n\t\t\t</div>\n\t\t</section>\n\t</div>\n</template>\n\n<script>\nimport { markRaw } from 'vue'\nimport CloudCheckOutline from 'vue-material-design-icons/CloudCheckOutline.vue'\nimport CloudOffOutline from 'vue-material-design-icons/CloudOffOutline.vue'\nimport InformationOutline from 'vue-material-design-icons/InformationOutline.vue'\nimport CnSectionsWidget from '../CnSectionsWidget/CnSectionsWidget.vue'\n\n/** Counter for unique heading ids across instances. */\nlet instanceCounter = 0\n\n/**\n * CnDeviceFramesWidget - the `device-frames` widget: several small pages side\n * by side, each in a phone frame with its own header (board DqInspectie,\n * \"Inspectie in het veld\": the day offline, a checklist question with a\n * photo, and the sync queue).\n *\n * Each frame stacks widgets of the surface, as the `sections` widget does,\n * under a header with the frame's title and an optional status line. The\n * status can follow the connection (\"Offline · synced at 07:42\" while the\n * device is offline). The frames wrap onto the next row when the page is\n * narrower, and a frame takes the full width on a phone.\n *\n * ```json\n * {\n * \"type\": \"device-frames\",\n * \"content\": {\n * \"width\": 350,\n * \"status\": { \"followConnection\": true, \"offlineText\": \"Offline · synced at 07:42\", \"onlineText\": \"Online\" },\n * \"frames\": [\n * { \"key\": \"today\", \"title\": \"Today\", \"widgetIds\": [\"today-runs\", \"offline-note\"] },\n * { \"key\": \"question\", \"title\": \"Kerkplein 7\", \"widgetIds\": [\"checklist-run\"] },\n * { \"key\": \"sync\", \"title\": \"Synchronise\", \"widgetIds\": [\"sync-queue\"] }\n * ]\n * }\n * }\n * ```\n *\n * @spec openspec/changes/device-frames-widget/specs/device-frames-widget/spec.md#requirement-a-page-can-show-several-small-pages-as-phone-frames\n */\nexport default {\n\tname: 'CnDeviceFramesWidget',\n\n\tcomponents: { CnSectionsWidget },\n\n\tinject: {\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget configuration.\n\t\t *\n\t\t * - `frames` — `[{ key?, title, widgetIds? | sections?, status? }]`, in order. `widgetIds` names\n\t\t * widgets of the surface, stacked; `sections` takes the `sections` widget's entries instead.\n\t\t * - `status` — the status line of every frame (a frame's own `status` wins): `{ text?, tone?,\n\t\t * followConnection?, onlineText?, offlineText? }`. With `followConnection` the line reads\n\t\t * `offlineText` while the device is offline and `onlineText` otherwise. `tone` is `warning`\n\t\t * (default while offline), `success` or `info`.\n\t\t * - `width` — the frame width in pixels (default 350).\n\t\t * - `height` — the frame height in pixels (at least 400); what does not fit scrolls inside it. Without it the frame grows with its content.\n\t\t *\n\t\t * @type {{frames?: Array<object>, status?: object, width?: number}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** Sibling widget definitions on the surface, for `widgetIds`. */\n\t\tavailableWidgets: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** The bound record's id, forwarded to the children. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The loaded record, forwarded to the children. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The resolved object-type slug. */\n\t\tobjectType: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The resolved JSON Schema object. */\n\t\tschemaObject: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** OpenRegister register slug of the surface. */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** OpenRegister schema slug of the surface. */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The effective object store. */\n\t\tstore: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Rendering surface forwarded to the children. */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/** Object context forwarded to integration children. */\n\t\tintegrationContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The consumer's component registry, for custom child widget types. */\n\t\tcnRegistry: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: instanceCounter,\n\t\t\tonline: typeof navigator === 'undefined' || navigator.onLine !== false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The frame width. */\n\t\tframeStyle() {\n\t\t\tconst width = Number(this.content?.width)\n\t\t\tconst height = Number(this.content?.height)\n\t\t\tconst style = { '--cn-device-frame-width': `${Number.isFinite(width) && width >= 240 ? width : 350}px` }\n\t\t\tif (Number.isFinite(height) && height >= 400) {\n\t\t\t\tstyle['--cn-device-frame-height'] = `${height}px`\n\t\t\t}\n\t\t\treturn style\n\t\t},\n\n\t\t/**\n\t\t * The frames to draw: a key, a translated title, the sections and the\n\t\t * status line.\n\t\t *\n\t\t * @return {Array<{key: string, title: string, sections: Array<object>, status: object|null}>}\n\t\t */\n\t\tframes() {\n\t\t\tconst list = Array.isArray(this.content?.frames) ? this.content.frames : []\n\t\t\treturn list\n\t\t\t\t.filter((frame) => frame && typeof frame === 'object')\n\t\t\t\t.map((frame, index) => {\n\t\t\t\t\tconst sections = Array.isArray(frame.sections)\n\t\t\t\t\t\t? frame.sections\n\t\t\t\t\t\t: (Array.isArray(frame.widgetIds) ? frame.widgetIds : []).filter((id) => typeof id === 'string' && id !== '').map((widgetId) => ({ widgetId }))\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey: String(frame.key || `frame-${index}`).replace(/[^\\w-]/g, '-'),\n\t\t\t\t\t\ttitle: this.tr(frame.title || ''),\n\t\t\t\t\t\tsections,\n\t\t\t\t\t\tstatus: this.statusOf(frame.status || this.content?.status || null),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.addEventListener('online', this.onConnection)\n\t\t\twindow.addEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tif (typeof window !== 'undefined') {\n\t\t\twindow.removeEventListener('online', this.onConnection)\n\t\t\twindow.removeEventListener('offline', this.onConnection)\n\t\t}\n\t},\n\n\tmethods: {\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 * The status line of a frame, or null.\n\t\t *\n\t\t * @param {object|null} status The configured status.\n\t\t * @return {{text: string, tone: string, icon: object}|null}\n\t\t */\n\t\tstatusOf(status) {\n\t\t\tif (!status || typeof status !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tlet text = status.text\n\t\t\tlet tone = status.tone\n\t\t\tif (status.followConnection === true) {\n\t\t\t\ttext = this.online ? status.onlineText : status.offlineText\n\t\t\t\ttone = tone || (this.online ? 'success' : 'warning')\n\t\t\t}\n\t\t\tif (typeof text !== 'string' || text === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst known = ['warning', 'success', 'info'].includes(tone) ? tone : 'info'\n\t\t\tconst icon = known === 'warning' ? CloudOffOutline : (known === 'success' ? CloudCheckOutline : InformationOutline)\n\t\t\treturn { text: this.tr(text), tone: known, icon: markRaw(icon) }\n\t\t},\n\n\t\t/** Follow the browser's connection state. */\n\t\tonConnection() {\n\t\t\tthis.online = typeof navigator === 'undefined' || navigator.onLine !== false\n\t\t},\n\n\t\t/**\n\t\t * The id of a frame's heading.\n\t\t *\n\t\t * @param {string} key The frame key.\n\t\t * @return {string}\n\t\t */\n\t\theadingId(key) {\n\t\t\treturn `cn-device-frame-${this.uid}-${key}`\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-device-frames-widget {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\talign-items: flex-start;\n\tgap: 20px;\n}\n\n.cn-device-frames-widget__frame {\n\tdisplay: flex;\n\tflex: none;\n\tflex-direction: column;\n\twidth: var(--cn-device-frame-width, 350px);\n\tmax-width: 100%;\n\tmin-height: 600px;\n\theight: var(--cn-device-frame-height, auto);\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tborder: 10px solid var(--color-main-text);\n\tborder-radius: 36px;\n\tbackground: var(--color-background-hover);\n}\n\n.cn-device-frames-widget__head {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n\tpadding: 14px 18px 10px;\n\tborder-bottom: 1px solid var(--color-border);\n\tbackground: var(--color-main-background);\n}\n\n.cn-device-frames-widget__status {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 6px;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tline-height: normal;\n}\n\n.cn-device-frames-widget__status--warning {\n\tcolor: var(--color-warning-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--success {\n\tcolor: var(--color-success-text, var(--color-main-text));\n}\n\n.cn-device-frames-widget__status--info {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-device-frames-widget__title {\n\tmargin: 0;\n\tfont-size: 20px;\n\tfont-weight: 700;\n\tline-height: 1.2;\n}\n\n.cn-device-frames-widget__body {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 14px;\n}\n\n/* `height` (DqInspectie: 700) makes every frame a phone of that height;\n what does not fit scrolls inside the screen. */\n.cn-device-frames-widget__frame[style*='--cn-device-frame-height'] .cn-device-frames-widget__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n\toverflow-y: auto;\n}\n\n/* On a phone the frame is the screen: no bezel, the full width. */\n@media (max-width: 640px) {\n\t.cn-device-frames-widget__frame {\n\t\twidth: 100%;\n\t\tmin-height: 0;\n\t\tborder-width: 0;\n\t\tborder-radius: var(--cn-board-card-radius, 12px);\n\t}\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","_resolveDynamicComponent","_createTextVNode","_toDisplayString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Z,WAAA,EAAAI,eAAA,CAAA,KAAK,CAAC,KAAK,CAAA,EAAA,CAAA,oBAAA,UAAA,CAAA;;;;YAKb,OAAO,EAAA,EAAA,QAAA,EAAc,KAAK,CAAA,QAAA,EAAA,KAAA,EAAA,KAAA,EAAA,SAAA,EAAA,IAAA,EAAA;AAC1B,YAAA,gBAAgB,EAAE,MAAA,CAAA,gBAAA;AAClB,YAAA,QAAQ,EAAE,MAAI,CAAA,QAAA;AACd,YAAA,UAAU,EAAE,MAAA,CAAA,UAAA;AACZ,YAAA,UAAU,EAAE,MAAI,CAAA,UAAA;AAChB,YAAA,YAAY,EAAE,MAAY,CAAA,YAAA;AAC1B,YAAA,QAAQ,EAAE,MAAQ,CAAA,QAAA;AAClB,YAAA,MAAE,EAAA,MAAA,CAAA,MAAA;AACF,YAAA,KAAK,EAAA,MAAA,CAAA,KAAA;AACL,YAAA,OAAA,EAAA,MAAA,CAAA,OAAA;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnDuplicateWarning.vue2.js';
|
|
|
2
2
|
import { render } from './CnDuplicateWarning.vue3.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-0588a184";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { translatePlural, translate } from '@nextcloud/l10n';
|
|
2
2
|
import { generateUrl } from '@nextcloud/router';
|
|
3
3
|
import { NcButton, NcNoteCard, NcTextField } from '@nextcloud/vue';
|
|
4
|
+
import __sfc_main$1 from '../CnIcon/CnIcon.vue.js';
|
|
4
5
|
import { duplicateAffordances } from '../../utils/duplicateWarning.js';
|
|
5
6
|
import { fillTemplate, firstFilled } from '../../utils/fillTemplate.js';
|
|
6
7
|
import __sfc_main from '../CnDialog/CnDialog.vue.js';
|
|
@@ -32,7 +33,7 @@ import __sfc_main from '../CnDialog/CnDialog.vue.js';
|
|
|
32
33
|
var script = {
|
|
33
34
|
name: 'CnDuplicateWarning',
|
|
34
35
|
|
|
35
|
-
components: { CnDialog: __sfc_main, NcButton, NcNoteCard, NcTextField },
|
|
36
|
+
components: { CnDialog: __sfc_main, CnIcon: __sfc_main$1, NcButton, NcNoteCard, NcTextField },
|
|
36
37
|
|
|
37
38
|
inject: {
|
|
38
39
|
/** The host app's translate (CnAppRoot `cnTranslate`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnDuplicateWarning.vue2.js","sources":["../../../../src/components/CnDuplicateWarning/CnDuplicateWarning.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnDialog\n\t\t:name=\"text(title) || t('nextcloud-vue', 'This may already exist')\"\n\t\t:eyebrow=\"text(eyebrow)\"\n\t\twidth=\"form\"\n\t\tdata-testid=\"cn-duplicate-warning\"\n\t\t@closing=\"close\">\n\t\t<div class=\"cn-duplicate-warning\">\n\t\t\t<NcNoteCard :type=\"affordances.blocked && !affordances.mayContinue ? 'error' : 'warning'\" data-testid=\"cn-duplicate-warning-note\">\n\t\t\t\t{{ headlineText }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<ul class=\"cn-duplicate-warning__matches\">\n\t\t\t\t<li v-for=\"row in rows\"\n\t\t\t\t\t:key=\"row.uuid\"\n\t\t\t\t\tclass=\"cn-duplicate-warning__match\"\n\t\t\t\t\tdata-testid=\"cn-duplicate-warning-match\">\n\t\t\t\t\t<a v-if=\"row.href\" :href=\"row.href\" class=\"cn-duplicate-warning__title\">{{ row.title }}</a>\n\t\t\t\t\t<span v-else class=\"cn-duplicate-warning__title\">{{ row.title }}</span>\n\t\t\t\t\t<span v-if=\"row.meta\" class=\"cn-duplicate-warning__meta\">{{ row.meta }}</span>\n\t\t\t\t\t<span class=\"cn-duplicate-warning__meta\">{{ row.matched }}</span>\n\t\t\t\t</li>\n\t\t\t</ul>\n\n\t\t\t<NcTextField v-if=\"affordances.needsReason\"\n\t\t\t\t:label=\"text(reasonLabel) || t('nextcloud-vue', 'Why file it anyway')\"\n\t\t\t\t:modelValue=\"reason\"\n\t\t\t\t:helperText=\"text(reasonHint)\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-reason\"\n\t\t\t\t@update:modelValue=\"reason = $event\" />\n\n\t\t\t<p v-if=\"affordances.blocked && !affordances.mayContinue\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-blocked\">\n\t\t\t\t{{ text(blockedText) || t('nextcloud-vue', 'This cannot be filed twice. Open the one it matches, or ask a coordinator.') }}\n\t\t\t</p>\n\n\t\t\t<p v-if=\"footnote\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-footnote\">\n\t\t\t\t{{ text(footnote) }}\n\t\t\t</p>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"tertiary\" data-testid=\"cn-duplicate-warning-cancel\" @click=\"close\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton v-if=\"affordances.mayContinue\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canFile\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-continue\"\n\t\t\t\t@click=\"fileAnyway\">\n\t\t\t\t{{ text(continueLabel) || t('nextcloud-vue', 'File it anyway') }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnDialog>\n</template>\n\n<script>\nimport { translatePlural as n, translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport { duplicateAffordances } from '../../utils/duplicateWarning.js'\nimport { fillTemplate, firstFilled } from '../../utils/fillTemplate.js'\nimport { CnDialog } from '../CnDialog/index.js'\n\n/**\n * CnDuplicateWarning — \"this may already exist\", before a record is filed.\n * It renders OpenRegister's scored matches (`{ uuid, score, matchedOn }`),\n * never scoring anything itself, with each matched record's title, a meta\n * line, what it matched on and how strongly. Under a `warn` policy anyone may\n * file it anyway; under `block` only a user who `mayOverride`, and they say\n * why. A match the user may not read is reported without disclosing it.\n * dossiq's case intake is the first consumer; pipelinq contacts share it.\n *\n * Open it in a template, or from code with `openDuplicateWarning(props)`,\n * which resolves with `{ reason, over }` or null.\n *\n * ```vue\n * <CnDuplicateWarning\n * :matches=\"matches\"\n * :records=\"readableCases\"\n * policy=\"block\"\n * :may-override=\"isCoordinator\"\n * record-url=\"/apps/dossiq/cases/{uuid}\"\n * :field-labels=\"{ requester: 'Requester', title: 'Subject' }\"\n * @file=\"save\"\n * @close=\"cancel\" />\n * ```\n */\nexport default {\n\tname: 'CnDuplicateWarning',\n\n\tcomponents: { CnDialog, NcButton, NcNoteCard, NcTextField },\n\n\tinject: {\n\t\t/** The host app's translate (CnAppRoot `cnTranslate`). */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The scored matches, as OpenRegister answered: `{ uuid, score, matchedOn }`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tmatches: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The matched records the user may read, matched by `id`, `uuid` or `@self.id`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\trecords: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** `warn` lets anyone file it anyway; `block` only a user who `mayOverride`. */\n\t\tpolicy: {\n\t\t\ttype: String,\n\t\t\tdefault: 'warn',\n\t\t},\n\n\t\t/** Whether this user may file over a block (and must say why). */\n\t\tmayOverride: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** A record's title, a template filled from it. */\n\t\trowTitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '{title}',\n\t\t},\n\n\t\t/**\n\t\t * A record's meta line, a template filled from it, or several: the\n\t\t * first that fills is shown (\"{identifier} · {caseType.title}\", then\n\t\t * \"{identifier}\" for a record that lacks the type).\n\t\t *\n\t\t * @type {string|Array<string>}\n\t\t */\n\t\trowMeta: {\n\t\t\ttype: [String, Array],\n\t\t\tdefault: '{identifier}',\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, `{fields}` (joined as a list: \"Aanvrager\n\t\t * en Onderwerp\") and `{percentage}` filled, through the host\n\t\t * translate. Empty: \"Aanvrager, Onderwerp (82%)\".\n\t\t */\n\t\tmatchedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A line above the title, as the board dialogs draw one. */\n\t\teyebrow: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The help line under the reason field. */\n\t\treasonHint: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A muted note under the matches and the reason, for what Cancel and a block mean. */\n\t\tfootnote: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A record's page, a template with `{uuid}`; empty draws no link. */\n\t\trecordUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Words for the matched fields (`{ requester: \"Requester\" }`), through the host translate.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfieldLabels: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The dialog title; defaults to \"This may already exist\". */\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The note's sentence, `{count}` filled; defaults to \"%n existing record looks like this one.\". */\n\t\theadline: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The sentence under a block the user may not pass. */\n\t\tblockedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The reason field's label. */\n\t\treasonLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The continue button's label; defaults to \"File it anyway\". */\n\t\tcontinueLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['close', 'file'],\n\n\tdata() {\n\t\treturn {\n\t\t\treason: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * What to draw and offer.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {{show: boolean, blocked: boolean, mayContinue: boolean, needsReason: boolean}}\n\t\t */\n\t\taffordances() {\n\t\t\treturn duplicateAffordances({ matches: this.matches, policy: this.policy, mayOverride: this.mayOverride })\n\t\t},\n\n\t\t/** @return {boolean} Whether \"file it anyway\" may be pressed. */\n\t\tcanFile() {\n\t\t\treturn this.affordances.mayContinue && (!this.affordances.needsReason || this.reason.trim() !== '')\n\t\t},\n\n\t\t/** @return {string} The note's sentence. */\n\t\theadlineText() {\n\t\t\tconst count = this.matches.length\n\t\t\tif (this.headline) {\n\t\t\t\treturn fillTemplate(this.cnTranslate(this.headline), { count })\n\t\t\t}\n\t\t\treturn n('nextcloud-vue', '%n existing record looks like this one.', '%n existing records look like this one.', count)\n\t\t},\n\n\t\t/**\n\t\t * One row per match: the readable record's title and meta and link, or\n\t\t * a neutral name for one the user may not read.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {Array<object>}\n\t\t */\n\t\trows() {\n\t\t\treturn this.matches.map((match) => {\n\t\t\t\tconst uuid = String((match && match.uuid) || '')\n\t\t\t\tconst record = this.records.find((row) => String((row && (row.id || row.uuid || (row['@self'] && row['@self'].id))) || '') === uuid)\n\t\t\t\tconst fields = Array.isArray(match && match.matchedOn) ? match.matchedOn : []\n\t\t\t\tconst score = Number(match && match.score)\n\t\t\t\tconst words = fields.map((field) => (this.fieldLabels[field] ? this.cnTranslate(this.fieldLabels[field]) : field))\n\t\t\t\tconst percentage = Number.isFinite(score) ? Math.max(0, Math.min(100, Math.round(score * 100))) : 0\n\t\t\t\treturn {\n\t\t\t\t\tuuid,\n\t\t\t\t\ttitle: record ? (fillTemplate(this.rowTitle, record).trim() || uuid) : t('nextcloud-vue', 'A record you may not open'),\n\t\t\t\t\tmeta: record ? firstFilled(this.rowMeta, record, (key) => key).trim() : '',\n\t\t\t\t\thref: record && this.recordUrl ? generateUrl(fillTemplate(this.recordUrl, { uuid: encodeURIComponent(uuid) })) : '',\n\t\t\t\t\tmatched: this.matchedLine(words, percentage),\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A prop text through the host translate.\n\t\t *\n\t\t * @param {string} value The text.\n\t\t * @return {string}\n\t\t */\n\t\ttext(value) {\n\t\t\treturn value ? this.cnTranslate(value) : ''\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, and how strongly.\n\t\t *\n\t\t * @param {Array<string>} words The matched fields, in the host's words.\n\t\t * @param {number} percentage The score as a percentage.\n\t\t * @return {string}\n\t\t */\n\t\tmatchedLine(words, percentage) {\n\t\t\tif (words.length === 0) {\n\t\t\t\treturn `${t('nextcloud-vue', 'Matched on the score, not on a single field')} (${percentage}%)`\n\t\t\t}\n\t\t\tif (!this.matchedText) {\n\t\t\t\treturn `${words.join(', ')} (${percentage}%)`\n\t\t\t}\n\t\t\tlet fields = words.join(', ')\n\t\t\ttry {\n\t\t\t\tfields = new Intl.ListFormat(document.documentElement.lang || undefined, { type: 'conjunction' }).format(words)\n\t\t\t} catch {\n\t\t\t\t// An engine without Intl.ListFormat keeps the comma list.\n\t\t\t}\n\t\t\treturn fillTemplate(this.cnTranslate(this.matchedText), { fields, percentage: String(percentage) })\n\t\t},\n\n\t\t/** File it over the warning, carrying the reason and what it was filed over. */\n\t\tfileAnyway() {\n\t\t\tif (!this.canFile) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t/** @event file The user files it anyway. Payload: `{ reason, over }`, `over` the matched uuids. */\n\t\t\tthis.$emit('file', { reason: this.reason.trim(), over: this.matches.map((m) => String((m && m.uuid) || '')).filter(Boolean) })\n\t\t},\n\n\t\t/** Go back without filing. */\n\t\tclose() {\n\t\t\t/** @event close The user went back without filing. */\n\t\t\tthis.$emit('close')\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-duplicate-warning {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-duplicate-warning__matches {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n\n.cn-duplicate-warning__match {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large, 8px);\n}\n\n.cn-duplicate-warning__title {\n\tfont-weight: 600;\n}\n\n.cn-duplicate-warning__meta,\n.cn-duplicate-warning__hint {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-duplicate-warning__hint {\n\tmargin: 0;\n}\n</style>\n"],"names":["CnDialog","n","t"],"mappings":";;;;;;;AAuEA;AACC;AACA;;AAEA;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;AAGA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,oBAAoB;;CAE1B,UAAU,EAAE,YAAEA,UAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAU,EAAG;;AAE3D,CAAA,MAAM,EAAE;;AAEP,EAAA,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,KAAK;EAC5C;;AAED,CAAA,KAAK,EAAE;AACN;AACC;AACA;AACA;;AAED,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,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,GAAG,CAAA;GAClG;;AAED;EACA,UAAU,GAAG;AACZ,GAAA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;IAClB,MAAK;AACN,IAAA;AACA;GACA,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAA,IAAK,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA,EAAG,EAAA;GAC7H;;;AAGD,EAAA,KAAK,GAAG;AACP;AACA,GAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAA;GAClB;EACD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CnDuplicateWarning.vue2.js","sources":["../../../../src/components/CnDuplicateWarning/CnDuplicateWarning.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnDialog\n\t\t:name=\"text(title) || t('nextcloud-vue', 'This may already exist')\"\n\t\t:eyebrow=\"text(eyebrow)\"\n\t\twidth=\"confirm\"\n\t\tdata-testid=\"cn-duplicate-warning\"\n\t\t@closing=\"close\">\n\t\t<div class=\"cn-duplicate-warning\">\n\t\t\t<NcNoteCard :type=\"affordances.blocked && !affordances.mayContinue ? 'error' : 'warning'\" data-testid=\"cn-duplicate-warning-note\">\n\t\t\t\t{{ headlineText }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<ul class=\"cn-duplicate-warning__matches\">\n\t\t\t\t<li v-for=\"row in rows\"\n\t\t\t\t\t:key=\"row.uuid\"\n\t\t\t\t\tclass=\"cn-duplicate-warning__match\"\n\t\t\t\t\tdata-testid=\"cn-duplicate-warning-match\">\n\t\t\t\t\t<a v-if=\"row.href\" :href=\"row.href\" class=\"cn-duplicate-warning__title\">{{ row.title }}</a>\n\t\t\t\t\t<span v-else class=\"cn-duplicate-warning__title\">{{ row.title }}</span>\n\t\t\t\t\t<span v-if=\"row.meta\" class=\"cn-duplicate-warning__meta\">{{ row.meta }}</span>\n\t\t\t\t\t<span class=\"cn-duplicate-warning__meta\">{{ row.matched }}</span>\n\t\t\t\t</li>\n\t\t\t</ul>\n\n\t\t\t<NcTextField v-if=\"affordances.needsReason\"\n\t\t\t\t:label=\"text(reasonLabel) || t('nextcloud-vue', 'Why file it anyway')\"\n\t\t\t\t:modelValue=\"reason\"\n\t\t\t\t:helperText=\"text(reasonHint)\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-reason\"\n\t\t\t\t@update:modelValue=\"reason = $event\" />\n\n\t\t\t<p v-if=\"affordances.blocked && !affordances.mayContinue\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-blocked\">\n\t\t\t\t{{ text(blockedText) || t('nextcloud-vue', 'This cannot be filed twice. Open the one it matches, or ask a coordinator.') }}\n\t\t\t</p>\n\n\t\t\t<p v-if=\"footnote\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-footnote\">\n\t\t\t\t{{ text(footnote) }}\n\t\t\t</p>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"secondary\" data-testid=\"cn-duplicate-warning-cancel\" @click=\"close\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton v-if=\"affordances.mayContinue\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canFile\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-continue\"\n\t\t\t\t@click=\"fileAnyway\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<CnIcon name=\"Plus\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ text(continueLabel) || t('nextcloud-vue', 'File it anyway') }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnDialog>\n</template>\n\n<script>\nimport { translatePlural as n, translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport { duplicateAffordances } from '../../utils/duplicateWarning.js'\nimport { fillTemplate, firstFilled } from '../../utils/fillTemplate.js'\nimport { CnDialog } from '../CnDialog/index.js'\n\n/**\n * CnDuplicateWarning — \"this may already exist\", before a record is filed.\n * It renders OpenRegister's scored matches (`{ uuid, score, matchedOn }`),\n * never scoring anything itself, with each matched record's title, a meta\n * line, what it matched on and how strongly. Under a `warn` policy anyone may\n * file it anyway; under `block` only a user who `mayOverride`, and they say\n * why. A match the user may not read is reported without disclosing it.\n * dossiq's case intake is the first consumer; pipelinq contacts share it.\n *\n * Open it in a template, or from code with `openDuplicateWarning(props)`,\n * which resolves with `{ reason, over }` or null.\n *\n * ```vue\n * <CnDuplicateWarning\n * :matches=\"matches\"\n * :records=\"readableCases\"\n * policy=\"block\"\n * :may-override=\"isCoordinator\"\n * record-url=\"/apps/dossiq/cases/{uuid}\"\n * :field-labels=\"{ requester: 'Requester', title: 'Subject' }\"\n * @file=\"save\"\n * @close=\"cancel\" />\n * ```\n */\nexport default {\n\tname: 'CnDuplicateWarning',\n\n\tcomponents: { CnDialog, CnIcon, NcButton, NcNoteCard, NcTextField },\n\n\tinject: {\n\t\t/** The host app's translate (CnAppRoot `cnTranslate`). */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The scored matches, as OpenRegister answered: `{ uuid, score, matchedOn }`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tmatches: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The matched records the user may read, matched by `id`, `uuid` or `@self.id`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\trecords: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** `warn` lets anyone file it anyway; `block` only a user who `mayOverride`. */\n\t\tpolicy: {\n\t\t\ttype: String,\n\t\t\tdefault: 'warn',\n\t\t},\n\n\t\t/** Whether this user may file over a block (and must say why). */\n\t\tmayOverride: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** A record's title, a template filled from it. */\n\t\trowTitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '{title}',\n\t\t},\n\n\t\t/**\n\t\t * A record's meta line, a template filled from it, or several: the\n\t\t * first that fills is shown (\"{identifier} · {caseType.title}\", then\n\t\t * \"{identifier}\" for a record that lacks the type).\n\t\t *\n\t\t * @type {string|Array<string>}\n\t\t */\n\t\trowMeta: {\n\t\t\ttype: [String, Array],\n\t\t\tdefault: '{identifier}',\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, `{fields}` (joined as a list: \"Aanvrager\n\t\t * en Onderwerp\") and `{percentage}` filled, through the host\n\t\t * translate. Empty: \"Aanvrager, Onderwerp (82%)\".\n\t\t */\n\t\tmatchedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A line above the title, as the board dialogs draw one. */\n\t\teyebrow: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The help line under the reason field. */\n\t\treasonHint: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A muted note under the matches and the reason, for what Cancel and a block mean. */\n\t\tfootnote: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A record's page, a template with `{uuid}`; empty draws no link. */\n\t\trecordUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Words for the matched fields (`{ requester: \"Requester\" }`), through the host translate.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfieldLabels: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The dialog title; defaults to \"This may already exist\". */\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The note's sentence, `{count}` filled; defaults to \"%n existing record looks like this one.\". */\n\t\theadline: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The sentence under a block the user may not pass. */\n\t\tblockedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The reason field's label. */\n\t\treasonLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The continue button's label; defaults to \"File it anyway\". */\n\t\tcontinueLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['close', 'file'],\n\n\tdata() {\n\t\treturn {\n\t\t\treason: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * What to draw and offer.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {{show: boolean, blocked: boolean, mayContinue: boolean, needsReason: boolean}}\n\t\t */\n\t\taffordances() {\n\t\t\treturn duplicateAffordances({ matches: this.matches, policy: this.policy, mayOverride: this.mayOverride })\n\t\t},\n\n\t\t/** @return {boolean} Whether \"file it anyway\" may be pressed. */\n\t\tcanFile() {\n\t\t\treturn this.affordances.mayContinue && (!this.affordances.needsReason || this.reason.trim() !== '')\n\t\t},\n\n\t\t/** @return {string} The note's sentence. */\n\t\theadlineText() {\n\t\t\tconst count = this.matches.length\n\t\t\tif (this.headline) {\n\t\t\t\treturn fillTemplate(this.cnTranslate(this.headline), { count })\n\t\t\t}\n\t\t\treturn n('nextcloud-vue', '%n existing record looks like this one.', '%n existing records look like this one.', count)\n\t\t},\n\n\t\t/**\n\t\t * One row per match: the readable record's title and meta and link, or\n\t\t * a neutral name for one the user may not read.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {Array<object>}\n\t\t */\n\t\trows() {\n\t\t\treturn this.matches.map((match) => {\n\t\t\t\tconst uuid = String((match && match.uuid) || '')\n\t\t\t\tconst record = this.records.find((row) => String((row && (row.id || row.uuid || (row['@self'] && row['@self'].id))) || '') === uuid)\n\t\t\t\tconst fields = Array.isArray(match && match.matchedOn) ? match.matchedOn : []\n\t\t\t\tconst score = Number(match && match.score)\n\t\t\t\tconst words = fields.map((field) => (this.fieldLabels[field] ? this.cnTranslate(this.fieldLabels[field]) : field))\n\t\t\t\tconst percentage = Number.isFinite(score) ? Math.max(0, Math.min(100, Math.round(score * 100))) : 0\n\t\t\t\treturn {\n\t\t\t\t\tuuid,\n\t\t\t\t\ttitle: record ? (fillTemplate(this.rowTitle, record).trim() || uuid) : t('nextcloud-vue', 'A record you may not open'),\n\t\t\t\t\tmeta: record ? firstFilled(this.rowMeta, record, (key) => key).trim() : '',\n\t\t\t\t\thref: record && this.recordUrl ? generateUrl(fillTemplate(this.recordUrl, { uuid: encodeURIComponent(uuid) })) : '',\n\t\t\t\t\tmatched: this.matchedLine(words, percentage),\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A prop text through the host translate.\n\t\t *\n\t\t * @param {string} value The text.\n\t\t * @return {string}\n\t\t */\n\t\ttext(value) {\n\t\t\treturn value ? this.cnTranslate(value) : ''\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, and how strongly.\n\t\t *\n\t\t * @param {Array<string>} words The matched fields, in the host's words.\n\t\t * @param {number} percentage The score as a percentage.\n\t\t * @return {string}\n\t\t */\n\t\tmatchedLine(words, percentage) {\n\t\t\tif (words.length === 0) {\n\t\t\t\treturn `${t('nextcloud-vue', 'Matched on the score, not on a single field')} (${percentage}%)`\n\t\t\t}\n\t\t\tif (!this.matchedText) {\n\t\t\t\treturn `${words.join(', ')} (${percentage}%)`\n\t\t\t}\n\t\t\tlet fields = words.join(', ')\n\t\t\ttry {\n\t\t\t\tfields = new Intl.ListFormat(document.documentElement.lang || undefined, { type: 'conjunction' }).format(words)\n\t\t\t} catch {\n\t\t\t\t// An engine without Intl.ListFormat keeps the comma list.\n\t\t\t}\n\t\t\treturn fillTemplate(this.cnTranslate(this.matchedText), { fields, percentage: String(percentage) })\n\t\t},\n\n\t\t/** File it over the warning, carrying the reason and what it was filed over. */\n\t\tfileAnyway() {\n\t\t\tif (!this.canFile) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t/** @event file The user files it anyway. Payload: `{ reason, over }`, `over` the matched uuids. */\n\t\t\tthis.$emit('file', { reason: this.reason.trim(), over: this.matches.map((m) => String((m && m.uuid) || '')).filter(Boolean) })\n\t\t},\n\n\t\t/** Go back without filing. */\n\t\tclose() {\n\t\t\t/** @event close The user went back without filing. */\n\t\t\tthis.$emit('close')\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-duplicate-warning {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-duplicate-warning__matches {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n\n.cn-duplicate-warning__match {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: 8px;\n}\n\n.cn-duplicate-warning__title {\n\tfont-weight: 600;\n}\n\n.cn-duplicate-warning__meta,\n.cn-duplicate-warning__hint {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-duplicate-warning__hint {\n\tmargin: 0;\n}\n</style>\n"],"names":["CnDialog","CnIcon","n","t"],"mappings":";;;;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,UAAU,CAAC,EAAE,CAAA;AAC7C,IAAA;GACA,IAAI,MAAO,GAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAA;AAC5B,GAAA,IAAI;IACH,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAK,IAAG,SAAS,EAAE,EAAE,IAAI,EAAE,aAAc,EAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAA;AAC/G,IAAA,CAAE,MAAM;;AAER,IAAA;AACA,GAAA,OAAO,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,GAAG,CAAA;GAClG;;AAED;EACA,UAAU,GAAG;AACZ,GAAA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;IAClB,MAAK;AACN,IAAA;AACA;GACA,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAA,IAAK,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA,EAAG,EAAA;GAC7H;;;AAGD,EAAA,KAAK,GAAG;AACP;AACA,GAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAA;GAClB;EACD;AACF;;;;"}
|
|
@@ -27,18 +27,19 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
27
27
|
const _component_NcNoteCard = resolveComponent("NcNoteCard");
|
|
28
28
|
const _component_NcTextField = resolveComponent("NcTextField");
|
|
29
29
|
const _component_NcButton = resolveComponent("NcButton");
|
|
30
|
+
const _component_CnIcon = resolveComponent("CnIcon");
|
|
30
31
|
const _component_CnDialog = resolveComponent("CnDialog");
|
|
31
32
|
|
|
32
33
|
return (openBlock(), createBlock(_component_CnDialog, {
|
|
33
34
|
name: $options.text($props.title) || $options.t('nextcloud-vue', 'This may already exist'),
|
|
34
35
|
eyebrow: $options.text($props.eyebrow),
|
|
35
|
-
width: "
|
|
36
|
+
width: "confirm",
|
|
36
37
|
"data-testid": "cn-duplicate-warning",
|
|
37
38
|
onClosing: $options.close
|
|
38
39
|
}, {
|
|
39
40
|
actions: withCtx(() => [
|
|
40
41
|
createVNode(_component_NcButton, {
|
|
41
|
-
variant: "
|
|
42
|
+
variant: "secondary",
|
|
42
43
|
"data-testid": "cn-duplicate-warning-cancel",
|
|
43
44
|
onClick: $options.close
|
|
44
45
|
}, {
|
|
@@ -55,8 +56,14 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
55
56
|
"data-testid": "cn-duplicate-warning-continue",
|
|
56
57
|
onClick: $options.fileAnyway
|
|
57
58
|
}, {
|
|
59
|
+
icon: withCtx(() => [
|
|
60
|
+
createVNode(_component_CnIcon, {
|
|
61
|
+
name: "Plus",
|
|
62
|
+
size: 20
|
|
63
|
+
})
|
|
64
|
+
]),
|
|
58
65
|
default: withCtx(() => [
|
|
59
|
-
createTextVNode(toDisplayString($options.text($props.continueLabel) || $options.t('nextcloud-vue', 'File it anyway')), 1 /* TEXT */)
|
|
66
|
+
createTextVNode(" " + toDisplayString($options.text($props.continueLabel) || $options.t('nextcloud-vue', 'File it anyway')), 1 /* TEXT */)
|
|
60
67
|
]),
|
|
61
68
|
_: 1 /* STABLE */
|
|
62
69
|
}, 8 /* PROPS */, ["disabled", "onClick"]))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnDuplicateWarning.vue3.js","sources":["../../../../src/components/CnDuplicateWarning/CnDuplicateWarning.vue?vue&type=template&id=22af78f5&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnDialog\n\t\t:name=\"text(title) || t('nextcloud-vue', 'This may already exist')\"\n\t\t:eyebrow=\"text(eyebrow)\"\n\t\twidth=\"form\"\n\t\tdata-testid=\"cn-duplicate-warning\"\n\t\t@closing=\"close\">\n\t\t<div class=\"cn-duplicate-warning\">\n\t\t\t<NcNoteCard :type=\"affordances.blocked && !affordances.mayContinue ? 'error' : 'warning'\" data-testid=\"cn-duplicate-warning-note\">\n\t\t\t\t{{ headlineText }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<ul class=\"cn-duplicate-warning__matches\">\n\t\t\t\t<li v-for=\"row in rows\"\n\t\t\t\t\t:key=\"row.uuid\"\n\t\t\t\t\tclass=\"cn-duplicate-warning__match\"\n\t\t\t\t\tdata-testid=\"cn-duplicate-warning-match\">\n\t\t\t\t\t<a v-if=\"row.href\" :href=\"row.href\" class=\"cn-duplicate-warning__title\">{{ row.title }}</a>\n\t\t\t\t\t<span v-else class=\"cn-duplicate-warning__title\">{{ row.title }}</span>\n\t\t\t\t\t<span v-if=\"row.meta\" class=\"cn-duplicate-warning__meta\">{{ row.meta }}</span>\n\t\t\t\t\t<span class=\"cn-duplicate-warning__meta\">{{ row.matched }}</span>\n\t\t\t\t</li>\n\t\t\t</ul>\n\n\t\t\t<NcTextField v-if=\"affordances.needsReason\"\n\t\t\t\t:label=\"text(reasonLabel) || t('nextcloud-vue', 'Why file it anyway')\"\n\t\t\t\t:modelValue=\"reason\"\n\t\t\t\t:helperText=\"text(reasonHint)\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-reason\"\n\t\t\t\t@update:modelValue=\"reason = $event\" />\n\n\t\t\t<p v-if=\"affordances.blocked && !affordances.mayContinue\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-blocked\">\n\t\t\t\t{{ text(blockedText) || t('nextcloud-vue', 'This cannot be filed twice. Open the one it matches, or ask a coordinator.') }}\n\t\t\t</p>\n\n\t\t\t<p v-if=\"footnote\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-footnote\">\n\t\t\t\t{{ text(footnote) }}\n\t\t\t</p>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"tertiary\" data-testid=\"cn-duplicate-warning-cancel\" @click=\"close\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton v-if=\"affordances.mayContinue\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canFile\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-continue\"\n\t\t\t\t@click=\"fileAnyway\">\n\t\t\t\t{{ text(continueLabel) || t('nextcloud-vue', 'File it anyway') }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnDialog>\n</template>\n\n<script>\nimport { translatePlural as n, translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport { duplicateAffordances } from '../../utils/duplicateWarning.js'\nimport { fillTemplate, firstFilled } from '../../utils/fillTemplate.js'\nimport { CnDialog } from '../CnDialog/index.js'\n\n/**\n * CnDuplicateWarning — \"this may already exist\", before a record is filed.\n * It renders OpenRegister's scored matches (`{ uuid, score, matchedOn }`),\n * never scoring anything itself, with each matched record's title, a meta\n * line, what it matched on and how strongly. Under a `warn` policy anyone may\n * file it anyway; under `block` only a user who `mayOverride`, and they say\n * why. A match the user may not read is reported without disclosing it.\n * dossiq's case intake is the first consumer; pipelinq contacts share it.\n *\n * Open it in a template, or from code with `openDuplicateWarning(props)`,\n * which resolves with `{ reason, over }` or null.\n *\n * ```vue\n * <CnDuplicateWarning\n * :matches=\"matches\"\n * :records=\"readableCases\"\n * policy=\"block\"\n * :may-override=\"isCoordinator\"\n * record-url=\"/apps/dossiq/cases/{uuid}\"\n * :field-labels=\"{ requester: 'Requester', title: 'Subject' }\"\n * @file=\"save\"\n * @close=\"cancel\" />\n * ```\n */\nexport default {\n\tname: 'CnDuplicateWarning',\n\n\tcomponents: { CnDialog, NcButton, NcNoteCard, NcTextField },\n\n\tinject: {\n\t\t/** The host app's translate (CnAppRoot `cnTranslate`). */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The scored matches, as OpenRegister answered: `{ uuid, score, matchedOn }`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tmatches: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The matched records the user may read, matched by `id`, `uuid` or `@self.id`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\trecords: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** `warn` lets anyone file it anyway; `block` only a user who `mayOverride`. */\n\t\tpolicy: {\n\t\t\ttype: String,\n\t\t\tdefault: 'warn',\n\t\t},\n\n\t\t/** Whether this user may file over a block (and must say why). */\n\t\tmayOverride: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** A record's title, a template filled from it. */\n\t\trowTitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '{title}',\n\t\t},\n\n\t\t/**\n\t\t * A record's meta line, a template filled from it, or several: the\n\t\t * first that fills is shown (\"{identifier} · {caseType.title}\", then\n\t\t * \"{identifier}\" for a record that lacks the type).\n\t\t *\n\t\t * @type {string|Array<string>}\n\t\t */\n\t\trowMeta: {\n\t\t\ttype: [String, Array],\n\t\t\tdefault: '{identifier}',\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, `{fields}` (joined as a list: \"Aanvrager\n\t\t * en Onderwerp\") and `{percentage}` filled, through the host\n\t\t * translate. Empty: \"Aanvrager, Onderwerp (82%)\".\n\t\t */\n\t\tmatchedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A line above the title, as the board dialogs draw one. */\n\t\teyebrow: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The help line under the reason field. */\n\t\treasonHint: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A muted note under the matches and the reason, for what Cancel and a block mean. */\n\t\tfootnote: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A record's page, a template with `{uuid}`; empty draws no link. */\n\t\trecordUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Words for the matched fields (`{ requester: \"Requester\" }`), through the host translate.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfieldLabels: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The dialog title; defaults to \"This may already exist\". */\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The note's sentence, `{count}` filled; defaults to \"%n existing record looks like this one.\". */\n\t\theadline: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The sentence under a block the user may not pass. */\n\t\tblockedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The reason field's label. */\n\t\treasonLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The continue button's label; defaults to \"File it anyway\". */\n\t\tcontinueLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['close', 'file'],\n\n\tdata() {\n\t\treturn {\n\t\t\treason: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * What to draw and offer.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {{show: boolean, blocked: boolean, mayContinue: boolean, needsReason: boolean}}\n\t\t */\n\t\taffordances() {\n\t\t\treturn duplicateAffordances({ matches: this.matches, policy: this.policy, mayOverride: this.mayOverride })\n\t\t},\n\n\t\t/** @return {boolean} Whether \"file it anyway\" may be pressed. */\n\t\tcanFile() {\n\t\t\treturn this.affordances.mayContinue && (!this.affordances.needsReason || this.reason.trim() !== '')\n\t\t},\n\n\t\t/** @return {string} The note's sentence. */\n\t\theadlineText() {\n\t\t\tconst count = this.matches.length\n\t\t\tif (this.headline) {\n\t\t\t\treturn fillTemplate(this.cnTranslate(this.headline), { count })\n\t\t\t}\n\t\t\treturn n('nextcloud-vue', '%n existing record looks like this one.', '%n existing records look like this one.', count)\n\t\t},\n\n\t\t/**\n\t\t * One row per match: the readable record's title and meta and link, or\n\t\t * a neutral name for one the user may not read.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {Array<object>}\n\t\t */\n\t\trows() {\n\t\t\treturn this.matches.map((match) => {\n\t\t\t\tconst uuid = String((match && match.uuid) || '')\n\t\t\t\tconst record = this.records.find((row) => String((row && (row.id || row.uuid || (row['@self'] && row['@self'].id))) || '') === uuid)\n\t\t\t\tconst fields = Array.isArray(match && match.matchedOn) ? match.matchedOn : []\n\t\t\t\tconst score = Number(match && match.score)\n\t\t\t\tconst words = fields.map((field) => (this.fieldLabels[field] ? this.cnTranslate(this.fieldLabels[field]) : field))\n\t\t\t\tconst percentage = Number.isFinite(score) ? Math.max(0, Math.min(100, Math.round(score * 100))) : 0\n\t\t\t\treturn {\n\t\t\t\t\tuuid,\n\t\t\t\t\ttitle: record ? (fillTemplate(this.rowTitle, record).trim() || uuid) : t('nextcloud-vue', 'A record you may not open'),\n\t\t\t\t\tmeta: record ? firstFilled(this.rowMeta, record, (key) => key).trim() : '',\n\t\t\t\t\thref: record && this.recordUrl ? generateUrl(fillTemplate(this.recordUrl, { uuid: encodeURIComponent(uuid) })) : '',\n\t\t\t\t\tmatched: this.matchedLine(words, percentage),\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A prop text through the host translate.\n\t\t *\n\t\t * @param {string} value The text.\n\t\t * @return {string}\n\t\t */\n\t\ttext(value) {\n\t\t\treturn value ? this.cnTranslate(value) : ''\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, and how strongly.\n\t\t *\n\t\t * @param {Array<string>} words The matched fields, in the host's words.\n\t\t * @param {number} percentage The score as a percentage.\n\t\t * @return {string}\n\t\t */\n\t\tmatchedLine(words, percentage) {\n\t\t\tif (words.length === 0) {\n\t\t\t\treturn `${t('nextcloud-vue', 'Matched on the score, not on a single field')} (${percentage}%)`\n\t\t\t}\n\t\t\tif (!this.matchedText) {\n\t\t\t\treturn `${words.join(', ')} (${percentage}%)`\n\t\t\t}\n\t\t\tlet fields = words.join(', ')\n\t\t\ttry {\n\t\t\t\tfields = new Intl.ListFormat(document.documentElement.lang || undefined, { type: 'conjunction' }).format(words)\n\t\t\t} catch {\n\t\t\t\t// An engine without Intl.ListFormat keeps the comma list.\n\t\t\t}\n\t\t\treturn fillTemplate(this.cnTranslate(this.matchedText), { fields, percentage: String(percentage) })\n\t\t},\n\n\t\t/** File it over the warning, carrying the reason and what it was filed over. */\n\t\tfileAnyway() {\n\t\t\tif (!this.canFile) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t/** @event file The user files it anyway. Payload: `{ reason, over }`, `over` the matched uuids. */\n\t\t\tthis.$emit('file', { reason: this.reason.trim(), over: this.matches.map((m) => String((m && m.uuid) || '')).filter(Boolean) })\n\t\t},\n\n\t\t/** Go back without filing. */\n\t\tclose() {\n\t\t\t/** @event close The user went back without filing. */\n\t\t\tthis.$emit('close')\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-duplicate-warning {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-duplicate-warning__matches {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n\n.cn-duplicate-warning__match {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large, 8px);\n}\n\n.cn-duplicate-warning__title {\n\tfont-weight: 600;\n}\n\n.cn-duplicate-warning__meta,\n.cn-duplicate-warning__hint {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-duplicate-warning__hint {\n\tmargin: 0;\n}\n</style>\n"],"names":["_createBlock","_createVNode","_createElementVNode","_createElementBlock","_Fragment","_renderList","_toDisplayString","_openBlock"],"mappings":";;;AAoBO,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,+BAA+B,GAAA;;;;AAMrC,EAAA,KAAA,EAAA,6BAAA;;;;;;AAEI,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,4BAA4B,GAAA;;;;AAazC,EAAA,aAAW,EAAC,8BAAI;;;;AAKhB,EAAA,KAAG,EAAA,4BAAA;;;;;;;;;;uBArCLA;AACC,IAAA,IAAI,EAAE,QAAA,CAAA,IAAI,CAAC,MAAA,CAAA,KAAI,KAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,wBAAA,CAAA;IACf,OAAO,EAAE,QAAI,CAAA,IAAA,CAAC,MAAO,CAAA,OAAA,CAAA;SACjB,EAAC,MAAO;AACX,IAAA,aAAS,EAAC,sBAAO;AAClB,IAAA,SAAO,EAAE,QAAG,CAAA,KAAA;;AAsCF,IAAA,OAAO,UAChB,MAEU;MAFVC,WAEU,CAAA,mBAAA,EAAA;AAFD,QAAA,OAAO,EAAA,UAAA;AAAA,QAAA,aAAA,EAAA,6BAAA;AAAA,QAAA,OAAA,EAAA,QAAA,CAAA,KAAA;;yBAChB,MAAmB;0CAAhB,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;AAEW,MAAA,CAAA,QAAA,CAAA,WAAI,CAAA,WAAA;w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A,WAAW,CAAC,WAAU;0BAAxCN,WAKuC,CAAA,sBAAA,EAAA;;AAJtC,cAAA,KAAK,EAAE,QAAA,CAAA,IAAI,CAAC,MAAA,CAAA,WAAW,KAAK,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,oBAAA,CAAA;;cAE9B,UAAW,EAAE,QAAI,CAAA,IAAA,CAAC,MAAU,CAAA,UAAA,CAAA;AAC5B,cAAA,aAAW,EAAC,6BAAqB;cAChC,qBAAiB,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAE,KAAM,CAAA,MAAA,GAAG,MAAM,CAAA,CAAA;;;AAEjC,QAAA,CAAA,QAAA,CAAA,WAAA,CAAA,OAAA,IAAA,CAAA,QAAA,CAAA,WAAA,CAAA,WAAA;AAAH,aAAAO,SAAA,EAAA,EAAAJ,kBAAA,CAII,KAJJ,UAII,EAAAG,eAAA,CADA,aAAI,CAAC,MAAA,CAAA,WAAW,KAAK,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,4EAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;SAGvB,MAAA,CAAA,QAAA;AAAH,aAAAC,SAAA,EAAA,EAAAJ,kBAAA,CAII,GAJJ,EAAA,UAII,EADAG,eAAA,CAAA,QAAA,CAAA,IAAK,CAAA,MAAQ,CAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnDuplicateWarning.vue3.js","sources":["../../../../src/components/CnDuplicateWarning/CnDuplicateWarning.vue?vue&type=template&id=0588a184&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<CnDialog\n\t\t:name=\"text(title) || t('nextcloud-vue', 'This may already exist')\"\n\t\t:eyebrow=\"text(eyebrow)\"\n\t\twidth=\"confirm\"\n\t\tdata-testid=\"cn-duplicate-warning\"\n\t\t@closing=\"close\">\n\t\t<div class=\"cn-duplicate-warning\">\n\t\t\t<NcNoteCard :type=\"affordances.blocked && !affordances.mayContinue ? 'error' : 'warning'\" data-testid=\"cn-duplicate-warning-note\">\n\t\t\t\t{{ headlineText }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<ul class=\"cn-duplicate-warning__matches\">\n\t\t\t\t<li v-for=\"row in rows\"\n\t\t\t\t\t:key=\"row.uuid\"\n\t\t\t\t\tclass=\"cn-duplicate-warning__match\"\n\t\t\t\t\tdata-testid=\"cn-duplicate-warning-match\">\n\t\t\t\t\t<a v-if=\"row.href\" :href=\"row.href\" class=\"cn-duplicate-warning__title\">{{ row.title }}</a>\n\t\t\t\t\t<span v-else class=\"cn-duplicate-warning__title\">{{ row.title }}</span>\n\t\t\t\t\t<span v-if=\"row.meta\" class=\"cn-duplicate-warning__meta\">{{ row.meta }}</span>\n\t\t\t\t\t<span class=\"cn-duplicate-warning__meta\">{{ row.matched }}</span>\n\t\t\t\t</li>\n\t\t\t</ul>\n\n\t\t\t<NcTextField v-if=\"affordances.needsReason\"\n\t\t\t\t:label=\"text(reasonLabel) || t('nextcloud-vue', 'Why file it anyway')\"\n\t\t\t\t:modelValue=\"reason\"\n\t\t\t\t:helperText=\"text(reasonHint)\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-reason\"\n\t\t\t\t@update:modelValue=\"reason = $event\" />\n\n\t\t\t<p v-if=\"affordances.blocked && !affordances.mayContinue\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-blocked\">\n\t\t\t\t{{ text(blockedText) || t('nextcloud-vue', 'This cannot be filed twice. Open the one it matches, or ask a coordinator.') }}\n\t\t\t</p>\n\n\t\t\t<p v-if=\"footnote\"\n\t\t\t\tclass=\"cn-duplicate-warning__hint\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-footnote\">\n\t\t\t\t{{ text(footnote) }}\n\t\t\t</p>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"secondary\" data-testid=\"cn-duplicate-warning-cancel\" @click=\"close\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton v-if=\"affordances.mayContinue\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canFile\"\n\t\t\t\tdata-testid=\"cn-duplicate-warning-continue\"\n\t\t\t\t@click=\"fileAnyway\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<CnIcon name=\"Plus\" :size=\"20\" />\n\t\t\t\t</template>\n\t\t\t\t{{ text(continueLabel) || t('nextcloud-vue', 'File it anyway') }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</CnDialog>\n</template>\n\n<script>\nimport { translatePlural as n, translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport CnIcon from '../CnIcon/CnIcon.vue'\nimport { duplicateAffordances } from '../../utils/duplicateWarning.js'\nimport { fillTemplate, firstFilled } from '../../utils/fillTemplate.js'\nimport { CnDialog } from '../CnDialog/index.js'\n\n/**\n * CnDuplicateWarning — \"this may already exist\", before a record is filed.\n * It renders OpenRegister's scored matches (`{ uuid, score, matchedOn }`),\n * never scoring anything itself, with each matched record's title, a meta\n * line, what it matched on and how strongly. Under a `warn` policy anyone may\n * file it anyway; under `block` only a user who `mayOverride`, and they say\n * why. A match the user may not read is reported without disclosing it.\n * dossiq's case intake is the first consumer; pipelinq contacts share it.\n *\n * Open it in a template, or from code with `openDuplicateWarning(props)`,\n * which resolves with `{ reason, over }` or null.\n *\n * ```vue\n * <CnDuplicateWarning\n * :matches=\"matches\"\n * :records=\"readableCases\"\n * policy=\"block\"\n * :may-override=\"isCoordinator\"\n * record-url=\"/apps/dossiq/cases/{uuid}\"\n * :field-labels=\"{ requester: 'Requester', title: 'Subject' }\"\n * @file=\"save\"\n * @close=\"cancel\" />\n * ```\n */\nexport default {\n\tname: 'CnDuplicateWarning',\n\n\tcomponents: { CnDialog, CnIcon, NcButton, NcNoteCard, NcTextField },\n\n\tinject: {\n\t\t/** The host app's translate (CnAppRoot `cnTranslate`). */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The scored matches, as OpenRegister answered: `{ uuid, score, matchedOn }`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\tmatches: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The matched records the user may read, matched by `id`, `uuid` or `@self.id`.\n\t\t *\n\t\t * @type {Array<object>}\n\t\t */\n\t\trecords: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/** `warn` lets anyone file it anyway; `block` only a user who `mayOverride`. */\n\t\tpolicy: {\n\t\t\ttype: String,\n\t\t\tdefault: 'warn',\n\t\t},\n\n\t\t/** Whether this user may file over a block (and must say why). */\n\t\tmayOverride: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/** A record's title, a template filled from it. */\n\t\trowTitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '{title}',\n\t\t},\n\n\t\t/**\n\t\t * A record's meta line, a template filled from it, or several: the\n\t\t * first that fills is shown (\"{identifier} · {caseType.title}\", then\n\t\t * \"{identifier}\" for a record that lacks the type).\n\t\t *\n\t\t * @type {string|Array<string>}\n\t\t */\n\t\trowMeta: {\n\t\t\ttype: [String, Array],\n\t\t\tdefault: '{identifier}',\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, `{fields}` (joined as a list: \"Aanvrager\n\t\t * en Onderwerp\") and `{percentage}` filled, through the host\n\t\t * translate. Empty: \"Aanvrager, Onderwerp (82%)\".\n\t\t */\n\t\tmatchedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A line above the title, as the board dialogs draw one. */\n\t\teyebrow: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The help line under the reason field. */\n\t\treasonHint: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A muted note under the matches and the reason, for what Cancel and a block mean. */\n\t\tfootnote: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** A record's page, a template with `{uuid}`; empty draws no link. */\n\t\trecordUrl: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/**\n\t\t * Words for the matched fields (`{ requester: \"Requester\" }`), through the host translate.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tfieldLabels: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The dialog title; defaults to \"This may already exist\". */\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The note's sentence, `{count}` filled; defaults to \"%n existing record looks like this one.\". */\n\t\theadline: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The sentence under a block the user may not pass. */\n\t\tblockedText: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The reason field's label. */\n\t\treasonLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The continue button's label; defaults to \"File it anyway\". */\n\t\tcontinueLabel: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['close', 'file'],\n\n\tdata() {\n\t\treturn {\n\t\t\treason: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * What to draw and offer.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {{show: boolean, blocked: boolean, mayContinue: boolean, needsReason: boolean}}\n\t\t */\n\t\taffordances() {\n\t\t\treturn duplicateAffordances({ matches: this.matches, policy: this.policy, mayOverride: this.mayOverride })\n\t\t},\n\n\t\t/** @return {boolean} Whether \"file it anyway\" may be pressed. */\n\t\tcanFile() {\n\t\t\treturn this.affordances.mayContinue && (!this.affordances.needsReason || this.reason.trim() !== '')\n\t\t},\n\n\t\t/** @return {string} The note's sentence. */\n\t\theadlineText() {\n\t\t\tconst count = this.matches.length\n\t\t\tif (this.headline) {\n\t\t\t\treturn fillTemplate(this.cnTranslate(this.headline), { count })\n\t\t\t}\n\t\t\treturn n('nextcloud-vue', '%n existing record looks like this one.', '%n existing records look like this one.', count)\n\t\t},\n\n\t\t/**\n\t\t * One row per match: the readable record's title and meta and link, or\n\t\t * a neutral name for one the user may not read.\n\t\t *\n\t\t * @spec openspec/changes/duplicate-warning/specs/duplicate-warning/spec.md#requirement-a-generic-duplicate-warning\n\t\t * @return {Array<object>}\n\t\t */\n\t\trows() {\n\t\t\treturn this.matches.map((match) => {\n\t\t\t\tconst uuid = String((match && match.uuid) || '')\n\t\t\t\tconst record = this.records.find((row) => String((row && (row.id || row.uuid || (row['@self'] && row['@self'].id))) || '') === uuid)\n\t\t\t\tconst fields = Array.isArray(match && match.matchedOn) ? match.matchedOn : []\n\t\t\t\tconst score = Number(match && match.score)\n\t\t\t\tconst words = fields.map((field) => (this.fieldLabels[field] ? this.cnTranslate(this.fieldLabels[field]) : field))\n\t\t\t\tconst percentage = Number.isFinite(score) ? Math.max(0, Math.min(100, Math.round(score * 100))) : 0\n\t\t\t\treturn {\n\t\t\t\t\tuuid,\n\t\t\t\t\ttitle: record ? (fillTemplate(this.rowTitle, record).trim() || uuid) : t('nextcloud-vue', 'A record you may not open'),\n\t\t\t\t\tmeta: record ? firstFilled(this.rowMeta, record, (key) => key).trim() : '',\n\t\t\t\t\thref: record && this.recordUrl ? generateUrl(fillTemplate(this.recordUrl, { uuid: encodeURIComponent(uuid) })) : '',\n\t\t\t\t\tmatched: this.matchedLine(words, percentage),\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * A prop text through the host translate.\n\t\t *\n\t\t * @param {string} value The text.\n\t\t * @return {string}\n\t\t */\n\t\ttext(value) {\n\t\t\treturn value ? this.cnTranslate(value) : ''\n\t\t},\n\n\t\t/**\n\t\t * What a match was found on, and how strongly.\n\t\t *\n\t\t * @param {Array<string>} words The matched fields, in the host's words.\n\t\t * @param {number} percentage The score as a percentage.\n\t\t * @return {string}\n\t\t */\n\t\tmatchedLine(words, percentage) {\n\t\t\tif (words.length === 0) {\n\t\t\t\treturn `${t('nextcloud-vue', 'Matched on the score, not on a single field')} (${percentage}%)`\n\t\t\t}\n\t\t\tif (!this.matchedText) {\n\t\t\t\treturn `${words.join(', ')} (${percentage}%)`\n\t\t\t}\n\t\t\tlet fields = words.join(', ')\n\t\t\ttry {\n\t\t\t\tfields = new Intl.ListFormat(document.documentElement.lang || undefined, { type: 'conjunction' }).format(words)\n\t\t\t} catch {\n\t\t\t\t// An engine without Intl.ListFormat keeps the comma list.\n\t\t\t}\n\t\t\treturn fillTemplate(this.cnTranslate(this.matchedText), { fields, percentage: String(percentage) })\n\t\t},\n\n\t\t/** File it over the warning, carrying the reason and what it was filed over. */\n\t\tfileAnyway() {\n\t\t\tif (!this.canFile) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t/** @event file The user files it anyway. Payload: `{ reason, over }`, `over` the matched uuids. */\n\t\t\tthis.$emit('file', { reason: this.reason.trim(), over: this.matches.map((m) => String((m && m.uuid) || '')).filter(Boolean) })\n\t\t},\n\n\t\t/** Go back without filing. */\n\t\tclose() {\n\t\t\t/** @event close The user went back without filing. */\n\t\t\tthis.$emit('close')\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-duplicate-warning {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-duplicate-warning__matches {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n\n.cn-duplicate-warning__match {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: 8px;\n}\n\n.cn-duplicate-warning__title {\n\tfont-weight: 600;\n}\n\n.cn-duplicate-warning__meta,\n.cn-duplicate-warning__hint {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-duplicate-warning__hint {\n\tmargin: 0;\n}\n</style>\n"],"names":["_createBlock","_createVNode","_createTextVNode","_createElementVNode","_createElementBlock","_Fragment","_renderList","_toDisplayString","_openBlock"],"mappings":";;;AAoBO,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,+BAA+B,GAAA;;;;AAMrC,EAAA,KAAA,EAAA,6BAAA;;;;;;AAEI,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,4BAA4B,GAAA;;;;AAazC,EAAA,aAAW,EAAC,8BAAI;;;;AAKhB,EAAA,KAAG,EAAA,4BAAA;;;;;;;;;;;uBArCLA;AACC,IAAA,IAAI,EAAE,QAAA,CAAA,IAAI,CAAC,MAAA,CAAA,KAAI,KAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,wBAAA,CAAA;IACf,OAAO,EAAE,QAAI,CAAA,IAAA,CAAC,MAAO,CAAA,OAAA,CAAA;SACjB,EAAC,SAAS;AACb,IAAA,aAAS,EAAC,sBAAO;AAClB,IAAA,SAAO,EAAE,QAAG,CAAA,KAAA;;AAsCF,IAAA,OAAO,UAChB,MAEU;MAFVC,WAEU,CAAA,mBAAA,EAAA;AAFD,QAAA,OAAO,EAAA,WAAA;AAAA,QAAA,aAAA,EAAA,6BAAA;AAAA,QAAA,OAAA,EAAA,QAAA,CAAA,KAAA;;yBAChB,MAAmB;0CAAhB,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;AAEW,MAAA,CAAA,QAAA,CAAA,WAAI,CAA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
6
|
+
script.__scopeId = "data-v-3ce13882";
|
|
7
7
|
const __sfc_main = script;
|
|
8
8
|
|
|
9
9
|
export { __sfc_main as default };
|
|
@@ -223,7 +223,7 @@ var script = {
|
|
|
223
223
|
* `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`.
|
|
224
224
|
* `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.
|
|
225
225
|
* 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.
|
|
226
|
-
* A `line` or `text` with `joinPrevious: true` is written on after the line or text just before it, as one paragraph (`joinSeparator`, default a space); with none before it, it stands alone.
|
|
226
|
+
* A `line` or `text` with `joinPrevious: true` is written on after the line or text just before it, as one paragraph (`joinSeparator`, default a space); with none before it, it stands alone. A text joined with a line break (`joinSeparator: "\n"`) keeps it: two address lines as one block.
|
|
227
227
|
* A row with `inline: true` spans both columns as one line, the label, the value and its buttons side by side (a masked BSN with Show).
|
|
228
228
|
* 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.
|
|
229
229
|
* A part may be `{ text }`, a constant; a `line` or `text` entry without `path` or `parts` shows its `text`.
|
|
@@ -248,7 +248,7 @@ var script = {
|
|
|
248
248
|
* - `emptyWhen` — a path; when the record's value there is truthy the card shows `emptyText` (an endpoint that answers `empty: true`).
|
|
249
249
|
* - `link` — `{ label, route? | href? }` at the foot. `{ label, icon?, sidebarTab }` instead opens the page's object sidebar on that tab (no link without a sidebar).
|
|
250
250
|
* - `hideEmpty` — drop an entry whose value is empty (default true).
|
|
251
|
-
* - `columns` — `2` lays the rows out in two columns with the label above the value (board DqContact); a row with `parts` joins them like a line (an address on one row). `1` stacks each label above its value in one column, for a narrow card with long labels (board DqHandhaving "Afwijking en definitief").
|
|
251
|
+
* - `columns` — `2` lays the rows out in two columns with the label above the value (board DqContact), `3` in three (board DqSociaalDomein "De melding"); a row with `parts` joins them like a line (an address on one row). `1` stacks each label above its value in one column, for a narrow card with long labels (board DqHandhaving "Afwijking en definitief").
|
|
252
252
|
* - `emptyText` — shown when no entry has a value.
|
|
253
253
|
*
|
|
254
254
|
* @type {{fields?: Array<object>, source?: object, link?: object, hideEmpty?: boolean, emptyText?: string}}
|
|
@@ -324,13 +324,23 @@ var script = {
|
|
|
324
324
|
},
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
|
-
* Whether the rows sit in
|
|
327
|
+
* Whether the rows sit in columns, label above value: two, or three.
|
|
328
328
|
*
|
|
329
329
|
* @spec openspec/changes/facts-columns/specs/facts-widget/spec.md#requirement-facts-rows-can-sit-in-two-columns
|
|
330
330
|
* @return {boolean}
|
|
331
331
|
*/
|
|
332
332
|
twoColumns() {
|
|
333
|
-
return Number(this.content?.columns)
|
|
333
|
+
return [2, 3].includes(Number(this.content?.columns))
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Whether the rows sit in three columns (board DqSociaalDomein "De melding").
|
|
338
|
+
*
|
|
339
|
+
* @spec openspec/changes/facts-columns/specs/facts-widget/spec.md#requirement-facts-rows-can-sit-in-three-columns
|
|
340
|
+
* @return {boolean}
|
|
341
|
+
*/
|
|
342
|
+
threeColumns() {
|
|
343
|
+
return Number(this.content?.columns) === 3
|
|
334
344
|
},
|
|
335
345
|
|
|
336
346
|
/**
|