@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.
Files changed (180) hide show
  1. package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
  2. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
  3. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
  4. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
  5. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
  6. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
  7. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
  8. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
  9. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
  10. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
  11. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
  12. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
  13. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
  14. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
  15. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
  16. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
  17. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
  18. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
  19. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
  20. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
  21. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
  22. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
  23. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
  24. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
  25. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
  26. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
  27. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
  28. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
  29. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
  30. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
  31. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
  32. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
  33. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
  34. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
  35. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
  36. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
  37. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
  38. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
  39. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
  40. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
  41. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
  42. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
  43. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
  44. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
  45. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
  46. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
  47. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
  48. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
  49. package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
  50. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
  51. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
  52. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
  53. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
  54. package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
  55. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  56. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
  57. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  58. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
  59. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
  60. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
  61. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
  62. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
  63. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
  64. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
  65. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
  66. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
  67. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
  68. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
  69. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
  70. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
  71. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
  72. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  73. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
  74. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
  75. package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
  76. package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
  77. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
  78. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
  79. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
  80. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
  81. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
  82. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
  83. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
  84. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
  85. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
  86. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  87. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
  88. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  89. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
  90. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  91. package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
  92. package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
  93. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
  94. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
  95. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
  96. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
  97. package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
  98. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
  99. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
  100. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
  101. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
  102. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
  103. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
  104. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
  105. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
  106. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
  107. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
  108. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  109. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
  110. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  111. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
  112. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  113. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  114. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
  115. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  116. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
  117. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  118. package/dist/esm/index.js +8 -0
  119. package/dist/esm/index.js.map +1 -1
  120. package/dist/esm/l10n/en.json.js +63 -1
  121. package/dist/esm/l10n/en.json.js.map +1 -1
  122. package/dist/esm/l10n/nl.json.js +63 -1
  123. package/dist/esm/l10n/nl.json.js.map +1 -1
  124. package/dist/esm/library-style.js +1 -1
  125. package/dist/esm/nextcloud-vue.css +1134 -499
  126. package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
  127. package/dist/esm/utils/captureLocation.js +32 -0
  128. package/dist/esm/utils/captureLocation.js.map +1 -0
  129. package/dist/esm/utils/childRecordTotals.js +157 -0
  130. package/dist/esm/utils/childRecordTotals.js.map +1 -0
  131. package/dist/esm/utils/isoDuration.js +51 -1
  132. package/dist/esm/utils/isoDuration.js.map +1 -1
  133. package/dist/esm/utils/qr.js +649 -0
  134. package/dist/esm/utils/qr.js.map +1 -0
  135. package/dist/esm/utils/schema.js +3 -0
  136. package/dist/esm/utils/schema.js.map +1 -1
  137. package/dist/esm/utils/templateVariables.js +54 -0
  138. package/dist/esm/utils/templateVariables.js.map +1 -0
  139. package/dist/nextcloud-vue.cjs.js +20307 -14544
  140. package/dist/nextcloud-vue.cjs.js.map +2 -2
  141. package/dist/nextcloud-vue.css +1134 -499
  142. package/l10n/en.json +63 -1
  143. package/l10n/nl.json +63 -1
  144. package/package.json +1 -1
  145. package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
  146. package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
  147. package/src/components/CnBlockListEditor/index.js +9 -0
  148. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
  149. package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
  150. package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
  151. package/src/components/CnChoiceMatrix/index.js +9 -0
  152. package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
  153. package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
  154. package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
  155. package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
  156. package/src/components/CnDisplayScreen/index.js +9 -0
  157. package/src/components/CnDurationField/CnDurationField.vue +330 -5
  158. package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
  159. package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
  160. package/src/components/CnGeoCaptureField/index.js +9 -0
  161. package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
  162. package/src/components/CnQrCode/CnQrCode.vue +321 -0
  163. package/src/components/CnQrCode/index.js +9 -0
  164. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
  165. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
  166. package/src/components/CnRevealField/CnRevealField.vue +273 -0
  167. package/src/components/CnRevealField/index.js +9 -0
  168. package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
  169. package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
  170. package/src/components/CnTransferCard/index.js +9 -0
  171. package/src/components/CnTreeView/CnTreeNode.vue +145 -2
  172. package/src/components/CnTreeView/CnTreeView.vue +210 -6
  173. package/src/components/index.js +7 -0
  174. package/src/index.js +8 -0
  175. package/src/utils/captureLocation.js +29 -0
  176. package/src/utils/childRecordTotals.js +153 -0
  177. package/src/utils/isoDuration.js +50 -0
  178. package/src/utils/qr.js +681 -0
  179. package/src/utils/schema.js +3 -0
  180. package/src/utils/templateVariables.js +51 -0
