@conduction/nextcloud-vue 2.174.0 → 2.176.1

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 (203) 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 +323 -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 +255 -10
  40. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
  41. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +70 -28
  42. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
  43. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +55 -6
  44. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  45. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  46. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
  47. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
  48. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
  49. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
  50. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
  51. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
  52. package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
  53. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
  54. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
  55. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
  56. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
  57. package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
  58. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  59. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
  60. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  61. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
  62. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
  63. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
  64. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
  65. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
  66. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
  67. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +40 -1
  68. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  69. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  70. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
  71. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
  72. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
  73. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
  74. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
  75. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
  76. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
  77. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
  78. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  79. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
  80. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
  81. package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
  82. package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
  83. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
  84. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
  85. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
  86. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
  87. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
  88. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
  89. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
  90. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
  91. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
  92. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  93. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
  94. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  95. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
  96. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  97. package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
  98. package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
  99. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
  100. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
  101. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
  102. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
  103. package/dist/esm/components/CnStorePage/CnStorePage.vue.js +1 -1
  104. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js +3 -3
  105. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js.map +1 -1
  106. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js +5 -5
  107. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js.map +1 -1
  108. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue.js +1 -1
  109. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js +6 -6
  110. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js.map +1 -1
  111. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js +1 -1
  112. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js.map +1 -1
  113. package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
  114. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
  115. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
  116. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
  117. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
  118. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
  119. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
  120. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
  121. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
  122. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
  123. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
  124. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  125. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
  126. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  127. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
  128. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  129. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  130. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
  131. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  132. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
  133. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  134. package/dist/esm/index.js +8 -0
  135. package/dist/esm/index.js.map +1 -1
  136. package/dist/esm/l10n/en.json.js +79 -14
  137. package/dist/esm/l10n/en.json.js.map +1 -1
  138. package/dist/esm/l10n/nl.json.js +79 -14
  139. package/dist/esm/l10n/nl.json.js.map +1 -1
  140. package/dist/esm/library-style.js +1 -1
  141. package/dist/esm/nextcloud-vue.css +1162 -523
  142. package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
  143. package/dist/esm/utils/captureLocation.js +32 -0
  144. package/dist/esm/utils/captureLocation.js.map +1 -0
  145. package/dist/esm/utils/childRecordTotals.js +157 -0
  146. package/dist/esm/utils/childRecordTotals.js.map +1 -0
  147. package/dist/esm/utils/isoDuration.js +51 -1
  148. package/dist/esm/utils/isoDuration.js.map +1 -1
  149. package/dist/esm/utils/parentCrumb.js +86 -0
  150. package/dist/esm/utils/parentCrumb.js.map +1 -0
  151. package/dist/esm/utils/qr.js +649 -0
  152. package/dist/esm/utils/qr.js.map +1 -0
  153. package/dist/esm/utils/schema.js +3 -0
  154. package/dist/esm/utils/schema.js.map +1 -1
  155. package/dist/esm/utils/templateVariables.js +54 -0
  156. package/dist/esm/utils/templateVariables.js.map +1 -0
  157. package/dist/nextcloud-vue.cjs.js +21125 -15025
  158. package/dist/nextcloud-vue.cjs.js.map +2 -2
  159. package/dist/nextcloud-vue.css +1162 -523
  160. package/l10n/en.json +79 -14
  161. package/l10n/nl.json +79 -14
  162. package/package.json +1 -1
  163. package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
  164. package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
  165. package/src/components/CnBlockListEditor/index.js +9 -0
  166. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +377 -10
  167. package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
  168. package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
  169. package/src/components/CnChoiceMatrix/index.js +9 -0
  170. package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
  171. package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
  172. package/src/components/CnDataMatrix/CnDataMatrix.vue +304 -17
  173. package/src/components/CnDetailPage/CnDetailPage.vue +55 -6
  174. package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
  175. package/src/components/CnDisplayScreen/index.js +9 -0
  176. package/src/components/CnDurationField/CnDurationField.vue +330 -5
  177. package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
  178. package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
  179. package/src/components/CnGeoCaptureField/index.js +9 -0
  180. package/src/components/CnIndexPage/CnIndexPage.vue +40 -1
  181. package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
  182. package/src/components/CnQrCode/CnQrCode.vue +321 -0
  183. package/src/components/CnQrCode/index.js +9 -0
  184. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
  185. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
  186. package/src/components/CnRevealField/CnRevealField.vue +273 -0
  187. package/src/components/CnRevealField/index.js +9 -0
  188. package/src/components/CnStorePage/CnStorePage.vue +8 -8
  189. package/src/components/CnStorePage/CnStorePublishDialog.vue +7 -7
  190. package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
  191. package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
  192. package/src/components/CnTransferCard/index.js +9 -0
  193. package/src/components/CnTreeView/CnTreeNode.vue +145 -2
  194. package/src/components/CnTreeView/CnTreeView.vue +210 -6
  195. package/src/components/index.js +7 -0
  196. package/src/index.js +8 -0
  197. package/src/utils/captureLocation.js +29 -0
  198. package/src/utils/childRecordTotals.js +153 -0
  199. package/src/utils/isoDuration.js +50 -0
  200. package/src/utils/parentCrumb.js +83 -0
  201. package/src/utils/qr.js +681 -0
  202. package/src/utils/schema.js +3 -0
  203. 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,13 @@ 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
