@conduction/nextcloud-vue 2.174.0 → 2.175.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
- package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +63 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +63 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1134 -499
- package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
- package/dist/esm/utils/captureLocation.js +32 -0
- package/dist/esm/utils/captureLocation.js.map +1 -0
- package/dist/esm/utils/childRecordTotals.js +157 -0
- package/dist/esm/utils/childRecordTotals.js.map +1 -0
- package/dist/esm/utils/isoDuration.js +51 -1
- package/dist/esm/utils/isoDuration.js.map +1 -1
- package/dist/esm/utils/qr.js +649 -0
- package/dist/esm/utils/qr.js.map +1 -0
- package/dist/esm/utils/schema.js +3 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/templateVariables.js +54 -0
- package/dist/esm/utils/templateVariables.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +20307 -14544
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1134 -499
- package/l10n/en.json +63 -1
- package/l10n/nl.json +63 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
- package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
- package/src/components/CnBlockListEditor/index.js +9 -0
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
- package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
- package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
- package/src/components/CnChoiceMatrix/index.js +9 -0
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
- package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
- package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
- package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
- package/src/components/CnDisplayScreen/index.js +9 -0
- package/src/components/CnDurationField/CnDurationField.vue +330 -5
- package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
- package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
- package/src/components/CnGeoCaptureField/index.js +9 -0
- package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
- package/src/components/CnQrCode/CnQrCode.vue +321 -0
- package/src/components/CnQrCode/index.js +9 -0
- package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
- package/src/components/CnRevealField/CnRevealField.vue +273 -0
- package/src/components/CnRevealField/index.js +9 -0
- package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
- package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
- package/src/components/CnTransferCard/index.js +9 -0
- package/src/components/CnTreeView/CnTreeNode.vue +145 -2
- package/src/components/CnTreeView/CnTreeView.vue +210 -6
- package/src/components/index.js +7 -0
- package/src/index.js +8 -0
- package/src/utils/captureLocation.js +29 -0
- package/src/utils/childRecordTotals.js +153 -0
- package/src/utils/isoDuration.js +50 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -6,18 +6,47 @@
|
|
|
6
6
|
<div class="cn-child-records-field">
|
|
7
7
|
<div class="cn-child-records-field__head">
|
|
8
8
|
<span class="cn-child-records-field__label">{{ inputLabel }}</span>
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
<div v-if="!disabled" class="cn-child-records-field__adds">
|
|
10
|
+
<CnSearchSelect
|
|
11
|
+
v-if="addFrom"
|
|
12
|
+
class="cn-child-records-field__pick"
|
|
13
|
+
data-testid="cn-child-records-add-from"
|
|
14
|
+
:modelValue="null"
|
|
15
|
+
:options="sourceOptions"
|
|
16
|
+
:loading="sourceLoading"
|
|
17
|
+
:inputLabel="addFromLabel"
|
|
18
|
+
:filterable="false"
|
|
19
|
+
@search="searchSource"
|
|
20
|
+
@update:modelValue="addFromPicked" />
|
|
21
|
+
<form
|
|
22
|
+
v-if="addFrom && addFrom.codeField"
|
|
23
|
+
class="cn-child-records-field__code"
|
|
24
|
+
data-testid="cn-child-records-code"
|
|
25
|
+
@submit.prevent="addByCode">
|
|
26
|
+
<NcTextField
|
|
27
|
+
:modelValue="code"
|
|
28
|
+
:label="codeLabel"
|
|
29
|
+
@update:modelValue="value => { code = value }" />
|
|
30
|
+
<NcButton type="submit" data-testid="cn-child-records-code-add">
|
|
31
|
+
{{ t('nextcloud-vue', 'Add') }}
|
|
32
|
+
</NcButton>
|
|
33
|
+
</form>
|
|
34
|
+
<NcButton
|
|
35
|
+
v-if="freeRows"
|
|
36
|
+
data-testid="cn-child-records-add"
|
|
37
|
+
@click="addRow">
|
|
38
|
+
{{ t('nextcloud-vue', 'Add row') }}
|
|
39
|
+
</NcButton>
|
|
40
|
+
</div>
|
|
15
41
|
</div>
|
|
16
42
|
<NcLoadingIcon v-if="loading" :name="t('nextcloud-vue', 'Loading …')" />
|
|
17
43
|
<table v-else class="cn-child-records-field__table">
|
|
18
44
|
<thead>
|
|
19
45
|
<tr>
|
|
20
|
-
<th v-for="col in columns"
|
|
46
|
+
<th v-for="col in columns"
|
|
47
|
+
:key="col.key"
|
|
48
|
+
scope="col"
|
|
49
|
+
:class="{ 'cn-child-records-field__num': col.numeric || col.computed }">
|
|
21
50
|
{{ col.label }}
|
|
22
51
|
</th>
|
|
23
52
|
<th v-if="!disabled" scope="col">
|
|
@@ -32,9 +61,10 @@
|
|
|
32
61
|
</td>
|
|
33
62
|
</tr>
|
|
34
63
|
<tr v-for="(row, index) in list" :key="index" data-testid="cn-child-records-row">
|
|
35
|
-
<td v-for="col in columns" :key="col.key">
|
|
64
|
+
<td v-for="col in columns" :key="col.key" :class="{ 'cn-child-records-field__num': col.numeric || col.computed }">
|
|
65
|
+
<span v-if="col.computed" data-testid="cn-child-records-computed">{{ computedText(row, col) }}</span>
|
|
36
66
|
<NcTextField
|
|
37
|
-
v-if="col.inline && !disabled"
|
|
67
|
+
v-else-if="col.inline && !disabled"
|
|
38
68
|
:modelValue="cellText(row, col)"
|
|
39
69
|
:label="`${col.label} ${index + 1}`"
|
|
40
70
|
:labelOutside="true"
|
|
@@ -55,7 +85,24 @@
|
|
|
55
85
|
</td>
|
|
56
86
|
</tr>
|
|
57
87
|
</tbody>
|
|
88
|
+
<tfoot v-if="totalRows.length > 0">
|
|
89
|
+
<tr v-for="totalRow in totalRows"
|
|
90
|
+
:key="totalRow.key"
|
|
91
|
+
:class="{ 'cn-child-records-field__total--emphasis': totalRow.emphasis }"
|
|
92
|
+
data-testid="cn-child-records-total">
|
|
93
|
+
<th scope="row" :colspan="Math.max(1, columns.length - 1)" class="cn-child-records-field__total-label">
|
|
94
|
+
{{ totalRow.label }}
|
|
95
|
+
</th>
|
|
96
|
+
<td class="cn-child-records-field__num" data-testid="cn-child-records-total-value">
|
|
97
|
+
{{ totalRow.text }}
|
|
98
|
+
</td>
|
|
99
|
+
<td v-if="!disabled" />
|
|
100
|
+
</tr>
|
|
101
|
+
</tfoot>
|
|
58
102
|
</table>
|
|
103
|
+
<p class="cn-child-records-field__sr" aria-live="polite" data-testid="cn-child-records-status">
|
|
104
|
+
{{ status }}
|
|
105
|
+
</p>
|
|
59
106
|
<p v-if="total > list.length" class="cn-child-records-field__more" data-testid="cn-child-records-more">
|
|
60
107
|
<template v-if="listUrl">
|
|
61
108
|
<a :href="listUrl">{{ moreLabel }}</a>
|
|
@@ -64,8 +111,8 @@
|
|
|
64
111
|
{{ moreLabel }}
|
|
65
112
|
</template>
|
|
66
113
|
</p>
|
|
67
|
-
<p v-if="error || problemText" class="cn-child-records-field__error" role="alert">
|
|
68
|
-
{{ error || problemText }}
|
|
114
|
+
<p v-if="error || problemText || addError" class="cn-child-records-field__error" role="alert">
|
|
115
|
+
{{ error || problemText || addError }}
|
|
69
116
|
</p>
|
|
70
117
|
<CnFormDialog
|
|
71
118
|
v-if="editing !== null && childSchema"
|
|
@@ -85,7 +132,10 @@ import { translate as t } from '@nextcloud/l10n'
|
|
|
85
132
|
import { generateUrl } from '@nextcloud/router'
|
|
86
133
|
import { NcButton, NcLoadingIcon, NcTextField } from '@nextcloud/vue'
|
|
87
134
|
import { defineAsyncComponent } from 'vue'
|
|
135
|
+
import CnSearchSelect from '../CnSearchSelect/CnSearchSelect.vue'
|
|
88
136
|
import { describeRowProblem, useChildRecords, validateChildRows } from '../../composables/useChildRecords.js'
|
|
137
|
+
import { computeRow, computeTotals, rowFromSource, storeComputed } from '../../utils/childRecordTotals.js'
|
|
138
|
+
import { formatMetricValue, normalizeMetricFormat } from '../../utils/formatMetric.js'
|
|
89
139
|
|
|
90
140
|
/**
|
|
91
141
|
* CnChildRecordsField — edits the records of another schema that point at this
|
|
@@ -99,6 +149,12 @@ import { describeRowProblem, useChildRecords, validateChildRows } from '../../co
|
|
|
99
149
|
* the parent's payload. Each row is checked against the child schema's
|
|
100
150
|
* required properties and the field reports the problems through `validity`.
|
|
101
151
|
*
|
|
152
|
+
* `config.computed` adds read-only columns worked out per row from a formula,
|
|
153
|
+
* `config.totals` adds total rows under the table (a sum over the rows, or a
|
|
154
|
+
* formula over the totals before it), and `config.addFrom` adds rows from
|
|
155
|
+
* another schema's records: picked from a search, or found by a typed or
|
|
156
|
+
* scanned code.
|
|
157
|
+
*
|
|
102
158
|
* ```vue
|
|
103
159
|
* <CnChildRecordsField v-model="lines" register="shop" :config="{ schema: 'order-line', parentField: 'order' }" parentId="o-1" />
|
|
104
160
|
* ```
|
|
@@ -109,6 +165,7 @@ export default {
|
|
|
109
165
|
components: {
|
|
110
166
|
// Lazy: CnFormDialog renders this field, so a static import is a cycle.
|
|
111
167
|
CnFormDialog: defineAsyncComponent(() => import('../CnFormDialog/CnFormDialog.vue')),
|
|
168
|
+
CnSearchSelect,
|
|
112
169
|
NcButton,
|
|
113
170
|
NcLoadingIcon,
|
|
114
171
|
NcTextField,
|
|
@@ -125,7 +182,16 @@ export default {
|
|
|
125
182
|
* The relation: `schema` (child schema slug), `parentField` (the child
|
|
126
183
|
* property pointing at the parent) and optional `columns` (keys shown).
|
|
127
184
|
*
|
|
128
|
-
*
|
|
185
|
+
* Optional `computed`: read-only columns, each `{ key, label, formula,
|
|
186
|
+
* format?, currency?, decimals?, store? }`; `store` writes the value into
|
|
187
|
+
* the row when the row changes. Optional `totals`: rows under the table,
|
|
188
|
+
* each `{ key, label, sum? | formula?, format?, currency?, decimals?,
|
|
189
|
+
* emphasis? }`. Optional `addFrom`: `{ schema, register?, map,
|
|
190
|
+
* titleField?, secondaryField?, label?, codeField?, codeLabel?,
|
|
191
|
+
* freeRows? }`, where `map` names per row key the source key to copy
|
|
192
|
+
* (`@id` for the source's id).
|
|
193
|
+
*
|
|
194
|
+
* @type {{schema: string, parentField: string, columns?: string[], computed?: object[], totals?: object[], addFrom?: object}}
|
|
129
195
|
*/
|
|
130
196
|
config: {
|
|
131
197
|
type: Object,
|
|
@@ -197,6 +263,13 @@ export default {
|
|
|
197
263
|
* @type {Array<{row: number, field: string, label: string}>}
|
|
198
264
|
*/
|
|
199
265
|
'validity',
|
|
266
|
+
/**
|
|
267
|
+
* The totals changed: the value per total key.
|
|
268
|
+
*
|
|
269
|
+
* @event totals
|
|
270
|
+
* @type {{[key: string]: number|null}}
|
|
271
|
+
*/
|
|
272
|
+
'totals',
|
|
200
273
|
],
|
|
201
274
|
|
|
202
275
|
data() {
|
|
@@ -205,6 +278,11 @@ export default {
|
|
|
205
278
|
childSchema: null,
|
|
206
279
|
total: 0,
|
|
207
280
|
editing: null,
|
|
281
|
+
sourceOptions: [],
|
|
282
|
+
sourceLoading: false,
|
|
283
|
+
code: '',
|
|
284
|
+
addError: '',
|
|
285
|
+
status: '',
|
|
208
286
|
}
|
|
209
287
|
},
|
|
210
288
|
|
|
@@ -225,11 +303,59 @@ export default {
|
|
|
225
303
|
}
|
|
226
304
|
keys = keys.slice(0, this.maxColumns)
|
|
227
305
|
}
|
|
228
|
-
|
|
306
|
+
const computedKeys = this.computedColumns.map((c) => c.key)
|
|
307
|
+
const plain = keys.filter((k) => k !== this.config.parentField && !computedKeys.includes(k)).map((key) => {
|
|
229
308
|
const type = props[key]?.type || 'string'
|
|
230
309
|
const inline = ['string', 'number', 'integer'].includes(type) && !props[key]?.enum && !props[key]?.$ref
|
|
231
310
|
return { key, label: props[key]?.title || key, inline, numeric: type === 'number' || type === 'integer' }
|
|
232
311
|
})
|
|
312
|
+
const computed = this.computedColumns.map((c) => ({
|
|
313
|
+
key: c.key,
|
|
314
|
+
label: c.label || props[c.key]?.title || c.key,
|
|
315
|
+
computed: true,
|
|
316
|
+
format: normalizeMetricFormat(c) || { style: 'decimal', decimals: 2 },
|
|
317
|
+
}))
|
|
318
|
+
return [...plain, ...computed]
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
/** The computed columns as configured. */
|
|
322
|
+
computedColumns() {
|
|
323
|
+
return Array.isArray(this.config.computed) ? this.config.computed.filter((c) => c && c.key) : []
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
/** The totals per key. */
|
|
327
|
+
totals() {
|
|
328
|
+
return computeTotals(this.list, this.config.totals, this.computedColumns)
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
/** The total rows, each with its formatted text. */
|
|
332
|
+
totalRows() {
|
|
333
|
+
const totals = Array.isArray(this.config.totals) ? this.config.totals.filter((x) => x && x.key) : []
|
|
334
|
+
return totals.map((x) => ({
|
|
335
|
+
key: x.key,
|
|
336
|
+
label: x.label || x.key,
|
|
337
|
+
emphasis: !!x.emphasis,
|
|
338
|
+
text: formatMetricValue(this.totals[x.key], normalizeMetricFormat(x) || { style: 'decimal', decimals: 2 }),
|
|
339
|
+
}))
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
/** The add-from source, or null. */
|
|
343
|
+
addFrom() {
|
|
344
|
+
const source = this.config.addFrom
|
|
345
|
+
return source && typeof source === 'object' && source.schema ? source : null
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
/** Whether a free, empty row can be added. */
|
|
349
|
+
freeRows() {
|
|
350
|
+
return !this.addFrom || this.addFrom.freeRows !== false
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
addFromLabel() {
|
|
354
|
+
return this.addFrom?.label || t('nextcloud-vue', 'Add from a list')
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
codeLabel() {
|
|
358
|
+
return this.addFrom?.codeLabel || t('nextcloud-vue', 'Scan or type a code')
|
|
233
359
|
},
|
|
234
360
|
|
|
235
361
|
problems() {
|
|
@@ -260,6 +386,15 @@ export default {
|
|
|
260
386
|
parentId() {
|
|
261
387
|
this.load()
|
|
262
388
|
},
|
|
389
|
+
|
|
390
|
+
totals: {
|
|
391
|
+
immediate: true,
|
|
392
|
+
handler(totals) {
|
|
393
|
+
if (Object.keys(totals).length > 0) {
|
|
394
|
+
this.$emit('totals', totals)
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
},
|
|
263
398
|
},
|
|
264
399
|
|
|
265
400
|
created() {
|
|
@@ -319,10 +454,127 @@ export default {
|
|
|
319
454
|
* @param {string} value The typed value.
|
|
320
455
|
*/
|
|
321
456
|
setCell(index, col, value) {
|
|
322
|
-
const next = this.list.map((r, i) => (i === index ? { ...r, [col.key]: col.numeric && value !== '' ? Number(value) : value } : r))
|
|
457
|
+
const next = this.list.map((r, i) => (i === index ? this.withComputed({ ...r, [col.key]: col.numeric && value !== '' ? Number(value) : value }) : r))
|
|
323
458
|
this.$emit('update:modelValue', next)
|
|
324
459
|
},
|
|
325
460
|
|
|
461
|
+
/**
|
|
462
|
+
* The row with its stored computed columns written in.
|
|
463
|
+
*
|
|
464
|
+
* @param {object} row The row.
|
|
465
|
+
* @return {object} The row.
|
|
466
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-1
|
|
467
|
+
*/
|
|
468
|
+
withComputed(row) {
|
|
469
|
+
return storeComputed(row, this.computedColumns)
|
|
470
|
+
},
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* The text of a computed cell.
|
|
474
|
+
*
|
|
475
|
+
* @param {object} row The row.
|
|
476
|
+
* @param {{key: string, format: object}} col The computed column.
|
|
477
|
+
* @return {string} The text.
|
|
478
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-1
|
|
479
|
+
*/
|
|
480
|
+
computedText(row, col) {
|
|
481
|
+
return formatMetricValue(computeRow(row, this.computedColumns)[col.key], col.format)
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* The URL of the add-from source's objects.
|
|
486
|
+
*
|
|
487
|
+
* @param {URLSearchParams} params The query.
|
|
488
|
+
* @return {string} The URL.
|
|
489
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-3
|
|
490
|
+
*/
|
|
491
|
+
sourceUrl(params) {
|
|
492
|
+
const register = this.addFrom.register || this.register
|
|
493
|
+
return generateUrl(`${this.apiBase}/objects/${register}/${this.addFrom.schema}?${params.toString()}`)
|
|
494
|
+
},
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Search the add-from source.
|
|
498
|
+
*
|
|
499
|
+
* @param {string} query The typed text.
|
|
500
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-3
|
|
501
|
+
*/
|
|
502
|
+
async searchSource(query) {
|
|
503
|
+
if (!query) {
|
|
504
|
+
this.sourceOptions = []
|
|
505
|
+
return
|
|
506
|
+
}
|
|
507
|
+
this.sourceLoading = true
|
|
508
|
+
try {
|
|
509
|
+
const response = await axios.get(this.sourceUrl(new URLSearchParams({ _search: query, _limit: '20' })))
|
|
510
|
+
const results = Array.isArray(response?.data?.results) ? response.data.results : []
|
|
511
|
+
const titleField = this.addFrom.titleField || 'name'
|
|
512
|
+
this.sourceOptions = results.map((source) => ({
|
|
513
|
+
id: String(source.id ?? source.uuid),
|
|
514
|
+
label: String(source[titleField] ?? source.id ?? ''),
|
|
515
|
+
secondary: this.addFrom.secondaryField ? String(source[this.addFrom.secondaryField] ?? '') : '',
|
|
516
|
+
source,
|
|
517
|
+
}))
|
|
518
|
+
} catch {
|
|
519
|
+
this.sourceOptions = []
|
|
520
|
+
}
|
|
521
|
+
this.sourceLoading = false
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* A source record was picked: add a row from it.
|
|
526
|
+
*
|
|
527
|
+
* @param {string|null} id The picked option's id.
|
|
528
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-3
|
|
529
|
+
*/
|
|
530
|
+
addFromPicked(id) {
|
|
531
|
+
const option = this.sourceOptions.find((o) => o.id === id)
|
|
532
|
+
if (option) {
|
|
533
|
+
this.addSourceRow(option.source)
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Find the source record with the typed or scanned code and add a row from it.
|
|
539
|
+
*
|
|
540
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-3
|
|
541
|
+
*/
|
|
542
|
+
async addByCode() {
|
|
543
|
+
const code = String(this.code || '').trim()
|
|
544
|
+
if (code === '') {
|
|
545
|
+
return
|
|
546
|
+
}
|
|
547
|
+
this.addError = ''
|
|
548
|
+
try {
|
|
549
|
+
const response = await axios.get(this.sourceUrl(new URLSearchParams({ [this.addFrom.codeField]: code, _limit: '2' })))
|
|
550
|
+
const results = Array.isArray(response?.data?.results) ? response.data.results : []
|
|
551
|
+
if (results.length === 1) {
|
|
552
|
+
this.addSourceRow(results[0])
|
|
553
|
+
this.code = ''
|
|
554
|
+
} else if (results.length === 0) {
|
|
555
|
+
this.addError = t('nextcloud-vue', 'No record has the code {code}.', { code })
|
|
556
|
+
} else {
|
|
557
|
+
this.addError = t('nextcloud-vue', 'More than one record has the code {code}.', { code })
|
|
558
|
+
}
|
|
559
|
+
} catch {
|
|
560
|
+
this.addError = t('nextcloud-vue', 'The code {code} could not be looked up.', { code })
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Append a row made from a source record.
|
|
566
|
+
*
|
|
567
|
+
* @param {object} source The source record.
|
|
568
|
+
* @spec openspec/changes/child-records-totals/tasks.md#task-3
|
|
569
|
+
*/
|
|
570
|
+
addSourceRow(source) {
|
|
571
|
+
this.addError = ''
|
|
572
|
+
const row = this.withComputed(rowFromSource(source, this.addFrom.map))
|
|
573
|
+
this.$emit('update:modelValue', [...this.list, row])
|
|
574
|
+
const name = source?.[this.addFrom.titleField || 'name'] ?? ''
|
|
575
|
+
this.status = t('nextcloud-vue', 'Added {name}.', { name: String(name) })
|
|
576
|
+
},
|
|
577
|
+
|
|
326
578
|
/** Append an empty row. */
|
|
327
579
|
addRow() {
|
|
328
580
|
this.$emit('update:modelValue', [...this.list, {}])
|
|
@@ -344,7 +596,7 @@ export default {
|
|
|
344
596
|
*/
|
|
345
597
|
onRowConfirm(values) {
|
|
346
598
|
const index = this.editing
|
|
347
|
-
this.$emit('update:modelValue', this.list.map((r, i) => (i === index ? { ...r, ...values } : r)))
|
|
599
|
+
this.$emit('update:modelValue', this.list.map((r, i) => (i === index ? this.withComputed({ ...r, ...values }) : r)))
|
|
348
600
|
this.editing = null
|
|
349
601
|
},
|
|
350
602
|
},
|
|
@@ -364,6 +616,45 @@ export default {
|
|
|
364
616
|
font-weight: 600;
|
|
365
617
|
}
|
|
366
618
|
|
|
619
|
+
.cn-child-records-field__head {
|
|
620
|
+
flex-wrap: wrap;
|
|
621
|
+
gap: 8px;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
.cn-child-records-field__adds,
|
|
625
|
+
.cn-child-records-field__code {
|
|
626
|
+
display: flex;
|
|
627
|
+
flex-wrap: wrap;
|
|
628
|
+
align-items: flex-end;
|
|
629
|
+
gap: 8px;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.cn-child-records-field__pick {
|
|
633
|
+
min-width: 240px;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.cn-child-records-field__table th.cn-child-records-field__num,
|
|
637
|
+
.cn-child-records-field__table td.cn-child-records-field__num {
|
|
638
|
+
text-align: end;
|
|
639
|
+
font-variant-numeric: tabular-nums;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.cn-child-records-field__table tfoot th,
|
|
643
|
+
.cn-child-records-field__table tfoot td {
|
|
644
|
+
border-bottom: none;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.cn-child-records-field__table .cn-child-records-field__total-label {
|
|
648
|
+
text-align: end;
|
|
649
|
+
font-weight: normal;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.cn-child-records-field__total--emphasis th,
|
|
653
|
+
.cn-child-records-field__total--emphasis td {
|
|
654
|
+
font-weight: 600;
|
|
655
|
+
border-top: 1px solid var(--color-border);
|
|
656
|
+
}
|
|
657
|
+
|
|
367
658
|
.cn-child-records-field__table {
|
|
368
659
|
width: 100%;
|
|
369
660
|
border-collapse: collapse;
|