@@ -20,6 +20,22 @@
20
20
  class="cn-checklist-run__form"
21
21
  novalidate
22
22
  @submit.prevent="next">
23
+ <div v-if="timeLeftText || savedLine" class="cn-checklist-run__status">
24
+ <span v-if="timeLeftText"
25
+ class="cn-checklist-run__time-left"
26
+ :class="{ 'cn-checklist-run__time-left--warning': timeWarning }"
27
+ role="timer"
28
+ aria-live="off"
29
+ data-testid="cn-checklist-run-time-left">
30
+ {{ timeLeftText }}
31
+ </span>
32
+ <span v-if="savedLine"
33
+ class="cn-checklist-run__saved"
34
+ role="status"
35
+ data-testid="cn-checklist-run-saved">
36
+ {{ savedLine }}
37
+ </span>
38
+ </div>
23
39
  <p
24
40
  ref="position"
25
41
  class="cn-checklist-run__position"
@@ -103,6 +119,13 @@
103
119
  data-testid="cn-checklist-run-note"
104
120
  @input="markDirty(question.id)" />
105
121
  </label>
122
+ <CnGeoCaptureField
123
+ v-if="locationField && (locating[question.id] || draft[question.id].location)"
124
+ :modelValue="draft[question.id].location || null"
125
+ :busy="locating[question.id] === true"
126
+ :goodAccuracy="goodAccuracy"
127
+ data-testid="cn-checklist-run-location"
128
+ @update:modelValue="setLocation(question.id, $event)" />
106
129
  <p
107
130
  v-if="missing.includes(question.id)"
108
131
  class="cn-checklist-run__error"
@@ -157,15 +180,22 @@
157
180
  <div class="cn-checklist-run__nav">
158
181
  <NcButton
159
182
  variant="secondary"
160
- :disabled="page === 0 || saving"
183
+ :disabled="page === 0 || saving || closed"
161
184
  data-testid="cn-checklist-run-previous"
162
185
  @click="previous">
163
186
  {{ previousLabel }}
164
187
  </NcButton>
165
- <NcButton
188
+ <NcButton v-if="submitLabel"
189
+ variant="secondary"
190
+ :disabled="saving || closed"
191
+ data-testid="cn-checklist-run-submit"
192
+ @click="submit">
193
+ {{ submitLabel }}
194
+ </NcButton>
195
+ <NcButton v-if="!submitLabel || !isLastPage"
166
196
  variant="primary"
167
197
  type="submit"
168
- :disabled="saving"
198
+ :disabled="saving || closed"
169
199
  data-testid="cn-checklist-run-next">
170
200
  {{ isLastPage ? finishLabel : nextLabel }}
171
201
  </NcButton>
@@ -189,10 +219,16 @@ import CameraOutline from 'vue-material-design-icons/CameraOutline.vue'
189
219
  import { uploadHeldFiles } from '../../composables/useHeldFileUpload.js'
190
220
  import { dispatchAction } from '../../utils/actionsDispatcher.js'
191
221
  import { fetchReferenceObjects } from '../../utils/boardReferenceColumns.js'
222
+ import { captureLocation } from '../../utils/captureLocation.js'
223
+ import { parseDateValue } from '../../utils/dateVariant.js'
192
224
  import { readPath } from '../../utils/readPath.js'