+ * `saveEachAnswer: true` (or a wait in ms) saves each answer a moment after
145
+ * it is given instead of when the user moves on.
146
+ *
119
147
  * `noteWhen: { answers: [...] }` shows a question's note field only once its
120
148
  * answer is one of those stored values (the board shows a note under "Nee"),
121
149
  * or when the question already holds a note; without it every question shows
@@ -127,6 +155,11 @@ function idOf(object) {
127
155
  * question, where the inspector was; without it the run opens at the first
128
156
  * page.
129
157
  *
158
+ * `captureLocation: { field, goodAccuracy? }` captures where each answer was
159
+ * given, unasked, the first time it changes: the page's save waits for the
160
+ * device, a rough fix or none says so and takes an address by hand, and the
161
+ * place is stored in `field` of the answer.
162
+ *
130
163
  * Question kinds: `yes_no`, `yes_no_na`, `choice` (the question's `options`,
131
164
  * a list of strings or `{ value, label }`), `number`, `photo` and `text`.
132
165
  * `typeMap` maps the app's type values onto them, `choiceValues` the stored
@@ -138,7 +171,7 @@ function idOf(object) {
138
171
  var script = {
139
172
  name: 'CnChecklistRunWidget',
140
173
 
141
- components: { CameraOutline, NcButton, NcLoadingIcon },
174
+ components: { CameraOutline, CnGeoCaptureField: __sfc_main, NcButton, NcLoadingIcon },
142
175
 
143
176
  inject: {
144
177
  /** The detail page's object context (`{ objectId, object }`), for tokens. */
@@ -157,7 +190,9 @@ var script = {
157
190
  * groupLabelField?, orderField?, fields?, typeMap?, choiceValues?,
158
191
  * answers | answersPath, answerKey?, answerFields?, recordPhotosField?,
159
192
  * record?, saveAction?, finishAction?, pageSize?, allowNote?, noteWhen?,
160
- * allowPhotos?, caption?, emptyText? }`, as in the component
193
+ * allowPhotos?, caption?, emptyText?, deadlineField?, serverNowField?,
194
+ * timeLeftText?, timeWarningSeconds?, savedText?, submitLabel?,
195
+ * saveEachAnswer? }`, as in the component
161
196
  * description and docs/components/cn-checklist-run-widget.md.
162
197
  *
163
198
  * @type {object}
@@ -210,6 +245,8 @@ var script = {
210
245
  recordAnswers: [],
211
246
  draft: {},
212
247
  dirty: {},
248
+ locating: {},
249
+ locationPending: {},
213
250
  photos: {},
214
251
  page: 0,
215
252
  // The source the page was last positioned for; `startAt` applies once per source.
@@ -220,10 +257,33 @@ var script = {
220
257
  // `content.record` with a filter: the record it picked, or null.
221
258
  pickedRecord: null,
222
259
  liveText: '',
260
+ // The deadline ticker: the moment now, its timer, and whether the run has finished.
261
+ now: Date.now(),
262
+ recordReadAt: Date.now(),
263
+ deadlineTimer: null,
264
+ // `saveEachAnswer`: the pending save, and the save that runs now.
265
+ answerSaveTimer: null,
266
+ pageSave: null,
267
+ finishedRun: false,
223
268
  }
224
269
  },
225
270
 
226
271
  computed: {
272
+ /**
273
+ * The wait before an answer saves on its own (`saveEachAnswer`: `true`
274
+ * waits 800 ms, a number that many ms), or null to save on moving on.
275
+ *
276
+ * @return {number|null}
277
+ * @spec openspec/changes/checklist-run-save-each-answer/specs/checklist-run-widget/spec.md#requirement-a-run-can-save-each-answer-as-it-is-given
278
+ */
279
+ answerSaveDelay() {
280
+ const option = this.content?.saveEachAnswer;
281
+ if (option === true) {
282
+ return 800
283
+ }
284
+ return typeof option === 'number' && option >= 0 ? option : null
285
+ },
286
+
227
287
  /** @return {object} What the tokens resolve against. */
228
288
  tokenCtx() {
229
289
  const unwrap = (c) => (c && typeof c === 'object' && 'value' in c ? c.value : c);
@@ -298,6 +358,16 @@ var script = {
298
358
  }).trim()
299
359
  },
300
360
 
361
+ /** @return {string} The answer field a captured place is stored in, '' when none is asked for. */
362
+ locationField() {
363
+ return this.content?.captureLocation?.field || ''
364
+ },
365
+
366
+ /** @return {number} The accuracy in metres above which a fix counts as low. */
367
+ goodAccuracy() {
368
+ return this.content?.captureLocation?.goodAccuracy ?? 50
369
+ },
370
+
301
371
  /** @return {boolean} Whether a note field shows (default true). */
302
372
  allowNote() {
303
373
  return this.content?.allowNote !== false
@@ -426,6 +496,60 @@ var script = {
426
496
  photoOnlyLabel: () => translate('nextcloud-vue', 'Answer with a photo.'),
427
497
  morePhotoLabel: () => translate('nextcloud-vue', 'Another photo'),
428
498
 
499
+ /** @return {number|null} The deadline as read off the open record, on this device's clock; null without one. */
500
+ deadlineAt() {
501
+ const field = this.content?.deadlineField;
502
+ const date = field ? parseDateValue(readPath(this.openRecord, field)) : null;
503
+ return date ? date.getTime() + this.serverOffset : null
504
+ },
505
+
506
+ /** @return {number} How far this device's clock runs ahead of the server's, in milliseconds. */
507
+ serverOffset() {
508
+ const field = this.content?.serverNowField;
509
+ const serverNow = field ? parseDateValue(readPath(this.openRecord, field)) : null;
510
+ return serverNow ? this.recordReadAt - serverNow.getTime() : 0
511
+ },
512
+
513
+ /** @return {number|null} Whole seconds until the deadline, never below 0; null without one. */
514
+ secondsLeft() {
515
+ return this.deadlineAt === null ? null : Math.max(0, Math.ceil((this.deadlineAt - this.now) / 1000))
516
+ },
517
+
518
+ /** @return {boolean} Whether the time left is in its warning stretch. */
519
+ timeWarning() {
520
+ return this.secondsLeft !== null && this.secondsLeft <= (this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS)
521
+ },
522
+
523
+ /** @return {string} The time left in words, or ''. */
524
+ timeLeftText() {
525
+ if (this.secondsLeft === null) {
526
+ return ''
527
+ }
528
+ const time = clockOf(this.secondsLeft);
529
+ return this.content?.timeLeftText
530
+ ? this.translate(this.content.timeLeftText).replace('{time}', time)
531
+ : translate('nextcloud-vue', 'Time left: {time}', { time })
532
+ },
533
+
534
+ /** @return {string} `savedText`, while nothing is unsaved and something was answered. */
535
+ savedLine() {
536
+ const text = this.content?.savedText;
537
+ if (!text || this.answeredCount === 0 || Object.keys(this.dirty).length > 0 || this.saveError) {
538
+ return ''
539
+ }
540
+ return this.translate(text)
541
+ },
542
+
543
+ /** @return {boolean} A timed run finishes once: it is over, so nothing moves any more. */
544
+ closed() {
545
+ return this.finishedRun && this.deadlineAt !== null
546
+ },
547
+
548
+ /** @return {string} The label of the button that finishes from any page, or ''. */
549
+ submitLabel() {
550
+ return this.content?.submitLabel ? this.translate(this.content.submitLabel) : ''
551
+ },
552
+
429
553
  /** @return {string} The note field's label. */
430
554
  noteLabel() {
431
555
  return this.content?.noteLabel ? this.translate(this.content.noteLabel) : translate('nextcloud-vue', 'Note')
@@ -445,9 +569,82 @@ var script = {
445
569
 
446
570
  immediate: true,
447
571
  },
572
+
573
+ openRecord: {
574
+ handler() {
575
+ this.recordReadAt = Date.now();
576
+ },
577
+
578
+ immediate: true,
579
+ },
580
+
581
+ deadlineAt() {
582
+ this.startDeadlineTimer();
583
+ },
584
+
585
+ 'questions.length': function() {
586
+ this.startDeadlineTimer();
587
+ },
588
+ },
589
+
590
+ mounted() {
591
+ this.startDeadlineTimer();
592
+ },
593
+
594
+ beforeUnmount() {
595
+ clearInterval(this.deadlineTimer);
596
+ if (this.answerSaveTimer) {
597
+ clearTimeout(this.answerSaveTimer);
598
+ this.answerSaveTimer = null;
599
+ this.savePage();
600
+ }
448
601
  },
449
602
 
450
603
  methods: {
604
+ /**
605
+ * Run the ticker while a run with questions has a deadline.
606
+ *
607
+ * @return {void}
608
+ */
609
+ startDeadlineTimer() {
610
+ clearInterval(this.deadlineTimer);
611
+ this.deadlineTimer = null;
612
+ if (this.deadlineAt === null || this.questions.length === 0 || this.finishedRun) {
613
+ return
614
+ }
615
+ this.deadlineTimer = setInterval(this.onDeadlineTick, TICK_MS);
616
+ this.onDeadlineTick();
617
+ },
618
+
619
+ /**
620
+ * Bring the time left up to date, say the warning and the last minute
621
+ * once, and at zero save and finish. A failed save leaves the run open,
622
+ * so the user can try again and sees why. While a save runs it waits for
623
+ * the next tick.
624
+ *
625
+ * @return {Promise<void>}
626
+ */
627
+ async onDeadlineTick() {
628
+ const before = this.secondsLeft;
629
+ this.now = Date.now();
630
+ const left = this.secondsLeft;
631
+ if (left === null) {
632
+ return
633
+ }
634
+ const warning = this.content?.timeWarningSeconds ?? DEFAULT_TIME_WARNING_SECONDS;
635
+ if (left > 0 && before !== null && [warning, LAST_MINUTE_SECONDS].some((mark) => before > mark && left <= mark)) {
636
+ this.liveText = this.timeLeftText;
637
+ }
638
+ if (left > 0 || this.saving) {
639
+ return
640
+ }
641
+ clearInterval(this.deadlineTimer);
642
+ this.deadlineTimer = null;
643
+ if (await this.savePage()) {
644
+ await this.finish('deadline');
645
+ }
646
+ },
647
+
451
648
  /**
452
649
  * Whether a question shows its note field: always, unless `noteWhen`
453
650
  * names the answers that ask for one and this question has none of
@@ -706,7 +903,7 @@ var script = {
706
903
  const qid = String(readPath(entry, key) ?? '');
707
904
  const question = questions.find((x) => x.id === qid);
708
905
  if (question && !answerIds[qid]) {
709
- draft[qid] = this.draftFromEntry(question, entry);
906
+ draft[qid] = { ...this.draftFromEntry(question, entry), location: this.locationField ? (readPath(entry, this.locationField) ?? null) : null };
710
907
  answerIds[qid] = qid;
711
908
  const photos = readPath(entry, this.answerFields.photos);
712
909
  storedPhotos[qid] = Array.isArray(photos) ? photos : [];
@@ -719,6 +916,7 @@ var script = {
719
916
  draft[qid] = {
720
917
  value: String(readPath(answer, a.valueField || 'answer') ?? ''),
721
918
  note: String(readPath(answer, a.noteField || 'note') ?? ''),
919
+ location: this.locationField ? (readPath(answer, this.locationField) ?? null) : null,
722
920
  };
723
921
  answerIds[qid] = idOf(answer);
724
922
  const stored = a.photosField ? readPath(answer, a.photosField) : null;
@@ -756,6 +954,60 @@ var script = {
756
954
  markDirty(id) {
757
955
  this.dirty = { ...this.dirty, [id]: true };
758
956
  this.missing = this.missing.filter((m) => m !== id);
957
+ this.startLocating(id);
958
+ this.scheduleAnswerSave();
959
+ },
960
+
961
+ /**
962
+ * With `saveEachAnswer`, save the page a moment after the last change,
963
+ * so typing saves once and a quick run of answers saves together.
964
+ *
965
+ * @return {void}
966
+ * @spec openspec/changes/checklist-run-save-each-answer/specs/checklist-run-widget/spec.md#requirement-a-run-can-save-each-answer-as-it-is-given
967
+ */
968
+ scheduleAnswerSave() {
969
+ const delay = this.answerSaveDelay;
970
+ if (delay === null) {
971
+ return
972
+ }
973
+ clearTimeout(this.answerSaveTimer);
974
+ this.answerSaveTimer = setTimeout(() => {
975
+ this.answerSaveTimer = null;
976
+ this.savePage();
977
+ }, delay);
978
+ },
979
+
980
+ /**
981
+ * Capture the place of an answer once, the first time it changes. The
982
+ * promise is kept so the page's save can wait for it.
983
+ *
984
+ * @param {string} id The question id.
985
+ * @return {void}
986
+ * @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-an-answer-carries-where-it-was-given
987
+ */
988
+ startLocating(id) {
989
+ if (!this.locationField || this.draft[id]?.location || this.locating[id]) {
990
+ return
991
+ }
992
+ this.locating = { ...this.locating, [id]: true };
993
+ this.locationPending[id] = captureLocation().then((fix) => {
994
+ delete this.locationPending[id];
995
+ this.locating = { ...this.locating, [id]: false };
996
+ this.draft[id].location = fix ? { ...fix, low: fix.accuracy > this.goodAccuracy } : { low: true };
997
+ });
998
+ },
999
+
1000
+ /**
1001
+ * The place was changed in the field: a new fix or a typed address.
1002
+ *
1003
+ * @param {string} id The question id.
1004
+ * @param {object} location The place.
1005
+ * @return {void}
1006
+ */
1007
+ setLocation(id, location) {
1008
+ this.draft[id].location = location;
1009
+ this.dirty = { ...this.dirty, [id]: true };
1010
+ this.scheduleAnswerSave();
759
1011
  },
760
1012
 
761
1013
  /**
@@ -787,6 +1039,7 @@ var script = {
787
1039
  }
788
1040
  this.photos = { ...this.photos, [id]: [...(this.photos[id] || []), ...files] };
789
1041
  this.dirty = { ...this.dirty, [id]: true };
1042
+ this.scheduleAnswerSave();
790
1043
  this.missingPhoto = this.missingPhoto.filter((m) => m !== id);
791
1044
  if (event.target) {
792
1045
  event.target.value = '';
@@ -802,6 +1055,24 @@ var script = {
802
1055
  * @spec openspec/changes/checklist-run-widget/specs/checklist-run-widget/spec.md#requirement-answers-are-saved-under-the-readers-own-rights
803
1056
  */
804
1057
  async savePage() {
1058
+ // One save at a time, so an answer is never created twice.
1059
+ while (this.pageSave) {
1060
+ await this.pageSave;
1061
+ }
1062
+ this.pageSave = this.savePageNow();
1063
+ try {
1064
+ return await this.pageSave
1065
+ } finally {
1066
+ this.pageSave = null;
1067
+ }
1068
+ },
1069
+
1070
+ /**
1071
+ * Save the changed answers of this page now (see `savePage`).
1072
+ *
1073
+ * @return {Promise<boolean>} True when everything saved.
1074
+ */
1075
+ async savePageNow() {
805
1076
  const changed = this.pageQuestions.filter((q) => this.dirty[q.id]);
806
1077
  if (changed.length === 0) {
807
1078
  return true
@@ -809,6 +1080,7 @@ var script = {
809
1080
  this.saving = true;
810
1081
  this.saveError = '';
811
1082
  try {
1083
+ await Promise.all(Object.values(this.locationPending));
812
1084
  if (this.inRecord && !this.content?.saveAction) {
813
1085
  await this.saveIntoRecord(changed);
814
1086
  this.dirty = Object.fromEntries(Object.entries(this.dirty).filter(([id]) => !changed.some((q) => q.id === id)));
@@ -868,6 +1140,9 @@ var script = {
868
1140
  if (af.at) {
869
1141
  entry[af.at] = new Date().toISOString();
870
1142
  }
1143
+ if (this.locationField) {
1144
+ entry[this.locationField] = draft.location ?? null;
1145
+ }
871
1146
  const held = this.photos[question.id] || [];
872
1147
  if (this.photosEnabled && held.length) {
873
1148
  const field = c.recordPhotosField;
@@ -904,6 +1179,9 @@ var script = {
904
1179
  async saveAnswer(question) {
905
1180
  const entry = this.draft[question.id];
906
1181
  const answer = { questionId: question.id, value: entry.value, note: entry.note };
1182
+ if (this.locationField) {
1183
+ answer.location = entry.location ?? null;
1184
+ }
907
1185
  const action = this.content?.saveAction;
908
1186
  if (action && typeof action === 'object') {
909
1187
  const resolved = resolveDeepTokens(action, this.tokenCtx);
@@ -923,6 +1201,9 @@ var script = {
923
1201
  if (this.allowNote) {
924
1202
  body[a.noteField || 'note'] = entry.note;
925
1203
  }
1204
+ if (this.locationField) {
1205
+ body[this.locationField] = entry.location ?? null;
1206
+ }
926
1207
  const base = generateUrl(`${OBJECT_API}/${encodeURIComponent(a.register)}/${encodeURIComponent(a.schema)}`);
927
1208
  let id = this.answerIds[question.id];
928
1209
  if (id) {
@@ -971,13 +1252,41 @@ var script = {
971
1252
  if (!(await this.savePage())) {
972
1253
  return
973
1254
  }
1255
+ if (this.secondsLeft === 0) {
1256
+ await this.finish('deadline');
1257
+ return
1258
+ }
974
1259
  if (this.isLastPage) {
975
- await this.finish();
1260
+ if (!this.submitLabel) {
1261
+ await this.finish();
1262
+ }
976
1263
  return
977
1264
  }
978
1265
  this.goTo(this.page + 1);
979
1266
  },
980
1267
 
1268
+ /**
1269
+ * Finish from any page. A required question without an answer holds it
1270
+ * back and opens that question's page.
1271
+ *
1272
+ * @return {Promise<void>}
1273
+ */
1274
+ async submit() {
1275
+ const open = this.questions.findIndex((q) => q.required && !this.isAnswered(q));
1276
+ if (open >= 0) {
1277
+ if (!(await this.savePage())) {
1278
+ return
1279
+ }
1280
+ this.missing = [this.questions[open].id];
1281
+ this.goTo(Math.floor(open / this.pageSize));
1282
+ return
1283
+ }
1284
+ this.missing = [];
1285
+ if (await this.savePage()) {
1286
+ await this.finish();
1287
+ }
1288
+ },
1289
+
981
1290
  /**
982
1291
  * Save this page and go back one.
983
1292
  *
@@ -1009,9 +1318,16 @@ var script = {
1009
1318
  /**
1010
1319
  * The run is done: dispatch `finishAction` when set, and emit `finished`.
1011
1320
  *
1321
+ * @param {string} [reason] `user`, or `deadline` when the time ran out.
1012
1322
  * @return {Promise<void>}
1013
1323
  */
1014
- async finish() {
1324
+ async finish(reason = 'user') {
1325
+ if (this.closed) {
1326
+ return
1327
+ }
1328
+ this.finishedRun = true;
1329
+ clearInterval(this.deadlineTimer);
1330
+ this.deadlineTimer = null;
1015
1331
  const action = this.content?.finishAction;
1016
1332
  if (action && typeof action === 'object') {
1017
1333
  const resolved = resolveDeepTokens(action, this.tokenCtx);
@@ -1021,9 +1337,9 @@ var script = {
1021
1337
  this.liveText = translate('nextcloud-vue', 'Checklist finished.');
1022
1338
  /**
1023
1339
  * @event finished The last page was saved.
1024
- * @type {{answered: number, total: number}}
1340
+ * @type {{answered: number, total: number, reason: string}}
1025
1341
  */
1026
- this.$emit('finished', { answered: this.answeredCount, total: this.questions.length });
1342
+ this.$emit('finished', { answered: this.answeredCount, total: this.questions.length, reason });
1027
1343
  },
1028
1344
  },
1029
1345
  };