@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.
- 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 +323 -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 +255 -10
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +70 -28
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +55 -6
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.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/CnIndexPage/CnIndexPage.vue2.js +40 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- 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/CnStorePage/CnStorePage.vue.js +1 -1
- package/dist/esm/components/CnStorePage/CnStorePage.vue2.js +3 -3
- package/dist/esm/components/CnStorePage/CnStorePage.vue2.js.map +1 -1
- package/dist/esm/components/CnStorePage/CnStorePage.vue3.js +5 -5
- package/dist/esm/components/CnStorePage/CnStorePage.vue3.js.map +1 -1
- package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue.js +1 -1
- package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js +6 -6
- package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js +1 -1
- package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js.map +1 -1
- 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 +79 -14
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +79 -14
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1162 -523
- 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/parentCrumb.js +86 -0
- package/dist/esm/utils/parentCrumb.js.map +1 -0
- 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 +21125 -15025
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1162 -523
- package/l10n/en.json +79 -14
- package/l10n/nl.json +79 -14
- 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 +377 -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 +304 -17
- package/src/components/CnDetailPage/CnDetailPage.vue +55 -6
- 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/CnIndexPage/CnIndexPage.vue +40 -1
- 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/CnStorePage/CnStorePage.vue +8 -8
- package/src/components/CnStorePage/CnStorePublishDialog.vue +7 -7
- 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/parentCrumb.js +83 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -38,15 +38,27 @@
|
|
|
38
38
|
data-testid="cn-countdown-progress">
|
|
39
39
|
<span class="cn-countdown-widget__progress-fill" :style="{ width: `${progress}%` }" />
|
|
40
40
|
</span>
|
|
41
|
-
<
|
|
42
|
-
v-if="
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
<CnNoteCard
|
|
42
|
+
v-if="stateNotice"
|
|
43
|
+
class="cn-countdown-widget__notice"
|
|
44
|
+
:type="stateNotice.type"
|
|
45
|
+
:heading="stateNotice.lead || undefined"
|
|
46
|
+
:text="stateNotice.text"
|
|
47
|
+
data-testid="cn-countdown-notice" />
|
|
48
|
+
<div v-if="actionButtons.length" class="cn-countdown-widget__actions">
|
|
49
|
+
<button
|
|
50
|
+
v-for="button in actionButtons"
|
|
51
|
+
:key="button.index"
|
|
52
|
+
type="button"
|
|
53
|
+
class="cn-countdown-widget__action"
|
|
54
|
+
:class="{ 'cn-countdown-widget__action--primary': button.primary }"
|
|
55
|
+
:disabled="button.disabled"
|
|
56
|
+
:aria-disabled="button.disabled ? 'true' : null"
|
|
57
|
+
data-testid="cn-countdown-action"
|
|
58
|
+
@click="runAction(button.action)">
|
|
59
|
+
{{ button.label }}
|
|
60
|
+
</button>
|
|
61
|
+
</div>
|
|
50
62
|
</div>
|
|
51
63
|
</div>
|
|
52
64
|
</template>
|
|
@@ -54,6 +66,7 @@
|
|
|
54
66
|
<script>
|
|
55
67
|
import { translate as t } from '@nextcloud/l10n'
|
|
56
68
|
import { inject } from 'vue'
|
|
69
|
+
import CnNoteCard from '../CnNoteCard/CnNoteCard.vue'
|
|
57
70
|
import CnWidgetIcon from '../CnWidgetGrid/CnWidgetIcon.vue'
|
|
58
71
|
import { getByPath } from '../../composables/useEndpointSource.js'
|
|
59
72
|
import { normalizeLook } from '../../composables/useLook.js'
|
|
@@ -64,6 +77,18 @@ import { userLocale } from '../../utils/userLocale.js'
|
|
|
64
77
|
|
|
65
78
|
const MS_PER_DAY = 24 * 60 * 60 * 1000
|
|
66
79
|
|
|
80
|
+
/** The note-card types a state notice may take. */
|
|
81
|
+
const NOTICE_TYPES = ['success', 'info', 'warning', 'error']
|
|
82
|
+
|
|
83
|
+
/** The note-card type of each state's notice when the notice names none. */
|
|
84
|
+
const DEFAULT_NOTICE_TYPES = Object.freeze({
|
|
85
|
+
onTrack: 'info',
|
|
86
|
+
warning: 'warning',
|
|
87
|
+
danger: 'error',
|
|
88
|
+
overdue: 'error',
|
|
89
|
+
extended: 'info',
|
|
90
|
+
})
|
|
91
|
+
|
|
67
92
|
const VARIANT_COLORS = Object.freeze({
|
|
68
93
|
default: 'var(--color-primary-element)',
|
|
69
94
|
success: 'var(--color-success)',
|
|
@@ -113,6 +138,33 @@ const VARIANT_COLORS = Object.freeze({
|
|
|
113
138
|
* content: { field: 'deadline', settledField: 'isFinalStatus', settledLabel: 'Handled' }
|
|
114
139
|
* ```
|
|
115
140
|
*
|
|
141
|
+
* ## The states of a term
|
|
142
|
+
*
|
|
143
|
+
* A term card reads differently as its date nears. `states` gives each state
|
|
144
|
+
* its own headline, caption and notice, and `actions` puts several buttons
|
|
145
|
+
* under the card, each greyed out in the states its `disabledIn` names:
|
|
146
|
+
*
|
|
147
|
+
* ```js
|
|
148
|
+
* content: {
|
|
149
|
+
* field: 'deadline',
|
|
150
|
+
* thresholds: { warn: 14, danger: 7 },
|
|
151
|
+
* extendedField: 'extendedOn',
|
|
152
|
+
* states: {
|
|
153
|
+
* warning: { notice: { lead: 'Watch the term', text: 'Two weeks left.' } },
|
|
154
|
+
* overdue: { headline: 'Term passed', caption: 'Was due {date}, {count} days ago' },
|
|
155
|
+
* },
|
|
156
|
+
* actions: [
|
|
157
|
+
* { label: 'Extend', type: 'handler', handler: 'extendTerm', disabledIn: ['overdue', 'extended'] },
|
|
158
|
+
* { label: 'Suspend', type: 'handler', handler: 'suspendTerm' },
|
|
159
|
+
* ],
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* The state is `overdue` past the date, else `danger` or `warning` by the
|
|
164
|
+
* thresholds, else `extended` when `extendedField` is truthy, else `onTrack`.
|
|
165
|
+
* `extended` also counts for `disabledIn` while a threshold applies, so a
|
|
166
|
+
* term extended once cannot be extended again a week before its end.
|
|
167
|
+
*
|
|
116
168
|
* ## An unset date
|
|
117
169
|
*
|
|
118
170
|
* Renders a dash and no threshold colour. A case with no deadline is not urgent
|
|
@@ -123,6 +175,7 @@ export default {
|
|
|
123
175
|
name: 'CnCountdownWidget',
|
|
124
176
|
|
|
125
177
|
components: {
|
|
178
|
+
CnNoteCard,
|
|
126
179
|
CnWidgetIcon,
|
|
127
180
|
},
|
|
128
181
|
|
|
@@ -144,8 +197,11 @@ export default {
|
|
|
144
197
|
* - `emptyLabel` — the headline while the date is unset (default a dash).
|
|
145
198
|
* - `emptyCaption` — the line under it while the date is unset, with `{date}` read from `emptyDateField`.
|
|
146
199
|
* - `facts` — `[{ label, field }]` rows under the caption.
|
|
200
|
+
* - `extendedField` — property on the record that is truthy once the term has been extended.
|
|
201
|
+
* - `states` — per state (`onTrack`, `warning`, `danger`, `overdue`, `extended`) a `{ headline?, caption?, notice?: { lead?, text?, type? } }`; texts take `{date}` and `{count}` and run through the host's translate.
|
|
202
|
+
* - `actions` — several manifest actions under the card, each with an optional `disabledIn` list of states.
|
|
147
203
|
*
|
|
148
|
-
* @type {{ field?: string, label?: string, icon?: string, thresholds?: {warn?: number, danger?: number}, showDate?: boolean, settledField?: string, settledLabel?: string, daysLabel?: {one?: string, other?: string}, caption?: string, startField?: string, action?: object, emptyLabel?: string, emptyCaption?: string, emptyDateField?: string, facts?: Array<{label: string, field: string}> }}
|
|
204
|
+
* @type {{ field?: string, label?: string, icon?: string, thresholds?: {warn?: number, danger?: number}, showDate?: boolean, settledField?: string, settledLabel?: string, daysLabel?: {one?: string, other?: string}, caption?: string, startField?: string, action?: object, emptyLabel?: string, emptyCaption?: string, emptyDateField?: string, facts?: Array<{label: string, field: string}>, extendedField?: string, states?: object, actions?: Array<object> }}
|
|
149
205
|
*/
|
|
150
206
|
content: {
|
|
151
207
|
type: Object,
|
|
@@ -261,6 +317,9 @@ export default {
|
|
|
261
317
|
return t('nextcloud-vue', 'Closed')
|
|
262
318
|
}
|
|
263
319
|
const days = this.daysRemaining
|
|
320
|
+
if (this.stateConfig.headline) {
|
|
321
|
+
return this.fillStateText(this.stateConfig.headline)
|
|
322
|
+
}
|
|
264
323
|
if (days === null) {
|
|
265
324
|
return this.content?.emptyLabel ? this.translate(this.content.emptyLabel) : '—'
|
|
266
325
|
}
|
|
@@ -338,22 +397,109 @@ export default {
|
|
|
338
397
|
.filter((row) => row.value !== '')
|
|
339
398
|
},
|
|
340
399
|
|
|
341
|
-
/**
|
|
342
|
-
|
|
343
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Whether the record says its term has been extended (`extendedField`).
|
|
402
|
+
*
|
|
403
|
+
* @return {boolean} True for an extended term.
|
|
404
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-a-term-card-reads-per-state
|
|
405
|
+
*/
|
|
406
|
+
isExtended() {
|
|
407
|
+
const field = this.content?.extendedField
|
|
408
|
+
return Boolean(field && this.record && getByPath(this.record, field))
|
|
344
409
|
},
|
|
345
410
|
|
|
346
411
|
/**
|
|
347
|
-
* The
|
|
412
|
+
* The state of the term: `overdue`, `danger`, `warning`, `extended` or
|
|
413
|
+
* `onTrack`; null while the date is unset or the record is settled.
|
|
348
414
|
*
|
|
349
|
-
* @return {string} The
|
|
350
|
-
* @spec openspec/changes/countdown-
|
|
415
|
+
* @return {string|null} The state.
|
|
416
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-a-term-card-reads-per-state
|
|
417
|
+
*/
|
|
418
|
+
termState() {
|
|
419
|
+
if (this.daysRemaining === null || this.isSettled) {
|
|
420
|
+
return null
|
|
421
|
+
}
|
|
422
|
+
if (this.daysRemaining < 0) {
|
|
423
|
+
return 'overdue'
|
|
424
|
+
}
|
|
425
|
+
if (this.variant === 'error') {
|
|
426
|
+
return 'danger'
|
|
427
|
+
}
|
|
428
|
+
if (this.variant === 'warning') {
|
|
429
|
+
return 'warning'
|
|
430
|
+
}
|
|
431
|
+
return this.isExtended ? 'extended' : 'onTrack'
|
|
432
|
+
},
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Every state that holds now: the term state, plus `extended` while a
|
|
436
|
+
* threshold or the date outranks it.
|
|
437
|
+
*
|
|
438
|
+
* @return {string[]} The states.
|
|
439
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-an-action-can-be-greyed-out-per-state
|
|
440
|
+
*/
|
|
441
|
+
activeStates() {
|
|
442
|
+
if (this.termState === null) {
|
|
443
|
+
return []
|
|
444
|
+
}
|
|
445
|
+
return this.isExtended && this.termState !== 'extended' ? [this.termState, 'extended'] : [this.termState]
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* The `states` entry of the current state, or an empty object.
|
|
450
|
+
*
|
|
451
|
+
* @return {{headline?: string, caption?: string, notice?: object}} The entry.
|
|
452
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-a-term-card-reads-per-state
|
|
453
|
+
*/
|
|
454
|
+
stateConfig() {
|
|
455
|
+
const states = this.content?.states
|
|
456
|
+
const entry = this.termState && states && typeof states === 'object' ? states[this.termState] : null
|
|
457
|
+
return entry && typeof entry === 'object' ? entry : {}
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The notice of the current state, its texts filled in, or null.
|
|
462
|
+
*
|
|
463
|
+
* @return {{lead: string, text: string, type: string}|null} The notice.
|
|
464
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-a-term-card-reads-per-state
|
|
351
465
|
*/
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
466
|
+
stateNotice() {
|
|
467
|
+
const notice = this.stateConfig.notice
|
|
468
|
+
if (!notice || typeof notice !== 'object' || (!notice.lead && !notice.text)) {
|
|
469
|
+
return null
|
|
470
|
+
}
|
|
471
|
+
const type = NOTICE_TYPES.includes(notice.type) ? notice.type : DEFAULT_NOTICE_TYPES[this.termState]
|
|
472
|
+
return {
|
|
473
|
+
lead: notice.lead ? this.fillStateText(notice.lead) : '',
|
|
474
|
+
text: notice.text ? this.fillStateText(notice.text) : '',
|
|
475
|
+
type,
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* The buttons under the card: `content.actions`, or `content.action`
|
|
481
|
+
* alone, each greyed out while a state its `disabledIn` names holds.
|
|
482
|
+
*
|
|
483
|
+
* @return {Array<{index: number, label: string, primary: boolean, disabled: boolean, action: object}>} The buttons.
|
|
484
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-an-action-can-be-greyed-out-per-state
|
|
485
|
+
*/
|
|
486
|
+
actionButtons() {
|
|
487
|
+
const list = Array.isArray(this.content?.actions) ? this.content.actions : [this.content?.action]
|
|
488
|
+
return list
|
|
489
|
+
.map((action, index) => ({ action, index }))
|
|
490
|
+
.filter(({ action }) => action && typeof action === 'object' && typeof action.label === 'string' && action.label !== '')
|
|
491
|
+
.map(({ action, index }) => ({
|
|
492
|
+
index,
|
|
493
|
+
label: this.translate(action.label),
|
|
494
|
+
primary: action.variant === 'primary',
|
|
495
|
+
disabled: Array.isArray(action.disabledIn) && action.disabledIn.some((state) => this.activeStates.includes(state)),
|
|
496
|
+
action,
|
|
497
|
+
}))
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
/** @return {string} The accessible name of the progress bar. */
|
|
501
|
+
progressLabel() {
|
|
502
|
+
return t('nextcloud-vue', 'Time passed')
|
|
357
503
|
},
|
|
358
504
|
|
|
359
505
|
/**
|
|
@@ -372,6 +518,9 @@ export default {
|
|
|
372
518
|
if (!this.targetDate || this.content?.showDate === false) {
|
|
373
519
|
return ''
|
|
374
520
|
}
|
|
521
|
+
if (this.stateConfig.caption) {
|
|
522
|
+
return this.fillStateText(this.stateConfig.caption)
|
|
523
|
+
}
|
|
375
524
|
const date = this.targetDate.toLocaleDateString(userLocale(), { day: 'numeric', month: 'long', year: 'numeric' })
|
|
376
525
|
const caption = this.content?.caption
|
|
377
526
|
if (typeof caption === 'string' && caption !== '') {
|
|
@@ -440,20 +589,38 @@ export default {
|
|
|
440
589
|
},
|
|
441
590
|
|
|
442
591
|
/**
|
|
443
|
-
*
|
|
444
|
-
* the
|
|
592
|
+
* A state text through the host's translate, with `{date}` the long
|
|
593
|
+
* date and `{count}` the days left, or the days past once overdue.
|
|
594
|
+
*
|
|
595
|
+
* @param {string} text The text.
|
|
596
|
+
* @return {string} The filled text.
|
|
597
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-a-term-card-reads-per-state
|
|
598
|
+
*/
|
|
599
|
+
fillStateText(text) {
|
|
600
|
+
const date = this.targetDate ? this.targetDate.toLocaleDateString(userLocale(), { day: 'numeric', month: 'long', year: 'numeric' }) : ''
|
|
601
|
+
const count = this.daysRemaining === null ? '' : String(Math.abs(this.daysRemaining))
|
|
602
|
+
return this.translate(text).replace(/\{date\}/g, date).replace(/\{count\}/g, count)
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Dispatch a manifest action with the record's tokens resolved, through
|
|
607
|
+
* the page's dispatcher when there is one. A greyed-out action does nothing.
|
|
445
608
|
*
|
|
609
|
+
* @param {object} [action] The action; `content.action` when left out.
|
|
446
610
|
* @return {unknown}
|
|
447
|
-
* @spec openspec/changes/countdown-
|
|
611
|
+
* @spec openspec/changes/countdown-term-states/specs/countdown-term-states/spec.md#requirement-an-action-can-be-greyed-out-per-state
|
|
448
612
|
*/
|
|
449
|
-
runAction() {
|
|
450
|
-
const action = this.content?.action
|
|
613
|
+
runAction(action = this.content?.action) {
|
|
451
614
|
if (!action || typeof action !== 'object') {
|
|
452
615
|
return undefined
|
|
453
616
|
}
|
|
454
617
|
const ctx = resolveObjectTokenContext(this.cnObjectContextInjected, this.cnDetailObjectContextInjected) || {}
|
|
455
618
|
const tokenCtx = { ...ctx, object: this.record || ctx.object || null, objectId: this.record?.id ?? ctx.objectId ?? null }
|
|
456
|
-
const
|
|
619
|
+
const { disabledIn, ...declared } = action
|
|
620
|
+
if (Array.isArray(disabledIn) && disabledIn.some((state) => this.activeStates.includes(state))) {
|
|
621
|
+
return undefined
|
|
622
|
+
}
|
|
623
|
+
const resolved = resolveDeepTokens(declared, tokenCtx)
|
|
457
624
|
if (typeof this.cnDispatchAction === 'function') {
|
|
458
625
|
return this.cnDispatchAction(resolved)
|
|
459
626
|
}
|
|
@@ -518,6 +685,34 @@ export default {
|
|
|
518
685
|
margin: 0;
|
|
519
686
|
}
|
|
520
687
|
|
|
688
|
+
.cn-countdown-widget__actions {
|
|
689
|
+
align-self: stretch;
|
|
690
|
+
display: flex;
|
|
691
|
+
flex-wrap: wrap;
|
|
692
|
+
gap: 8px;
|
|
693
|
+
margin-block-start: 10px;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
.cn-countdown-widget__actions .cn-countdown-widget__action {
|
|
697
|
+
margin: 0;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.cn-countdown-widget__action:disabled {
|
|
701
|
+
background: var(--color-background-hover);
|
|
702
|
+
color: var(--color-text-maxcontrast);
|
|
703
|
+
cursor: not-allowed;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.cn-countdown-widget__notice {
|
|
707
|
+
align-self: stretch;
|
|
708
|
+
margin: 10px 0 0;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.cn-countdown-widget--board .cn-countdown-widget__actions,
|
|
712
|
+
.cn-countdown-widget--board .cn-countdown-widget__notice {
|
|
713
|
+
margin: 0;
|
|
714
|
+
}
|
|
715
|
+
|
|
521
716
|
.cn-countdown-widget__action--primary {
|
|
522
717
|
background: var(--color-primary-element-light);
|
|
523
718
|
color: var(--color-primary-element-light-text);
|
|
@@ -538,7 +733,7 @@ export default {
|
|
|
538
733
|
margin: 0;
|
|
539
734
|
}
|
|
540
735
|
|
|
541
|
-
.cn-countdown-widget__action:hover,
|
|
736
|
+
.cn-countdown-widget__action:not(:disabled):hover,
|
|
542
737
|
.cn-countdown-widget__action:focus-visible {
|
|
543
738
|
background: var(--color-background-hover);
|
|
544
739
|
}
|
|
@@ -27,6 +27,16 @@
|
|
|
27
27
|
:clearable="false"
|
|
28
28
|
:allowCreate="false"
|
|
29
29
|
@update:modelValue="(id) => onFieldUpdate({ key: field.key, value: id || '' })" />
|
|
30
|
+
<NcTextField
|
|
31
|
+
v-else-if="field.type === 'date' || field.type === 'number'"
|
|
32
|
+
:modelValue="form[field.key]"
|
|
33
|
+
:type="field.type"
|
|
34
|
+
:label="field.label"
|
|
35
|
+
:step="field.type === 'number' ? (field.step || 'any') : undefined"
|
|
36
|
+
:min="field.min"
|
|
37
|
+
:max="field.max"
|
|
38
|
+
:data-testid="`cn-create-form-input-${field.key}`"
|
|
39
|
+
@update:modelValue="(v) => onFieldUpdate({ key: field.key, value: v })" />
|
|
30
40
|
<NcCheckboxRadioSwitch
|
|
31
41
|
v-else-if="field.type === 'checkbox'"
|
|
32
42
|
:modelValue="form[field.key] === true"
|
|
@@ -46,6 +56,16 @@
|
|
|
46
56
|
</template>
|
|
47
57
|
|
|
48
58
|
<template #actions>
|
|
59
|
+
<span v-if="timerConfig && timerStartedAt !== null"
|
|
60
|
+
class="cn-create-form-widget__elapsed"
|
|
61
|
+
role="timer"
|
|
62
|
+
data-testid="cn-create-form-elapsed">{{ elapsedText }}</span>
|
|
63
|
+
<NcButton
|
|
64
|
+
v-if="timerConfig"
|
|
65
|
+
data-testid="cn-create-form-timer"
|
|
66
|
+
@click="toggleTimer">
|
|
67
|
+
{{ timerStartedAt === null ? timerStartLabel : timerStopLabel }}
|
|
68
|
+
</NcButton>
|
|
49
69
|
<NcButton
|
|
50
70
|
variant="primary"
|
|
51
71
|
:wide="content.wideSubmit !== false"
|
|
@@ -63,7 +83,7 @@
|
|
|
63
83
|
|
|
64
84
|
<script>
|
|
65
85
|
import { translate as t } from '@nextcloud/l10n'
|
|
66
|
-
import { NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'
|
|
86
|
+
import { NcButton, NcCheckboxRadioSwitch, NcTextField } from '@nextcloud/vue'
|
|
67
87
|
import { camelize } from 'vue'
|
|
68
88
|
import CnFormWidgetBase from '../CnFormWidgetBase/CnFormWidgetBase.vue'
|
|
69
89
|
import CnIcon from '../CnIcon/CnIcon.vue'
|
|
@@ -100,7 +120,7 @@ import { resolveDeepTokens, resolveFilterValue } from '../../utils/resolveFilter
|
|
|
100
120
|
export default {
|
|
101
121
|
name: 'CnCreateFormWidget',
|
|
102
122
|
|
|
103
|
-
components: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch },
|
|
123
|
+
components: { CnFormWidgetBase, CnIcon, CnResourceSelect, NcButton, NcCheckboxRadioSwitch, NcTextField },
|
|
104
124
|
|
|
105
125
|
inject: {
|
|
106
126
|
/** Page-level workspace context from CnDashboardPage, for `@workspace.<key>` defaults. */
|
|
@@ -121,6 +141,18 @@ export default {
|
|
|
121
141
|
type: Object,
|
|
122
142
|
default: () => ({}),
|
|
123
143
|
},
|
|
144
|
+
|
|
145
|
+
/** The record of a detail page, for `@objectId` in `values`. */
|
|
146
|
+
objectId: {
|
|
147
|
+
type: [String, Number],
|
|
148
|
+
default: null,
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/** The record of a detail page, for `@object.<field>` in `values`. */
|
|
152
|
+
objectData: {
|
|
153
|
+
type: Object,
|
|
154
|
+
default: null,
|
|
155
|
+
},
|
|
124
156
|
},
|
|
125
157
|
|
|
126
158
|
emits: ['saved'],
|
|
@@ -131,6 +163,8 @@ export default {
|
|
|
131
163
|
optionsByField: {},
|
|
132
164
|
saving: false,
|
|
133
165
|
errorMessage: '',
|
|
166
|
+
timerStartedAt: null,
|
|
167
|
+
timerNow: 0,
|
|
134
168
|
}
|
|
135
169
|
},
|
|
136
170
|
|
|
@@ -166,9 +200,9 @@ export default {
|
|
|
166
200
|
: { key: field.key, type: field.type === 'text' ? 'text' : 'custom', label: field.type === 'checkbox' ? '' : field.label }))
|
|
167
201
|
},
|
|
168
202
|
|
|
169
|
-
/** The fields drawn through a `field-<key>` slot
|
|
203
|
+
/** The fields drawn through a `field-<key>` slot. */
|
|
170
204
|
slotFields() {
|
|
171
|
-
return this.fields.filter((field) =>
|
|
205
|
+
return this.fields.filter((field) => ['reference', 'checkbox', 'date', 'number'].includes(field.type))
|
|
172
206
|
},
|
|
173
207
|
|
|
174
208
|
workspace() {
|
|
@@ -206,6 +240,27 @@ export default {
|
|
|
206
240
|
return t('nextcloud-vue', 'Creating…')
|
|
207
241
|
},
|
|
208
242
|
|
|
243
|
+
/** `content.timer` when it names a field of this form, else null. */
|
|
244
|
+
timerConfig() {
|
|
245
|
+
const timer = this.content.timer
|
|
246
|
+
return timer && this.fields.some((field) => field.key === timer.field) ? timer : null
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
timerStartLabel() {
|
|
250
|
+
return this.copy(this.timerConfig?.startLabel) || t('nextcloud-vue', 'Start timer')
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
timerStopLabel() {
|
|
254
|
+
return this.copy(this.timerConfig?.stopLabel) || t('nextcloud-vue', 'Stop timer')
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
/** The running timer as h:mm:ss. */
|
|
258
|
+
elapsedText() {
|
|
259
|
+
const seconds = Math.max(0, Math.floor((this.timerNow - this.timerStartedAt) / 1000))
|
|
260
|
+
const minutes = String(Math.floor(seconds / 60) % 60).padStart(2, '0')
|
|
261
|
+
return `${Math.floor(seconds / 3600)}:${minutes}:${String(seconds % 60).padStart(2, '0')}`
|
|
262
|
+
},
|
|
263
|
+
|
|
209
264
|
typeSlug() {
|
|
210
265
|
return `${this.register}-${this.schema}`
|
|
211
266
|
},
|
|
@@ -230,7 +285,37 @@ export default {
|
|
|
230
285
|
this.loadOptions()
|
|
231
286
|
},
|
|
232
287
|
|
|
288
|
+
beforeUnmount() {
|
|
289
|
+
clearInterval(this.timerInterval)
|
|
290
|
+
},
|
|
291
|
+
|
|
233
292
|
methods: {
|
|
293
|
+
/**
|
|
294
|
+
* Start the timer, or stop it and write the time into its field: hours
|
|
295
|
+
* with two decimals, minutes with `unit: "minutes"`, never less than the
|
|
296
|
+
* smallest step so a short run does not read as nothing.
|
|
297
|
+
*
|
|
298
|
+
* @spec openspec/changes/create-form-date-number-timer/specs/create-form-date-number-timer/spec.md#requirement-a-timer-fills-a-field
|
|
299
|
+
* @return {void}
|
|
300
|
+
*/
|
|
301
|
+
toggleTimer() {
|
|
302
|
+
if (this.timerStartedAt === null) {
|
|
303
|
+
this.timerStartedAt = Date.now()
|
|
304
|
+
this.timerNow = this.timerStartedAt
|
|
305
|
+
this.timerInterval = setInterval(() => {
|
|
306
|
+
this.timerNow = Date.now()
|
|
307
|
+
}, 1000)
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
clearInterval(this.timerInterval)
|
|
311
|
+
const milliseconds = Date.now() - this.timerStartedAt
|
|
312
|
+
this.timerStartedAt = null
|
|
313
|
+
const value = this.timerConfig.unit === 'minutes'
|
|
314
|
+
? Math.max(1, Math.round(milliseconds / 60000))
|
|
315
|
+
: Math.max(0.01, Math.round(milliseconds / 36000) / 100)
|
|
316
|
+
this.onFieldUpdate({ key: this.timerConfig.field, value: String(value) })
|
|
317
|
+
},
|
|
318
|
+
|
|
234
319
|
/**
|
|
235
320
|
* A manifest string through the host's translate, else the library's.
|
|
236
321
|
*
|
|
@@ -316,10 +401,11 @@ export default {
|
|
|
316
401
|
this.saving = true
|
|
317
402
|
this.errorMessage = ''
|
|
318
403
|
try {
|
|
319
|
-
const values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace })
|
|
404
|
+
const values = resolveDeepTokens(this.content.values || {}, { workspace: this.workspace, objectId: this.objectId, object: this.objectData })
|
|
320
405
|
const payload = { ...values }
|
|
321
406
|
for (const field of this.fields) {
|
|
322
|
-
|
|
407
|
+
const value = this.form[field.key]
|
|
408
|
+
payload[field.key] = field.type === 'number' && value !== '' && value !== null && value !== undefined ? Number(value) : value
|
|
323
409
|
}
|
|
324
410
|
if (typeof store.registerObjectType === 'function' && !store.objectTypeRegistry?.[this.typeSlug]) {
|
|
325
411
|
store.registerObjectType(this.typeSlug, this.schema, this.register)
|
|
@@ -352,4 +438,9 @@ export default {
|
|
|
352
438
|
font-weight: 600;
|
|
353
439
|
text-decoration: underline;
|
|
354
440
|
}
|
|
441
|
+
|
|
442
|
+
.cn-create-form-widget__elapsed {
|
|
443
|
+
align-self: center;
|
|
444
|
+
font-variant-numeric: tabular-nums;
|
|
445
|
+
}
|
|
355
446
|
</style>
|