193
225
  import { hasUnresolvedTokens, resolveDeepTokens, resolveFilterTokens } from '../../utils/resolveFilterTokens.js'
226
+ import { CnGeoCaptureField } from '../CnGeoCaptureField/index.js'
194
227
 
195
228
  const OBJECT_API = '/apps/openregister/api/objects'
229
+ const TICK_MS = 1000
230
+ const DEFAULT_TIME_WARNING_SECONDS = 300
231
+ const LAST_MINUTE_SECONDS = 60
196
232
 
197
233
  let instanceCounter = 0
198
234
 
@@ -251,6 +287,21 @@ function idOf(object) {
251
287
  return String(object?.id ?? object?.['@self']?.id ?? object?.uuid ?? '')
252
288
  }
253
289
 
290
+ /**
291
+ * A number of seconds as a clock: "18:42", or "1:04:05" from an hour.
292
+ *
293
+ * @param {number} seconds The seconds.
294
+ * @return {string} The clock.
295
+ */
296
+ function clockOf(seconds) {
297
+ const pad = (value) => String(value).padStart(2, '0')
298
+ const hours = Math.floor(seconds / 3600)
299
+ const minutes = Math.floor((seconds % 3600) / 60)
300
+ return hours > 0
301
+ ? `${hours}:${pad(minutes)}:${pad(seconds % 60)}`
302
+ : `${pad(minutes)}:${pad(seconds % 60)}`
303
+ }
304
+
254
305
  /**
255
306
  * CnChecklistRunWidget — the `checklist-run` widget: a checklist answered a
256
307
  * page of questions at a time (board DqInspectie, the middle phone frame).
@@ -299,6 +350,11 @@ function idOf(object) {
299
350
  * with no bound record, `record: { register, schema, filter, sort }` picks
300
351
  * the open record: the first match, under the reader's rights.
301
352
  *
353
+ * A timed run names the record's deadline in `deadlineField`: the time left
354
+ * follows that moment rather than the page's start, so a reload keeps it. At
355
+ * zero the page is saved and the run finishes. `submitLabel` adds a button
356
+ * that finishes from any page, and `savedText` says so while nothing is unsaved.
357
+ *
302
358
  * `noteWhen: { answers: [...] }` shows a question's note field only once its
303
359
  * answer is one of those stored values (the board shows a note under "Nee"),
304
360
  * or when the question already holds a note; without it every question shows
@@ -310,6 +366,11 @@ function idOf(object) {
310
366
  * question, where the inspector was; without it the run opens at the first
311
367
  * page.
312
368
  *
369
+ * `captureLocation: { field, goodAccuracy? }` captures where each answer was
370
+ * given, unasked, the first time it changes: the page's save waits for the
371
+ * device, a rough fix or none says so and takes an address by hand, and the
372
+ * place is stored in `field` of the answer.
373
+ *
313
374
  * Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,
314
375
  * a list of strings or `{ value, label }`), `number`, `photo` and `text`.
315
376
  * `typeMap` maps the app's type values onto them, `choiceValues` the stored
@@ -321,7 +382,7 @@ function idOf(object) {
321
382
  export default {
322
383
  name: 'CnChecklistRunWidget',
323
384
 
324
- components: { CameraOutline, NcButton, NcLoadingIcon },
385
+ components: { CameraOutline, CnGeoCaptureField, NcButton, NcLoadingIcon },
325
386
 
326
387
  inject: {
327
388
  /** The detail page's object context (`{ objectId, object }`), for tokens. */
@@ -340,7 +401,8 @@ export default {
340
401
  * groupLabelField?, orderField?, fields?, typeMap?, choiceValues?,
341
402
  * answers | answersPath, answerKey?, answerFields?, recordPhotosField?,
342
403
  * record?, saveAction?, finishAction?, pageSize?, allowNote?, noteWhen?,
343
- * allowPhotos?, caption?, emptyText? }`, as in the component
404
+ * allowPhotos?, caption?, emptyText?, deadlineField?, serverNowField?,
405
+ * timeLeftText?, timeWarningSeconds?, savedText?, submitLabel? }`, as in the component
344
406
  * description and docs/components/cn-checklist-run-widget.md.
