@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
|
@@ -4,7 +4,49 @@
|
|
|
4
4
|
-->
|
|
5
5
|
<template>
|
|
6
6
|
<div class="cn-duration-field">
|
|
7
|
-
<div v-if="
|
|
7
|
+
<div v-if="timer" class="cn-duration-field__row cn-duration-field__row--timer">
|
|
8
|
+
<NcTextField
|
|
9
|
+
class="cn-duration-field__clock"
|
|
10
|
+
:label="inputLabel"
|
|
11
|
+
:modelValue="clockText"
|
|
12
|
+
:disabled="disabled"
|
|
13
|
+
:error="error || clockInvalid"
|
|
14
|
+
:helperText="clockInvalid ? t('nextcloud-vue', 'Enter minutes, or minutes and seconds as 04:23.') : hint"
|
|
15
|
+
data-testid="cn-duration-clock"
|
|
16
|
+
@update:modelValue="onClock" />
|
|
17
|
+
<div
|
|
18
|
+
class="cn-duration-field__controls"
|
|
19
|
+
role="group"
|
|
20
|
+
:aria-label="timerLabel">
|
|
21
|
+
<NcButton
|
|
22
|
+
v-if="!running"
|
|
23
|
+
:disabled="disabled"
|
|
24
|
+
data-testid="cn-duration-start"
|
|
25
|
+
@click="start">
|
|
26
|
+
{{ t('nextcloud-vue', 'Start') }}
|
|
27
|
+
</NcButton>
|
|
28
|
+
<NcButton
|
|
29
|
+
v-else
|
|
30
|
+
:disabled="disabled"
|
|
31
|
+
data-testid="cn-duration-stop"
|
|
32
|
+
@click="stop">
|
|
33
|
+
{{ t('nextcloud-vue', 'Stop') }}
|
|
34
|
+
</NcButton>
|
|
35
|
+
<NcButton
|
|
36
|
+
variant="tertiary"
|
|
37
|
+
:disabled="disabled"
|
|
38
|
+
data-testid="cn-duration-reset"
|
|
39
|
+
@click="reset">
|
|
40
|
+
{{ t('nextcloud-vue', 'Reset') }}
|
|
41
|
+
</NcButton>
|
|
42
|
+
</div>
|
|
43
|
+
<span
|
|
44
|
+
class="cn-duration-field__state"
|
|
45
|
+
:class="{ 'cn-duration-field__state--running': running }"
|
|
46
|
+
role="status"
|
|
47
|
+
data-testid="cn-duration-state">{{ stateText }}</span>
|
|
48
|
+
</div>
|
|
49
|
+
<div v-else-if="!rawMode" class="cn-duration-field__row">
|
|
8
50
|
<NcTextField
|
|
9
51
|
class="cn-duration-field__amount"
|
|
10
52
|
type="number"
|
|
@@ -39,13 +81,37 @@
|
|
|
39
81
|
{{ t('nextcloud-vue', 'Edit as ISO') }}
|
|
40
82
|
</NcButton>
|
|
41
83
|
</div>
|
|
84
|
+
<div
|
|
85
|
+
v-if="timer && normSeconds"
|
|
86
|
+
class="cn-duration-field__norm"
|
|
87
|
+
:class="`cn-duration-field__norm--${normLevel}`"
|
|
88
|
+
data-testid="cn-duration-norm">
|
|
89
|
+
<div class="cn-duration-field__norm-line">
|
|
90
|
+
<span>{{ normText }}</span>
|
|
91
|
+
<span>{{ normPercent }}%</span>
|
|
92
|
+
<span v-if="normWords" data-testid="cn-duration-norm-words">{{ normWords }}</span>
|
|
93
|
+
</div>
|
|
94
|
+
<NcProgressBar
|
|
95
|
+
:value="Math.min(normPercent, 100)"
|
|
96
|
+
:error="normLevel === 'over'"
|
|
97
|
+
:aria-label="normText" />
|
|
98
|
+
</div>
|
|
42
99
|
</div>
|
|
43
100
|
</template>
|
|
44
101
|
|
|
45
102
|
<script>
|
|
46
103
|
import { translate as t } from '@nextcloud/l10n'
|
|
47
|
-
import { NcButton, NcSelect, NcTextField } from '@nextcloud/vue'
|
|
48
|
-
import {
|
|
104
|
+
import { NcButton, NcProgressBar, NcSelect, NcTextField } from '@nextcloud/vue'
|
|
105
|
+
import {
|
|
106
|
+
DURATION_UNITS,
|
|
107
|
+
durationSeconds,
|
|
108
|
+
formatClock,
|
|
109
|
+
formatDuration,
|
|
110
|
+
isIsoDuration,
|
|
111
|
+
parseClock,
|
|
112
|
+
parseDuration,
|
|
113
|
+
secondsToDuration,
|
|
114
|
+
} from '../../utils/isoDuration.js'
|
|
49
115
|
|
|
50
116
|
/**
|
|
51
117
|
* CnDurationField — edits an ISO 8601 duration as a number plus a unit
|
|
@@ -57,15 +123,21 @@ import { DURATION_UNITS, formatDuration, isIsoDuration, parseDuration } from '..
|
|
|
57
123
|
* with an "Edit as ISO" toggle, so nothing is rounded. Clearing the number
|
|
58
124
|
* writes `null`.
|
|
59
125
|
*
|
|
126
|
+
* With `timer` the field is a clock: Start, Stop and Reset run it, and it writes
|
|
127
|
+
* the running time into the value every second, so a form saved mid-run holds it.
|
|
128
|
+
* Typing a time stops the clock and keeps what was typed. `autoStart` starts it
|
|
129
|
+
* when the field holds no value yet. `norm` shows the time against a length.
|
|
130
|
+
*
|
|
60
131
|
* Example:
|
|
61
132
|
* ```vue
|
|
62
133
|
* <CnDurationField v-model="term" input-label="Handling term" />
|
|
134
|
+
* <CnDurationField v-model="length" input-label="Duration" timer auto-start norm="PT5M" />
|
|
63
135
|
* ```
|
|
64
136
|
*/
|
|
65
137
|
export default {
|
|
66
138
|
name: 'CnDurationField',
|
|
67
139
|
|
|
68
|
-
components: { NcButton, NcSelect, NcTextField },
|
|
140
|
+
components: { NcButton, NcProgressBar, NcSelect, NcTextField },
|
|
69
141
|
|
|
70
142
|
props: {
|
|
71
143
|
/** ISO 8601 duration string (v-model), or null. */
|
|
@@ -97,15 +169,64 @@ export default {
|
|
|
97
169
|
type: Boolean,
|
|
98
170
|
default: false,
|
|
99
171
|
},
|
|
172
|
+
|
|
173
|
+
/** Draw the field as a clock with Start, Stop and Reset. */
|
|
174
|
+
timer: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: false,
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
/** With `timer`: start the clock when the field holds no value yet. */
|
|
180
|
+
autoStart: {
|
|
181
|
+
type: Boolean,
|
|
182
|
+
default: false,
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/** With `timer`: an ISO 8601 length to show the time against. */
|
|
186
|
+
norm: {
|
|
187
|
+
type: String,
|
|
188
|
+
default: null,
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/** Percentage of `norm` from which the bar warns. */
|
|
192
|
+
normWarningPercent: {
|
|
193
|
+
type: Number,
|
|
194
|
+
default: 80,
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
/** Words before the time on the norm line. */
|
|
198
|
+
normLabel: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: '',
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
/** Accessible name of the Start, Stop and Reset group. */
|
|
204
|
+
timerLabel: {
|
|
205
|
+
type: String,
|
|
206
|
+
default: () => t('nextcloud-vue', 'Timer'),
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
/** With `timer`: a line under the clock. */
|
|
210
|
+
hint: {
|
|
211
|
+
type: String,
|
|
212
|
+
default: '',
|
|
213
|
+
},
|
|
100
214
|
},
|
|
101
215
|
|
|
102
|
-
emits: ['update:modelValue'],
|
|
216
|
+
emits: ['update:modelValue', 'started', 'stopped', 'reset'],
|
|
103
217
|
|
|
104
218
|
data() {
|
|
105
219
|
return {
|
|
106
220
|
unit: 'days',
|
|
107
221
|
editIso: false,
|
|
108
222
|
draftIso: null,
|
|
223
|
+
running: false,
|
|
224
|
+
hasRun: false,
|
|
225
|
+
startedAt: 0,
|
|
226
|
+
secondsBefore: 0,
|
|
227
|
+
elapsed: 0,
|
|
228
|
+
clockDraft: null,
|
|
229
|
+
interval: null,
|
|
109
230
|
}
|
|
110
231
|
},
|
|
111
232
|
|
|
@@ -154,9 +275,168 @@ export default {
|
|
|
154
275
|
unitOption() {
|
|
155
276
|
return this.unitOptions.find((o) => o.id === this.currentUnit) || null
|
|
156
277
|
},
|
|
278
|
+
|
|
279
|
+
clockInvalid() {
|
|
280
|
+
return this.clockDraft !== null && this.clockDraft.trim() !== '' && parseClock(this.clockDraft) === null
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
clockText() {
|
|
284
|
+
if (this.clockDraft !== null) {
|
|
285
|
+
return this.clockDraft
|
|
286
|
+
}
|
|
287
|
+
return this.running || this.hasValue ? formatClock(this.elapsed) : ''
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
stateText() {
|
|
291
|
+
if (this.running) {
|
|
292
|
+
return t('nextcloud-vue', 'Running')
|
|
293
|
+
}
|
|
294
|
+
return this.hasRun ? t('nextcloud-vue', 'Stopped') : ''
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
normSeconds() {
|
|
298
|
+
return this.norm ? durationSeconds(this.norm) : null
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
normPercent() {
|
|
302
|
+
return this.normSeconds ? Math.round((this.elapsed / this.normSeconds) * 100) : 0
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
normLevel() {
|
|
306
|
+
if (this.normPercent >= 100) {
|
|
307
|
+
return 'over'
|
|
308
|
+
}
|
|
309
|
+
return this.normPercent >= this.normWarningPercent ? 'near' : 'within'
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
normWords() {
|
|
313
|
+
if (this.normLevel === 'over') {
|
|
314
|
+
return t('nextcloud-vue', 'Over the norm')
|
|
315
|
+
}
|
|
316
|
+
return this.normLevel === 'near' ? t('nextcloud-vue', 'Close to the norm') : ''
|
|
317
|
+
},
|
|
318
|
+
|
|
319
|
+
normText() {
|
|
320
|
+
const amount = t('nextcloud-vue', '{elapsed} of {norm}', {
|
|
321
|
+
elapsed: formatClock(this.elapsed),
|
|
322
|
+
norm: formatClock(this.normSeconds),
|
|
323
|
+
})
|
|
324
|
+
return this.normLabel ? `${this.normLabel} ${amount}` : amount
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
watch: {
|
|
329
|
+
// The clock owns the value while it runs; the echo of its own write is ignored.
|
|
330
|
+
modelValue: {
|
|
331
|
+
immediate: true,
|
|
332
|
+
handler(value) {
|
|
333
|
+
if (!this.running) {
|
|
334
|
+
this.elapsed = durationSeconds(value) ?? 0
|
|
335
|
+
}
|
|
336
|
+
if (this.clockDraft !== null && secondsToDuration(parseClock(this.clockDraft)) !== value) {
|
|
337
|
+
this.clockDraft = null
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
autoStart() {
|
|
343
|
+
this.maybeAutoStart()
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
mounted() {
|
|
348
|
+
this.maybeAutoStart()
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
beforeUnmount() {
|
|
352
|
+
clearInterval(this.interval)
|
|
157
353
|
},
|
|
158
354
|
|
|
159
355
|
methods: {
|
|
356
|
+
t,
|
|
357
|
+
|
|
358
|
+
maybeAutoStart() {
|
|
359
|
+
if (this.timer && this.autoStart && !this.disabled && !this.hasRun && !this.hasValue) {
|
|
360
|
+
this.start()
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Run the clock from the time it shows now.
|
|
366
|
+
*
|
|
367
|
+
* @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
|
|
368
|
+
*/
|
|
369
|
+
start() {
|
|
370
|
+
if (this.running) {
|
|
371
|
+
return
|
|
372
|
+
}
|
|
373
|
+
this.clockDraft = null
|
|
374
|
+
this.secondsBefore = this.elapsed
|
|
375
|
+
this.startedAt = Date.now()
|
|
376
|
+
this.running = true
|
|
377
|
+
this.hasRun = true
|
|
378
|
+
this.interval = setInterval(this.tick, 1000)
|
|
379
|
+
/** @event started The clock started. */
|
|
380
|
+
this.$emit('started')
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
// Counted from the start time, because a background tab throttles intervals.
|
|
384
|
+
tick() {
|
|
385
|
+
this.elapsed = this.secondsBefore + Math.floor((Date.now() - this.startedAt) / 1000)
|
|
386
|
+
this.$emit('update:modelValue', secondsToDuration(this.elapsed))
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
halt() {
|
|
390
|
+
clearInterval(this.interval)
|
|
391
|
+
this.interval = null
|
|
392
|
+
this.running = false
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Stop the clock and write the final time.
|
|
397
|
+
*
|
|
398
|
+
* @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
|
|
399
|
+
*/
|
|
400
|
+
stop() {
|
|
401
|
+
if (!this.running) {
|
|
402
|
+
return
|
|
403
|
+
}
|
|
404
|
+
this.tick()
|
|
405
|
+
this.halt()
|
|
406
|
+
const value = secondsToDuration(this.elapsed)
|
|
407
|
+
/** @event stopped The clock stopped; carries the ISO string of the time. */
|
|
408
|
+
this.$emit('stopped', value)
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Stop the clock and clear the value.
|
|
413
|
+
*
|
|
414
|
+
* @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
|
|
415
|
+
*/
|
|
416
|
+
reset() {
|
|
417
|
+
this.halt()
|
|
418
|
+
this.elapsed = 0
|
|
419
|
+
this.clockDraft = null
|
|
420
|
+
this.hasRun = false
|
|
421
|
+
this.$emit('update:modelValue', null)
|
|
422
|
+
/** @event reset The clock stopped and the value was cleared. */
|
|
423
|
+
this.$emit('reset')
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
onClock(text) {
|
|
427
|
+
const seconds = parseClock(text)
|
|
428
|
+
this.clockDraft = text
|
|
429
|
+
if (String(text).trim() === '') {
|
|
430
|
+
this.halt()
|
|
431
|
+
this.elapsed = 0
|
|
432
|
+
this.$emit('update:modelValue', null)
|
|
433
|
+
} else if (seconds !== null) {
|
|
434
|
+
this.halt()
|
|
435
|
+
this.elapsed = seconds
|
|
436
|
+
this.$emit('update:modelValue', secondsToDuration(seconds))
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
|
|
160
440
|
onAmount(value) {
|
|
161
441
|
/** @event update:modelValue The ISO string for the chosen amount and unit; null when the amount is cleared. */
|
|
162
442
|
this.$emit('update:modelValue', formatDuration(value, this.currentUnit))
|
|
@@ -199,4 +479,49 @@ export default {
|
|
|
199
479
|
.cn-duration-field__unit {
|
|
200
480
|
min-width: 140px;
|
|
201
481
|
}
|
|
482
|
+
|
|
483
|
+
.cn-duration-field__row--timer {
|
|
484
|
+
flex-wrap: wrap;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.cn-duration-field__clock {
|
|
488
|
+
flex: 0 1 160px;
|
|
489
|
+
font-variant-numeric: tabular-nums;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.cn-duration-field__controls {
|
|
493
|
+
display: flex;
|
|
494
|
+
gap: 4px;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.cn-duration-field__state {
|
|
498
|
+
align-self: center;
|
|
499
|
+
color: var(--color-text-maxcontrast);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.cn-duration-field__state--running {
|
|
503
|
+
color: var(--color-success-text);
|
|
504
|
+
font-weight: bold;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.cn-duration-field__norm {
|
|
508
|
+
margin-top: 8px;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.cn-duration-field__norm-line {
|
|
512
|
+
display: flex;
|
|
513
|
+
flex-wrap: wrap;
|
|
514
|
+
gap: 8px;
|
|
515
|
+
justify-content: space-between;
|
|
516
|
+
margin-bottom: 4px;
|
|
517
|
+
font-variant-numeric: tabular-nums;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.cn-duration-field__norm--near .cn-duration-field__norm-line {
|
|
521
|
+
color: var(--color-warning-text);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.cn-duration-field__norm--over .cn-duration-field__norm-line {
|
|
525
|
+
color: var(--color-error-text);
|
|
526
|
+
}
|
|
202
527
|
</style>
|
|
@@ -731,6 +731,10 @@
|
|
|
731
731
|
:inputLabel="fieldLabelText(field)"
|
|
732
732
|
:disabled="field.readOnly"
|
|
733
733
|
:error="!!errors[field.key]"
|
|
734
|
+
:timer="field.timer === true"
|
|
735
|
+
:autoStart="field.autoStart === true"
|
|
736
|
+
:norm="field.norm || null"
|
|
737
|
+
:normLabel="field.normLabel || ''"
|
|
734
738
|
@update:modelValue="value => updateField(field.key, value)" />
|
|
735
739
|
<CnFieldHelper
|
|
736
740
|
:id="helpId(field)"
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
- SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
-->
|
|
5
|
+
<template>
|
|
6
|
+
<div class="cn-geo-capture" data-testid="cn-geo-capture">
|
|
7
|
+
<p class="cn-geo-capture__line" role="status" data-testid="cn-geo-capture-line">
|
|
8
|
+
{{ lineText }}
|
|
9
|
+
</p>
|
|
10
|
+
<template v-if="!searching && needsAddress">
|
|
11
|
+
<NcButton variant="tertiary" data-testid="cn-geo-capture-retry" @click="retry">
|
|
12
|
+
{{ t('nextcloud-vue', 'Try again') }}
|
|
13
|
+
</NcButton>
|
|
14
|
+
<NcTextField
|
|
15
|
+
:modelValue="modelValue?.address || ''"
|
|
16
|
+
:label="t('nextcloud-vue', 'Address (by hand)')"
|
|
17
|
+
data-testid="cn-geo-capture-address"
|
|
18
|
+
@update:modelValue="setAddress" />
|
|
19
|
+
</template>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
25
|
+
import { NcButton, NcTextField } from '@nextcloud/vue'
|
|
26
|
+
import { captureLocation } from '../../utils/captureLocation.js'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* CnGeoCaptureField: the place something was recorded, captured from the
|
|
30
|
+
* device (board DqInspectie: "51.9012, 4.4831 · ±12 m · 10:52"). A fix whose
|
|
31
|
+
* accuracy is worse than `goodAccuracy`, or no fix at all, says so, offers a
|
|
32
|
+
* retry and takes an address by hand. The user can always carry on, and the
|
|
33
|
+
* value says how good it was through `low`.
|
|
34
|
+
*
|
|
35
|
+
* The value is `{ lat, lng, accuracy, at, low, address? }`, or null.
|
|
36
|
+
*
|
|
37
|
+
* ```vue
|
|
38
|
+
* <CnGeoCaptureField v-model="place" auto />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @event update:modelValue The new value.
|
|
42
|
+
* @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-a-field-captures-where-something-was-recorded
|
|
43
|
+
*/
|
|
44
|
+
export default {
|
|
45
|
+
name: 'CnGeoCaptureField',
|
|
46
|
+
|
|
47
|
+
components: { NcButton, NcTextField },
|
|
48
|
+
|
|
49
|
+
props: {
|
|
50
|
+
/** The captured place: `{ lat, lng, accuracy, at, low, address? }`, or null. */
|
|
51
|
+
modelValue: { type: Object, default: null },
|
|
52
|
+
/** Capture on mount when no value is held yet. */
|
|
53
|
+
auto: { type: Boolean, default: false },
|
|
54
|
+
/** A host is capturing; the field says it is looking. */
|
|
55
|
+
busy: { type: Boolean, default: false },
|
|
56
|
+
/** The accuracy in metres above which a fix counts as low. */
|
|
57
|
+
goodAccuracy: { type: Number, default: 50 },
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
emits: ['update:modelValue'],
|
|
61
|
+
|
|
62
|
+
data() {
|
|
63
|
+
return { capturing: false }
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
computed: {
|
|
67
|
+
/** @return {boolean} Whether a capture is under way. */
|
|
68
|
+
searching() {
|
|
69
|
+
return this.busy || this.capturing
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/** @return {boolean} Whether the value has coordinates. */
|
|
73
|
+
hasFix() {
|
|
74
|
+
return Number.isFinite(this.modelValue?.lat) && Number.isFinite(this.modelValue?.lng)
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/** @return {boolean} Whether the fix is missing or too rough. */
|
|
78
|
+
needsAddress() {
|
|
79
|
+
return !this.hasFix || this.modelValue.low === true
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/** @return {string} The state of the capture in words. */
|
|
83
|
+
lineText() {
|
|
84
|
+
if (this.searching) {
|
|
85
|
+
return t('nextcloud-vue', 'Looking for your location…')
|
|
86
|
+
}
|
|
87
|
+
if (!this.hasFix) {
|
|
88
|
+
return t('nextcloud-vue', 'No location found. You can carry on, or add the address by hand.')
|
|
89
|
+
}
|
|
90
|
+
const accuracy = Math.round(this.modelValue.accuracy)
|
|
91
|
+
if (this.modelValue.low === true) {
|
|
92
|
+
return t('nextcloud-vue', 'Location is inaccurate (±{accuracy} m). Wait for a better signal or add the address by hand.', { accuracy })
|
|
93
|
+
}
|
|
94
|
+
const time = new Date(this.modelValue.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
95
|
+
return `${this.modelValue.lat.toFixed(4)}, ${this.modelValue.lng.toFixed(4)} · ±${accuracy} m · ${time}`
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
mounted() {
|
|
100
|
+
if (this.auto && !this.modelValue) {
|
|
101
|
+
this.retry()
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
methods: {
|
|
106
|
+
t,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Ask the device again. A fix replaces what is held, keeping a typed
|
|
110
|
+
* address; no fix keeps it all.
|
|
111
|
+
*
|
|
112
|
+
* @return {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
async retry() {
|
|
115
|
+
this.capturing = true
|
|
116
|
+
const fix = await captureLocation()
|
|
117
|
+
this.capturing = false
|
|
118
|
+
if (fix) {
|
|
119
|
+
this.$emit('update:modelValue', { ...this.modelValue, ...fix, low: fix.accuracy > this.goodAccuracy })
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Keep the address typed by hand beside whatever fix there is.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} address The address.
|
|
127
|
+
* @return {void}
|
|
128
|
+
*/
|
|
129
|
+
setAddress(address) {
|
|
130
|
+
this.$emit('update:modelValue', { low: true, ...this.modelValue, address })
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style scoped>
|
|
137
|
+
.cn-geo-capture {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
gap: 6px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.cn-geo-capture__line {
|
|
144
|
+
color: var(--color-text-maxcontrast);
|
|
145
|
+
font-variant-numeric: tabular-nums;
|
|
146
|
+
margin: 0;
|
|
147
|
+
}
|
|
148
|
+
</style>
|