@conduction/nextcloud-vue 2.56.0-beta.69 → 2.56.0-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
- package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +63 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +63 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1134 -499
- package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
- package/dist/esm/utils/captureLocation.js +32 -0
- package/dist/esm/utils/captureLocation.js.map +1 -0
- package/dist/esm/utils/childRecordTotals.js +157 -0
- package/dist/esm/utils/childRecordTotals.js.map +1 -0
- package/dist/esm/utils/isoDuration.js +51 -1
- package/dist/esm/utils/isoDuration.js.map +1 -1
- package/dist/esm/utils/qr.js +649 -0
- package/dist/esm/utils/qr.js.map +1 -0
- package/dist/esm/utils/schema.js +3 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/templateVariables.js +54 -0
- package/dist/esm/utils/templateVariables.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +20307 -14544
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1134 -499
- package/l10n/en.json +63 -1
- package/l10n/nl.json +63 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
- package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
- package/src/components/CnBlockListEditor/index.js +9 -0
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
- package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
- package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
- package/src/components/CnChoiceMatrix/index.js +9 -0
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
- package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
- package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
- package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
- package/src/components/CnDisplayScreen/index.js +9 -0
- package/src/components/CnDurationField/CnDurationField.vue +330 -5
- package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
- package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
- package/src/components/CnGeoCaptureField/index.js +9 -0
- package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
- package/src/components/CnQrCode/CnQrCode.vue +321 -0
- package/src/components/CnQrCode/index.js +9 -0
- package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
- package/src/components/CnRevealField/CnRevealField.vue +273 -0
- package/src/components/CnRevealField/index.js +9 -0
- package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
- package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
- package/src/components/CnTransferCard/index.js +9 -0
- package/src/components/CnTreeView/CnTreeNode.vue +145 -2
- package/src/components/CnTreeView/CnTreeView.vue +210 -6
- package/src/components/index.js +7 -0
- package/src/index.js +8 -0
- package/src/utils/captureLocation.js +29 -0
- package/src/utils/childRecordTotals.js +153 -0
- package/src/utils/isoDuration.js +50 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -6,10 +6,16 @@ import CameraOutline from 'vue-material-design-icons/CameraOutline.vue';
|
|
|
6
6
|
import { uploadHeldFiles } from '../../composables/useHeldFileUpload.js';
|
|
7
7
|
import { dispatchAction } from '../../utils/actionsDispatcher.js';
|
|
8
8
|
import { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js';
|
|
9
|
+
import { captureLocation } from '../../utils/captureLocation.js';
|
|
10
|
+
import { parseDateValue } from '../../utils/dateVariant.js';
|
|
9
11
|
import { readPath } from '../../utils/readPath.js';
|
|
10
12
|
import { resolveFilterTokens, hasUnresolvedTokens, resolveDeepTokens } from '../../utils/resolveFilterTokens.js';
|
|
13
|
+
import __sfc_main from '../CnGeoCaptureField/CnGeoCaptureField.vue.js';
|
|
11
14
|
|
|
12
15
|
const OBJECT_API = '/apps/openregister/api/objects';
|
|
16
|
+
const TICK_MS = 1000;
|
|
17
|
+
const DEFAULT_TIME_WARNING_SECONDS = 300;
|
|
18
|
+
const LAST_MINUTE_SECONDS = 60;
|
|
13
19
|
|
|
14
20
|
let instanceCounter = 0;
|
|
15
21
|
|
|
@@ -68,6 +74,21 @@ function idOf(object) {
|
|
|
68
74
|
return String(object?.id ?? object?.['@self']?.id ?? object?.uuid ?? '')
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
/**
|
|
78
|
+
* A number of seconds as a clock: "18:42", or "1:04:05" from an hour.
|
|
79
|
+
*
|
|
80
|
+
* @param {number} seconds The seconds.
|
|
81
|
+
* @return {string} The clock.
|
|
82
|
+
*/
|
|
83
|
+
function clockOf(seconds) {
|
|
84
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
85
|
+
const hours = Math.floor(seconds / 3600);
|
|
86
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
87
|
+
return hours > 0
|
|
88
|
+
? `${hours}:${pad(minutes)}:${pad(seconds % 60)}`
|
|
89
|
+
: `${pad(minutes)}:${pad(seconds % 60)}`
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
/**
|
|
72
93
|
* CnChecklistRunWidget — the `checklist-run` widget: a checklist answered a
|
|
73
94
|
* page of questions at a time (board DqInspectie, the middle phone frame).
|
|
@@ -116,6 +137,11 @@ function idOf(object) {
|
|
|
116
137
|
* with no bound record, `record: { register, schema, filter, sort }` picks
|
|
117
138
|
* the open record: the first match, under the reader's rights.
|
|
118
139
|
*
|
|
140
|
+
* A timed run names the record's deadline in `deadlineField`: the time left
|
|
141
|
+
* follows that moment rather than the page's start, so a reload keeps it. At
|
|
142
|
+
* zero the page is saved and the run finishes. `submitLabel` adds a button
|
|
143
|
+
* that finishes from any page, and `savedText` says so while nothing is unsaved.
|
|
144
|
+
*
|
|
119
145
|
* `noteWhen: { answers: [...] }` shows a question's note field only once its
|
|
120
146
|
* answer is one of those stored values (the board shows a note under "Nee"),
|
|
121
147
|
* or when the question already holds a note; without it every question shows
|
|
@@ -127,6 +153,11 @@ function idOf(object) {
|
|
|
127
153
|
* question, where the inspector was; without it the run opens at the first
|
|
128
154
|
* page.
|
|
129
155
|
*
|
|
156
|
+
* `captureLocation: { field, goodAccuracy? }` captures where each answer was
|
|
157
|
+
* given, unasked, the first time it changes: the page's save waits for the
|
|
158
|
+
* device, a rough fix or none says so and takes an address by hand, and the
|
|
159
|
+
* place is stored in `field` of the answer.
|
|
160
|
+
*
|
|
130
161
|
* Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,
|
|
131
162
|
* a list of strings or `{ value, label }`), `number`, `photo` and `text`.
|
|
132
163
|
* `typeMap` maps the app's type values onto them, `choiceValues` the stored
|
|
@@ -138,7 +169,7 @@ function idOf(object) {
|
|
|
138
169
|
var script = {
|
|
139
170
|
name: 'CnChecklistRunWidget',
|
|
140
171
|
|
|
141
|
-
components: { CameraOutline, NcButton, NcLoadingIcon },
|
|
172
|
+
components: { CameraOutline, CnGeoCaptureField: __sfc_main, NcButton, NcLoadingIcon },
|
|
142
173
|
|
|
143
174
|
inject: {
|
|
144
175
|
/** The detail page's object context (`{ objectId, object }`), for tokens. */
|
|
@@ -157,7 +188,8 @@ var script = {
|
|
|
157
188
|
* groupLabelField?, orderField?, fields?, typeMap?, choiceValues?,
|
|
158
189
|
* answers | answersPath, answerKey?, answerFields?, recordPhotosField?,
|
|
159
190
|
* record?, saveAction?, finishAction?, pageSize?, allowNote?, noteWhen?,
|
|
160
|
-
* allowPhotos?, caption?, emptyText
|
|
191
|
+
* allowPhotos?, caption?, emptyText?, deadlineField?, serverNowField?,
|
|
192
|
+
* timeLeftText?, timeWarningSeconds?, savedText?, submitLabel? }`, as in the component
|
|
161
193
|
* description and docs/components/cn-checklist-run-widget.md.
|
|
162
194
|
*
|
|
163
195
|
* @type {object}
|
|
@@ -210,6 +242,8 @@ var script = {
|
|
|
210
242
|
recordAnswers: [],
|
|
211
243
|
draft: {},
|
|
212
244
|
dirty: {},
|
|
245
|
+
locating: {},
|
|
246
|
+
locationPending: {},
|
|
213
247
|
photos: {},
|
|
214
248
|
page: 0,
|
|
215
249
|
// The source the page was last positioned for; `startAt` applies once per source.
|
|
@@ -220,6 +254,11 @@ var script = {
|
|
|
220
254
|
// `content.record` with a filter: the record it picked, or null.
|
|
221
255
|
pickedRecord: null,
|
|
222
256
|
liveText: '',
|
|
257
|
+
// The deadline ticker: the moment now, its timer, and whether the run has finished.
|
|
258
|
+
now: Date.now(),
|
|
259
|
+
recordReadAt: Date.now(),
|
|
260
|
+
deadlineTimer: null,
|
|
261
|
+
finishedRun: false,
|
|
223
262
|
}
|
|
224
263
|
},
|
|
225
264
|
|
|
@@ -298,6 +337,16 @@ var script = {
|
|
|
298
337
|
}).trim()
|
|
299
338
|
},
|
|
300
339
|
|
|
340
|
+
/** @return {string} The answer field a captured place is stored in, '' when none is asked for. */
|
|
341
|
+
locationField() {
|
|
342
|
+
return this.content?.captureLocation?.field || ''
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
/** @return {number} The accuracy in metres above which a fix counts as low. */
|
|
346
|
+
goodAccuracy() {
|
|
347
|
+
return this.content?.captureLocation?.goodAccuracy ?? 50
|
|
348
|
+
},
|
|
349
|
+
|
|
301
350
|
/** @return {boolean} Whether a note field shows (default true). */
|
|
302
351
|
allowNote() {
|
|
303
352
|
return this.content?.allowNote !== false
|
|
@@ -426,6 +475,60 @@ var script = {
|
|
|
426
475
|
photoOnlyLabel: () => translate('nextcloud-vue', 'Answer with a photo.'),
|
|
427
476
|
morePhotoLabel: () => translate('nextcloud-vue', 'Another photo'),
|
|
428
477
|
|
|
478
|
+
/** @return {number|null} The deadline as read off the open record, on this device's clock; null without one. */
|
|
479
|
+
deadlineAt() {
|
|
480
|
+
const field = this.content?.deadlineField;
|
|
481
|
+
const date = field ? parseDateValue(readPath(this.openRecord, field)) : null;
|
|
482
|
+
return date ? date.getTime() + this.serverOffset : null
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
/** @return {number} How far this device's clock runs ahead of the server's, in milliseconds. */
|
|
486
|
+
serverOffset() {
|
|
487
|
+
const field = this.content?.serverNowField;
|
|
488
|
+
const serverNow = field ? parseDateValue(readPath(this.openRecord, field)) : null;
|
|
489
|
+
return serverNow ? this.recordReadAt - serverNow.getTime() : 0
|
|
490
|
+
},
|
|
491
|
+
|
|
492
|
+
/** @return {number|null} Whole seconds until the deadline, never below 0; null without one. */
|
|
493
|
+
secondsLeft() {
|
|
494
|
+
return this.deadlineAt === null ? null : Math.max(0, Math.ceil((this.deadlineAt - this.now) / 1000))
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
/** @return {boolean} Whether the time left is in its warning stretch. */
|
|
498
|
+
timeWarning() {
|
|
499
|
+
return this.secondsLeft !== null && this.secondsLeft <= (this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS)
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
/** @return {string} The time left in words, or ''. */
|
|
503
|
+
timeLeftText() {
|
|
504
|
+
if (this.secondsLeft === null) {
|
|
505
|
+
return ''
|
|
506
|
+
}
|
|
507
|
+
const time = clockOf(this.secondsLeft);
|
|
508
|
+
return this.content?.timeLeftText
|
|
509
|
+
? this.translate(this.content.timeLeftText).replace('{time}', time)
|
|
510
|
+
: translate('nextcloud-vue', 'Time left: {time}', { time })
|
|
511
|
+
},
|
|
512
|
+
|
|
513
|
+
/** @return {string} `savedText`, while nothing is unsaved and something was answered. */
|
|
514
|
+
savedLine() {
|
|
515
|
+
const text = this.content?.savedText;
|
|
516
|
+
if (!text || this.answeredCount === 0 || Object.keys(this.dirty).length > 0 || this.saveError) {
|
|
517
|
+
return ''
|
|
518
|
+
}
|
|
519
|
+
return this.translate(text)
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
/** @return {boolean} A timed run finishes once: it is over, so nothing moves any more. */
|
|
523
|
+
closed() {
|
|
524
|
+
return this.finishedRun && this.deadlineAt !== null
|
|
525
|
+
},
|
|
526
|
+
|
|
527
|
+
/** @return {string} The label of the button that finishes from any page, or ''. */
|
|
528
|
+
submitLabel() {
|
|
529
|
+
return this.content?.submitLabel ? this.translate(this.content.submitLabel) : ''
|
|
530
|
+
},
|
|
531
|
+
|
|
429
532
|
/** @return {string} The note field's label. */
|
|
430
533
|
noteLabel() {
|
|
431
534
|
return this.content?.noteLabel ? this.translate(this.content.noteLabel) : translate('nextcloud-vue', 'Note')
|
|
@@ -445,9 +548,77 @@ var script = {
|
|
|
445
548
|
|
|
446
549
|
immediate: true,
|
|
447
550
|
},
|
|
551
|
+
|
|
552
|
+
openRecord: {
|
|
553
|
+
handler() {
|
|
554
|
+
this.recordReadAt = Date.now();
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
immediate: true,
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
deadlineAt() {
|
|
561
|
+
this.startDeadlineTimer();
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
'questions.length': function() {
|
|
565
|
+
this.startDeadlineTimer();
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
|
|
569
|
+
mounted() {
|
|
570
|
+
this.startDeadlineTimer();
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
beforeUnmount() {
|
|
574
|
+
clearInterval(this.deadlineTimer);
|
|
448
575
|
},
|
|
449
576
|
|
|
450
577
|
methods: {
|
|
578
|
+
/**
|
|
579
|
+
* Run the ticker while a run with questions has a deadline.
|
|
580
|
+
*
|
|
581
|
+
* @return {void}
|
|
582
|
+
*/
|
|
583
|
+
startDeadlineTimer() {
|
|
584
|
+
clearInterval(this.deadlineTimer);
|
|
585
|
+
this.deadlineTimer = null;
|
|
586
|
+
if (this.deadlineAt === null || this.questions.length === 0 || this.finishedRun) {
|
|
587
|
+
return
|
|
588
|
+
}
|
|
589
|
+
this.deadlineTimer = setInterval(this.onDeadlineTick, TICK_MS);
|
|
590
|
+
this.onDeadlineTick();
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Bring the time left up to date, say the warning and the last minute
|
|
595
|
+
* once, and at zero save and finish. A failed save leaves the run open,
|
|
596
|
+
* so the user can try again and sees why. While a save runs it waits for
|
|
597
|
+
* the next tick.
|
|
598
|
+
*
|
|
599
|
+
* @return {Promise<void>}
|
|
600
|
+
*/
|
|
601
|
+
async onDeadlineTick() {
|
|
602
|
+
const before = this.secondsLeft;
|
|
603
|
+
this.now = Date.now();
|
|
604
|
+
const left = this.secondsLeft;
|
|
605
|
+
if (left === null) {
|
|
606
|
+
return
|
|
607
|
+
}
|
|
608
|
+
const warning = this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS;
|
|
609
|
+
if (left > 0 && before !== null && [warning, LAST_MINUTE_SECONDS].some((mark) => before > mark && left <= mark)) {
|
|
610
|
+
this.liveText = this.timeLeftText;
|
|
611
|
+
}
|
|
612
|
+
if (left > 0 || this.saving) {
|
|
613
|
+
return
|
|
614
|
+
}
|
|
615
|
+
clearInterval(this.deadlineTimer);
|
|
616
|
+
this.deadlineTimer = null;
|
|
617
|
+
if (await this.savePage()) {
|
|
618
|
+
await this.finish('deadline');
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
|
|
451
622
|
/**
|
|
452
623
|
* Whether a question shows its note field: always, unless `noteWhen`
|
|
453
624
|
* names the answers that ask for one and this question has none of
|
|
@@ -706,7 +877,7 @@ var script = {
|
|
|
706
877
|
const qid = String(readPath(entry, key) ?? '');
|
|
707
878
|
const question = questions.find((x) => x.id === qid);
|
|
708
879
|
if (question && !answerIds[qid]) {
|
|
709
|
-
draft[qid] = this.draftFromEntry(question, entry);
|
|
880
|
+
draft[qid] = { ...this.draftFromEntry(question, entry), location: this.locationField ? (readPath(entry, this.locationField) ?? null) : null };
|
|
710
881
|
answerIds[qid] = qid;
|
|
711
882
|
const photos = readPath(entry, this.answerFields.photos);
|
|
712
883
|
storedPhotos[qid] = Array.isArray(photos) ? photos : [];
|
|
@@ -719,6 +890,7 @@ var script = {
|
|
|
719
890
|
draft[qid] = {
|
|
720
891
|
value: String(readPath(answer, a.valueField || 'answer') ?? ''),
|
|
721
892
|
note: String(readPath(answer, a.noteField || 'note') ?? ''),
|
|
893
|
+
location: this.locationField ? (readPath(answer, this.locationField) ?? null) : null,
|
|
722
894
|
};
|
|
723
895
|
answerIds[qid] = idOf(answer);
|
|
724
896
|
const stored = a.photosField ? readPath(answer, a.photosField) : null;
|
|
@@ -756,6 +928,39 @@ var script = {
|
|
|
756
928
|
markDirty(id) {
|
|
757
929
|
this.dirty = { ...this.dirty, [id]: true };
|
|
758
930
|
this.missing = this.missing.filter((m) => m !== id);
|
|
931
|
+
this.startLocating(id);
|
|
932
|
+
},
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Capture the place of an answer once, the first time it changes. The
|
|
936
|
+
* promise is kept so the page's save can wait for it.
|
|
937
|
+
*
|
|
938
|
+
* @param {string} id The question id.
|
|
939
|
+
* @return {void}
|
|
940
|
+
* @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-an-answer-carries-where-it-was-given
|
|
941
|
+
*/
|
|
942
|
+
startLocating(id) {
|
|
943
|
+
if (!this.locationField || this.draft[id]?.location || this.locating[id]) {
|
|
944
|
+
return
|
|
945
|
+
}
|
|
946
|
+
this.locating = { ...this.locating, [id]: true };
|
|
947
|
+
this.locationPending[id] = captureLocation().then((fix) => {
|
|
948
|
+
delete this.locationPending[id];
|
|
949
|
+
this.locating = { ...this.locating, [id]: false };
|
|
950
|
+
this.draft[id].location = fix ? { ...fix, low: fix.accuracy > this.goodAccuracy } : { low: true };
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* The place was changed in the field: a new fix or a typed address.
|
|
956
|
+
*
|
|
957
|
+
* @param {string} id The question id.
|
|
958
|
+
* @param {object} location The place.
|
|
959
|
+
* @return {void}
|
|
960
|
+
*/
|
|
961
|
+
setLocation(id, location) {
|
|
962
|
+
this.draft[id].location = location;
|
|
963
|
+
this.dirty = { ...this.dirty, [id]: true };
|
|
759
964
|
},
|
|
760
965
|
|
|
761
966
|
/**
|
|
@@ -809,6 +1014,7 @@ var script = {
|
|
|
809
1014
|
this.saving = true;
|
|
810
1015
|
this.saveError = '';
|
|
811
1016
|
try {
|
|
1017
|
+
await Promise.all(Object.values(this.locationPending));
|
|
812
1018
|
if (this.inRecord && !this.content?.saveAction) {
|
|
813
1019
|
await this.saveIntoRecord(changed);
|
|
814
1020
|
this.dirty = Object.fromEntries(Object.entries(this.dirty).filter(([id]) => !changed.some((q) => q.id === id)));
|
|
@@ -868,6 +1074,9 @@ var script = {
|
|
|
868
1074
|
if (af.at) {
|
|
869
1075
|
entry[af.at] = new Date().toISOString();
|
|
870
1076
|
}
|
|
1077
|
+
if (this.locationField) {
|
|
1078
|
+
entry[this.locationField] = draft.location ?? null;
|
|
1079
|
+
}
|
|
871
1080
|
const held = this.photos[question.id] || [];
|
|
872
1081
|
if (this.photosEnabled && held.length) {
|
|
873
1082
|
const field = c.recordPhotosField;
|
|
@@ -904,6 +1113,9 @@ var script = {
|
|
|
904
1113
|
async saveAnswer(question) {
|
|
905
1114
|
const entry = this.draft[question.id];
|
|
906
1115
|
const answer = { questionId: question.id, value: entry.value, note: entry.note };
|
|
1116
|
+
if (this.locationField) {
|
|
1117
|
+
answer.location = entry.location ?? null;
|
|
1118
|
+
}
|
|
907
1119
|
const action = this.content?.saveAction;
|
|
908
1120
|
if (action && typeof action === 'object') {
|
|
909
1121
|
const resolved = resolveDeepTokens(action, this.tokenCtx);
|
|
@@ -923,6 +1135,9 @@ var script = {
|
|
|
923
1135
|
if (this.allowNote) {
|
|
924
1136
|
body[a.noteField || 'note'] = entry.note;
|
|
925
1137
|
}
|
|
1138
|
+
if (this.locationField) {
|
|
1139
|
+
body[this.locationField] = entry.location ?? null;
|
|
1140
|
+
}
|
|
926
1141
|
const base = generateUrl(`${OBJECT_API}/${encodeURIComponent(a.register)}/${encodeURIComponent(a.schema)}`);
|
|
927
1142
|
let id = this.answerIds[question.id];
|
|
928
1143
|
if (id) {
|
|
@@ -971,13 +1186,41 @@ var script = {
|
|
|
971
1186
|
if (!(await this.savePage())) {
|
|
972
1187
|
return
|
|
973
1188
|
}
|
|
1189
|
+
if (this.secondsLeft === 0) {
|
|
1190
|
+
await this.finish('deadline');
|
|
1191
|
+
return
|
|
1192
|
+
}
|
|
974
1193
|
if (this.isLastPage) {
|
|
975
|
-
|
|
1194
|
+
if (!this.submitLabel) {
|
|
1195
|
+
await this.finish();
|
|
1196
|
+
}
|
|
976
1197
|
return
|
|
977
1198
|
}
|
|
978
1199
|
this.goTo(this.page + 1);
|
|
979
1200
|
},
|
|
980
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Finish from any page. A required question without an answer holds it
|
|
1204
|
+
* back and opens that question's page.
|
|
1205
|
+
*
|
|
1206
|
+
* @return {Promise<void>}
|
|
1207
|
+
*/
|
|
1208
|
+
async submit() {
|
|
1209
|
+
const open = this.questions.findIndex((q) => q.required && !this.isAnswered(q));
|
|
1210
|
+
if (open >= 0) {
|
|
1211
|
+
if (!(await this.savePage())) {
|
|
1212
|
+
return
|
|
1213
|
+
}
|
|
1214
|
+
this.missing = [this.questions[open].id];
|
|
1215
|
+
this.goTo(Math.floor(open / this.pageSize));
|
|
1216
|
+
return
|
|
1217
|
+
}
|
|
1218
|
+
this.missing = [];
|
|
1219
|
+
if (await this.savePage()) {
|
|
1220
|
+
await this.finish();
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
|
|
981
1224
|
/**
|
|
982
1225
|
* Save this page and go back one.
|
|
983
1226
|
*
|
|
@@ -1009,9 +1252,16 @@ var script = {
|
|
|
1009
1252
|
/**
|
|
1010
1253
|
* The run is done: dispatch `finishAction` when set, and emit `finished`.
|
|
1011
1254
|
*
|
|
1255
|
+
* @param {string} [reason] `user`, or `deadline` when the time ran out.
|
|
1012
1256
|
* @return {Promise<void>}
|
|
1013
1257
|
*/
|
|
1014
|
-
async finish() {
|
|
1258
|
+
async finish(reason = 'user') {
|
|
1259
|
+
if (this.closed) {
|
|
1260
|
+
return
|
|
1261
|
+
}
|
|
1262
|
+
this.finishedRun = true;
|
|
1263
|
+
clearInterval(this.deadlineTimer);
|
|
1264
|
+
this.deadlineTimer = null;
|
|
1015
1265
|
const action = this.content?.finishAction;
|
|
1016
1266
|
if (action && typeof action === 'object') {
|
|
1017
1267
|
const resolved = resolveDeepTokens(action, this.tokenCtx);
|
|
@@ -1021,9 +1271,9 @@ var script = {
|
|
|
1021
1271
|
this.liveText = translate('nextcloud-vue', 'Checklist finished.');
|
|
1022
1272
|
/**
|
|
1023
1273
|
* @event finished The last page was saved.
|
|
1024
|
-
* @type {{answered: number, total: number}}
|
|
1274
|
+
* @type {{answered: number, total: number, reason: string}}
|
|
1025
1275
|
*/
|
|
1026
|
-
this.$emit('finished', { answered: this.answeredCount, total: this.questions.length });
|
|
1276
|
+
this.$emit('finished', { answered: this.answeredCount, total: this.questions.length, reason });
|
|
1027
1277
|
},
|
|
1028
1278
|
},
|
|
1029
1279
|
};
|