345
407
  *
346
408
  * @type {object}
@@ -393,6 +455,8 @@ export default {
393
455
  recordAnswers: [],
394
456
  draft: {},
395
457
  dirty: {},
458
+ locating: {},
459
+ locationPending: {},
396
460
  photos: {},
397
461
  page: 0,
398
462
  // The source the page was last positioned for; `startAt` applies once per source.
@@ -403,6 +467,11 @@ export default {
403
467
  // `content.record` with a filter: the record it picked, or null.
404
468
  pickedRecord: null,
405
469
  liveText: '',
470
+ // The deadline ticker: the moment now, its timer, and whether the run has finished.
471
+ now: Date.now(),
472
+ recordReadAt: Date.now(),
473
+ deadlineTimer: null,
474
+ finishedRun: false,
406
475
  }
407
476
  },
408
477
 
@@ -481,6 +550,16 @@ export default {
481
550
  }).trim()
482
551
  },
483
552
 
553
+ /** @return {string} The answer field a captured place is stored in, '' when none is asked for. */
554
+ locationField() {
555
+ return this.content?.captureLocation?.field || ''
556
+ },
557
+
558
+ /** @return {number} The accuracy in metres above which a fix counts as low. */
559
+ goodAccuracy() {
560
+ return this.content?.captureLocation?.goodAccuracy ?? 50
561
+ },
562
+
484
563
  /** @return {boolean} Whether a note field shows (default true). */
