@conduction/nextcloud-vue 2.171.0 → 2.172.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +22 -3
- 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/CnDeviceFramesWidget/CnDeviceFramesWidget.vue.js +1 -1
- package/dist/esm/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue2.js +75 -4
- 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/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +7 -3
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +270 -162
- package/dist/esm/utils/builtInFormatters.js +19 -1
- package/dist/esm/utils/builtInFormatters.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +122 -13
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +270 -162
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +4 -1
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +24 -3
- package/src/components/CnDeviceFramesWidget/CnDeviceFramesWidget.vue +75 -4
- package/src/components/CnFactsWidget/CnFactsWidget.vue +7 -3
- package/src/css/look-board-detail.css +100 -1
- package/src/css/look-board-index.css +7 -6
- package/src/css/patches.css +4 -1
- package/src/utils/builtInFormatters.js +18 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnChecklistRunWidget.vue3.js","sources":["../../../../src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue?vue&type=template&id=4713ce24&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<div class=\"cn-checklist-run\" data-testid=\"cn-checklist-run\">\n\t\t<p v-if=\"error\"\n\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\trole=\"alert\"\n\t\t\tdata-testid=\"cn-checklist-run-error\">\n\t\t\t{{ error }}\n\t\t</p>\n\t\t<div v-else-if=\"loading\" class=\"cn-checklist-run__loading\">\n\t\t\t<NcLoadingIcon :size=\"20\" :name=\"loadingLabel\" />\n\t\t</div>\n\t\t<p v-else-if=\"questions.length === 0\" class=\"cn-checklist-run__empty\" data-testid=\"cn-checklist-run-empty\">\n\t\t\t{{ emptyLabel }}\n\t\t</p>\n\t\t<form v-else\n\t\t\tclass=\"cn-checklist-run__form\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"next\">\n\t\t\t<p\n\t\t\t\tref=\"position\"\n\t\t\t\tclass=\"cn-checklist-run__position\"\n\t\t\t\ttabindex=\"-1\"\n\t\t\t\tdata-testid=\"cn-checklist-run-position\">\n\t\t\t\t{{ positionText }}\n\t\t\t</p>\n\t\t\t<span\n\t\t\t\tclass=\"cn-checklist-run__progress\"\n\t\t\t\trole=\"progressbar\"\n\t\t\t\t:aria-label=\"progressLabel\"\n\t\t\t\taria-valuemin=\"0\"\n\t\t\t\t:aria-valuemax=\"questions.length\"\n\t\t\t\t:aria-valuenow=\"answeredCount\"\n\t\t\t\tdata-testid=\"cn-checklist-run-progress\">\n\t\t\t\t<span class=\"cn-checklist-run__progress-fill\" :style=\"{ width: `${progressShare}%` }\" />\n\t\t\t</span>\n\t\t\t<span class=\"cn-checklist-run__live\" aria-live=\"polite\">{{ liveText }}</span>\n\n\t\t\t<p v-if=\"pageGroup\" class=\"cn-checklist-run__group\" data-testid=\"cn-checklist-run-group\">\n\t\t\t\t{{ pageGroup }}\n\t\t\t</p>\n\t\t\t<fieldset\n\t\t\t\tv-for=\"question in pageQuestions\"\n\t\t\t\t:key=\"question.id\"\n\t\t\t\tclass=\"cn-checklist-run__question\"\n\t\t\t\t:aria-describedby=\"question.help ? `${uid}-help-${question.id}` : null\"\n\t\t\t\tdata-testid=\"cn-checklist-run-question\">\n\t\t\t\t<legend class=\"cn-checklist-run__legend\">\n\t\t\t\t\t{{ question.text }}<span v-if=\"question.required\" class=\"cn-checklist-run__required\">\n\t\t\t\t\t\t<span aria-hidden=\"true\"> *</span><span class=\"cn-checklist-run__sr\">{{ requiredLabel }}</span>\n\t\t\t\t\t</span>\n\t\t\t\t</legend>\n\t\t\t\t<p v-if=\"question.help\" :id=\"`${uid}-help-${question.id}`\" class=\"cn-checklist-run__help\">\n\t\t\t\t\t{{ question.help }}\n\t\t\t\t</p>\n\t\t\t\t<template v-if=\"question.choices.length\">\n\t\t\t\t\t<label\n\t\t\t\t\t\tv-for=\"choice in question.choices\"\n\t\t\t\t\t\t:key=\"choice.value\"\n\t\t\t\t\t\tclass=\"cn-checklist-run__choice\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t:name=\"`${uid}-${question.id}`\"\n\t\t\t\t\t\t\t:value=\"choice.value\"\n\t\t\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\t\t\tdata-testid=\"cn-checklist-run-choice\"\n\t\t\t\t\t\t\t@change=\"markDirty(question.id)\">\n\t\t\t\t\t\t{{ choice.label }}\n\t\t\t\t\t</label>\n\t\t\t\t</template>\n\t\t\t\t<input\n\t\t\t\t\tv-else-if=\"question.kind === 'number'\"\n\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\tclass=\"cn-checklist-run__number\"\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t:aria-label=\"question.text\"\n\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-number\"\n\t\t\t\t\t@input=\"markDirty(question.id)\">\n\t\t\t\t<p v-else-if=\"question.kind === 'photo'\" class=\"cn-checklist-run__help\">\n\t\t\t\t\t{{ photoOnlyLabel }}\n\t\t\t\t</p>\n\t\t\t\t<textarea\n\t\t\t\t\tv-else\n\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\tclass=\"cn-checklist-run__text\"\n\t\t\t\t\trows=\"3\"\n\t\t\t\t\t:aria-label=\"question.text\"\n\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-text\"\n\t\t\t\t\t@input=\"markDirty(question.id)\" />\n\t\t\t\t<label v-if=\"allowNote && noteShown(question)\" class=\"cn-checklist-run__note-label\">\n\t\t\t\t\t{{ noteLabel }}\n\t\t\t\t\t<textarea\n\t\t\t\t\t\tv-model=\"draft[question.id].note\"\n\t\t\t\t\t\tclass=\"cn-checklist-run__text\"\n\t\t\t\t\t\trows=\"2\"\n\t\t\t\t\t\tdata-testid=\"cn-checklist-run-note\"\n\t\t\t\t\t\t@input=\"markDirty(question.id)\" />\n\t\t\t\t</label>\n\t\t\t\t<p\n\t\t\t\t\tv-if=\"missing.includes(question.id)\"\n\t\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\t\trole=\"alert\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-missing\">\n\t\t\t\t\t{{ missingLabel }}\n\t\t\t\t</p>\n\t\t\t</fieldset>\n\n\t\t\t<div\n\t\t\t\tv-for=\"question in photoQuestions\"\n\t\t\t\t:key=\"`photos-${question.id}`\"\n\t\t\t\tclass=\"cn-checklist-run__photos\"\n\t\t\t\tdata-testid=\"cn-checklist-run-photos\">\n\t\t\t\t<strong class=\"cn-checklist-run__photos-title\">{{ photoTitle(question) }}</strong>\n\t\t\t\t<ul v-if=\"photoNamesFor(question).length\" class=\"cn-checklist-run__photo-list\">\n\t\t\t\t\t<li v-for=\"name in photoNamesFor(question)\" :key=\"name\" data-testid=\"cn-checklist-run-photo\">\n\t\t\t\t\t\t{{ name }}\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t\t<!-- A button that opens the hidden file input, so the control is\n\t\t\t\t a button to every reader; the input stays out of the tab\n\t\t\t\t order and the accessibility tree. -->\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"cn-checklist-run__photo-button\"\n\t\t\t\t\t:aria-describedby=\"missingPhoto.includes(question.id) ? `${uid}-photo-${question.id}` : null\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-photo-button\"\n\t\t\t\t\t@click=\"openPhotoPicker\">\n\t\t\t\t\t<CameraOutline :size=\"16\" />\n\t\t\t\t\t{{ photoNamesFor(question).length || (storedPhotos[question.id] || []).length ? morePhotoLabel : addPhotoLabel }}\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tclass=\"cn-checklist-run__photo-input\"\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tcapture=\"environment\"\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-photo-input\"\n\t\t\t\t\t@change=\"addPhotos($event, question.id)\">\n\t\t\t\t<p\n\t\t\t\t\tv-if=\"missingPhoto.includes(question.id)\"\n\t\t\t\t\t:id=\"`${uid}-photo-${question.id}`\"\n\t\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\t\trole=\"alert\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-missing-photo\">\n\t\t\t\t\t{{ missingPhotoLabel }}\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t<div class=\"cn-checklist-run__nav\">\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t:disabled=\"page === 0 || saving\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-previous\"\n\t\t\t\t\t@click=\"previous\">\n\t\t\t\t\t{{ previousLabel }}\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-next\">\n\t\t\t\t\t{{ isLastPage ? finishLabel : nextLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t\t<p v-if=\"saveError\"\n\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\trole=\"alert\"\n\t\t\t\tdata-testid=\"cn-checklist-run-save-error\">\n\t\t\t\t{{ saveError }}\n\t\t\t</p>\n\t\t</form>\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcLoadingIcon } from '@nextcloud/vue'\nimport CameraOutline from 'vue-material-design-icons/CameraOutline.vue'\nimport { uploadHeldFiles } from '../../composables/useHeldFileUpload.js'\nimport { dispatchAction } from '../../utils/actionsDispatcher.js'\nimport { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { hasUnresolvedTokens, resolveDeepTokens, resolveFilterTokens } from '../../utils/resolveFilterTokens.js'\n\nconst OBJECT_API = '/apps/openregister/api/objects'\n\nlet instanceCounter = 0\n\n/**\n * The choices a question type offers, before translation.\n *\n * @type {Record<string, Array<{value: string, label: string}>>}\n */\nconst TYPE_CHOICES = Object.freeze({\n\tyes_no: [{ key: 'yes', label: 'Yes' }, { key: 'no', label: 'No' }],\n\tyes_no_na: [{ key: 'yes', label: 'Yes' }, { key: 'no', label: 'No' }, { key: 'na', label: 'Not applicable' }],\n})\n\n/** The kinds of question the widget draws. */\nconst KINDS = Object.freeze(['yes_no', 'yes_no_na', 'choice', 'text', 'number', 'photo'])\n\n/**\n * Sort by a numeric field, lowest first, keeping the given order for ties and\n * for entries without the field.\n *\n * @param {Array<object>} list The entries.\n * @param {string} field The field.\n * @return {Array<object>} A sorted copy.\n */\nfunction byOrder(list, field) {\n\tif (!field) {\n\t\treturn [...list]\n\t}\n\tconst rank = (entry) => {\n\t\tconst n = Number(readPath(entry, field))\n\t\treturn Number.isFinite(n) ? n : Infinity\n\t}\n\treturn list.map((entry, index) => ({ entry, index })).sort((a, b) => (rank(a.entry) - rank(b.entry)) || (a.index - b.index)).map(({ entry }) => entry)\n}\n\n/**\n * A register or schema as the object API path takes it.\n *\n * @param {string|object} value A slug, or a register/schema object.\n * @return {string} The slug or id.\n */\nfunction slugOf(value) {\n\tif (value && typeof value === 'object') {\n\t\treturn String(value.slug ?? value.id ?? '')\n\t}\n\treturn value ? String(value) : ''\n}\n\n/**\n * The id of an object, wherever OpenRegister carries it.\n *\n * @param {object|null} object The object.\n * @return {string} The id, or ''.\n */\nfunction idOf(object) {\n\treturn String(object?.id ?? object?.['@self']?.id ?? object?.uuid ?? '')\n}\n\n/**\n * CnChecklistRunWidget — the `checklist-run` widget: a checklist answered a\n * page of questions at a time (board DqInspectie, the middle phone frame).\n *\n * The questions are records of a register, listed with a token-resolved\n * filter. Each page shows `pageSize` questions (one by default) as radio\n * choices or a text field, an optional note, and photos for the first\n * question of the page, then Previous and Next. The answers of a page are\n * saved when the user moves on.\n *\n * Answers are stored one record per question through the OpenRegister object\n * API, under the reader's own rights: an existing answer is updated, a new\n * one created with the `answers.create` fields. Photos go up through the\n * object's own file upload (`uploadHeldFiles`) and are attached to the\n * answer's `photosField`. An app that stores answers its own way names a\n * `saveAction` instead; it is dispatched per answer with the answer as its\n * last argument, and photos are not uploaded then.\n *\n * ```json\n * {\n * \"type\": \"checklist-run\",\n * \"content\": {\n * \"questions\": { \"register\": \"app\", \"schema\": \"question\", \"filter\": { \"checklist\": \"@object.checklist\" }, \"orderField\": \"position\" },\n * \"fields\": { \"text\": \"text\", \"type\": \"type\", \"options\": \"options\", \"required\": \"required\", \"help\": \"help\" },\n * \"answers\": {\n * \"register\": \"app\", \"schema\": \"answer\", \"filter\": { \"run\": \"@objectId\" },\n * \"questionField\": \"question\", \"valueField\": \"answer\", \"noteField\": \"note\", \"photosField\": \"photos\",\n * \"create\": { \"run\": \"@objectId\" }\n * },\n * \"pageSize\": 1,\n * \"caption\": \"{title} version {version}\"\n * }\n * }\n * ```\n *\n * The questions and answers can also live inside the open record:\n * `questionsPath` (with `itemsKey` for groups, both sorted by `orderField`)\n * reads the questions off it, and `answersPath` writes the answers into an\n * array on it, one entry per question keyed by `answerKey`, by updating the\n * record through the object API. Photos then go to the record's own files\n * (`recordPhotosField`) and their references into the answer.\n *\n * A question can require a photo: `fields.photoRequired` names its rule,\n * `photoRequiredValues` maps the stored values onto `never`, `always` or\n * `{ whenAnswer }`, and the page holds until the photo is there. On a page\n * with no bound record, `record: { register, schema, filter, sort }` picks\n * the open record: the first match, under the reader's rights.\n *\n * `noteWhen: { answers: [...] }` shows a question's note field only once its\n * answer is one of those stored values (the board shows a note under \"Nee\"),\n * or when the question already holds a note; without it every question shows\n * one (`allowNote: false` hides them all).\n *\n * `startAt: \"firstOpen\"` opens a run that was started earlier at the page of\n * its first unanswered question (the last page when all are answered), once\n * per record; without it the run opens at the first page.\n *\n * Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,\n * a list of strings or `{ value, label }`), `number`, `photo` and `text`.\n * `typeMap` maps the app's type values onto them, `choiceValues` the stored\n * values of yes / no / not applicable.\n * Keyboard: the choices are native radio buttons in a fieldset whose legend is\n * the question; on a new page focus moves to the position line and a polite\n * live region reads it.\n */\nexport default {\n\tname: 'CnChecklistRunWidget',\n\n\tcomponents: { CameraOutline, NcButton, NcLoadingIcon },\n\n\tinject: {\n\t\t/** The detail page's object context (`{ objectId, object }`), for tokens. */\n\t\tcnObjectContext: { default: null },\n\t\t/** The page's workspace values, for `@workspace.<key>` tokens. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host's translate, for manifest texts and question texts. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t\t/** The page's pre-bound action dispatcher, for `saveAction` / `finishAction`. */\n\t\tcnDispatchAction: { default: null },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget config: `{ questions | questionsPath, itemsKey?,\n\t\t * groupLabelField?, orderField?, fields?, typeMap?, choiceValues?,\n\t\t * answers | answersPath, answerKey?, answerFields?, recordPhotosField?,\n\t\t * record?, saveAction?, finishAction?, pageSize?, allowNote?, noteWhen?,\n\t\t * allowPhotos?, caption?, emptyText? }`, as in the component\n\t\t * description and docs/components/cn-checklist-run-widget.md.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The bound record's id, for `@objectId`. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The bound record, for `@object.<field>`, the caption and `questionsPath` / `answersPath`. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The bound record's register, for writing `answersPath` (`content.record` wins). */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The bound record's schema, for writing `answersPath` (`content.record` wins). */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['finished'],\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: `cn-checklist-run-${instanceCounter}`,\n\t\t\tloading: false,\n\t\t\terror: '',\n\t\t\tsaving: false,\n\t\t\tsaveError: '',\n\t\t\tquestions: [],\n\t\t\tanswerIds: {},\n\t\t\t// Photos an answer already holds, kept when new ones are attached.\n\t\t\tstoredPhotos: {},\n\t\t\t// `answersPath` mode: the answer entries as last read or written.\n\t\t\trecordAnswers: [],\n\t\t\tdraft: {},\n\t\t\tdirty: {},\n\t\t\tphotos: {},\n\t\t\tpage: 0,\n\t\t\t// The source the page was last positioned for; `startAt` applies once per source.\n\t\t\tpositionedFor: '',\n\t\t\tmissing: [],\n\t\t\t// Questions on this page that still need their photo.\n\t\t\tmissingPhoto: [],\n\t\t\t// `content.record` with a filter: the record it picked, or null.\n\t\t\tpickedRecord: null,\n\t\t\tliveText: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} What the tokens resolve against. */\n\t\ttokenCtx() {\n\t\t\tconst unwrap = (c) => (c && typeof c === 'object' && 'value' in c ? c.value : c)\n\t\t\tconst injected = unwrap(this.cnObjectContext) || {}\n\t\t\treturn {\n\t\t\t\t...injected,\n\t\t\t\tobjectId: (this.pickedRecord && idOf(this.pickedRecord)) || this.objectId || injected.objectId || this.objectData?.id || null,\n\t\t\t\tobject: this.pickedRecord || this.objectData || injected.object || null,\n\t\t\t\tworkspace: unwrap(this.cnWorkspaceContext) || {},\n\t\t\t}\n\t\t},\n\n\t\t/** @return {object} The question field paths, with their defaults. */\n\t\tfields() {\n\t\t\treturn { id: 'id', text: 'text', type: 'type', options: 'options', required: 'required', help: 'help', ...(this.content?.fields || {}) }\n\t\t},\n\n\t\t/** @return {number} Questions per page, at least 1. */\n\t\tpageSize() {\n\t\t\tconst n = Math.floor(Number(this.content?.pageSize))\n\t\t\treturn Number.isFinite(n) && n >= 1 ? n : 1\n\t\t},\n\n\t\t/** @return {number} The number of pages. */\n\t\tpageCount() {\n\t\t\treturn Math.max(1, Math.ceil(this.questions.length / this.pageSize))\n\t\t},\n\n\t\t/** @return {boolean} Whether this is the last page. */\n\t\tisLastPage() {\n\t\t\treturn this.page >= this.pageCount - 1\n\t\t},\n\n\t\t/** @return {object[]} The questions on this page. */\n\t\tpageQuestions() {\n\t\t\treturn this.questions.slice(this.page * this.pageSize, (this.page + 1) * this.pageSize)\n\t\t},\n\n\t\t/** @return {object|null} The first question on this page, the one photos belong to. */\n\t\tcurrentQuestion() {\n\t\t\treturn this.pageQuestions[0] || null\n\t\t},\n\n\t\t/** @return {number} Questions with an answer. */\n\t\tansweredCount() {\n\t\t\treturn this.questions.filter((q) => this.isAnswered(q)).length\n\t\t},\n\n\t\t/** @return {number} The share answered, 0 to 100. */\n\t\tprogressShare() {\n\t\t\treturn this.questions.length ? Math.round((this.answeredCount / this.questions.length) * 100) : 0\n\t\t},\n\n\t\t/** @return {string} \"Question 7 of 24\", with the caption after it. */\n\t\tpositionText() {\n\t\t\tconst first = this.page * this.pageSize + 1\n\t\t\tconst position = t('nextcloud-vue', 'Question {n} of {total}', { n: first, total: this.questions.length })\n\t\t\tconst caption = this.caption\n\t\t\treturn caption ? `${position} · ${caption}` : position\n\t\t},\n\n\t\t/** @return {string} `content.caption` with `{field}` filled from the record. */\n\t\tcaption() {\n\t\t\tconst template = this.content?.caption\n\t\t\tif (typeof template !== 'string' || template === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst object = this.tokenCtx.object || {}\n\t\t\treturn this.translate(template).replace(/\\{([A-Za-z0-9_.]+)\\}/g, (_m, path) => {\n\t\t\t\tconst value = readPath(object, path)\n\t\t\t\treturn value === null || value === undefined ? '' : String(value)\n\t\t\t}).trim()\n\t\t},\n\n\t\t/** @return {boolean} Whether a note field shows (default true). */\n\t\tallowNote() {\n\t\t\treturn this.content?.allowNote !== false\n\t\t},\n\n\t\t/** @return {boolean} Whether the answers are written into an array on the open record. */\n\t\tinRecord() {\n\t\t\treturn typeof this.content?.answersPath === 'string' && this.content.answersPath !== ''\n\t\t},\n\n\t\t/** @return {object} `answersPath` field names, with their defaults. */\n\t\tanswerFields() {\n\t\t\treturn { value: 'value', number: 'value', choice: 'value', note: 'note', photos: 'photos', ...(this.content?.answerFields || {}) }\n\t\t},\n\n\t\t/** @return {{register: string, schema: string}} Where the open record lives. */\n\t\trecordRef() {\n\t\t\tconst own = this.content?.record || {}\n\t\t\treturn { register: slugOf(own.register || this.register), schema: slugOf(own.schema || this.schema) }\n\t\t},\n\n\t\t/**\n\t\t * Whether photos can be added: allowed, and somewhere to put them.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tphotosEnabled() {\n\t\t\tif (this.content?.allowPhotos === false || this.content?.saveAction) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.inRecord) {\n\t\t\t\treturn Boolean(this.content?.recordPhotosField && this.answerFields.photos)\n\t\t\t}\n\t\t\treturn Boolean(this.content?.answers?.photosField)\n\t\t},\n\n\t\t/** @return {string} The group (section) of this page's first question, or ''. */\n\t\tpageGroup() {\n\t\t\treturn this.currentQuestion?.group || ''\n\t\t},\n\n\t\t/**\n\t\t * The questions of this page that get a photo control: with a\n\t\t * `photoRequired` field, those whose rule is not never (and photo\n\t\t * questions); without one, the first question of the page.\n\t\t *\n\t\t * @return {object[]} The questions.\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-question-can-require-a-photo\n\t\t */\n\t\tphotoQuestions() {\n\t\t\tif (!this.photosEnabled) {\n\t\t\t\treturn []\n\t\t\t}\n\t\t\tif (this.fields.photoRequired) {\n\t\t\t\treturn this.pageQuestions.filter((q) => q.kind === 'photo' || q.photoRule !== 'never')\n\t\t\t}\n\t\t\tconst first = this.currentQuestion\n\t\t\tconst extra = this.pageQuestions.filter((q) => q.kind === 'photo' && q !== first)\n\t\t\treturn first ? [first, ...extra] : extra\n\t\t},\n\n\t\t/**\n\t\t * `content.record` with a `filter`: the list to pick the open record\n\t\t * from (first match of `sort`), `'blocked'` while a token is\n\t\t * unresolved, or null without a filter.\n\t\t *\n\t\t * @return {object|string|null}\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-checklist-run-can-pick-its-record-by-filter\n\t\t */\n\t\trecordPicker() {\n\t\t\tconst own = this.content?.record\n\t\t\tif (!own || typeof own !== 'object' || !own.filter || typeof own.filter !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst unwrap = (c) => (c && typeof c === 'object' && 'value' in c ? c.value : c)\n\t\t\tconst filter = resolveFilterTokens(own.filter, { objectId: this.objectId || null, object: this.objectData, workspace: unwrap(this.cnWorkspaceContext) || {} })\n\t\t\tif (hasUnresolvedTokens(filter)) {\n\t\t\t\treturn 'blocked'\n\t\t\t}\n\t\t\tconst sort = own.sort && typeof own.sort === 'object' && own.sort.field ? { [`_order[${own.sort.field}]`]: own.sort.dir === 'asc' ? 'asc' : 'desc' } : {}\n\t\t\treturn { register: slugOf(own.register), schema: slugOf(own.schema), filter: { ...filter, ...sort } }\n\t\t},\n\n\t\t/** @return {object|null} The record the run lives in: the picked one, else the bound one. */\n\t\topenRecord() {\n\t\t\treturn this.recordPicker ? this.pickedRecord : this.tokenCtx.object\n\t\t},\n\n\t\t/** @return {string} The key of the source lists, to read them again when they change. */\n\t\tsourceKey() {\n\t\t\tconst picker = this.recordPicker\n\t\t\tif (picker === 'blocked') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tif (picker && typeof this.content?.questionsPath === 'string' && this.content.questionsPath !== '') {\n\t\t\t\treturn JSON.stringify({ pick: picker, path: this.content.questionsPath })\n\t\t\t}\n\t\t\tif (typeof this.content?.questionsPath === 'string' && this.content.questionsPath !== '') {\n\t\t\t\tconst object = this.tokenCtx.object\n\t\t\t\treturn object ? JSON.stringify({ path: this.content.questionsPath, id: idOf(object), at: object['@self']?.updated ?? null }) : ''\n\t\t\t}\n\t\t\tconst q = this.content?.questions\n\t\t\tif (!q || !q.register || !q.schema) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst qFilter = resolveFilterTokens(q.filter || {}, this.tokenCtx)\n\t\t\tconst a = this.content?.answers\n\t\t\tconst aFilter = a && a.register && a.schema ? resolveFilterTokens(a.filter || {}, this.tokenCtx) : null\n\t\t\tif (hasUnresolvedTokens(qFilter) || (aFilter && hasUnresolvedTokens(aFilter))) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn JSON.stringify({ q: [q.register, q.schema, qFilter], a: aFilter ? [a.register, a.schema, aFilter] : null })\n\t\t},\n\n\t\tloadingLabel: () => t('nextcloud-vue', 'Loading …'),\n\t\tprogressLabel: () => t('nextcloud-vue', 'Questions answered'),\n\t\trequiredLabel: () => ` ${t('nextcloud-vue', '(required)')}`,\n\t\tmissingLabel: () => t('nextcloud-vue', 'Answer this question to go on.'),\n\t\tpreviousLabel: () => t('nextcloud-vue', 'Previous'),\n\t\tnextLabel: () => t('nextcloud-vue', 'Next'),\n\t\tfinishLabel: () => t('nextcloud-vue', 'Finish'),\n\t\taddPhotoLabel: () => t('nextcloud-vue', 'Take or add a photo'),\n\t\tmissingPhotoLabel: () => t('nextcloud-vue', 'This answer needs a photo. Add one to go on.'),\n\t\tphotoOnlyLabel: () => t('nextcloud-vue', 'Answer with a photo.'),\n\t\tmorePhotoLabel: () => t('nextcloud-vue', 'Another photo'),\n\n\t\t/** @return {string} The note field's label. */\n\t\tnoteLabel() {\n\t\t\treturn this.content?.noteLabel ? this.translate(this.content.noteLabel) : t('nextcloud-vue', 'Note')\n\t\t},\n\n\t\t/** @return {string} The empty-state text. */\n\t\temptyLabel() {\n\t\t\treturn this.content?.emptyText ? this.translate(this.content.emptyText) : t('nextcloud-vue', 'This checklist has no questions.')\n\t\t},\n\t},\n\n\twatch: {\n\t\tsourceKey: {\n\t\t\thandler() {\n\t\t\t\tthis.load()\n\t\t\t},\n\n\t\t\timmediate: true,\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Whether a question shows its note field: always, unless `noteWhen`\n\t\t * names the answers that ask for one and this question has none of\n\t\t * them and no note yet.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean}\n\t\t */\n\t\tnoteShown(question) {\n\t\t\tconst answers = this.content?.noteWhen?.answers\n\t\t\tif (!Array.isArray(answers)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst draft = this.draft[question.id] || {}\n\t\t\treturn (draft.note || '') !== '' || answers.map(String).includes(String(draft.value ?? ''))\n\t\t},\n\n\t\t/**\n\t\t * The host's translate, or the text unchanged.\n\t\t *\n\t\t * @param {string} text The text.\n\t\t * @return {string} The translation.\n\t\t */\n\t\ttranslate(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Whether a value counts as an answer.\n\t\t *\n\t\t * @param {unknown} value The value.\n\t\t * @return {boolean} True for a non-empty value.\n\t\t */\n\t\thasValue(value) {\n\t\t\treturn value !== null && value !== undefined && String(value).trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether a question has an answer: a value, or for a photo question\n\t\t * a photo stored or held.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True when answered.\n\t\t */\n\t\tisAnswered(question) {\n\t\t\tif (question.kind === 'photo') {\n\t\t\t\treturn this.hasPhoto(question)\n\t\t\t}\n\t\t\treturn this.hasValue(this.draft[question.id]?.value)\n\t\t},\n\n\t\t/**\n\t\t * A question record as the widget draws it.\n\t\t *\n\t\t * @param {object} record The question record.\n\t\t * @param {string} [group] The group (section) it belongs to.\n\t\t * @return {{id: string, text: string, kind: string, required: boolean, help: string, choices: Array<{value: string, label: string}>, group: string}} The question.\n\t\t */\n\t\ttoQuestion(record, group = '') {\n\t\t\tconst f = this.fields\n\t\t\tconst raw = String(readPath(record, f.type) ?? '')\n\t\t\tconst mapped = this.content?.typeMap && typeof this.content.typeMap === 'object' ? this.content.typeMap[raw] : undefined\n\t\t\tconst kind = KINDS.includes(mapped) ? mapped : (KINDS.includes(raw) ? raw : 'text')\n\t\t\tconst stored = { yes: 'yes', no: 'no', na: 'na', ...(this.content?.choiceValues || {}) }\n\t\t\tlet choices = (TYPE_CHOICES[kind] || []).map((c) => ({ value: String(stored[c.key]), label: t('nextcloud-vue', c.label) }))\n\t\t\tif (kind === 'choice') {\n\t\t\t\tconst options = readPath(record, f.options)\n\t\t\t\tchoices = (Array.isArray(options) ? options : []).map((o) => (o && typeof o === 'object'\n\t\t\t\t\t? { value: String(o.value ?? o.label ?? ''), label: this.translate(String(o.label ?? o.value ?? '')) }\n\t\t\t\t\t: { value: String(o), label: this.translate(String(o)) })).filter((c) => c.value !== '')\n\t\t\t}\n\t\t\tconst help = readPath(record, f.help)\n\t\t\treturn {\n\t\t\t\tid: String(readPath(record, f.id) ?? idOf(record)),\n\t\t\t\ttext: this.translate(String(readPath(record, f.text) ?? '')),\n\t\t\t\tkind,\n\t\t\t\trequired: Boolean(readPath(record, f.required)),\n\t\t\t\thelp: typeof help === 'string' && help !== '' ? this.translate(help) : '',\n\t\t\t\tchoices,\n\t\t\t\tgroup,\n\t\t\t\tphotoRule: this.photoRuleOf(record),\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * A question's photo rule, from its `photoRequired` field mapped\n\t\t * through `photoRequiredValues`: `'never'`, `'always'` or\n\t\t * `{ whenAnswer }` (a photo is needed when the answer is that value).\n\t\t *\n\t\t * @param {object} record The question record.\n\t\t * @return {('never'|'always'|{whenAnswer: string})} The rule.\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-question-can-require-a-photo\n\t\t */\n\t\tphotoRuleOf(record) {\n\t\t\tconst path = this.fields.photoRequired\n\t\t\tif (!path) {\n\t\t\t\treturn 'never'\n\t\t\t}\n\t\t\tconst raw = readPath(record, path)\n\t\t\tconst map = { true: 'always', false: 'never', always: 'always', never: 'never', ...(this.content?.photoRequiredValues || {}) }\n\t\t\tconst rule = raw === null || raw === undefined ? 'never' : map[String(raw)]\n\t\t\tif (rule && typeof rule === 'object' && rule.whenAnswer !== undefined) {\n\t\t\t\treturn { whenAnswer: String(rule.whenAnswer) }\n\t\t\t}\n\t\t\treturn rule === 'always' ? 'always' : 'never'\n\t\t},\n\n\t\t/**\n\t\t * Whether a question needs a photo with its current answer.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True when a photo is required now.\n\t\t */\n\t\tneedsPhoto(question) {\n\t\t\tconst rule = question.photoRule\n\t\t\tif (rule === 'always') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn Boolean(rule && typeof rule === 'object' && String(this.draft[question.id]?.value ?? '') === rule.whenAnswer)\n\t\t},\n\n\t\t/**\n\t\t * Whether a question has a photo, stored or held.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True with at least one photo.\n\t\t */\n\t\thasPhoto(question) {\n\t\t\treturn (this.storedPhotos[question.id] || []).length > 0 || (this.photos[question.id] || []).length > 0\n\t\t},\n\n\t\t/**\n\t\t * The photo card title for a question: its position in the run.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {string} The title.\n\t\t */\n\t\tphotoTitle(question) {\n\t\t\tconst n = this.questions.indexOf(question) + 1\n\t\t\treturn t('nextcloud-vue', 'Photo for question {n}', { n })\n\t\t},\n\n\t\t/**\n\t\t * The names of the photos held for a question.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {string[]} The file names.\n\t\t */\n\t\tphotoNamesFor(question) {\n\t\t\treturn (this.photos[question.id] || []).map((file) => file.name)\n\t\t},\n\n\t\t/**\n\t\t * The questions on the open record (`questionsPath`): a list of\n\t\t * questions, or of groups whose `itemsKey` holds them, both levels\n\t\t * sorted by `orderField`.\n\t\t *\n\t\t * @return {object[]} The questions.\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tquestionsFromRecord() {\n\t\t\tconst c = this.content\n\t\t\tconst list = readPath(this.openRecord, c.questionsPath)\n\t\t\tconst orderField = c.orderField === undefined ? 'order' : c.orderField\n\t\t\tconst top = byOrder(Array.isArray(list) ? list : [], orderField)\n\t\t\tif (!c.itemsKey) {\n\t\t\t\treturn top.map((record) => this.toQuestion(record))\n\t\t\t}\n\t\t\tconst labelField = c.groupLabelField || 'name'\n\t\t\treturn top.flatMap((group) => {\n\t\t\t\tconst items = readPath(group, c.itemsKey)\n\t\t\t\tconst label = readPath(group, labelField)\n\t\t\t\treturn byOrder(Array.isArray(items) ? items : [], orderField).map((record) => this.toQuestion(record, typeof label === 'string' ? this.translate(label) : ''))\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The draft of one answer entry from the open record's `answersPath`.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @param {object} entry The stored entry.\n\t\t * @return {{value: string, note: string}} The draft.\n\t\t */\n\t\tdraftFromEntry(question, entry) {\n\t\t\tconst af = this.answerFields\n\t\t\tconst field = question.kind === 'number' ? af.number : (question.kind === 'choice' ? af.choice : af.value)\n\t\t\tconst value = readPath(entry, field)\n\t\t\tconst note = readPath(entry, af.note)\n\t\t\treturn { value: value === null || value === undefined ? '' : String(value), note: note === null || note === undefined ? '' : String(note) }\n\t\t},\n\n\t\t/**\n\t\t * Read the questions and the answers given so far.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-a-checklist-run-shows-a-page-of-questions-at-a-time\n\t\t */\n\t\tasync load() {\n\t\t\tconst key = this.sourceKey\n\t\t\tif (key === '') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\tthis.error = ''\n\t\t\ttry {\n\t\t\t\tconst picker = this.recordPicker\n\t\t\t\tif (picker) {\n\t\t\t\t\tconst found = await fetchReferenceObjects({ register: picker.register, schema: picker.schema, filter: picker.filter, limit: 1 })\n\t\t\t\t\tif (key !== this.sourceKey) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.pickedRecord = found[0] || null\n\t\t\t\t}\n\t\t\t\tlet questions\n\t\t\t\tif (picker && !this.pickedRecord) {\n\t\t\t\t\tquestions = []\n\t\t\t\t} else if (this.content.questionsPath) {\n\t\t\t\t\tquestions = this.questionsFromRecord()\n\t\t\t\t} else {\n\t\t\t\t\tconst q = this.content.questions\n\t\t\t\t\tconst records = await fetchReferenceObjects({ register: q.register, schema: q.schema, filter: resolveFilterTokens(q.filter || {}, this.tokenCtx), limit: q.limit || 500 })\n\t\t\t\t\tquestions = byOrder(records, q.orderField).map((r) => this.toQuestion(r))\n\t\t\t\t}\n\t\t\t\tquestions = questions.filter((x) => x.id !== '' && x.text !== '')\n\t\t\t\tconst a = this.inRecord ? null : this.content.answers\n\t\t\t\tconst answers = a && a.register && a.schema\n\t\t\t\t\t? await fetchReferenceObjects({ register: a.register, schema: a.schema, filter: resolveFilterTokens(a.filter || {}, this.tokenCtx), limit: a.limit || 500 })\n\t\t\t\t\t: []\n\t\t\t\tif (key !== this.sourceKey) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst draft = {}\n\t\t\t\tconst answerIds = {}\n\t\t\t\tconst storedPhotos = {}\n\t\t\t\tfor (const question of questions) {\n\t\t\t\t\tdraft[question.id] = { value: '', note: '' }\n\t\t\t\t}\n\t\t\t\tif (this.inRecord) {\n\t\t\t\t\tconst entries = readPath(this.openRecord, this.content.answersPath)\n\t\t\t\t\tthis.recordAnswers = Array.isArray(entries) ? entries : []\n\t\t\t\t\tconst key = this.content.answerKey || 'questionId'\n\t\t\t\t\tfor (const entry of this.recordAnswers) {\n\t\t\t\t\t\tconst qid = String(readPath(entry, key) ?? '')\n\t\t\t\t\t\tconst question = questions.find((x) => x.id === qid)\n\t\t\t\t\t\tif (question && !answerIds[qid]) {\n\t\t\t\t\t\t\tdraft[qid] = this.draftFromEntry(question, entry)\n\t\t\t\t\t\t\tanswerIds[qid] = qid\n\t\t\t\t\t\t\tconst photos = readPath(entry, this.answerFields.photos)\n\t\t\t\t\t\t\tstoredPhotos[qid] = Array.isArray(photos) ? photos : []\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const answer of answers) {\n\t\t\t\t\tconst qid = String(readPath(answer, a.questionField || 'question') ?? '')\n\t\t\t\t\tif (draft[qid] && !answerIds[qid]) {\n\t\t\t\t\t\tdraft[qid] = {\n\t\t\t\t\t\t\tvalue: String(readPath(answer, a.valueField || 'answer') ?? ''),\n\t\t\t\t\t\t\tnote: String(readPath(answer, a.noteField || 'note') ?? ''),\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanswerIds[qid] = idOf(answer)\n\t\t\t\t\t\tconst stored = a.photosField ? readPath(answer, a.photosField) : null\n\t\t\t\t\t\tstoredPhotos[qid] = Array.isArray(stored) ? stored : []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.questions = questions\n\t\t\t\tthis.draft = draft\n\t\t\t\tthis.answerIds = answerIds\n\t\t\t\tthis.storedPhotos = storedPhotos\n\t\t\t\tthis.dirty = {}\n\t\t\t\tconst lastPage = Math.max(0, Math.ceil(questions.length / this.pageSize) - 1)\n\t\t\t\tif (this.positionedFor !== key && this.content?.startAt === 'firstOpen') {\n\t\t\t\t\tconst open = questions.findIndex((question) => !this.isAnswered(question))\n\t\t\t\t\tthis.page = open === -1 ? lastPage : Math.floor(open / this.pageSize)\n\t\t\t\t}\n\t\t\t\tthis.positionedFor = key\n\t\t\t\tthis.page = Math.min(this.page, lastPage)\n\t\t\t} catch {\n\t\t\t\tthis.error = t('nextcloud-vue', 'The checklist could not be loaded.')\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Note that a question's answer changed, so the page saves it.\n\t\t *\n\t\t * @param {string} id The question id.\n\t\t * @return {void}\n\t\t */\n\t\tmarkDirty(id) {\n\t\t\tthis.dirty = { ...this.dirty, [id]: true }\n\t\t\tthis.missing = this.missing.filter((m) => m !== id)\n\t\t},\n\n\t\t/**\n\t\t * Open the file picker of the photo button's own question: the hidden\n\t\t * input that follows the button.\n\t\t *\n\t\t * @param {MouseEvent} event The button's click.\n\t\t * @return {void}\n\t\t */\n\t\topenPhotoPicker(event) {\n\t\t\tconst input = event.currentTarget.nextElementSibling\n\t\t\tif (input && input.type === 'file') {\n\t\t\t\tinput.click()\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Hold the photos picked for a question until the page saves.\n\t\t *\n\t\t * @param {Event} event The file input's change event.\n\t\t * @param {string} [questionId] The question, else the first of the page.\n\t\t * @return {void}\n\t\t */\n\t\taddPhotos(event, questionId) {\n\t\t\tconst id = questionId || this.currentQuestion?.id\n\t\t\tconst files = Array.from(event?.target?.files || [])\n\t\t\tif (!id || files.length === 0) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.photos = { ...this.photos, [id]: [...(this.photos[id] || []), ...files] }\n\t\t\tthis.dirty = { ...this.dirty, [id]: true }\n\t\t\tthis.missingPhoto = this.missingPhoto.filter((m) => m !== id)\n\t\t\tif (event.target) {\n\t\t\t\tevent.target.value = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Save the changed answers of this page: through `saveAction` when\n\t\t * set, else one answer record per question through the object API,\n\t\t * then its held photos.\n\t\t *\n\t\t * @return {Promise<boolean>} True when everything saved.\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-answers-are-saved-under-the-readers-own-rights\n\t\t */\n\t\tasync savePage() {\n\t\t\tconst changed = this.pageQuestions.filter((q) => this.dirty[q.id])\n\t\t\tif (changed.length === 0) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.saveError = ''\n\t\t\ttry {\n\t\t\t\tif (this.inRecord && !this.content?.saveAction) {\n\t\t\t\t\tawait this.saveIntoRecord(changed)\n\t\t\t\t\tthis.dirty = Object.fromEntries(Object.entries(this.dirty).filter(([id]) => !changed.some((q) => q.id === id)))\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tfor (const question of changed) {\n\t\t\t\t\tawait this.saveAnswer(question)\n\t\t\t\t\tconst { [question.id]: _done, ...rest } = this.dirty\n\t\t\t\t\tthis.dirty = rest\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t} catch {\n\t\t\t\tthis.saveError = t('nextcloud-vue', 'The answer could not be saved. Try again.')\n\t\t\t\treturn false\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Write the changed answers of this page into the open record's\n\t\t * `answersPath` array (one entry per question, keyed by `answerKey`)\n\t\t * with one update of the record through the object API. Held photos\n\t\t * go first to the record's own files (`recordPhotosField`), and their\n\t\t * references (`photoRefField`, default `id`) into the answer.\n\t\t *\n\t\t * @param {object[]} changed The changed questions.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tasync saveIntoRecord(changed) {\n\t\t\tconst { register, schema } = this.recordRef\n\t\t\tconst objectId = idOf(this.openRecord) || String(this.openRecordId || '')\n\t\t\tif (!register || !schema || !objectId) {\n\t\t\t\tthrow new Error('no record to write to')\n\t\t\t}\n\t\t\tconst c = this.content\n\t\t\tconst af = this.answerFields\n\t\t\tconst key = c.answerKey || 'questionId'\n\t\t\tconst refField = c.photoRefField || 'id'\n\t\t\tlet recordPhotos = Array.isArray(readPath(this.openRecord, c.recordPhotosField)) ? readPath(this.openRecord, c.recordPhotosField) : []\n\t\t\tconst entries = [...this.recordAnswers]\n\t\t\tfor (const question of changed) {\n\t\t\t\tconst draft = this.draft[question.id]\n\t\t\t\tconst index = entries.findIndex((entry) => String(readPath(entry, key) ?? '') === question.id)\n\t\t\t\tconst entry = { ...(index >= 0 ? entries[index] : { [key]: question.id }) }\n\t\t\t\tif (question.kind === 'number') {\n\t\t\t\t\tentry[af.number] = draft.value === '' ? null : Number(draft.value)\n\t\t\t\t} else if (question.kind === 'choice') {\n\t\t\t\t\tentry[af.choice] = draft.value\n\t\t\t\t} else if (question.kind !== 'photo') {\n\t\t\t\t\tentry[af.value] = draft.value\n\t\t\t\t}\n\t\t\t\tif (this.allowNote) {\n\t\t\t\t\tentry[af.note] = draft.note\n\t\t\t\t}\n\t\t\t\tif (af.at) {\n\t\t\t\t\tentry[af.at] = new Date().toISOString()\n\t\t\t\t}\n\t\t\t\tconst held = this.photos[question.id] || []\n\t\t\t\tif (this.photosEnabled && held.length) {\n\t\t\t\t\tconst field = c.recordPhotosField\n\t\t\t\t\tconst { failed, attached } = await uploadHeldFiles({ register, schema, objectId, held: { [field]: held }, kept: { [field]: recordPhotos } })\n\t\t\t\t\tif (failed.length) {\n\t\t\t\t\t\tthrow new Error('photo upload failed')\n\t\t\t\t\t}\n\t\t\t\t\tconst now = Array.isArray(attached[field]) ? attached[field] : recordPhotos\n\t\t\t\t\tconst added = now.slice(recordPhotos.length).map((ref) => (ref && typeof ref === 'object' ? ref[refField] ?? ref : ref))\n\t\t\t\t\trecordPhotos = now\n\t\t\t\t\tconst existing = Array.isArray(entry[af.photos]) ? entry[af.photos] : []\n\t\t\t\t\tentry[af.photos] = [...existing, ...added]\n\t\t\t\t\tthis.storedPhotos = { ...this.storedPhotos, [question.id]: entry[af.photos] }\n\t\t\t\t\tconst { [question.id]: _sent, ...rest } = this.photos\n\t\t\t\t\tthis.photos = rest\n\t\t\t\t}\n\t\t\t\tif (index >= 0) {\n\t\t\t\t\tentries[index] = entry\n\t\t\t\t} else {\n\t\t\t\t\tentries.push(entry)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst url = generateUrl(`${OBJECT_API}/${encodeURIComponent(register)}/${encodeURIComponent(schema)}/${encodeURIComponent(objectId)}`)\n\t\t\tawait axios.patch(url, { [c.answersPath]: entries })\n\t\t\tthis.recordAnswers = entries\n\t\t},\n\n\t\t/**\n\t\t * Save one answer.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync saveAnswer(question) {\n\t\t\tconst entry = this.draft[question.id]\n\t\t\tconst answer = { questionId: question.id, value: entry.value, note: entry.note }\n\t\t\tconst action = this.content?.saveAction\n\t\t\tif (action && typeof action === 'object') {\n\t\t\t\tconst resolved = resolveDeepTokens(action, this.tokenCtx)\n\t\t\t\tconst wrapped = { ...resolved, args: [...(Array.isArray(resolved.args) ? resolved.args : []), answer] }\n\t\t\t\tconst run = typeof this.cnDispatchAction === 'function' ? this.cnDispatchAction(wrapped) : dispatchAction(wrapped, { router: this.$router || null, tokenCtx: this.tokenCtx })\n\t\t\t\tawait run\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst a = this.content?.answers\n\t\t\tif (!a || !a.register || !a.schema) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst body = {\n\t\t\t\t[a.questionField || 'question']: question.id,\n\t\t\t\t[a.valueField || 'answer']: entry.value,\n\t\t\t}\n\t\t\tif (this.allowNote) {\n\t\t\t\tbody[a.noteField || 'note'] = entry.note\n\t\t\t}\n\t\t\tconst base = generateUrl(`${OBJECT_API}/${encodeURIComponent(a.register)}/${encodeURIComponent(a.schema)}`)\n\t\t\tlet id = this.answerIds[question.id]\n\t\t\tif (id) {\n\t\t\t\tawait axios.patch(`${base}/${encodeURIComponent(id)}`, body)\n\t\t\t} else {\n\t\t\t\tconst create = resolveDeepTokens(a.create && typeof a.create === 'object' ? a.create : {}, this.tokenCtx)\n\t\t\t\tconst response = await axios.post(base, { ...create, ...body })\n\t\t\t\tid = idOf(response?.data)\n\t\t\t\tthis.answerIds = { ...this.answerIds, [question.id]: id }\n\t\t\t}\n\t\t\tconst held = this.photos[question.id] || []\n\t\t\tif (this.photosEnabled && held.length && id) {\n\t\t\t\tconst { failed, attached } = await uploadHeldFiles({ register: a.register, schema: a.schema, objectId: id, held: { [a.photosField]: held }, kept: { [a.photosField]: this.storedPhotos[question.id] || [] } })\n\t\t\t\tif (failed.length) {\n\t\t\t\t\tthrow new Error('photo upload failed')\n\t\t\t\t}\n\t\t\t\tif (Array.isArray(attached[a.photosField])) {\n\t\t\t\t\tthis.storedPhotos = { ...this.storedPhotos, [question.id]: attached[a.photosField] }\n\t\t\t\t}\n\t\t\t\tconst { [question.id]: _sent, ...rest } = this.photos\n\t\t\t\tthis.photos = rest\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The required questions on this page without an answer.\n\t\t *\n\t\t * @return {string[]} Their ids.\n\t\t */\n\t\tunansweredRequired() {\n\t\t\treturn this.pageQuestions.filter((q) => q.required && !this.isAnswered(q)).map((q) => q.id)\n\t\t},\n\n\t\t/**\n\t\t * Save this page and go to the next one; on the last page, finish.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-a-checklist-run-shows-a-page-of-questions-at-a-time\n\t\t */\n\t\tasync next() {\n\t\t\tthis.missing = this.unansweredRequired()\n\t\t\tthis.missingPhoto = this.photosEnabled ? this.pageQuestions.filter((q) => this.needsPhoto(q) && !this.hasPhoto(q)).map((q) => q.id) : []\n\t\t\tif (this.missing.length || this.missingPhoto.length) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!(await this.savePage())) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.isLastPage) {\n\t\t\t\tawait this.finish()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.goTo(this.page + 1)\n\t\t},\n\n\t\t/**\n\t\t * Save this page and go back one.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync previous() {\n\t\t\tif (this.page === 0 || !(await this.savePage())) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.missing = []\n\t\t\tthis.missingPhoto = []\n\t\t\tthis.goTo(this.page - 1)\n\t\t},\n\n\t\t/**\n\t\t * Show a page, move focus to its position line and announce it.\n\t\t *\n\t\t * @param {number} page The page.\n\t\t * @return {void}\n\t\t */\n\t\tgoTo(page) {\n\t\t\tthis.page = page\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.liveText = this.positionText\n\t\t\t\tthis.$refs.position?.focus?.()\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The run is done: dispatch `finishAction` when set, and emit `finished`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync finish() {\n\t\t\tconst action = this.content?.finishAction\n\t\t\tif (action && typeof action === 'object') {\n\t\t\t\tconst resolved = resolveDeepTokens(action, this.tokenCtx)\n\t\t\t\tconst run = typeof this.cnDispatchAction === 'function' ? this.cnDispatchAction(resolved) : dispatchAction(resolved, { router: this.$router || null, tokenCtx: this.tokenCtx })\n\t\t\t\tawait run\n\t\t\t}\n\t\t\tthis.liveText = t('nextcloud-vue', 'Checklist finished.')\n\t\t\t/**\n\t\t\t * @event finished The last page was saved.\n\t\t\t * @type {{answered: number, total: number}}\n\t\t\t */\n\t\t\tthis.$emit('finished', { answered: this.answeredCount, total: this.questions.length })\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-checklist-run__form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-checklist-run__position {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-size: 13px;\n\tline-height: 17px;\n\tmargin: 0;\n}\n\n.cn-checklist-run__progress {\n\tbackground: var(--color-border);\n\tborder-radius: 3px;\n\tdisplay: block;\n\theight: 6px;\n\toverflow: hidden;\n}\n\n.cn-checklist-run__progress-fill {\n\tbackground: var(--color-primary-element);\n\tdisplay: block;\n\theight: 100%;\n}\n\n.cn-checklist-run__live,\n.cn-checklist-run__sr {\n\tclip-path: inset(50%);\n\theight: 1px;\n\toverflow: hidden;\n\tposition: absolute;\n\twhite-space: nowrap;\n\twidth: 1px;\n}\n\n.cn-checklist-run__question,\n.cn-checklist-run__photos {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large, 12px);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 12px 14px;\n}\n\n.cn-checklist-run__photos-title {\n\tfont-size: 15px;\n\tline-height: 1.2;\n}\n\n.cn-checklist-run__legend {\n\tfont-size: 15px;\n\tfont-weight: 600;\n\tline-height: 1.2;\n\tpadding: 0 4px;\n}\n\n.cn-checklist-run__help {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-size: 14px;\n\tline-height: 1.2;\n\tmargin: 0;\n}\n\n/* An option reads as text, not as a field label (a theme makes every label\n bold with !important); 15px, 31px apart, as the board draws it (DqInspectie). */\n.cn-checklist-run__choice {\n\talign-items: center;\n\tdisplay: flex;\n\tfont-size: 15px;\n\tfont-weight: 400 !important;\n\tgap: 10px;\n\tmin-height: 23px;\n}\n\n/* The board draws the radio with the browser's own 3px 3px 0 5px margin. */\n.cn-checklist-run__choice input {\n\taccent-color: var(--color-primary-element);\n\theight: 20px;\n\tmargin: 3px 3px 0 5px;\n\twidth: 20px;\n}\n\n/* The board look sizes every radio 18px with a (0,4,1) rule. */\n.cn-checklist-run__choice.cn-checklist-run__choice.cn-checklist-run__choice input[type=\"radio\"] {\n\theight: 20px;\n\tmin-height: 20px;\n\tmin-width: 20px;\n\twidth: 20px;\n}\n\n.cn-checklist-run__text,\n.cn-checklist-run__number {\n\tbox-sizing: border-box;\n\twidth: 100%;\n}\n\n/* A note is two 15px lines on the normal line height, 8px 12px in: 54px, as\n the board draws it. A theme pads every textarea 5px 12px with !important. */\n.cn-checklist-run__text.cn-checklist-run__text {\n\tpadding: 8px 12px !important;\n\tline-height: normal;\n\tmargin: 0;\n}\n\n.cn-checklist-run__group {\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tline-height: normal;\n\tmargin: 0;\n}\n\n.cn-checklist-run__note-label {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tline-height: 1.2;\n}\n\n.cn-checklist-run__photo-list {\n\tmargin: 0;\n\tpadding-inline-start: 18px;\n}\n\n/* The photo button is the board's 34px secondary control across its card\n (DqInspectie, 272px), its 14px/600 label after a camera. The doubled class\n outranks Nextcloud's `button:not(.button-vue)` margin, padding and height,\n and a theme's bold label weight set with !important. */\n.cn-checklist-run__photo-button.cn-checklist-run__photo-button {\n\talign-items: center;\n\talign-self: stretch;\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--cn-board-control-border, var(--color-border-dark));\n\tborder-radius: var(--border-radius-element, 8px);\n\tbox-sizing: border-box;\n\tcolor: var(--color-main-text);\n\tcursor: pointer;\n\tdisplay: flex;\n\tfont-size: 14px;\n\tfont-weight: 600 !important;\n\tgap: 8px;\n\theight: 34px;\n\tmargin: 0;\n\tmin-height: 34px;\n\tpadding: 0 14px;\n}\n\n.cn-checklist-run__photo-button:focus-visible {\n\toutline: 2px solid var(--color-primary-element);\n\toutline-offset: 2px;\n}\n\n.cn-checklist-run__photo-input {\n\tclip-path: inset(50%);\n\theight: 1px;\n\toverflow: hidden;\n\tposition: absolute;\n\twidth: 1px;\n}\n\n.cn-checklist-run__nav {\n\tdisplay: flex;\n\tjustify-content: space-between;\n}\n\n/* Previous and Next are as wide as the board draws them: the board pads the\n button 14px and the label not at all (Vorige 70.3px); NcButton's label\n padding made them 4px wider. */\n.cn-checklist-run__nav :deep(.button-vue__text) {\n\tpadding-inline: 0;\n}\n\n.cn-checklist-run__error {\n\tcolor: var(--color-error-text, var(--color-error));\n\tmargin: 0;\n}\n\n.cn-checklist-run__empty {\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_createVNode","_createElementVNode","_Fragment","_renderList","_createTextVNode","_vModelRadio","_vModelText"],"mappings":";;;AASM,EAAA,KAAK,EAAC,kBAAkB;AAAC,EAAA,aAAQ,EAAA,kBAAA;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IAAG,EAAA,OAAA;;yCAEA,QAAiB,CAAA,iBAAA,CAAA,EAAA,CAAA,oBAAA,WAAA,CAAA;;;;AAIpB,cAAAA,kBAAA,CAeI,OAfJ,WAeI,EAAA;gBAdJD,WAMU,CAAA,mBAAA,EAAA;AALV,kBAAA,OAAO,EAAC,WAAU;kBACjB,QAAQ,EAAA,KAAA,CAAA,IAAA,KAAA,CAAA,IAAA,KAAA,CAAA,MAAA;AACT,kBAAA,aAAO,EAAA,2BAAA;AACN,kBAAA,OAAK,EAAE,QAAQ,CAAA,QAAA;;mCAChB,MAAY;oDAAT,QAAS,CAAA,aAAA,CAAA,EAAA,CAAA,YAAA;;;;gBAEZA,WAMU,CAAA,mBAAA,EAAA;AALV,kBAAA,OAAO,EAAC,SAAS;AACjB,kBAAA,IAAI,EAAC,QAAI;AACR,kBAAA,QAAE,EAAA,KAAA,CAAA,MAAA;AACF,kBAAA,aAAU,EAAC,uBAAI;;mCAChB,MAA6B;oDAA1B,QAAU,CAAA,UAAA,GAAG,QAAW,CAAA,WAAA,GAAE,QAAA,CAAA,SAAA,CAAA,EAAA,CAAA,YAAA;;;;;eAGtB,KAAM,CAAA,SAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnChecklistRunWidget.vue3.js","sources":["../../../../src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue?vue&type=template&id=05891472&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<div class=\"cn-checklist-run\" data-testid=\"cn-checklist-run\">\n\t\t<p v-if=\"error\"\n\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\trole=\"alert\"\n\t\t\tdata-testid=\"cn-checklist-run-error\">\n\t\t\t{{ error }}\n\t\t</p>\n\t\t<div v-else-if=\"loading\" class=\"cn-checklist-run__loading\">\n\t\t\t<NcLoadingIcon :size=\"20\" :name=\"loadingLabel\" />\n\t\t</div>\n\t\t<p v-else-if=\"questions.length === 0\" class=\"cn-checklist-run__empty\" data-testid=\"cn-checklist-run-empty\">\n\t\t\t{{ emptyLabel }}\n\t\t</p>\n\t\t<form v-else\n\t\t\tclass=\"cn-checklist-run__form\"\n\t\t\tnovalidate\n\t\t\t@submit.prevent=\"next\">\n\t\t\t<p\n\t\t\t\tref=\"position\"\n\t\t\t\tclass=\"cn-checklist-run__position\"\n\t\t\t\ttabindex=\"-1\"\n\t\t\t\tdata-testid=\"cn-checklist-run-position\">\n\t\t\t\t{{ positionText }}\n\t\t\t</p>\n\t\t\t<span\n\t\t\t\tclass=\"cn-checklist-run__progress\"\n\t\t\t\trole=\"progressbar\"\n\t\t\t\t:aria-label=\"progressLabel\"\n\t\t\t\taria-valuemin=\"0\"\n\t\t\t\t:aria-valuemax=\"questions.length\"\n\t\t\t\t:aria-valuenow=\"answeredCount\"\n\t\t\t\tdata-testid=\"cn-checklist-run-progress\">\n\t\t\t\t<span class=\"cn-checklist-run__progress-fill\" :style=\"{ width: `${progressShare}%` }\" />\n\t\t\t</span>\n\t\t\t<span class=\"cn-checklist-run__live\" aria-live=\"polite\">{{ liveText }}</span>\n\n\t\t\t<p v-if=\"pageGroup\" class=\"cn-checklist-run__group\" data-testid=\"cn-checklist-run-group\">\n\t\t\t\t{{ pageGroup }}\n\t\t\t</p>\n\t\t\t<fieldset\n\t\t\t\tv-for=\"question in pageQuestions\"\n\t\t\t\t:key=\"question.id\"\n\t\t\t\tclass=\"cn-checklist-run__question\"\n\t\t\t\t:aria-describedby=\"question.help ? `${uid}-help-${question.id}` : null\"\n\t\t\t\tdata-testid=\"cn-checklist-run-question\">\n\t\t\t\t<legend class=\"cn-checklist-run__legend\">\n\t\t\t\t\t{{ question.text }}<span v-if=\"question.required\" class=\"cn-checklist-run__required\">\n\t\t\t\t\t\t<span aria-hidden=\"true\"> *</span><span class=\"cn-checklist-run__sr\">{{ requiredLabel }}</span>\n\t\t\t\t\t</span>\n\t\t\t\t</legend>\n\t\t\t\t<p v-if=\"question.help\" :id=\"`${uid}-help-${question.id}`\" class=\"cn-checklist-run__help\">\n\t\t\t\t\t{{ question.help }}\n\t\t\t\t</p>\n\t\t\t\t<template v-if=\"question.choices.length\">\n\t\t\t\t\t<label\n\t\t\t\t\t\tv-for=\"choice in question.choices\"\n\t\t\t\t\t\t:key=\"choice.value\"\n\t\t\t\t\t\tclass=\"cn-checklist-run__choice\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t:name=\"`${uid}-${question.id}`\"\n\t\t\t\t\t\t\t:value=\"choice.value\"\n\t\t\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\t\t\tdata-testid=\"cn-checklist-run-choice\"\n\t\t\t\t\t\t\t@change=\"markDirty(question.id)\">\n\t\t\t\t\t\t{{ choice.label }}\n\t\t\t\t\t</label>\n\t\t\t\t</template>\n\t\t\t\t<input\n\t\t\t\t\tv-else-if=\"question.kind === 'number'\"\n\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\tclass=\"cn-checklist-run__number\"\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t:aria-label=\"question.text\"\n\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-number\"\n\t\t\t\t\t@input=\"markDirty(question.id)\">\n\t\t\t\t<p v-else-if=\"question.kind === 'photo'\" class=\"cn-checklist-run__help\">\n\t\t\t\t\t{{ photoOnlyLabel }}\n\t\t\t\t</p>\n\t\t\t\t<textarea\n\t\t\t\t\tv-else\n\t\t\t\t\tv-model=\"draft[question.id].value\"\n\t\t\t\t\tclass=\"cn-checklist-run__text\"\n\t\t\t\t\trows=\"3\"\n\t\t\t\t\t:aria-label=\"question.text\"\n\t\t\t\t\t:required=\"question.required\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-text\"\n\t\t\t\t\t@input=\"markDirty(question.id)\" />\n\t\t\t\t<label v-if=\"allowNote && noteShown(question)\" class=\"cn-checklist-run__note-label\">\n\t\t\t\t\t{{ noteLabel }}\n\t\t\t\t\t<textarea\n\t\t\t\t\t\tv-model=\"draft[question.id].note\"\n\t\t\t\t\t\tclass=\"cn-checklist-run__text\"\n\t\t\t\t\t\trows=\"2\"\n\t\t\t\t\t\tdata-testid=\"cn-checklist-run-note\"\n\t\t\t\t\t\t@input=\"markDirty(question.id)\" />\n\t\t\t\t</label>\n\t\t\t\t<p\n\t\t\t\t\tv-if=\"missing.includes(question.id)\"\n\t\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\t\trole=\"alert\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-missing\">\n\t\t\t\t\t{{ missingLabel }}\n\t\t\t\t</p>\n\t\t\t</fieldset>\n\n\t\t\t<div\n\t\t\t\tv-for=\"question in photoQuestions\"\n\t\t\t\t:key=\"`photos-${question.id}`\"\n\t\t\t\tclass=\"cn-checklist-run__photos\"\n\t\t\t\tdata-testid=\"cn-checklist-run-photos\">\n\t\t\t\t<strong class=\"cn-checklist-run__photos-title\">{{ photoTitle(question) }}</strong>\n\t\t\t\t<ul v-if=\"photoNamesFor(question).length\" class=\"cn-checklist-run__photo-list\">\n\t\t\t\t\t<li v-for=\"name in photoNamesFor(question)\" :key=\"name\" data-testid=\"cn-checklist-run-photo\">\n\t\t\t\t\t\t{{ name }}\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t\t<!-- A button that opens the hidden file input, so the control is\n\t\t\t\t a button to every reader; the input stays out of the tab\n\t\t\t\t order and the accessibility tree. -->\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"cn-checklist-run__photo-button\"\n\t\t\t\t\t:aria-describedby=\"missingPhoto.includes(question.id) ? `${uid}-photo-${question.id}` : null\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-photo-button\"\n\t\t\t\t\t@click=\"openPhotoPicker\">\n\t\t\t\t\t<CameraOutline :size=\"16\" />\n\t\t\t\t\t{{ photoNamesFor(question).length || (storedPhotos[question.id] || []).length ? morePhotoLabel : addPhotoLabel }}\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tclass=\"cn-checklist-run__photo-input\"\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tcapture=\"environment\"\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-photo-input\"\n\t\t\t\t\t@change=\"addPhotos($event, question.id)\">\n\t\t\t\t<p\n\t\t\t\t\tv-if=\"missingPhoto.includes(question.id)\"\n\t\t\t\t\t:id=\"`${uid}-photo-${question.id}`\"\n\t\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\t\trole=\"alert\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-missing-photo\">\n\t\t\t\t\t{{ missingPhotoLabel }}\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t<div class=\"cn-checklist-run__nav\">\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t:disabled=\"page === 0 || saving\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-previous\"\n\t\t\t\t\t@click=\"previous\">\n\t\t\t\t\t{{ previousLabel }}\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t:disabled=\"saving\"\n\t\t\t\t\tdata-testid=\"cn-checklist-run-next\">\n\t\t\t\t\t{{ isLastPage ? finishLabel : nextLabel }}\n\t\t\t\t</NcButton>\n\t\t\t</div>\n\t\t\t<p v-if=\"saveError\"\n\t\t\t\tclass=\"cn-checklist-run__error\"\n\t\t\t\trole=\"alert\"\n\t\t\t\tdata-testid=\"cn-checklist-run-save-error\">\n\t\t\t\t{{ saveError }}\n\t\t\t</p>\n\t\t</form>\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { translate as t } from '@nextcloud/l10n'\nimport { generateUrl } from '@nextcloud/router'\nimport { NcButton, NcLoadingIcon } from '@nextcloud/vue'\nimport CameraOutline from 'vue-material-design-icons/CameraOutline.vue'\nimport { uploadHeldFiles } from '../../composables/useHeldFileUpload.js'\nimport { dispatchAction } from '../../utils/actionsDispatcher.js'\nimport { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { hasUnresolvedTokens, resolveDeepTokens, resolveFilterTokens } from '../../utils/resolveFilterTokens.js'\n\nconst OBJECT_API = '/apps/openregister/api/objects'\n\nlet instanceCounter = 0\n\n/**\n * The choices a question type offers, before translation.\n *\n * @type {Record<string, Array<{value: string, label: string}>>}\n */\nconst TYPE_CHOICES = Object.freeze({\n\tyes_no: [{ key: 'yes', label: 'Yes' }, { key: 'no', label: 'No' }],\n\tyes_no_na: [{ key: 'yes', label: 'Yes' }, { key: 'no', label: 'No' }, { key: 'na', label: 'Not applicable' }],\n})\n\n/** The kinds of question the widget draws. */\nconst KINDS = Object.freeze(['yes_no', 'yes_no_na', 'choice', 'text', 'number', 'photo'])\n\n/**\n * Sort by a numeric field, lowest first, keeping the given order for ties and\n * for entries without the field.\n *\n * @param {Array<object>} list The entries.\n * @param {string} field The field.\n * @return {Array<object>} A sorted copy.\n */\nfunction byOrder(list, field) {\n\tif (!field) {\n\t\treturn [...list]\n\t}\n\tconst rank = (entry) => {\n\t\tconst n = Number(readPath(entry, field))\n\t\treturn Number.isFinite(n) ? n : Infinity\n\t}\n\treturn list.map((entry, index) => ({ entry, index })).sort((a, b) => (rank(a.entry) - rank(b.entry)) || (a.index - b.index)).map(({ entry }) => entry)\n}\n\n/**\n * A register or schema as the object API path takes it.\n *\n * @param {string|object} value A slug, or a register/schema object.\n * @return {string} The slug or id.\n */\nfunction slugOf(value) {\n\tif (value && typeof value === 'object') {\n\t\treturn String(value.slug ?? value.id ?? '')\n\t}\n\treturn value ? String(value) : ''\n}\n\n/**\n * The id of an object, wherever OpenRegister carries it.\n *\n * @param {object|null} object The object.\n * @return {string} The id, or ''.\n */\nfunction idOf(object) {\n\treturn String(object?.id ?? object?.['@self']?.id ?? object?.uuid ?? '')\n}\n\n/**\n * CnChecklistRunWidget — the `checklist-run` widget: a checklist answered a\n * page of questions at a time (board DqInspectie, the middle phone frame).\n *\n * The questions are records of a register, listed with a token-resolved\n * filter. Each page shows `pageSize` questions (one by default) as radio\n * choices or a text field, an optional note, and photos for the first\n * question of the page, then Previous and Next. The answers of a page are\n * saved when the user moves on.\n *\n * Answers are stored one record per question through the OpenRegister object\n * API, under the reader's own rights: an existing answer is updated, a new\n * one created with the `answers.create` fields. Photos go up through the\n * object's own file upload (`uploadHeldFiles`) and are attached to the\n * answer's `photosField`. An app that stores answers its own way names a\n * `saveAction` instead; it is dispatched per answer with the answer as its\n * last argument, and photos are not uploaded then.\n *\n * ```json\n * {\n * \"type\": \"checklist-run\",\n * \"content\": {\n * \"questions\": { \"register\": \"app\", \"schema\": \"question\", \"filter\": { \"checklist\": \"@object.checklist\" }, \"orderField\": \"position\" },\n * \"fields\": { \"text\": \"text\", \"type\": \"type\", \"options\": \"options\", \"required\": \"required\", \"help\": \"help\" },\n * \"answers\": {\n * \"register\": \"app\", \"schema\": \"answer\", \"filter\": { \"run\": \"@objectId\" },\n * \"questionField\": \"question\", \"valueField\": \"answer\", \"noteField\": \"note\", \"photosField\": \"photos\",\n * \"create\": { \"run\": \"@objectId\" }\n * },\n * \"pageSize\": 1,\n * \"caption\": \"{title} version {version}\"\n * }\n * }\n * ```\n *\n * The questions and answers can also live inside the open record:\n * `questionsPath` (with `itemsKey` for groups, both sorted by `orderField`)\n * reads the questions off it, and `answersPath` writes the answers into an\n * array on it, one entry per question keyed by `answerKey`, by updating the\n * record through the object API. Photos then go to the record's own files\n * (`recordPhotosField`) and their references into the answer.\n *\n * A question can require a photo: `fields.photoRequired` names its rule,\n * `photoRequiredValues` maps the stored values onto `never`, `always` or\n * `{ whenAnswer }`, and the page holds until the photo is there. On a page\n * with no bound record, `record: { register, schema, filter, sort }` picks\n * the open record: the first match, under the reader's rights.\n *\n * `noteWhen: { answers: [...] }` shows a question's note field only once its\n * answer is one of those stored values (the board shows a note under \"Nee\"),\n * or when the question already holds a note; without it every question shows\n * one (`allowNote: false` hides them all).\n *\n * `startAt: \"firstOpen\"` opens a run that was started earlier at the page of\n * its first unanswered question (the last page when all are answered), once\n * per record; `startAt: \"lastAnswered\"` at the page of its last answered\n * question, where the inspector was; without it the run opens at the first\n * page.\n *\n * Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,\n * a list of strings or `{ value, label }`), `number`, `photo` and `text`.\n * `typeMap` maps the app's type values onto them, `choiceValues` the stored\n * values of yes / no / not applicable.\n * Keyboard: the choices are native radio buttons in a fieldset whose legend is\n * the question; on a new page focus moves to the position line and a polite\n * live region reads it.\n */\nexport default {\n\tname: 'CnChecklistRunWidget',\n\n\tcomponents: { CameraOutline, NcButton, NcLoadingIcon },\n\n\tinject: {\n\t\t/** The detail page's object context (`{ objectId, object }`), for tokens. */\n\t\tcnObjectContext: { default: null },\n\t\t/** The page's workspace values, for `@workspace.<key>` tokens. */\n\t\tcnWorkspaceContext: { default: null },\n\t\t/** The host's translate, for manifest texts and question texts. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t\t/** The page's pre-bound action dispatcher, for `saveAction` / `finishAction`. */\n\t\tcnDispatchAction: { default: null },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The widget config: `{ questions | questionsPath, itemsKey?,\n\t\t * groupLabelField?, orderField?, fields?, typeMap?, choiceValues?,\n\t\t * answers | answersPath, answerKey?, answerFields?, recordPhotosField?,\n\t\t * record?, saveAction?, finishAction?, pageSize?, allowNote?, noteWhen?,\n\t\t * allowPhotos?, caption?, emptyText? }`, as in the component\n\t\t * description and docs/components/cn-checklist-run-widget.md.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The bound record's id, for `@objectId`. */\n\t\tobjectId: {\n\t\t\ttype: [String, Number],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The bound record, for `@object.<field>`, the caption and `questionsPath` / `answersPath`. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** The bound record's register, for writing `answersPath` (`content.record` wins). */\n\t\tregister: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\n\t\t/** The bound record's schema, for writing `answersPath` (`content.record` wins). */\n\t\tschema: {\n\t\t\ttype: [String, Object],\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: ['finished'],\n\n\tdata() {\n\t\tinstanceCounter += 1\n\t\treturn {\n\t\t\tuid: `cn-checklist-run-${instanceCounter}`,\n\t\t\tloading: false,\n\t\t\terror: '',\n\t\t\tsaving: false,\n\t\t\tsaveError: '',\n\t\t\tquestions: [],\n\t\t\tanswerIds: {},\n\t\t\t// Photos an answer already holds, kept when new ones are attached.\n\t\t\tstoredPhotos: {},\n\t\t\t// `answersPath` mode: the answer entries as last read or written.\n\t\t\trecordAnswers: [],\n\t\t\tdraft: {},\n\t\t\tdirty: {},\n\t\t\tphotos: {},\n\t\t\tpage: 0,\n\t\t\t// The source the page was last positioned for; `startAt` applies once per source.\n\t\t\tpositionedFor: '',\n\t\t\tmissing: [],\n\t\t\t// Questions on this page that still need their photo.\n\t\t\tmissingPhoto: [],\n\t\t\t// `content.record` with a filter: the record it picked, or null.\n\t\t\tpickedRecord: null,\n\t\t\tliveText: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} What the tokens resolve against. */\n\t\ttokenCtx() {\n\t\t\tconst unwrap = (c) => (c && typeof c === 'object' && 'value' in c ? c.value : c)\n\t\t\tconst injected = unwrap(this.cnObjectContext) || {}\n\t\t\treturn {\n\t\t\t\t...injected,\n\t\t\t\tobjectId: (this.pickedRecord && idOf(this.pickedRecord)) || this.objectId || injected.objectId || this.objectData?.id || null,\n\t\t\t\tobject: this.pickedRecord || this.objectData || injected.object || null,\n\t\t\t\tworkspace: unwrap(this.cnWorkspaceContext) || {},\n\t\t\t}\n\t\t},\n\n\t\t/** @return {object} The question field paths, with their defaults. */\n\t\tfields() {\n\t\t\treturn { id: 'id', text: 'text', type: 'type', options: 'options', required: 'required', help: 'help', ...(this.content?.fields || {}) }\n\t\t},\n\n\t\t/** @return {number} Questions per page, at least 1. */\n\t\tpageSize() {\n\t\t\tconst n = Math.floor(Number(this.content?.pageSize))\n\t\t\treturn Number.isFinite(n) && n >= 1 ? n : 1\n\t\t},\n\n\t\t/** @return {number} The number of pages. */\n\t\tpageCount() {\n\t\t\treturn Math.max(1, Math.ceil(this.questions.length / this.pageSize))\n\t\t},\n\n\t\t/** @return {boolean} Whether this is the last page. */\n\t\tisLastPage() {\n\t\t\treturn this.page >= this.pageCount - 1\n\t\t},\n\n\t\t/** @return {object[]} The questions on this page. */\n\t\tpageQuestions() {\n\t\t\treturn this.questions.slice(this.page * this.pageSize, (this.page + 1) * this.pageSize)\n\t\t},\n\n\t\t/** @return {object|null} The first question on this page, the one photos belong to. */\n\t\tcurrentQuestion() {\n\t\t\treturn this.pageQuestions[0] || null\n\t\t},\n\n\t\t/** @return {number} Questions with an answer. */\n\t\tansweredCount() {\n\t\t\treturn this.questions.filter((q) => this.isAnswered(q)).length\n\t\t},\n\n\t\t/** @return {number} The share answered, 0 to 100. */\n\t\tprogressShare() {\n\t\t\treturn this.questions.length ? Math.round((this.answeredCount / this.questions.length) * 100) : 0\n\t\t},\n\n\t\t/** @return {string} \"Question 7 of 24\", with the caption after it. */\n\t\tpositionText() {\n\t\t\tconst first = this.page * this.pageSize + 1\n\t\t\tconst position = t('nextcloud-vue', 'Question {n} of {total}', { n: first, total: this.questions.length })\n\t\t\tconst caption = this.caption\n\t\t\treturn caption ? `${position} · ${caption}` : position\n\t\t},\n\n\t\t/** @return {string} `content.caption` with `{field}` filled from the record. */\n\t\tcaption() {\n\t\t\tconst template = this.content?.caption\n\t\t\tif (typeof template !== 'string' || template === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst object = this.tokenCtx.object || {}\n\t\t\treturn this.translate(template).replace(/\\{([A-Za-z0-9_.]+)\\}/g, (_m, path) => {\n\t\t\t\tconst value = readPath(object, path)\n\t\t\t\treturn value === null || value === undefined ? '' : String(value)\n\t\t\t}).trim()\n\t\t},\n\n\t\t/** @return {boolean} Whether a note field shows (default true). */\n\t\tallowNote() {\n\t\t\treturn this.content?.allowNote !== false\n\t\t},\n\n\t\t/** @return {boolean} Whether the answers are written into an array on the open record. */\n\t\tinRecord() {\n\t\t\treturn typeof this.content?.answersPath === 'string' && this.content.answersPath !== ''\n\t\t},\n\n\t\t/** @return {object} `answersPath` field names, with their defaults. */\n\t\tanswerFields() {\n\t\t\treturn { value: 'value', number: 'value', choice: 'value', note: 'note', photos: 'photos', ...(this.content?.answerFields || {}) }\n\t\t},\n\n\t\t/** @return {{register: string, schema: string}} Where the open record lives. */\n\t\trecordRef() {\n\t\t\tconst own = this.content?.record || {}\n\t\t\treturn { register: slugOf(own.register || this.register), schema: slugOf(own.schema || this.schema) }\n\t\t},\n\n\t\t/**\n\t\t * Whether photos can be added: allowed, and somewhere to put them.\n\t\t *\n\t\t * @return {boolean}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tphotosEnabled() {\n\t\t\tif (this.content?.allowPhotos === false || this.content?.saveAction) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.inRecord) {\n\t\t\t\treturn Boolean(this.content?.recordPhotosField && this.answerFields.photos)\n\t\t\t}\n\t\t\treturn Boolean(this.content?.answers?.photosField)\n\t\t},\n\n\t\t/** @return {string} The group (section) of this page's first question, or ''. */\n\t\tpageGroup() {\n\t\t\treturn this.currentQuestion?.group || ''\n\t\t},\n\n\t\t/**\n\t\t * The questions of this page that get a photo control: with a\n\t\t * `photoRequired` field, those whose rule is not never (and photo\n\t\t * questions), less a `{ whenAnswer }` question answered otherwise that\n\t\t * holds no photo; without one, the first question of the page.\n\t\t *\n\t\t * @return {object[]} The questions.\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-question-can-require-a-photo\n\t\t */\n\t\tphotoQuestions() {\n\t\t\tif (!this.photosEnabled) {\n\t\t\t\treturn []\n\t\t\t}\n\t\t\tif (this.fields.photoRequired) {\n\t\t\t\treturn this.pageQuestions.filter((q) => q.kind === 'photo' || (q.photoRule !== 'never' && !this.photoRuledOut(q)))\n\t\t\t}\n\t\t\tconst first = this.currentQuestion\n\t\t\tconst extra = this.pageQuestions.filter((q) => q.kind === 'photo' && q !== first)\n\t\t\treturn first ? [first, ...extra] : extra\n\t\t},\n\n\t\t/**\n\t\t * `content.record` with a `filter`: the list to pick the open record\n\t\t * from (first match of `sort`), `'blocked'` while a token is\n\t\t * unresolved, or null without a filter.\n\t\t *\n\t\t * @return {object|string|null}\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-checklist-run-can-pick-its-record-by-filter\n\t\t */\n\t\trecordPicker() {\n\t\t\tconst own = this.content?.record\n\t\t\tif (!own || typeof own !== 'object' || !own.filter || typeof own.filter !== 'object') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst unwrap = (c) => (c && typeof c === 'object' && 'value' in c ? c.value : c)\n\t\t\tconst filter = resolveFilterTokens(own.filter, { objectId: this.objectId || null, object: this.objectData, workspace: unwrap(this.cnWorkspaceContext) || {} })\n\t\t\tif (hasUnresolvedTokens(filter)) {\n\t\t\t\treturn 'blocked'\n\t\t\t}\n\t\t\tconst sort = own.sort && typeof own.sort === 'object' && own.sort.field ? { [`_order[${own.sort.field}]`]: own.sort.dir === 'asc' ? 'asc' : 'desc' } : {}\n\t\t\treturn { register: slugOf(own.register), schema: slugOf(own.schema), filter: { ...filter, ...sort } }\n\t\t},\n\n\t\t/** @return {object|null} The record the run lives in: the picked one, else the bound one. */\n\t\topenRecord() {\n\t\t\treturn this.recordPicker ? this.pickedRecord : this.tokenCtx.object\n\t\t},\n\n\t\t/** @return {string} The key of the source lists, to read them again when they change. */\n\t\tsourceKey() {\n\t\t\tconst picker = this.recordPicker\n\t\t\tif (picker === 'blocked') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tif (picker && typeof this.content?.questionsPath === 'string' && this.content.questionsPath !== '') {\n\t\t\t\treturn JSON.stringify({ pick: picker, path: this.content.questionsPath })\n\t\t\t}\n\t\t\tif (typeof this.content?.questionsPath === 'string' && this.content.questionsPath !== '') {\n\t\t\t\tconst object = this.tokenCtx.object\n\t\t\t\treturn object ? JSON.stringify({ path: this.content.questionsPath, id: idOf(object), at: object['@self']?.updated ?? null }) : ''\n\t\t\t}\n\t\t\tconst q = this.content?.questions\n\t\t\tif (!q || !q.register || !q.schema) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst qFilter = resolveFilterTokens(q.filter || {}, this.tokenCtx)\n\t\t\tconst a = this.content?.answers\n\t\t\tconst aFilter = a && a.register && a.schema ? resolveFilterTokens(a.filter || {}, this.tokenCtx) : null\n\t\t\tif (hasUnresolvedTokens(qFilter) || (aFilter && hasUnresolvedTokens(aFilter))) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn JSON.stringify({ q: [q.register, q.schema, qFilter], a: aFilter ? [a.register, a.schema, aFilter] : null })\n\t\t},\n\n\t\tloadingLabel: () => t('nextcloud-vue', 'Loading …'),\n\t\tprogressLabel: () => t('nextcloud-vue', 'Questions answered'),\n\t\trequiredLabel: () => ` ${t('nextcloud-vue', '(required)')}`,\n\t\tmissingLabel: () => t('nextcloud-vue', 'Answer this question to go on.'),\n\t\tpreviousLabel: () => t('nextcloud-vue', 'Previous'),\n\t\tnextLabel: () => t('nextcloud-vue', 'Next'),\n\t\tfinishLabel: () => t('nextcloud-vue', 'Finish'),\n\t\taddPhotoLabel: () => t('nextcloud-vue', 'Take or add a photo'),\n\t\tmissingPhotoLabel: () => t('nextcloud-vue', 'This answer needs a photo. Add one to go on.'),\n\t\tphotoOnlyLabel: () => t('nextcloud-vue', 'Answer with a photo.'),\n\t\tmorePhotoLabel: () => t('nextcloud-vue', 'Another photo'),\n\n\t\t/** @return {string} The note field's label. */\n\t\tnoteLabel() {\n\t\t\treturn this.content?.noteLabel ? this.translate(this.content.noteLabel) : t('nextcloud-vue', 'Note')\n\t\t},\n\n\t\t/** @return {string} The empty-state text. */\n\t\temptyLabel() {\n\t\t\treturn this.content?.emptyText ? this.translate(this.content.emptyText) : t('nextcloud-vue', 'This checklist has no questions.')\n\t\t},\n\t},\n\n\twatch: {\n\t\tsourceKey: {\n\t\t\thandler() {\n\t\t\t\tthis.load()\n\t\t\t},\n\n\t\t\timmediate: true,\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Whether a question shows its note field: always, unless `noteWhen`\n\t\t * names the answers that ask for one and this question has none of\n\t\t * them and no note yet.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean}\n\t\t */\n\t\tnoteShown(question) {\n\t\t\tconst answers = this.content?.noteWhen?.answers\n\t\t\tif (!Array.isArray(answers)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst draft = this.draft[question.id] || {}\n\t\t\treturn (draft.note || '') !== '' || answers.map(String).includes(String(draft.value ?? ''))\n\t\t},\n\n\t\t/**\n\t\t * The host's translate, or the text unchanged.\n\t\t *\n\t\t * @param {string} text The text.\n\t\t * @return {string} The translation.\n\t\t */\n\t\ttranslate(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Whether a value counts as an answer.\n\t\t *\n\t\t * @param {unknown} value The value.\n\t\t * @return {boolean} True for a non-empty value.\n\t\t */\n\t\thasValue(value) {\n\t\t\treturn value !== null && value !== undefined && String(value).trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether a question has an answer: a value, or for a photo question\n\t\t * a photo stored or held.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True when answered.\n\t\t */\n\t\tisAnswered(question) {\n\t\t\tif (question.kind === 'photo') {\n\t\t\t\treturn this.hasPhoto(question)\n\t\t\t}\n\t\t\treturn this.hasValue(this.draft[question.id]?.value)\n\t\t},\n\n\t\t/**\n\t\t * A question record as the widget draws it.\n\t\t *\n\t\t * @param {object} record The question record.\n\t\t * @param {string} [group] The group (section) it belongs to.\n\t\t * @return {{id: string, text: string, kind: string, required: boolean, help: string, choices: Array<{value: string, label: string}>, group: string}} The question.\n\t\t */\n\t\ttoQuestion(record, group = '') {\n\t\t\tconst f = this.fields\n\t\t\tconst raw = String(readPath(record, f.type) ?? '')\n\t\t\tconst mapped = this.content?.typeMap && typeof this.content.typeMap === 'object' ? this.content.typeMap[raw] : undefined\n\t\t\tconst kind = KINDS.includes(mapped) ? mapped : (KINDS.includes(raw) ? raw : 'text')\n\t\t\tconst stored = { yes: 'yes', no: 'no', na: 'na', ...(this.content?.choiceValues || {}) }\n\t\t\tlet choices = (TYPE_CHOICES[kind] || []).map((c) => ({ value: String(stored[c.key]), label: t('nextcloud-vue', c.label) }))\n\t\t\tif (kind === 'choice') {\n\t\t\t\tconst options = readPath(record, f.options)\n\t\t\t\tchoices = (Array.isArray(options) ? options : []).map((o) => (o && typeof o === 'object'\n\t\t\t\t\t? { value: String(o.value ?? o.label ?? ''), label: this.translate(String(o.label ?? o.value ?? '')) }\n\t\t\t\t\t: { value: String(o), label: this.translate(String(o)) })).filter((c) => c.value !== '')\n\t\t\t}\n\t\t\tconst help = readPath(record, f.help)\n\t\t\treturn {\n\t\t\t\tid: String(readPath(record, f.id) ?? idOf(record)),\n\t\t\t\ttext: this.translate(String(readPath(record, f.text) ?? '')),\n\t\t\t\tkind,\n\t\t\t\trequired: Boolean(readPath(record, f.required)),\n\t\t\t\thelp: typeof help === 'string' && help !== '' ? this.translate(help) : '',\n\t\t\t\tchoices,\n\t\t\t\tgroup,\n\t\t\t\tphotoRule: this.photoRuleOf(record),\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * A question's photo rule, from its `photoRequired` field mapped\n\t\t * through `photoRequiredValues`: `'never'`, `'always'` or\n\t\t * `{ whenAnswer }` (a photo is needed when the answer is that value).\n\t\t *\n\t\t * @param {object} record The question record.\n\t\t * @return {('never'|'always'|{whenAnswer: string})} The rule.\n\t\t * @spec openspec/changes/checklist-run-photo-rule/specs/checklist-run-photo-rule/spec.md#requirement-a-question-can-require-a-photo\n\t\t */\n\t\tphotoRuleOf(record) {\n\t\t\tconst path = this.fields.photoRequired\n\t\t\tif (!path) {\n\t\t\t\treturn 'never'\n\t\t\t}\n\t\t\tconst raw = readPath(record, path)\n\t\t\tconst map = { true: 'always', false: 'never', always: 'always', never: 'never', ...(this.content?.photoRequiredValues || {}) }\n\t\t\tconst rule = raw === null || raw === undefined ? 'never' : map[String(raw)]\n\t\t\tif (rule && typeof rule === 'object' && rule.whenAnswer !== undefined) {\n\t\t\t\treturn { whenAnswer: String(rule.whenAnswer) }\n\t\t\t}\n\t\t\treturn rule === 'always' ? 'always' : 'never'\n\t\t},\n\n\t\t/**\n\t\t * Whether a question needs a photo with its current answer.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True when a photo is required now.\n\t\t */\n\t\tneedsPhoto(question) {\n\t\t\tconst rule = question.photoRule\n\t\t\tif (rule === 'always') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn Boolean(rule && typeof rule === 'object' && String(this.draft[question.id]?.value ?? '') === rule.whenAnswer)\n\t\t},\n\n\t\t/**\n\t\t * Whether a question's answer rules its photo out: a `{ whenAnswer }`\n\t\t * question answered with another value and holding no photo.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True when no photo control is needed.\n\t\t */\n\t\tphotoRuledOut(question) {\n\t\t\tconst rule = question.photoRule\n\t\t\tconst value = String(this.draft[question.id]?.value ?? '')\n\t\t\treturn Boolean(rule && typeof rule === 'object' && value !== '' && value !== rule.whenAnswer && !this.hasPhoto(question))\n\t\t},\n\n\t\t/**\n\t\t * Whether a question has a photo, stored or held.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {boolean} True with at least one photo.\n\t\t */\n\t\thasPhoto(question) {\n\t\t\treturn (this.storedPhotos[question.id] || []).length > 0 || (this.photos[question.id] || []).length > 0\n\t\t},\n\n\t\t/**\n\t\t * The photo card title for a question: its position in the run.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {string} The title.\n\t\t */\n\t\tphotoTitle(question) {\n\t\t\tconst n = this.questions.indexOf(question) + 1\n\t\t\treturn t('nextcloud-vue', 'Photo for question {n}', { n })\n\t\t},\n\n\t\t/**\n\t\t * The names of the photos held for a question.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {string[]} The file names.\n\t\t */\n\t\tphotoNamesFor(question) {\n\t\t\treturn (this.photos[question.id] || []).map((file) => file.name)\n\t\t},\n\n\t\t/**\n\t\t * The questions on the open record (`questionsPath`): a list of\n\t\t * questions, or of groups whose `itemsKey` holds them, both levels\n\t\t * sorted by `orderField`.\n\t\t *\n\t\t * @return {object[]} The questions.\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tquestionsFromRecord() {\n\t\t\tconst c = this.content\n\t\t\tconst list = readPath(this.openRecord, c.questionsPath)\n\t\t\tconst orderField = c.orderField === undefined ? 'order' : c.orderField\n\t\t\tconst top = byOrder(Array.isArray(list) ? list : [], orderField)\n\t\t\tif (!c.itemsKey) {\n\t\t\t\treturn top.map((record) => this.toQuestion(record))\n\t\t\t}\n\t\t\tconst labelField = c.groupLabelField || 'name'\n\t\t\treturn top.flatMap((group) => {\n\t\t\t\tconst items = readPath(group, c.itemsKey)\n\t\t\t\tconst label = readPath(group, labelField)\n\t\t\t\treturn byOrder(Array.isArray(items) ? items : [], orderField).map((record) => this.toQuestion(record, typeof label === 'string' ? this.translate(label) : ''))\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The draft of one answer entry from the open record's `answersPath`.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @param {object} entry The stored entry.\n\t\t * @return {{value: string, note: string}} The draft.\n\t\t */\n\t\tdraftFromEntry(question, entry) {\n\t\t\tconst af = this.answerFields\n\t\t\tconst field = question.kind === 'number' ? af.number : (question.kind === 'choice' ? af.choice : af.value)\n\t\t\tconst value = readPath(entry, field)\n\t\t\tconst note = readPath(entry, af.note)\n\t\t\treturn { value: value === null || value === undefined ? '' : String(value), note: note === null || note === undefined ? '' : String(note) }\n\t\t},\n\n\t\t/**\n\t\t * Read the questions and the answers given so far.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-a-checklist-run-shows-a-page-of-questions-at-a-time\n\t\t */\n\t\tasync load() {\n\t\t\tconst key = this.sourceKey\n\t\t\tif (key === '') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.loading = true\n\t\t\tthis.error = ''\n\t\t\ttry {\n\t\t\t\tconst picker = this.recordPicker\n\t\t\t\tif (picker) {\n\t\t\t\t\tconst found = await fetchReferenceObjects({ register: picker.register, schema: picker.schema, filter: picker.filter, limit: 1 })\n\t\t\t\t\tif (key !== this.sourceKey) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.pickedRecord = found[0] || null\n\t\t\t\t}\n\t\t\t\tlet questions\n\t\t\t\tif (picker && !this.pickedRecord) {\n\t\t\t\t\tquestions = []\n\t\t\t\t} else if (this.content.questionsPath) {\n\t\t\t\t\tquestions = this.questionsFromRecord()\n\t\t\t\t} else {\n\t\t\t\t\tconst q = this.content.questions\n\t\t\t\t\tconst records = await fetchReferenceObjects({ register: q.register, schema: q.schema, filter: resolveFilterTokens(q.filter || {}, this.tokenCtx), limit: q.limit || 500 })\n\t\t\t\t\tquestions = byOrder(records, q.orderField).map((r) => this.toQuestion(r))\n\t\t\t\t}\n\t\t\t\tquestions = questions.filter((x) => x.id !== '' && x.text !== '')\n\t\t\t\tconst a = this.inRecord ? null : this.content.answers\n\t\t\t\tconst answers = a && a.register && a.schema\n\t\t\t\t\t? await fetchReferenceObjects({ register: a.register, schema: a.schema, filter: resolveFilterTokens(a.filter || {}, this.tokenCtx), limit: a.limit || 500 })\n\t\t\t\t\t: []\n\t\t\t\tif (key !== this.sourceKey) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst draft = {}\n\t\t\t\tconst answerIds = {}\n\t\t\t\tconst storedPhotos = {}\n\t\t\t\tfor (const question of questions) {\n\t\t\t\t\tdraft[question.id] = { value: '', note: '' }\n\t\t\t\t}\n\t\t\t\tif (this.inRecord) {\n\t\t\t\t\tconst entries = readPath(this.openRecord, this.content.answersPath)\n\t\t\t\t\tthis.recordAnswers = Array.isArray(entries) ? entries : []\n\t\t\t\t\tconst key = this.content.answerKey || 'questionId'\n\t\t\t\t\tfor (const entry of this.recordAnswers) {\n\t\t\t\t\t\tconst qid = String(readPath(entry, key) ?? '')\n\t\t\t\t\t\tconst question = questions.find((x) => x.id === qid)\n\t\t\t\t\t\tif (question && !answerIds[qid]) {\n\t\t\t\t\t\t\tdraft[qid] = this.draftFromEntry(question, entry)\n\t\t\t\t\t\t\tanswerIds[qid] = qid\n\t\t\t\t\t\t\tconst photos = readPath(entry, this.answerFields.photos)\n\t\t\t\t\t\t\tstoredPhotos[qid] = Array.isArray(photos) ? photos : []\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const answer of answers) {\n\t\t\t\t\tconst qid = String(readPath(answer, a.questionField || 'question') ?? '')\n\t\t\t\t\tif (draft[qid] && !answerIds[qid]) {\n\t\t\t\t\t\tdraft[qid] = {\n\t\t\t\t\t\t\tvalue: String(readPath(answer, a.valueField || 'answer') ?? ''),\n\t\t\t\t\t\t\tnote: String(readPath(answer, a.noteField || 'note') ?? ''),\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanswerIds[qid] = idOf(answer)\n\t\t\t\t\t\tconst stored = a.photosField ? readPath(answer, a.photosField) : null\n\t\t\t\t\t\tstoredPhotos[qid] = Array.isArray(stored) ? stored : []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.questions = questions\n\t\t\t\tthis.draft = draft\n\t\t\t\tthis.answerIds = answerIds\n\t\t\t\tthis.storedPhotos = storedPhotos\n\t\t\t\tthis.dirty = {}\n\t\t\t\tconst lastPage = Math.max(0, Math.ceil(questions.length / this.pageSize) - 1)\n\t\t\t\tif (this.positionedFor !== key && this.content?.startAt === 'firstOpen') {\n\t\t\t\t\tconst open = questions.findIndex((question) => !this.isAnswered(question))\n\t\t\t\t\tthis.page = open === -1 ? lastPage : Math.floor(open / this.pageSize)\n\t\t\t\t} else if (this.positionedFor !== key && this.content?.startAt === 'lastAnswered') {\n\t\t\t\t\tconst last = questions.findLastIndex((question) => this.isAnswered(question))\n\t\t\t\t\tthis.page = last === -1 ? 0 : Math.floor(last / this.pageSize)\n\t\t\t\t}\n\t\t\t\tthis.positionedFor = key\n\t\t\t\tthis.page = Math.min(this.page, lastPage)\n\t\t\t} catch {\n\t\t\t\tthis.error = t('nextcloud-vue', 'The checklist could not be loaded.')\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Note that a question's answer changed, so the page saves it.\n\t\t *\n\t\t * @param {string} id The question id.\n\t\t * @return {void}\n\t\t */\n\t\tmarkDirty(id) {\n\t\t\tthis.dirty = { ...this.dirty, [id]: true }\n\t\t\tthis.missing = this.missing.filter((m) => m !== id)\n\t\t},\n\n\t\t/**\n\t\t * Open the file picker of the photo button's own question: the hidden\n\t\t * input that follows the button.\n\t\t *\n\t\t * @param {MouseEvent} event The button's click.\n\t\t * @return {void}\n\t\t */\n\t\topenPhotoPicker(event) {\n\t\t\tconst input = event.currentTarget.nextElementSibling\n\t\t\tif (input && input.type === 'file') {\n\t\t\t\tinput.click()\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Hold the photos picked for a question until the page saves.\n\t\t *\n\t\t * @param {Event} event The file input's change event.\n\t\t * @param {string} [questionId] The question, else the first of the page.\n\t\t * @return {void}\n\t\t */\n\t\taddPhotos(event, questionId) {\n\t\t\tconst id = questionId || this.currentQuestion?.id\n\t\t\tconst files = Array.from(event?.target?.files || [])\n\t\t\tif (!id || files.length === 0) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.photos = { ...this.photos, [id]: [...(this.photos[id] || []), ...files] }\n\t\t\tthis.dirty = { ...this.dirty, [id]: true }\n\t\t\tthis.missingPhoto = this.missingPhoto.filter((m) => m !== id)\n\t\t\tif (event.target) {\n\t\t\t\tevent.target.value = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Save the changed answers of this page: through `saveAction` when\n\t\t * set, else one answer record per question through the object API,\n\t\t * then its held photos.\n\t\t *\n\t\t * @return {Promise<boolean>} True when everything saved.\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-answers-are-saved-under-the-readers-own-rights\n\t\t */\n\t\tasync savePage() {\n\t\t\tconst changed = this.pageQuestions.filter((q) => this.dirty[q.id])\n\t\t\tif (changed.length === 0) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tthis.saving = true\n\t\t\tthis.saveError = ''\n\t\t\ttry {\n\t\t\t\tif (this.inRecord && !this.content?.saveAction) {\n\t\t\t\t\tawait this.saveIntoRecord(changed)\n\t\t\t\t\tthis.dirty = Object.fromEntries(Object.entries(this.dirty).filter(([id]) => !changed.some((q) => q.id === id)))\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tfor (const question of changed) {\n\t\t\t\t\tawait this.saveAnswer(question)\n\t\t\t\t\tconst { [question.id]: _done, ...rest } = this.dirty\n\t\t\t\t\tthis.dirty = rest\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t} catch {\n\t\t\t\tthis.saveError = t('nextcloud-vue', 'The answer could not be saved. Try again.')\n\t\t\t\treturn false\n\t\t\t} finally {\n\t\t\t\tthis.saving = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Write the changed answers of this page into the open record's\n\t\t * `answersPath` array (one entry per question, keyed by `answerKey`)\n\t\t * with one update of the record through the object API. Held photos\n\t\t * go first to the record's own files (`recordPhotosField`), and their\n\t\t * references (`photoRefField`, default `id`) into the answer.\n\t\t *\n\t\t * @param {object[]} changed The changed questions.\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-questions-and-answers-can-live-inside-the-open-record\n\t\t */\n\t\tasync saveIntoRecord(changed) {\n\t\t\tconst { register, schema } = this.recordRef\n\t\t\tconst objectId = idOf(this.openRecord) || String(this.openRecordId || '')\n\t\t\tif (!register || !schema || !objectId) {\n\t\t\t\tthrow new Error('no record to write to')\n\t\t\t}\n\t\t\tconst c = this.content\n\t\t\tconst af = this.answerFields\n\t\t\tconst key = c.answerKey || 'questionId'\n\t\t\tconst refField = c.photoRefField || 'id'\n\t\t\tlet recordPhotos = Array.isArray(readPath(this.openRecord, c.recordPhotosField)) ? readPath(this.openRecord, c.recordPhotosField) : []\n\t\t\tconst entries = [...this.recordAnswers]\n\t\t\tfor (const question of changed) {\n\t\t\t\tconst draft = this.draft[question.id]\n\t\t\t\tconst index = entries.findIndex((entry) => String(readPath(entry, key) ?? '') === question.id)\n\t\t\t\tconst entry = { ...(index >= 0 ? entries[index] : { [key]: question.id }) }\n\t\t\t\tif (question.kind === 'number') {\n\t\t\t\t\tentry[af.number] = draft.value === '' ? null : Number(draft.value)\n\t\t\t\t} else if (question.kind === 'choice') {\n\t\t\t\t\tentry[af.choice] = draft.value\n\t\t\t\t} else if (question.kind !== 'photo') {\n\t\t\t\t\tentry[af.value] = draft.value\n\t\t\t\t}\n\t\t\t\tif (this.allowNote) {\n\t\t\t\t\tentry[af.note] = draft.note\n\t\t\t\t}\n\t\t\t\tif (af.at) {\n\t\t\t\t\tentry[af.at] = new Date().toISOString()\n\t\t\t\t}\n\t\t\t\tconst held = this.photos[question.id] || []\n\t\t\t\tif (this.photosEnabled && held.length) {\n\t\t\t\t\tconst field = c.recordPhotosField\n\t\t\t\t\tconst { failed, attached } = await uploadHeldFiles({ register, schema, objectId, held: { [field]: held }, kept: { [field]: recordPhotos } })\n\t\t\t\t\tif (failed.length) {\n\t\t\t\t\t\tthrow new Error('photo upload failed')\n\t\t\t\t\t}\n\t\t\t\t\tconst now = Array.isArray(attached[field]) ? attached[field] : recordPhotos\n\t\t\t\t\tconst added = now.slice(recordPhotos.length).map((ref) => (ref && typeof ref === 'object' ? ref[refField] ?? ref : ref))\n\t\t\t\t\trecordPhotos = now\n\t\t\t\t\tconst existing = Array.isArray(entry[af.photos]) ? entry[af.photos] : []\n\t\t\t\t\tentry[af.photos] = [...existing, ...added]\n\t\t\t\t\tthis.storedPhotos = { ...this.storedPhotos, [question.id]: entry[af.photos] }\n\t\t\t\t\tconst { [question.id]: _sent, ...rest } = this.photos\n\t\t\t\t\tthis.photos = rest\n\t\t\t\t}\n\t\t\t\tif (index >= 0) {\n\t\t\t\t\tentries[index] = entry\n\t\t\t\t} else {\n\t\t\t\t\tentries.push(entry)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst url = generateUrl(`${OBJECT_API}/${encodeURIComponent(register)}/${encodeURIComponent(schema)}/${encodeURIComponent(objectId)}`)\n\t\t\tawait axios.patch(url, { [c.answersPath]: entries })\n\t\t\tthis.recordAnswers = entries\n\t\t},\n\n\t\t/**\n\t\t * Save one answer.\n\t\t *\n\t\t * @param {object} question The question.\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync saveAnswer(question) {\n\t\t\tconst entry = this.draft[question.id]\n\t\t\tconst answer = { questionId: question.id, value: entry.value, note: entry.note }\n\t\t\tconst action = this.content?.saveAction\n\t\t\tif (action && typeof action === 'object') {\n\t\t\t\tconst resolved = resolveDeepTokens(action, this.tokenCtx)\n\t\t\t\tconst wrapped = { ...resolved, args: [...(Array.isArray(resolved.args) ? resolved.args : []), answer] }\n\t\t\t\tconst run = typeof this.cnDispatchAction === 'function' ? this.cnDispatchAction(wrapped) : dispatchAction(wrapped, { router: this.$router || null, tokenCtx: this.tokenCtx })\n\t\t\t\tawait run\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst a = this.content?.answers\n\t\t\tif (!a || !a.register || !a.schema) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst body = {\n\t\t\t\t[a.questionField || 'question']: question.id,\n\t\t\t\t[a.valueField || 'answer']: entry.value,\n\t\t\t}\n\t\t\tif (this.allowNote) {\n\t\t\t\tbody[a.noteField || 'note'] = entry.note\n\t\t\t}\n\t\t\tconst base = generateUrl(`${OBJECT_API}/${encodeURIComponent(a.register)}/${encodeURIComponent(a.schema)}`)\n\t\t\tlet id = this.answerIds[question.id]\n\t\t\tif (id) {\n\t\t\t\tawait axios.patch(`${base}/${encodeURIComponent(id)}`, body)\n\t\t\t} else {\n\t\t\t\tconst create = resolveDeepTokens(a.create && typeof a.create === 'object' ? a.create : {}, this.tokenCtx)\n\t\t\t\tconst response = await axios.post(base, { ...create, ...body })\n\t\t\t\tid = idOf(response?.data)\n\t\t\t\tthis.answerIds = { ...this.answerIds, [question.id]: id }\n\t\t\t}\n\t\t\tconst held = this.photos[question.id] || []\n\t\t\tif (this.photosEnabled && held.length && id) {\n\t\t\t\tconst { failed, attached } = await uploadHeldFiles({ register: a.register, schema: a.schema, objectId: id, held: { [a.photosField]: held }, kept: { [a.photosField]: this.storedPhotos[question.id] || [] } })\n\t\t\t\tif (failed.length) {\n\t\t\t\t\tthrow new Error('photo upload failed')\n\t\t\t\t}\n\t\t\t\tif (Array.isArray(attached[a.photosField])) {\n\t\t\t\t\tthis.storedPhotos = { ...this.storedPhotos, [question.id]: attached[a.photosField] }\n\t\t\t\t}\n\t\t\t\tconst { [question.id]: _sent, ...rest } = this.photos\n\t\t\t\tthis.photos = rest\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The required questions on this page without an answer.\n\t\t *\n\t\t * @return {string[]} Their ids.\n\t\t */\n\t\tunansweredRequired() {\n\t\t\treturn this.pageQuestions.filter((q) => q.required && !this.isAnswered(q)).map((q) => q.id)\n\t\t},\n\n\t\t/**\n\t\t * Save this page and go to the next one; on the last page, finish.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-a-checklist-run-shows-a-page-of-questions-at-a-time\n\t\t */\n\t\tasync next() {\n\t\t\tthis.missing = this.unansweredRequired()\n\t\t\tthis.missingPhoto = this.photosEnabled ? this.pageQuestions.filter((q) => this.needsPhoto(q) && !this.hasPhoto(q)).map((q) => q.id) : []\n\t\t\tif (this.missing.length || this.missingPhoto.length) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!(await this.savePage())) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.isLastPage) {\n\t\t\t\tawait this.finish()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.goTo(this.page + 1)\n\t\t},\n\n\t\t/**\n\t\t * Save this page and go back one.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync previous() {\n\t\t\tif (this.page === 0 || !(await this.savePage())) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.missing = []\n\t\t\tthis.missingPhoto = []\n\t\t\tthis.goTo(this.page - 1)\n\t\t},\n\n\t\t/**\n\t\t * Show a page, move focus to its position line and announce it.\n\t\t *\n\t\t * @param {number} page The page.\n\t\t * @return {void}\n\t\t */\n\t\tgoTo(page) {\n\t\t\tthis.page = page\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.liveText = this.positionText\n\t\t\t\tthis.$refs.position?.focus?.()\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * The run is done: dispatch `finishAction` when set, and emit `finished`.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync finish() {\n\t\t\tconst action = this.content?.finishAction\n\t\t\tif (action && typeof action === 'object') {\n\t\t\t\tconst resolved = resolveDeepTokens(action, this.tokenCtx)\n\t\t\t\tconst run = typeof this.cnDispatchAction === 'function' ? this.cnDispatchAction(resolved) : dispatchAction(resolved, { router: this.$router || null, tokenCtx: this.tokenCtx })\n\t\t\t\tawait run\n\t\t\t}\n\t\t\tthis.liveText = t('nextcloud-vue', 'Checklist finished.')\n\t\t\t/**\n\t\t\t * @event finished The last page was saved.\n\t\t\t * @type {{answered: number, total: number}}\n\t\t\t */\n\t\t\tthis.$emit('finished', { answered: this.answeredCount, total: this.questions.length })\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-checklist-run__form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-checklist-run__position {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-size: 13px;\n\tline-height: 17px;\n\tmargin: 0;\n}\n\n.cn-checklist-run__progress {\n\tbackground: var(--color-border);\n\tborder-radius: 3px;\n\tdisplay: block;\n\theight: 6px;\n\toverflow: hidden;\n}\n\n.cn-checklist-run__progress-fill {\n\tbackground: var(--color-primary-element);\n\tdisplay: block;\n\theight: 100%;\n}\n\n.cn-checklist-run__live,\n.cn-checklist-run__sr {\n\tclip-path: inset(50%);\n\theight: 1px;\n\toverflow: hidden;\n\tposition: absolute;\n\twhite-space: nowrap;\n\twidth: 1px;\n}\n\n.cn-checklist-run__question,\n.cn-checklist-run__photos {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large, 12px);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tmargin: 0;\n\tpadding: 12px 14px;\n}\n\n.cn-checklist-run__photos-title {\n\tfont-size: 15px;\n\tline-height: 1.2;\n}\n\n.cn-checklist-run__legend {\n\tfont-size: 15px;\n\tfont-weight: 600;\n\tline-height: 1.2;\n\tpadding: 0 4px;\n}\n\n.cn-checklist-run__help {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-size: 14px;\n\tline-height: 1.2;\n\tmargin: 0;\n}\n\n/* An option reads as text, not as a field label (a theme makes every label\n bold with !important); 15px, 31px apart, as the board draws it (DqInspectie). */\n.cn-checklist-run__choice {\n\talign-items: center;\n\tdisplay: flex;\n\tfont-size: 15px;\n\tfont-weight: 400 !important;\n\tgap: 10px;\n\tmin-height: 23px;\n}\n\n/* The board draws the radio with the browser's own 3px 3px 0 5px margin. */\n.cn-checklist-run__choice input {\n\taccent-color: var(--color-primary-element);\n\theight: 20px;\n\tmargin: 3px 3px 0 5px;\n\twidth: 20px;\n}\n\n/* The board look sizes every radio 18px with a (0,4,1) rule. */\n.cn-checklist-run__choice.cn-checklist-run__choice.cn-checklist-run__choice input[type=\"radio\"] {\n\theight: 20px;\n\tmin-height: 20px;\n\tmin-width: 20px;\n\twidth: 20px;\n}\n\n.cn-checklist-run__text,\n.cn-checklist-run__number {\n\tbox-sizing: border-box;\n\twidth: 100%;\n}\n\n/* A note is two 15px lines on the normal line height, 8px 12px in: 54px, as\n the board draws it. A theme pads every textarea 5px 12px with !important. */\n.cn-checklist-run__text.cn-checklist-run__text {\n\tpadding: 8px 12px !important;\n\tline-height: normal;\n\tmargin: 0;\n}\n\n.cn-checklist-run__group {\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tline-height: normal;\n\tmargin: 0;\n}\n\n.cn-checklist-run__note-label {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tfont-size: 14px;\n\tfont-weight: 600 !important;\n\tline-height: 1.2;\n}\n\n.cn-checklist-run__photo-list {\n\tmargin: 0;\n\tpadding-inline-start: 18px;\n}\n\n/* The photo button is the board's 34px secondary control across its card\n (DqInspectie, 272px), its 14px/600 label after a camera. The doubled class\n outranks Nextcloud's `button:not(.button-vue)` margin, padding and height,\n and a theme's bold label weight set with !important. */\n.cn-checklist-run__photo-button.cn-checklist-run__photo-button {\n\talign-items: center;\n\talign-self: stretch;\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--cn-board-control-border, var(--color-border-dark));\n\tborder-radius: var(--border-radius-element, 8px);\n\tbox-sizing: border-box;\n\tcolor: var(--color-main-text);\n\tcursor: pointer;\n\tdisplay: flex;\n\tfont-size: 14px;\n\tfont-weight: 600 !important;\n\tgap: 8px;\n\theight: 34px;\n\tmargin: 0;\n\tmin-height: 34px;\n\tpadding: 0 14px;\n}\n\n.cn-checklist-run__photo-button:focus-visible {\n\toutline: 2px solid var(--color-primary-element);\n\toutline-offset: 2px;\n}\n\n.cn-checklist-run__photo-input {\n\tclip-path: inset(50%);\n\theight: 1px;\n\toverflow: hidden;\n\tposition: absolute;\n\twidth: 1px;\n}\n\n.cn-checklist-run__nav {\n\tdisplay: flex;\n\tjustify-content: space-between;\n}\n\n/* Previous and Next are as wide as the board draws them: the board pads the\n button 14px and the label not at all (Vorige 70.3px); NcButton's label\n padding made them 4px wider. */\n.cn-checklist-run__nav :deep(.button-vue__text) {\n\tpadding-inline: 0;\n}\n\n.cn-checklist-run__error {\n\tcolor: var(--color-error-text, var(--color-error));\n\tmargin: 0;\n}\n\n.cn-checklist-run__empty {\n\tcolor: var(--color-text-maxcontrast);\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_createVNode","_createElementVNode","_Fragment","_renderList","_createTextVNode","_vModelRadio","_vModelText"],"mappings":";;;AASM,EAAA,KAAK,EAAC,kBAAkB;AAAC,EAAA,aAAQ,EAAA,kBAAA;;;;AAEpC,EAAA,KAAE,EAAA,yBAAA;AACF,EAAA,IAAI,EAAC,OAAO;AACZ,EAAA,aAAW,EAAC,wBAA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,cAAAA,kBAAA,CAeI,OAfJ,WAeI,EAAA;gBAdJD,WAMU,CAAA,mBAAA,EAAA;AALV,kBAAA,OAAO,EAAC,WAAU;kBACjB,QAAQ,EAAA,KAAA,CAAA,IAAA,KAAA,CAAA,IAAA,KAAA,CAAA,MAAA;AACT,kBAAA,aAAO,EAAA,2BAAA;AACN,kBAAA,OAAK,EAAE,QAAQ,CAAA,QAAA;;mCAChB,MAAY;oDAAT,QAAS,CAAA,aAAA,CAAA,EAAA,CAAA,YAAA;;;;gBAEZA,WAMU,CAAA,mBAAA,EAAA;AALV,kBAAA,OAAO,EAAC,SAAS;AACjB,kBAAA,IAAI,EAAC,QAAI;AACR,kBAAA,QAAE,EAAA,KAAA,CAAA,MAAA;AACF,kBAAA,aAAU,EAAC,uBAAI;;mCAChB,MAA6B;oDAA1B,QAAU,CAAA,UAAA,GAAG,QAAW,CAAA,WAAA,GAAE,QAAA,CAAA,SAAA,CAAA,EAAA,CAAA,YAAA;;;;;eAGtB,KAAM,CAAA,SAAA;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnDeviceFramesWidget.vue2.js';
|
|
|
2
2
|
import { render } from './CnDeviceFramesWidget.vue3.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-41a3b42e";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -3,6 +3,9 @@ import CloudCheckOutline from 'vue-material-design-icons/CloudCheckOutline.vue';
|
|
|
3
3
|
import CloudOffOutline from 'vue-material-design-icons/CloudOffOutline.vue';
|
|
4
4
|
import InformationOutline from 'vue-material-design-icons/InformationOutline.vue';
|
|
5
5
|
import __sfc_main from '../CnSectionsWidget/CnSectionsWidget.vue.js';
|
|
6
|
+
import { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js';
|
|
7
|
+
import { readPath } from '../../utils/readPath.js';
|
|
8
|
+
import { resolveFilterTokens, hasUnresolvedTokens } from '../../utils/resolveFilterTokens.js';
|
|
6
9
|
|
|
7
10
|
/** Counter for unique heading ids across instances. */
|
|
8
11
|
let instanceCounter = 0;
|
|
@@ -49,12 +52,16 @@ var script = {
|
|
|
49
52
|
/**
|
|
50
53
|
* The widget configuration.
|
|
51
54
|
*
|
|
52
|
-
* - `frames` — `[{ key?, title, widgetIds? | sections?, status? }]`, in order. `widgetIds` names
|
|
55
|
+
* - `frames` — `[{ key?, title, titleFrom?, widgetIds? | sections?, status? }]`, in order. `widgetIds` names
|
|
53
56
|
* widgets of the surface, stacked; `sections` takes the `sections` widget's entries instead.
|
|
57
|
+
* `titleFrom: { source: { register, schema, filter, sort? }, field }` titles the frame by that field of the
|
|
58
|
+
* first matching record, read under the reader's rights; `title` stays while none matches.
|
|
54
59
|
* - `status` — the status line of every frame (a frame's own `status` wins): `{ text?, tone?,
|
|
55
60
|
* followConnection?, onlineText?, offlineText? }`. With `followConnection` the line reads
|
|
56
61
|
* `offlineText` while the device is offline and `onlineText` otherwise. `tone` is `warning`
|
|
57
|
-
* (default while offline), `success` or `info`.
|
|
62
|
+
* (default while offline), `success` or `info`. With `syncedFrom: { source: { register, schema,
|
|
63
|
+
* filter }, field }` the newest value of that date field is the last synchronisation, and while
|
|
64
|
+
* offline the line reads `offlineSyncedText` with `{time}` as its time (`offlineText` without one).
|
|
58
65
|
* - `width` — the frame width in pixels (default 350).
|
|
59
66
|
* - `height` — the frame height in pixels (at least 400); what does not fit scrolls inside it. Without it the frame grows with its content.
|
|
60
67
|
*
|
|
@@ -137,6 +144,8 @@ var script = {
|
|
|
137
144
|
return {
|
|
138
145
|
uid: instanceCounter,
|
|
139
146
|
online: typeof navigator === 'undefined' || navigator.onLine !== false,
|
|
147
|
+
readTitles: {},
|
|
148
|
+
syncedTime: '',
|
|
140
149
|
}
|
|
141
150
|
},
|
|
142
151
|
|
|
@@ -168,7 +177,7 @@ var script = {
|
|
|
168
177
|
: (Array.isArray(frame.widgetIds) ? frame.widgetIds : []).filter((id) => typeof id === 'string' && id !== '').map((widgetId) => ({ widgetId }));
|
|
169
178
|
return {
|
|
170
179
|
key: String(frame.key || `frame-${index}`).replace(/[^\w-]/g, '-'),
|
|
171
|
-
title: this.tr(frame.title || ''),
|
|
180
|
+
title: this.readTitles[index] || this.tr(frame.title || ''),
|
|
172
181
|
sections,
|
|
173
182
|
status: this.statusOf(frame.status || this.content?.status || null),
|
|
174
183
|
}
|
|
@@ -177,6 +186,7 @@ var script = {
|
|
|
177
186
|
},
|
|
178
187
|
|
|
179
188
|
mounted() {
|
|
189
|
+
this.readSources();
|
|
180
190
|
if (typeof window !== 'undefined') {
|
|
181
191
|
window.addEventListener('online', this.onConnection);
|
|
182
192
|
window.addEventListener('offline', this.onConnection);
|
|
@@ -216,13 +226,74 @@ var script = {
|
|
|
216
226
|
if (status.followConnection === true) {
|
|
217
227
|
text = this.online ? status.onlineText : status.offlineText;
|
|
218
228
|
tone = tone || (this.online ? 'success' : 'warning');
|
|
229
|
+
if (!this.online && this.syncedTime && typeof status.offlineSyncedText === 'string' && status.offlineSyncedText !== '') {
|
|
230
|
+
return this.statusLine(this.tr(status.offlineSyncedText).replace('{time}', this.syncedTime), tone)
|
|
231
|
+
}
|
|
219
232
|
}
|
|
220
233
|
if (typeof text !== 'string' || text === '') {
|
|
221
234
|
return null
|
|
222
235
|
}
|
|
236
|
+
return this.statusLine(this.tr(text), tone)
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A status line of a text and a tone.
|
|
241
|
+
*
|
|
242
|
+
* @param {string} text The translated text.
|
|
243
|
+
* @param {string} tone The tone.
|
|
244
|
+
* @return {{text: string, tone: string, icon: object}}
|
|
245
|
+
*/
|
|
246
|
+
statusLine(text, tone) {
|
|
223
247
|
const known = ['warning', 'success', 'info'].includes(tone) ? tone : 'info';
|
|
224
248
|
const icon = known === 'warning' ? CloudOffOutline : (known === 'success' ? CloudCheckOutline : InformationOutline);
|
|
225
|
-
return { text
|
|
249
|
+
return { text, tone: known, icon: markRaw(icon) }
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The first record of a `{ source: { register, schema, filter, sort? } }`, sorted by `sort` (or
|
|
254
|
+
* newest first by `orderBy`), under the reader's rights; null without one or while a token is unresolved.
|
|
255
|
+
*
|
|
256
|
+
* @param {object} spec The source spec.
|
|
257
|
+
* @param {string} [orderBy] A field to sort on, newest first, when the source names no sort.
|
|
258
|
+
* @return {Promise<object|null>}
|
|
259
|
+
*/
|
|
260
|
+
async firstOf(spec, orderBy = '') {
|
|
261
|
+
const source = spec?.source;
|
|
262
|
+
if (!source || typeof source !== 'object' || !source.register || !source.schema) {
|
|
263
|
+
return null
|
|
264
|
+
}
|
|
265
|
+
const filter = resolveFilterTokens(source.filter || {}, { objectId: this.objectId || null, object: this.objectData });
|
|
266
|
+
if (hasUnresolvedTokens(filter)) {
|
|
267
|
+
return null
|
|
268
|
+
}
|
|
269
|
+
const sort = source.sort?.field ? { [`_order[${source.sort.field}]`]: source.sort.dir === 'asc' ? 'asc' : 'desc' } : (orderBy ? { [`_order[${orderBy}]`]: 'desc' } : {});
|
|
270
|
+
try {
|
|
271
|
+
const rows = await fetchReferenceObjects({ register: source.register, schema: source.schema, filter: { ...filter, ...sort }, limit: 1 });
|
|
272
|
+
return Array.isArray(rows) && rows.length > 0 ? rows[0] : null
|
|
273
|
+
} catch {
|
|
274
|
+
return null
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
/** Read the frame titles (`titleFrom`) and the last synchronisation (`status.syncedFrom`). */
|
|
279
|
+
async readSources() {
|
|
280
|
+
const list = Array.isArray(this.content?.frames) ? this.content.frames.filter((frame) => frame && typeof frame === 'object') : [];
|
|
281
|
+
const titles = {};
|
|
282
|
+
await Promise.all(list.map(async (frame, index) => {
|
|
283
|
+
if (!frame.titleFrom?.field) {
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
const value = readPath(await this.firstOf(frame.titleFrom), frame.titleFrom.field);
|
|
287
|
+
if (typeof value === 'string' && value !== '') {
|
|
288
|
+
titles[index] = value;
|
|
289
|
+
}
|
|
290
|
+
}));
|
|
291
|
+
this.readTitles = titles;
|
|
292
|
+
const synced = this.content?.status?.syncedFrom;
|
|
293
|
+
if (synced?.field) {
|
|
294
|
+
const at = new Date(readPath(await this.firstOf(synced, synced.field), synced.field) ?? '');
|
|
295
|
+
this.syncedTime = Number.isNaN(at.getTime()) ? '' : `${String(at.getHours()).padStart(2, '0')}:${String(at.getMinutes()).padStart(2, '0')}`;
|
|
296
|
+
}
|
|
226
297
|
},
|
|
227
298
|
|
|
228
299
|
/** Follow the browser's connection state. */
|
|
@@ -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, dividers: false, gap: 12, 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 plain sections, 12px apart\n * without a rule, under a header with the frame's title and an optional\n * status line. The status can follow the connection (\"Offline · synced at\n * 07:42\" while the device is offline). The frames wrap onto the next row\n * when the page is 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"],"mappings":";;;;;;AAqDA;AACA,IAAI,kBAAkB,EAAA;;AAEtB;AACC;;;;AAIA;;;;;;AAMA;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,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,MAAM;AACZ,GAAA,OAAO,EAAE,OAAO,EAAE,CAAC;GACnB;;;AAGD,EAAA,gBAAgB,EAAE;GACjB,IAAI,EAAE,KAAK;AACX,GAAA,OAAO,EAAE,MAAM,EAAE;GACjB;;;AAGD,EAAA,QAAQ,EAAE;AACT,GAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;GACtB,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E,MAAM,CAAC,UAAW,GAAE,MAAM,CAAC,YAAU;AAC1D,IAAA,IAAG,GAAI,IAAK,KAAI,IAAI,CAAC,MAAK,GAAI,YAAY,SAAS,EAAA;AACpD,IAAA;AACA,GAAA,IAAI,OAAO,IAAG,KAAM,QAAO,IAAK,SAAS,EAAE,EAAE;AAC5C,IAAA,OAAO,IAAG;AACX,IAAA;AACA,GAAA,MAAM,KAAM,GAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAE,GAAE,IAAG,GAAI,OAAK;GAC1E,MAAM,OAAO,UAAU,SAAQ,GAAI,mBAAmB,UAAU,YAAY,iBAAgB,GAAI,kBAAkB,EAAA;GAClH,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,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
|
+
{"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, dividers: false, gap: 12, 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'\nimport { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'\nimport { readPath } from '../../utils/readPath.js'\nimport { hasUnresolvedTokens, resolveFilterTokens } from '../../utils/resolveFilterTokens.js'\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 plain sections, 12px apart\n * without a rule, under a header with the frame's title and an optional\n * status line. The status can follow the connection (\"Offline · synced at\n * 07:42\" while the device is offline). The frames wrap onto the next row\n * when the page is 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, titleFrom?, 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 * `titleFrom: { source: { register, schema, filter, sort? }, field }` titles the frame by that field of the\n\t\t * first matching record, read under the reader's rights; `title` stays while none matches.\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`. With `syncedFrom: { source: { register, schema,\n\t\t * filter }, field }` the newest value of that date field is the last synchronisation, and while\n\t\t * offline the line reads `offlineSyncedText` with `{time}` as its time (`offlineText` without one).\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\treadTitles: {},\n\t\t\tsyncedTime: '',\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.readTitles[index] || 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\tthis.readSources()\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\tif (!this.online && this.syncedTime && typeof status.offlineSyncedText === 'string' && status.offlineSyncedText !== '') {\n\t\t\t\t\treturn this.statusLine(this.tr(status.offlineSyncedText).replace('{time}', this.syncedTime), tone)\n\t\t\t\t}\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\treturn this.statusLine(this.tr(text), tone)\n\t\t},\n\n\t\t/**\n\t\t * A status line of a text and a tone.\n\t\t *\n\t\t * @param {string} text The translated text.\n\t\t * @param {string} tone The tone.\n\t\t * @return {{text: string, tone: string, icon: object}}\n\t\t */\n\t\tstatusLine(text, tone) {\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, tone: known, icon: markRaw(icon) }\n\t\t},\n\n\t\t/**\n\t\t * The first record of a `{ source: { register, schema, filter, sort? } }`, sorted by `sort` (or\n\t\t * newest first by `orderBy`), under the reader's rights; null without one or while a token is unresolved.\n\t\t *\n\t\t * @param {object} spec The source spec.\n\t\t * @param {string} [orderBy] A field to sort on, newest first, when the source names no sort.\n\t\t * @return {Promise<object|null>}\n\t\t */\n\t\tasync firstOf(spec, orderBy = '') {\n\t\t\tconst source = spec?.source\n\t\t\tif (!source || typeof source !== 'object' || !source.register || !source.schema) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst filter = resolveFilterTokens(source.filter || {}, { objectId: this.objectId || null, object: this.objectData })\n\t\t\tif (hasUnresolvedTokens(filter)) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst sort = source.sort?.field ? { [`_order[${source.sort.field}]`]: source.sort.dir === 'asc' ? 'asc' : 'desc' } : (orderBy ? { [`_order[${orderBy}]`]: 'desc' } : {})\n\t\t\ttry {\n\t\t\t\tconst rows = await fetchReferenceObjects({ register: source.register, schema: source.schema, filter: { ...filter, ...sort }, limit: 1 })\n\t\t\t\treturn Array.isArray(rows) && rows.length > 0 ? rows[0] : null\n\t\t\t} catch {\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\n\t\t/** Read the frame titles (`titleFrom`) and the last synchronisation (`status.syncedFrom`). */\n\t\tasync readSources() {\n\t\t\tconst list = Array.isArray(this.content?.frames) ? this.content.frames.filter((frame) => frame && typeof frame === 'object') : []\n\t\t\tconst titles = {}\n\t\t\tawait Promise.all(list.map(async (frame, index) => {\n\t\t\t\tif (!frame.titleFrom?.field) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst value = readPath(await this.firstOf(frame.titleFrom), frame.titleFrom.field)\n\t\t\t\tif (typeof value === 'string' && value !== '') {\n\t\t\t\t\ttitles[index] = value\n\t\t\t\t}\n\t\t\t}))\n\t\t\tthis.readTitles = titles\n\t\t\tconst synced = this.content?.status?.syncedFrom\n\t\t\tif (synced?.field) {\n\t\t\t\tconst at = new Date(readPath(await this.firstOf(synced, synced.field), synced.field) ?? '')\n\t\t\t\tthis.syncedTime = Number.isNaN(at.getTime()) ? '' : `${String(at.getHours()).padStart(2, '0')}:${String(at.getMinutes()).padStart(2, '0')}`\n\t\t\t}\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"],"mappings":";;;;;;;;;AAwDA;AACA,IAAI,kBAAkB,EAAA;;AAEtB;AACC;;;;AAIA;;;;;;AAMA;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;AACA;AACA;AACA;AACA;;AAEA;;;AAGD,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,MAAM;AACZ,GAAA,OAAO,EAAE,OAAO,EAAE,CAAC;GACnB;;;AAGD,EAAA,gBAAgB,EAAE;GACjB,IAAI,EAAE,KAAK;AACX,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