485
564
  allowNote() {
486
565
  return this.content?.allowNote !== false
@@ -609,6 +688,60 @@ export default {
609
688
  photoOnlyLabel: () => t('nextcloud-vue', 'Answer with a photo.'),
610
689
  morePhotoLabel: () => t('nextcloud-vue', 'Another photo'),
611
690
 
691
+ /** @return {number|null} The deadline as read off the open record, on this device's clock; null without one. */
692
+ deadlineAt() {
693
+ const field = this.content?.deadlineField
694
+ const date = field ? parseDateValue(readPath(this.openRecord, field)) : null
695
+ return date ? date.getTime() + this.serverOffset : null
696
+ },
697
+
698
+ /** @return {number} How far this device's clock runs ahead of the server's, in milliseconds. */
699
+ serverOffset() {
700
+ const field = this.content?.serverNowField
701
+ const serverNow = field ? parseDateValue(readPath(this.openRecord, field)) : null
702
+ return serverNow ? this.recordReadAt - serverNow.getTime() : 0
703
+ },
704
+
705
+ /** @return {number|null} Whole seconds until the deadline, never below 0; null without one. */
706
+ secondsLeft() {
707
+ return this.deadlineAt === null ? null : Math.max(0, Math.ceil((this.deadlineAt - this.now) / 1000))
708
+ },
709
+
710
+ /** @return {boolean} Whether the time left is in its warning stretch. */
711
+ timeWarning() {
712
+ return this.secondsLeft !== null && this.secondsLeft <= (this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS)
713
+ },
714
+
715
+ /** @return {string} The time left in words, or ''. */
716
+ timeLeftText() {
717
+ if (this.secondsLeft === null) {
718
+ return ''
719
+ }
720
+ const time = clockOf(this.secondsLeft)
721
+ return this.content?.timeLeftText
722
+ ? this.translate(this.content.timeLeftText).replace('{time}', time)
723
+ : t('nextcloud-vue', 'Time left: {time}', { time })
724
+ },
725
+
726
+ /** @return {string} `savedText`, while nothing is unsaved and something was answered. */
727
+ savedLine() {
728
+ const text = this.content?.savedText
729
+ if (!text || this.answeredCount === 0 || Object.keys(this.dirty).length > 0 || this.saveError) {
730
+ return ''
731
+ }
732
+ return this.translate(text)
733
+ },
734
+
735
+ /** @return {boolean} A timed run finishes once: it is over, so nothing moves any more. */
736
+ closed() {
737
+ return this.finishedRun && this.deadlineAt !== null
738
+ },
739
+
740
+ /** @return {string} The label of the button that finishes from any page, or ''. */
741
+ submitLabel() {
742
+ return this.content?.submitLabel ? this.translate(this.content.submitLabel) : ''
743
+ },
744
+
612
745
  /** @return {string} The note field's label. */
613
746
  noteLabel() {
614
747
  return this.content?.noteLabel ? this.translate(this.content.noteLabel) : t('nextcloud-vue', 'Note')
@@ -628,9 +761,77 @@ export default {
628
761
 
629
762
  immediate: true,
630
763
  },
764
+
765
+ openRecord: {
766
+ handler() {
767
+ this.recordReadAt = Date.now()
768
+ },
769
+
770
+ immediate: true,
771
+ },
772
+
773
+ deadlineAt() {
774
+ this.startDeadlineTimer()
775
+ },
776
+
777
+ 'questions.length': function() {
778
+ this.startDeadlineTimer()
779
+ },
780
+ },
781
+
782
+ mounted() {
783
+ this.startDeadlineTimer()
784
+ },
785
+
786
+ beforeUnmount() {
787
+ clearInterval(this.deadlineTimer)
631
788
  },
632
789
 
633
790
  methods: {
791
+ /**
792
+ * Run the ticker while a run with questions has a deadline.
793
+ *
794
+ * @return {void}
795
+ */
796
+ startDeadlineTimer() {
797
+ clearInterval(this.deadlineTimer)
798
+ this.deadlineTimer = null
799
+ if (this.deadlineAt === null || this.questions.length === 0 || this.finishedRun) {
800
+ return
801
+ }
802
+ this.deadlineTimer = setInterval(this.onDeadlineTick, TICK_MS)
803
+ this.onDeadlineTick()
804
+ },
805
+
806
+ /**
807
+ * Bring the time left up to date, say the warning and the last minute
808
+ * once, and at zero save and finish. A failed save leaves the run open,
809
+ * so the user can try again and sees why. While a save runs it waits for
810
+ * the next tick.
811
+ *
812
+ * @return {Promise<void>}
813
+ */
814
+ async onDeadlineTick() {
815
+ const before = this.secondsLeft
816
+ this.now = Date.now()
817
+ const left = this.secondsLeft
818
+ if (left === null) {
819
+ return
820
+ }
821
+ const warning = this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS
822
+ if (left > 0 && before !== null && [warning, LAST_MINUTE_SECONDS].some((mark) => before > mark && left <= mark)) {
823
+ this.liveText = this.timeLeftText
824
+ }
825
+ if (left > 0 || this.saving) {
826
+ return
827
+ }
828
+ clearInterval(this.deadlineTimer)
829
+ this.deadlineTimer = null
830
+ if (await this.savePage()) {
831
+ await this.finish('deadline')
832
+ }
833
+ },
834
+
634
835
  /**
635
836
  * Whether a question shows its note field: always, unless `noteWhen`
636
837
  * names the answers that ask for one and this question has none of
@@ -889,7 +1090,7 @@ export default {
889
1090
  const qid = String(readPath(entry, key) ?? '')
890
1091
  const question = questions.find((x) => x.id === qid)
891
1092
  if (question && !answerIds[qid]) {
892
- draft[qid] = this.draftFromEntry(question, entry)
1093
+ draft[qid] = { ...this.draftFromEntry(question, entry), location: this.locationField ? (readPath(entry, this.locationField) ?? null) : null }
893
1094
  answerIds[qid] = qid
894
1095
  const photos = readPath(entry, this.answerFields.photos)
895
1096
  storedPhotos[qid] = Array.isArray(photos) ? photos : []
@@ -902,6 +1103,7 @@ export default {
902
1103
  draft[qid] = {
903
1104
  value: String(readPath(answer, a.valueField || 'answer') ?? ''),
904
1105
  note: String(readPath(answer, a.noteField || 'note') ?? ''),
1106
+ location: this.locationField ? (readPath(answer, this.locationField) ?? null) : null,
905
1107
  }
906
1108
  answerIds[qid] = idOf(answer)
907
1109
  const stored = a.photosField ? readPath(answer, a.photosField) : null
@@ -939,6 +1141,39 @@ export default {
939
1141
  markDirty(id) {
940
1142
  this.dirty = { ...this.dirty, [id]: true }
941
1143
  this.missing = this.missing.filter((m) => m !== id)
1144
+ this.startLocating(id)
1145
+ },
1146
+
1147
+ /**
1148
+ * Capture the place of an answer once, the first time it changes. The
1149
+ * promise is kept so the page's save can wait for it.
1150
+ *
1151
+ * @param {string} id The question id.
1152
+ * @return {void}
1153
+ * @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-an-answer-carries-where-it-was-given
1154
+ */
1155
+ startLocating(id) {
1156
+ if (!this.locationField || this.draft[id]?.location || this.locating[id]) {
1157
+ return
1158
+ }
1159
+ this.locating = { ...this.locating, [id]: true }
1160
+ this.locationPending[id] = captureLocation().then((fix) => {
1161
+ delete this.locationPending[id]
1162
+ this.locating = { ...this.locating, [id]: false }
1163
+ this.draft[id].location = fix ? { ...fix, low: fix.accuracy > this.goodAccuracy } : { low: true }
1164
+ })
1165
+ },
1166
+
1167
+ /**
1168
+ * The place was changed in the field: a new fix or a typed address.
1169
+ *
1170
+ * @param {string} id The question id.
1171
+ * @param {object} location The place.
1172
+ * @return {void}
1173
+ */
1174
+ setLocation(id, location) {
1175
+ this.draft[id].location = location
1176
+ this.dirty = { ...this.dirty, [id]: true }
942
1177
  },
943
1178
 
944
1179
  /**
@@ -992,6 +1227,7 @@ export default {
992
1227
  this.saving = true
993
1228
  this.saveError = ''
994
1229
  try {
1230
+ await Promise.all(Object.values(this.locationPending))
995
1231
  if (this.inRecord && !this.content?.saveAction) {
996
1232
  await this.saveIntoRecord(changed)
997
1233
  this.dirty = Object.fromEntries(Object.entries(this.dirty).filter(([id]) => !changed.some((q) => q.id === id)))
@@ -1051,6 +1287,9 @@ export default {
1051
1287
  if (af.at) {
1052
1288
  entry[af.at] = new Date().toISOString()
1053
1289
  }
1290
+ if (this.locationField) {
1291
+ entry[this.locationField] = draft.location ?? null
1292
+ }
1054
1293
  const held = this.photos[question.id] || []
1055
1294
  if (this.photosEnabled && held.length) {
1056
1295
  const field = c.recordPhotosField
@@ -1087,6 +1326,9 @@ export default {
1087
1326
  async saveAnswer(question) {
1088
1327
  const entry = this.draft[question.id]
1089
1328
  const answer = { questionId: question.id, value: entry.value, note: entry.note }
1329
+ if (this.locationField) {
1330
+ answer.location = entry.location ?? null
1331
+ }
1090
1332
  const action = this.content?.saveAction
1091
1333
  if (action && typeof action === 'object') {
1092
1334
  const resolved = resolveDeepTokens(action, this.tokenCtx)
@@ -1106,6 +1348,9 @@ export default {
1106
1348
  if (this.allowNote) {
1107
1349
  body[a.noteField || 'note'] = entry.note
1108
1350
  }
1351
+ if (this.locationField) {
1352
+ body[this.locationField] = entry.location ?? null
1353
+ }
1109
1354
  const base = generateUrl(`${OBJECT_API}/${encodeURIComponent(a.register)}/${encodeURIComponent(a.schema)}`)
1110
1355
  let id = this.answerIds[question.id]
1111
1356
  if (id) {
@@ -1154,13 +1399,41 @@ export default {
1154
1399
  if (!(await this.savePage())) {
1155
1400
  return
1156
1401
  }
1402
+ if (this.secondsLeft === 0) {
1403
+ await this.finish('deadline')
1404
+ return
1405
+ }
1157
1406
  if (this.isLastPage) {
1158
- await this.finish()
1407
+ if (!this.submitLabel) {
1408
+ await this.finish()
1409
+ }
1159
1410
  return
1160
1411
  }
1161
1412
  this.goTo(this.page + 1)
1162
1413
  },
1163
1414
 
1415
+ /**
1416
+ * Finish from any page. A required question without an answer holds it
1417
+ * back and opens that question's page.
1418
+ *
1419
+ * @return {Promise<void>}
1420
+ */
1421
+ async submit() {
1422
+ const open = this.questions.findIndex((q) => q.required && !this.isAnswered(q))
1423
+ if (open >= 0) {
1424
+ if (!(await this.savePage())) {
1425
+ return
1426
+ }
1427
+ this.missing = [this.questions[open].id]
1428
+ this.goTo(Math.floor(open / this.pageSize))
1429
+ return
1430
+ }
1431
+ this.missing = []
1432
+ if (await this.savePage()) {
1433
+ await this.finish()
1434
+ }
1435
+ },
1436
+
1164
1437
  /**
1165
1438
  * Save this page and go back one.
1166
1439
  *
@@ -1192,9 +1465,16 @@ export default {
1192
1465
  /**
1193
1466
  * The run is done: dispatch `finishAction` when set, and emit `finished`.
1194
1467
  *
1468
+ * @param {string} [reason] `user`, or `deadline` when the time ran out.
1195
1469
  * @return {Promise<void>}
1196
1470
  */
1197
- async finish() {
1471
+ async finish(reason = 'user') {
1472
+ if (this.closed) {
1473
+ return
1474
+ }
1475
+ this.finishedRun = true
1476
+ clearInterval(this.deadlineTimer)
1477
+ this.deadlineTimer = null
1198
1478
  const action = this.content?.finishAction
1199
1479
  if (action && typeof action === 'object') {
1200
1480
  const resolved = resolveDeepTokens(action, this.tokenCtx)
@@ -1204,9 +1484,9 @@ export default {
1204
1484
  this.liveText = t('nextcloud-vue', 'Checklist finished.')
1205
1485
  /**
1206
1486
  * @event finished The last page was saved.
1207
- * @type {{answered: number, total: number}}
1487
+ * @type {{answered: number, total: number, reason: string}}
1208
1488
  */
1209
- this.$emit('finished', { answered: this.answeredCount, total: this.questions.length })
1489
+ this.$emit('finished', { answered: this.answeredCount, total: this.questions.length, reason })
1210
1490
  },
1211
1491
  },
1212
1492
  }
@@ -1391,6 +1671,27 @@ export default {
1391
1671
  padding-inline: 0;
1392
1672
  }
1393
1673
 
1674
+ .cn-checklist-run__status {
1675
+ align-items: center;
1676
+ display: flex;
1677
+ flex-wrap: wrap;
1678
+ gap: 4px 16px;
1679
+ justify-content: space-between;
1680
+ }
1681
+
1682
+ .cn-checklist-run__time-left {
1683
+ font-variant-numeric: tabular-nums;
1684
+ font-weight: 600;
1685
+ }
1686
+
1687
+ .cn-checklist-run__time-left--warning {
1688
+ color: var(--color-error-text, var(--color-error));
1689
+ }
1690
+
1691
+ .cn-checklist-run__saved {
1692
+ color: var(--color-text-maxcontrast);
1693
+ }
1694
+
1394
1695
  .cn-checklist-run__error {
1395
1696
  color: var(--color-error-text, var(--color-error));
1396
1697
  margin: 0;