@conduction/nextcloud-vue 2.79.0 → 2.80.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/CnActionButtons/CnActionButtons.vue2.js.map +1 -1
- package/dist/esm/components/CnActionButtons/CnActionButtons.vue3.js +3 -1
- package/dist/esm/components/CnActionButtons/CnActionButtons.vue3.js.map +1 -1
- package/dist/esm/components/CnActionsBar/CnActionsBar.vue2.js +32 -3
- package/dist/esm/components/CnActionsBar/CnActionsBar.vue2.js.map +1 -1
- package/dist/esm/components/CnActionsBar/CnActionsBar.vue3.js +10 -8
- package/dist/esm/components/CnActionsBar/CnActionsBar.vue3.js.map +1 -1
- package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js +39 -3
- package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +79 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +133 -96
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +1 -0
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +62 -4
- 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/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js +24 -0
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js +43 -4
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +11 -0
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js.map +1 -0
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +736 -0
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js +238 -0
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnFactsWidget/index.js +30 -0
- package/dist/esm/components/CnFactsWidget/index.js.map +1 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue.js +10 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue.js.map +1 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js +551 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js +183 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnFieldListWidget/index.js +29 -0
- package/dist/esm/components/CnFieldListWidget/index.js.map +1 -0
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js +65 -17
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +4 -4
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnFormPage/CnFormPage.vue2.js +18 -3
- package/dist/esm/components/CnFormPage/CnFormPage.vue2.js.map +1 -1
- package/dist/esm/components/CnFormPage/CnFormPage.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +305 -72
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +31 -13
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue.js +10 -0
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue.js.map +1 -0
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue2.js +99 -0
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue2.js.map +1 -0
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue3.js +48 -0
- package/dist/esm/components/CnIndexPage/CnIndexPageWidgets.vue3.js.map +1 -0
- package/dist/esm/components/CnPageRenderer/CnPageRenderer.vue2.js +29 -1
- package/dist/esm/components/CnPageRenderer/CnPageRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnPageRenderer/CnPageRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +10 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js.map +1 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +387 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +169 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnRecordListWidget/index.js +31 -0
- package/dist/esm/components/CnRecordListWidget/index.js.map +1 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue.js +10 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue.js.map +1 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue2.js +351 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue3.js +71 -0
- package/dist/esm/components/CnSectionsWidget/CnSectionsWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnSectionsWidget/index.js +35 -0
- package/dist/esm/components/CnSectionsWidget/index.js.map +1 -0
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js +81 -2
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue3.js +1 -0
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js +122 -7
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js +84 -23
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +4 -0
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
- package/dist/esm/components/CnWorkspaceFilterWidget/CnWorkspaceFilterWidget.vue2.js +106 -2
- package/dist/esm/components/CnWorkspaceFilterWidget/CnWorkspaceFilterWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnWorkspaceFilterWidget/CnWorkspaceFilterWidget.vue3.js +105 -53
- package/dist/esm/components/CnWorkspaceFilterWidget/CnWorkspaceFilterWidget.vue3.js.map +1 -1
- package/dist/esm/composables/useFormDraft.js +140 -9
- package/dist/esm/composables/useFormDraft.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/builtin/field-inspection/CnFieldInspectionCard.vue2.js +28 -20
- package/dist/esm/integrations/builtin/field-inspection/CnFieldInspectionCard.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/field-inspection/CnFieldInspectionCard.vue3.js +9 -0
- package/dist/esm/integrations/builtin/field-inspection/CnFieldInspectionCard.vue3.js.map +1 -1
- package/dist/esm/integrations/builtin/field-inspection.js +21 -0
- package/dist/esm/integrations/builtin/field-inspection.js.map +1 -1
- package/dist/esm/integrations/offline/checklistSubmission.js +141 -0
- package/dist/esm/integrations/offline/checklistSubmission.js.map +1 -0
- package/dist/esm/integrations/offline/fieldCollectionHelpers.js +70 -5
- package/dist/esm/integrations/offline/fieldCollectionHelpers.js.map +1 -1
- package/dist/esm/integrations/offline/index.js +2 -1
- package/dist/esm/integrations/offline/index.js.map +1 -1
- package/dist/esm/integrations/offline/offlineDb.js +6 -1
- package/dist/esm/integrations/offline/offlineDb.js.map +1 -1
- package/dist/esm/integrations/offline/syncReplayService.js +8 -2
- package/dist/esm/integrations/offline/syncReplayService.js.map +1 -1
- package/dist/esm/l10n/en.json.js +12 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +16 -2
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/nextcloud-vue.css +1000 -59
- package/dist/esm/utils/detailActionModel.js +60 -3
- package/dist/esm/utils/detailActionModel.js.map +1 -1
- package/dist/esm/utils/fillTemplate.js +114 -0
- package/dist/esm/utils/fillTemplate.js.map +1 -0
- package/dist/esm/utils/libraryWidgetKeys.js +4 -0
- package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
- package/dist/esm/utils/queryPresets.js +96 -0
- package/dist/esm/utils/queryPresets.js.map +1 -0
- package/dist/esm/utils/resolveFilterTokens.js +11 -0
- package/dist/esm/utils/resolveFilterTokens.js.map +1 -1
- package/dist/esm/utils/schema.js +21 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/sentinelTokens.js +3 -3
- package/dist/esm/utils/sentinelTokens.js.map +1 -1
- package/dist/esm/utils/validateManifestV2.compiled.js +3 -3
- package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
- package/dist/esm/utils/widgetDispatch.js +7 -1
- package/dist/esm/utils/widgetDispatch.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +12368 -7717
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1000 -59
- package/l10n/en.json +12 -1
- package/l10n/nl.json +16 -2
- package/package.json +1 -1
- package/src/components/CnActionButtons/CnActionButtons.vue +2 -0
- package/src/components/CnActionsBar/CnActionsBar.md +4 -0
- package/src/components/CnActionsBar/CnActionsBar.vue +42 -10
- package/src/components/CnBannerWidget/CnBannerWidget.vue +39 -3
- package/src/components/CnCellRenderer/CnCellRenderer.vue +188 -1
- package/src/components/CnDataTable/CnDataTable.vue +1 -0
- package/src/components/CnDetailPage/CnDetailPage.md +1 -1
- package/src/components/CnDetailPage/CnDetailPage.vue +63 -3
- package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +66 -0
- package/src/components/CnFactsWidget/CnFactsWidget.vue +1050 -0
- package/src/components/CnFactsWidget/index.js +29 -0
- package/src/components/CnFieldListWidget/CnFieldListWidget.vue +746 -0
- package/src/components/CnFieldListWidget/index.js +28 -0
- package/src/components/CnFormDialog/CnFormDialog.md +9 -3
- package/src/components/CnFormDialog/CnFormDialog.vue +69 -21
- package/src/components/CnFormPage/CnFormPage.vue +18 -3
- package/src/components/CnIndexPage/CnIndexPage.vue +254 -6
- package/src/components/CnIndexPage/CnIndexPageWidgets.vue +169 -0
- package/src/components/CnPageRenderer/CnPageRenderer.vue +29 -1
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +603 -0
- package/src/components/CnRecordListWidget/index.js +30 -0
- package/src/components/CnSectionsWidget/CnSectionsWidget.vue +489 -0
- package/src/components/CnSectionsWidget/index.js +34 -0
- package/src/components/CnStagesWidget/CnStagesWidget.vue +81 -2
- package/src/components/CnStatWidget/CnStatWidget.vue +1 -1
- package/src/components/CnTabsWidget/CnTabsWidget.vue +184 -8
- package/src/components/CnWidgetGrid/registerDashboardWidgets.js +4 -0
- package/src/components/CnWorkspaceFilterWidget/CnWorkspaceFilterWidget.vue +188 -4
- package/src/components/index.js +4 -0
- package/src/composables/__tests__/useFormDraft.spec.js +69 -0
- package/src/composables/useFormDraft.js +139 -8
- package/src/css/form-field.css +14 -0
- package/src/css/index-page.css +71 -0
- package/src/css/kpi-card.css +32 -0
- package/src/css/look-board-detail.css +77 -0
- package/src/css/look-board-index.css +51 -0
- package/src/css/look-board.css +37 -2
- package/src/css/table.css +19 -0
- package/src/index.js +4 -0
- package/src/integrations/builtin/field-inspection/CnFieldInspectionCard.vue +35 -20
- package/src/integrations/builtin/field-inspection.js +21 -0
- package/src/integrations/offline/checklistSubmission.js +137 -0
- package/src/integrations/offline/fieldCollectionHelpers.js +69 -4
- package/src/integrations/offline/index.js +3 -0
- package/src/integrations/offline/offlineDb.js +6 -1
- package/src/integrations/offline/syncReplayService.js +8 -2
- package/src/schemas/app-manifest-v2.schema.json +104 -5
- package/src/utils/detailActionModel.js +59 -2
- package/src/utils/fillTemplate.js +110 -0
- package/src/utils/libraryWidgetKeys.js +4 -0
- package/src/utils/queryPresets.js +93 -0
- package/src/utils/resolveFilterTokens.js +11 -0
- package/src/utils/schema.js +21 -0
- package/src/utils/sentinelTokens.js +3 -3
- package/src/utils/validateManifestV2.compiled.js +3 -3
- package/src/utils/widgetDispatch.js +7 -1
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
- SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<div class="cn-field-list-widget" data-testid="cn-field-list-widget">
|
|
8
|
+
<p v-if="rows.length === 0" class="cn-field-list-widget__empty" data-testid="cn-field-list-empty">
|
|
9
|
+
{{ emptyLabel }}
|
|
10
|
+
</p>
|
|
11
|
+
<ul v-else class="cn-field-list-widget__rows">
|
|
12
|
+
<li
|
|
13
|
+
v-for="row in rows"
|
|
14
|
+
:key="row.key"
|
|
15
|
+
class="cn-field-list-widget__row"
|
|
16
|
+
:data-testid="`cn-field-list-row-${row.key}`">
|
|
17
|
+
<div class="cn-field-list-widget__line">
|
|
18
|
+
<span v-if="row.initials" class="cn-field-list-widget__avatar" aria-hidden="true">{{ row.initials }}</span>
|
|
19
|
+
<span class="cn-field-list-widget__main">
|
|
20
|
+
<span class="cn-field-list-widget__title">{{ row.title }}</span>
|
|
21
|
+
<span v-if="row.meta" class="cn-field-list-widget__meta">{{ row.meta }}</span>
|
|
22
|
+
</span>
|
|
23
|
+
<CnStatusBadge
|
|
24
|
+
v-if="row.pill"
|
|
25
|
+
:label="row.pill.label"
|
|
26
|
+
:variant="row.pill.variant"
|
|
27
|
+
size="small" />
|
|
28
|
+
<span v-if="row.aside" class="cn-field-list-widget__aside">{{ row.aside }}</span>
|
|
29
|
+
<NcButton
|
|
30
|
+
v-for="action in row.actions"
|
|
31
|
+
:key="action.id"
|
|
32
|
+
variant="tertiary"
|
|
33
|
+
:disabled="busy !== ''"
|
|
34
|
+
:data-testid="`cn-field-list-action-${action.id}-${row.key}`"
|
|
35
|
+
@click="runAction(action, row)">
|
|
36
|
+
{{ action.label }}
|
|
37
|
+
</NcButton>
|
|
38
|
+
<NcButton
|
|
39
|
+
v-if="canRemove"
|
|
40
|
+
variant="tertiary"
|
|
41
|
+
:disabled="busy !== ''"
|
|
42
|
+
:aria-label="removeAriaLabel(row)"
|
|
43
|
+
:data-testid="`cn-field-list-remove-${row.key}`"
|
|
44
|
+
@click="remove(row)">
|
|
45
|
+
{{ removeLabel }}
|
|
46
|
+
</NcButton>
|
|
47
|
+
</div>
|
|
48
|
+
<p v-if="row.detail" class="cn-field-list-widget__detail">
|
|
49
|
+
{{ row.detail }}
|
|
50
|
+
</p>
|
|
51
|
+
</li>
|
|
52
|
+
</ul>
|
|
53
|
+
|
|
54
|
+
<p v-if="hint" class="cn-field-list-widget__hint">
|
|
55
|
+
{{ hint }}
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
<form
|
|
59
|
+
v-if="canAdd"
|
|
60
|
+
class="cn-field-list-widget__add"
|
|
61
|
+
data-testid="cn-field-list-add"
|
|
62
|
+
@submit.prevent="add">
|
|
63
|
+
<div
|
|
64
|
+
v-for="field in addFields"
|
|
65
|
+
:key="field.key"
|
|
66
|
+
class="cn-field-list-widget__field"
|
|
67
|
+
:data-testid="`cn-field-list-input-${field.key}`">
|
|
68
|
+
<NcSelect
|
|
69
|
+
v-if="field.type === 'select'"
|
|
70
|
+
v-model="draft[field.key]"
|
|
71
|
+
:inputLabel="field.label"
|
|
72
|
+
:options="field.options"
|
|
73
|
+
:reduce="(option) => option.value"
|
|
74
|
+
:clearable="false"
|
|
75
|
+
label="label" />
|
|
76
|
+
<NcTextField
|
|
77
|
+
v-else
|
|
78
|
+
v-model="draft[field.key]"
|
|
79
|
+
:label="field.label"
|
|
80
|
+
:error="Boolean(errors[field.key])"
|
|
81
|
+
:helperText="errors[field.key] || ''" />
|
|
82
|
+
</div>
|
|
83
|
+
<NcButton type="submit"
|
|
84
|
+
variant="secondary"
|
|
85
|
+
:disabled="busy !== ''"
|
|
86
|
+
data-testid="cn-field-list-submit">
|
|
87
|
+
{{ addLabel }}
|
|
88
|
+
</NcButton>
|
|
89
|
+
</form>
|
|
90
|
+
|
|
91
|
+
<NcNoteCard v-if="notice" :type="noticeType" data-testid="cn-field-list-notice">
|
|
92
|
+
{{ notice }}
|
|
93
|
+
</NcNoteCard>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
96
|
+
|
|
97
|
+
<script>
|
|
98
|
+
import { NcButton, NcNoteCard, NcSelect, NcTextField } from '@nextcloud/vue'
|
|
99
|
+
import CnStatusBadge from '../CnStatusBadge/CnStatusBadge.vue'
|
|
100
|
+
import { isBadgeVariant } from '../../utils/badgeVariants.js'
|
|
101
|
+
import { formatBoardDate } from '../../utils/boardDate.js'
|
|
102
|
+
import { parseDateValue } from '../../utils/dateVariant.js'
|
|
103
|
+
import { prefixUrl } from '../../utils/headers.js'
|
|
104
|
+
import { readPath } from '../../utils/readPath.js'
|
|
105
|
+
import { serverErrorMessage } from '../../utils/serverErrorMessage.js'
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* CnFieldListWidget — the `field-list` widget: a list stored INSIDE one field
|
|
109
|
+
* of the current object (a portal's `domains[]`, its `editors[]`), shown as
|
|
110
|
+
* rows and edited in place.
|
|
111
|
+
*
|
|
112
|
+
* Rows are drawn from configuration (title, meta line, pill, aside, a detail
|
|
113
|
+
* line); a small form adds an entry, a button removes one, and each change is
|
|
114
|
+
* saved as ONE PATCH of that field on the object, after re-reading the stored
|
|
115
|
+
* value so a concurrent change to the same list is not overwritten with a
|
|
116
|
+
* stale copy. Optional row actions call a configured endpoint (a "check
|
|
117
|
+
* again"), and an optional `rowSource` merges live per-row state read from an
|
|
118
|
+
* endpoint by key without writing it back.
|
|
119
|
+
*
|
|
120
|
+
* The server decides who may write: a refused PATCH shows the server's words
|
|
121
|
+
* and leaves the list as stored.
|
|
122
|
+
*
|
|
123
|
+
* @spec openspec/changes/abstract-field-list/specs/field-list/spec.md
|
|
124
|
+
*/
|
|
125
|
+
export default {
|
|
126
|
+
name: 'CnFieldListWidget',
|
|
127
|
+
|
|
128
|
+
components: { CnStatusBadge, NcButton, NcNoteCard, NcSelect, NcTextField },
|
|
129
|
+
|
|
130
|
+
inject: {
|
|
131
|
+
cnTranslate: { default: () => (key) => key },
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
props: {
|
|
135
|
+
/**
|
|
136
|
+
* The widget configuration.
|
|
137
|
+
*
|
|
138
|
+
* - `field` (required) — the object field holding the array.
|
|
139
|
+
* - `key` — the item field that identifies an entry (default: the item itself for strings).
|
|
140
|
+
* - `row` — `{ title, titleFallback?, avatar?, meta?: [paths|{ path, map?, format? }], pill?: { path, map?, variantMap? }, aside?: { path, format?, prefix? }, detail?: { template, when? } }`.
|
|
141
|
+
* - `add` — `{ label?, fields: [{ key, label, type?: 'text'|'select', options?, required?, pattern?, patternMessage? }], unique?, defaults? }`.
|
|
142
|
+
* - `remove` — `{ label? }`; omitted = no remove.
|
|
143
|
+
* - `rowActions` — `[{ id, label, when?, request: { method?, url, payload? } }]`; tokens `@object.<field>`, `@objectId`, `@row.<field>`.
|
|
144
|
+
* - `rowSource` — `{ url, path?, key }`: live per-row state merged by key.
|
|
145
|
+
* - `readOnly`, `hint`, `emptyText`.
|
|
146
|
+
*
|
|
147
|
+
* @type {object}
|
|
148
|
+
*/
|
|
149
|
+
content: {
|
|
150
|
+
type: Object,
|
|
151
|
+
default: () => ({}),
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/** The current detail-page object. */
|
|
155
|
+
objectData: {
|
|
156
|
+
type: Object,
|
|
157
|
+
default: null,
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/** The current object id. */
|
|
161
|
+
objectId: {
|
|
162
|
+
type: [String, Number],
|
|
163
|
+
default: '',
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
/** OpenRegister register slug of the surface. */
|
|
167
|
+
register: {
|
|
168
|
+
type: [String, Object],
|
|
169
|
+
default: '',
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/** OpenRegister schema slug of the surface. */
|
|
173
|
+
schema: {
|
|
174
|
+
type: [String, Object],
|
|
175
|
+
default: '',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
emits: ['saved'],
|
|
180
|
+
|
|
181
|
+
data() {
|
|
182
|
+
return {
|
|
183
|
+
/** The list as last saved by this widget; null = read it off objectData. */
|
|
184
|
+
saved: null,
|
|
185
|
+
/** Live per-row state from `rowSource`, by key. */
|
|
186
|
+
live: {},
|
|
187
|
+
draft: {},
|
|
188
|
+
errors: {},
|
|
189
|
+
busy: '',
|
|
190
|
+
notice: '',
|
|
191
|
+
noticeType: 'error',
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
computed: {
|
|
196
|
+
/**
|
|
197
|
+
* The stored list.
|
|
198
|
+
*
|
|
199
|
+
* @return {Array}
|
|
200
|
+
*/
|
|
201
|
+
items() {
|
|
202
|
+
const list = this.saved !== null ? this.saved : readPath(this.objectData || {}, this.content.field)
|
|
203
|
+
return Array.isArray(list) ? list : []
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The rows to draw.
|
|
208
|
+
*
|
|
209
|
+
* @return {Array<object>}
|
|
210
|
+
* @spec openspec/changes/abstract-field-list/specs/field-list/spec.md#requirement-a-field-list-draws-the-entries-of-one-object-field
|
|
211
|
+
*/
|
|
212
|
+
rows() {
|
|
213
|
+
const spec = this.content.row || {}
|
|
214
|
+
return this.items.map((item, index) => {
|
|
215
|
+
const key = this.keyOf(item, index)
|
|
216
|
+
const entry = item && typeof item === 'object'
|
|
217
|
+
? { ...item, ...(this.live[key] || {}) }
|
|
218
|
+
: { value: item, ...(this.live[key] || {}) }
|
|
219
|
+
const title = this.text(entry, spec.title) || this.text(entry, spec.titleFallback) || (typeof item === 'string' ? item : key)
|
|
220
|
+
const meta = (Array.isArray(spec.meta) ? spec.meta : [])
|
|
221
|
+
.map((part) => this.text(entry, part))
|
|
222
|
+
.filter((part) => part !== '')
|
|
223
|
+
.join(' · ')
|
|
224
|
+
return {
|
|
225
|
+
key,
|
|
226
|
+
item,
|
|
227
|
+
entry,
|
|
228
|
+
title,
|
|
229
|
+
initials: spec.avatar ? this.initials(title) : '',
|
|
230
|
+
meta,
|
|
231
|
+
pill: this.pillOf(entry, spec.pill),
|
|
232
|
+
aside: spec.aside ? this.asideOf(entry, spec.aside) : '',
|
|
233
|
+
detail: spec.detail && this.matches(entry, spec.detail.when) ? this.fill(spec.detail.template, entry) : '',
|
|
234
|
+
actions: this.actionsFor(entry),
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
/** Whether the list is read-only. */
|
|
240
|
+
readOnly() {
|
|
241
|
+
return this.content.readOnly === true
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
/** Whether entries can be added. */
|
|
245
|
+
canAdd() {
|
|
246
|
+
return !this.readOnly && this.addFields.length > 0 && Boolean(this.content.field)
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
/** Whether entries can be removed. */
|
|
250
|
+
canRemove() {
|
|
251
|
+
return !this.readOnly && Boolean(this.content.remove) && Boolean(this.content.field)
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The add form's fields, labels translated, select options translated.
|
|
256
|
+
*
|
|
257
|
+
* @return {Array<object>}
|
|
258
|
+
*/
|
|
259
|
+
addFields() {
|
|
260
|
+
const fields = this.content.add && Array.isArray(this.content.add.fields) ? this.content.add.fields : []
|
|
261
|
+
return fields
|
|
262
|
+
.filter((field) => field && field.key)
|
|
263
|
+
.map((field) => ({
|
|
264
|
+
...field,
|
|
265
|
+
label: this.tr(field.label || field.key),
|
|
266
|
+
options: (Array.isArray(field.options) ? field.options : []).map((option) => (
|
|
267
|
+
typeof option === 'object' ? { value: option.value, label: this.tr(option.label || String(option.value)) } : { value: option, label: this.tr(String(option)) }
|
|
268
|
+
)),
|
|
269
|
+
}))
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
addLabel() {
|
|
273
|
+
return this.tr((this.content.add && this.content.add.label) || 'Add')
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
removeLabel() {
|
|
277
|
+
return this.tr((this.content.remove && this.content.remove.label) || 'Remove')
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
hint() {
|
|
281
|
+
return this.tr(this.content.hint || '')
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
emptyLabel() {
|
|
285
|
+
return this.tr(this.content.emptyText || 'Nothing listed yet')
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
/** The object URL the list is saved to, or '' when it is not known. */
|
|
289
|
+
objectUrl() {
|
|
290
|
+
const id = this.objectId || (this.objectData && this.objectData.id)
|
|
291
|
+
if (!this.register || !this.schema || !id || typeof this.register !== 'string' || typeof this.schema !== 'string') {
|
|
292
|
+
return ''
|
|
293
|
+
}
|
|
294
|
+
return `/apps/openregister/api/objects/${encodeURIComponent(this.register)}/${encodeURIComponent(this.schema)}/${encodeURIComponent(String(id))}`
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
watch: {
|
|
299
|
+
objectData() {
|
|
300
|
+
this.saved = null
|
|
301
|
+
this.loadLive()
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
created() {
|
|
306
|
+
this.resetDraft()
|
|
307
|
+
this.loadLive()
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
methods: {
|
|
311
|
+
tr(text) {
|
|
312
|
+
if (typeof text !== 'string' || text === '') {
|
|
313
|
+
return ''
|
|
314
|
+
}
|
|
315
|
+
return typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The identity of an entry.
|
|
320
|
+
*
|
|
321
|
+
* @param {unknown} item The entry.
|
|
322
|
+
* @param {number} index Its position.
|
|
323
|
+
* @return {string}
|
|
324
|
+
*/
|
|
325
|
+
keyOf(item, index) {
|
|
326
|
+
if (item === null || typeof item !== 'object') {
|
|
327
|
+
return String(item)
|
|
328
|
+
}
|
|
329
|
+
const key = this.content.key ? readPath(item, this.content.key) : undefined
|
|
330
|
+
return key === undefined || key === null || key === '' ? `item-${index}` : String(key)
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* A display text off an entry: a path, or `{ path, map?, format? }`.
|
|
335
|
+
*
|
|
336
|
+
* @param {object} entry The entry.
|
|
337
|
+
* @param {string|object} spec The spec.
|
|
338
|
+
* @return {string}
|
|
339
|
+
*/
|
|
340
|
+
text(entry, spec) {
|
|
341
|
+
if (!spec) {
|
|
342
|
+
return ''
|
|
343
|
+
}
|
|
344
|
+
const def = typeof spec === 'string' ? { path: spec } : spec
|
|
345
|
+
const raw = readPath(entry, def.path)
|
|
346
|
+
if (raw === null || raw === undefined || raw === '') {
|
|
347
|
+
return ''
|
|
348
|
+
}
|
|
349
|
+
if (def.format === 'date' || def.format === 'date-long') {
|
|
350
|
+
const date = parseDateValue(raw)
|
|
351
|
+
if (date === null) {
|
|
352
|
+
return ''
|
|
353
|
+
}
|
|
354
|
+
return def.format === 'date-long' ? formatBoardDate(date, new Date(date.getFullYear() + 1, 0, 1)) : formatBoardDate(date)
|
|
355
|
+
}
|
|
356
|
+
if (def.map && Object.hasOwn(def.map, String(raw))) {
|
|
357
|
+
return this.tr(def.map[String(raw)])
|
|
358
|
+
}
|
|
359
|
+
return typeof raw === 'object' ? '' : String(raw)
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
pillOf(entry, spec) {
|
|
363
|
+
if (!spec || !spec.path) {
|
|
364
|
+
return null
|
|
365
|
+
}
|
|
366
|
+
const raw = readPath(entry, spec.path)
|
|
367
|
+
if (raw === null || raw === undefined || raw === '') {
|
|
368
|
+
return null
|
|
369
|
+
}
|
|
370
|
+
const label = this.text(entry, spec)
|
|
371
|
+
const variant = spec.variantMap && spec.variantMap[String(raw)]
|
|
372
|
+
return { label, variant: isBadgeVariant(variant) ? variant : 'default' }
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
asideOf(entry, spec) {
|
|
376
|
+
const value = this.text(entry, spec)
|
|
377
|
+
if (value === '') {
|
|
378
|
+
return ''
|
|
379
|
+
}
|
|
380
|
+
return spec.prefix ? `${this.tr(spec.prefix)} ${value}` : value
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Whether an entry matches a `{ field: value }` condition (every field equal).
|
|
385
|
+
*
|
|
386
|
+
* @param {object} entry The entry.
|
|
387
|
+
* @param {object|undefined} when The condition.
|
|
388
|
+
* @return {boolean}
|
|
389
|
+
*/
|
|
390
|
+
matches(entry, when) {
|
|
391
|
+
if (!when || typeof when !== 'object') {
|
|
392
|
+
return true
|
|
393
|
+
}
|
|
394
|
+
return Object.entries(when).every(([field, expected]) => {
|
|
395
|
+
const actual = readPath(entry, field)
|
|
396
|
+
if (expected === false) {
|
|
397
|
+
return actual === false || actual === undefined || actual === null || actual === ''
|
|
398
|
+
}
|
|
399
|
+
return String(actual) === String(expected)
|
|
400
|
+
})
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Fill `{path}` placeholders from an entry; '' when one stays empty.
|
|
405
|
+
*
|
|
406
|
+
* @param {string} template The template, translated first.
|
|
407
|
+
* @param {object} entry The entry.
|
|
408
|
+
* @return {string}
|
|
409
|
+
*/
|
|
410
|
+
fill(template, entry) {
|
|
411
|
+
if (typeof template !== 'string') {
|
|
412
|
+
return ''
|
|
413
|
+
}
|
|
414
|
+
let missing = false
|
|
415
|
+
const out = this.tr(template).replace(/\{([\w.@]+)\}/g, (match, path) => {
|
|
416
|
+
const value = readPath(entry, path)
|
|
417
|
+
if (value === undefined || value === null || value === '') {
|
|
418
|
+
missing = true
|
|
419
|
+
return match
|
|
420
|
+
}
|
|
421
|
+
return String(value)
|
|
422
|
+
})
|
|
423
|
+
return missing ? '' : out
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
actionsFor(entry) {
|
|
427
|
+
if (this.readOnly) {
|
|
428
|
+
return []
|
|
429
|
+
}
|
|
430
|
+
const actions = Array.isArray(this.content.rowActions) ? this.content.rowActions : []
|
|
431
|
+
return actions
|
|
432
|
+
.filter((action) => action && action.id && action.request && action.request.url && this.matches(entry, action.when))
|
|
433
|
+
.map((action) => ({ ...action, label: this.tr(action.label || action.id) }))
|
|
434
|
+
},
|
|
435
|
+
|
|
436
|
+
initials(name) {
|
|
437
|
+
return String(name || '').split(/[\s@._-]+/).filter(Boolean).slice(0, 2).map((part) => part.charAt(0).toUpperCase()).join('')
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
removeAriaLabel(row) {
|
|
441
|
+
return `${this.removeLabel}: ${row.title}`
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
resetDraft() {
|
|
445
|
+
const draft = {}
|
|
446
|
+
for (const field of this.addFields) {
|
|
447
|
+
const first = field.type === 'select' && field.options.length > 0 ? field.options[0].value : ''
|
|
448
|
+
draft[field.key] = field.default !== undefined ? field.default : first
|
|
449
|
+
}
|
|
450
|
+
this.draft = draft
|
|
451
|
+
this.errors = {}
|
|
452
|
+
},
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Resolve `@objectId`, `@object.<field>` and `@row.<field>` inside a string or a payload.
|
|
456
|
+
*
|
|
457
|
+
* @param {unknown} value The value.
|
|
458
|
+
* @param {object} entry The row entry.
|
|
459
|
+
* @return {unknown}
|
|
460
|
+
*/
|
|
461
|
+
resolve(value, entry) {
|
|
462
|
+
if (Array.isArray(value)) {
|
|
463
|
+
return value.map((v) => this.resolve(v, entry))
|
|
464
|
+
}
|
|
465
|
+
if (value && typeof value === 'object') {
|
|
466
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, this.resolve(v, entry)]))
|
|
467
|
+
}
|
|
468
|
+
if (typeof value !== 'string') {
|
|
469
|
+
return value
|
|
470
|
+
}
|
|
471
|
+
const object = this.objectData || {}
|
|
472
|
+
const read = (source, path) => {
|
|
473
|
+
const v = readPath(source || {}, path)
|
|
474
|
+
return v === undefined || v === null ? '' : v
|
|
475
|
+
}
|
|
476
|
+
const whole = value.match(/^@(row|object)\.([\w.@]+)$/)
|
|
477
|
+
if (whole) {
|
|
478
|
+
return read(whole[1] === 'row' ? entry : object, whole[2])
|
|
479
|
+
}
|
|
480
|
+
return value
|
|
481
|
+
.replace(/@objectId/g, () => encodeURIComponent(String(this.objectId || object.id || '')))
|
|
482
|
+
.replace(/@(row|object)\.([\w.@]+)/g, (m, scope, path) => encodeURIComponent(String(read(scope === 'row' ? entry : object, path))))
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
async http() {
|
|
486
|
+
const { default: axios } = await import('@nextcloud/axios')
|
|
487
|
+
return { axios }
|
|
488
|
+
},
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Read live per-row state from `rowSource` and keep it by key.
|
|
492
|
+
*
|
|
493
|
+
* @return {Promise<void>}
|
|
494
|
+
*/
|
|
495
|
+
async loadLive() {
|
|
496
|
+
const source = this.content.rowSource
|
|
497
|
+
if (!source || !source.url || !source.key || !this.objectData) {
|
|
498
|
+
return
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
const { axios } = await this.http()
|
|
502
|
+
const response = await axios.get(prefixUrl(this.resolve(source.url, {})))
|
|
503
|
+
const data = response && response.data
|
|
504
|
+
const list = source.path ? readPath(data, source.path) : data
|
|
505
|
+
const live = {}
|
|
506
|
+
for (const item of Array.isArray(list) ? list : []) {
|
|
507
|
+
const key = item && readPath(item, source.key)
|
|
508
|
+
if (key !== undefined && key !== null) {
|
|
509
|
+
live[String(key)] = item
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
this.live = live
|
|
513
|
+
} catch (e) {
|
|
514
|
+
// eslint-disable-next-line no-console
|
|
515
|
+
console.warn('[CnFieldListWidget] rowSource could not be read:', e?.message || e)
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Save a new list: re-read the stored value, apply the change to it, and
|
|
521
|
+
* PATCH that one field.
|
|
522
|
+
*
|
|
523
|
+
* @param {(stored: Array) => Array} change Builds the next list from the stored one, or throws an Error with a `userMessage`.
|
|
524
|
+
* @param {string} busyKey What is busy.
|
|
525
|
+
* @return {Promise<boolean>} Whether it saved.
|
|
526
|
+
* @spec openspec/changes/abstract-field-list/specs/field-list/spec.md#requirement-a-field-list-saves-one-field-with-one-patch
|
|
527
|
+
*/
|
|
528
|
+
async save(change, busyKey) {
|
|
529
|
+
if (!this.objectUrl) {
|
|
530
|
+
this.notify(this.tr('This list cannot be saved here.'))
|
|
531
|
+
return false
|
|
532
|
+
}
|
|
533
|
+
this.busy = busyKey
|
|
534
|
+
this.notice = ''
|
|
535
|
+
try {
|
|
536
|
+
const { axios } = await this.http()
|
|
537
|
+
const { data: stored } = await axios.get(prefixUrl(this.objectUrl))
|
|
538
|
+
const current = readPath(stored || {}, this.content.field)
|
|
539
|
+
const next = change(Array.isArray(current) ? current : [])
|
|
540
|
+
const { data } = await axios.patch(prefixUrl(this.objectUrl), { [this.content.field]: next })
|
|
541
|
+
const written = readPath(data || {}, this.content.field)
|
|
542
|
+
this.saved = Array.isArray(written) ? written : next
|
|
543
|
+
/**
|
|
544
|
+
* @event saved The list was saved: one PATCH of the field succeeded.
|
|
545
|
+
* @type {{field: string, value: Array}}
|
|
546
|
+
*/
|
|
547
|
+
this.$emit('saved', { field: this.content.field, value: this.saved })
|
|
548
|
+
return true
|
|
549
|
+
} catch (e) {
|
|
550
|
+
this.notify(e && e.userMessage ? e.userMessage : serverErrorMessage(e))
|
|
551
|
+
return false
|
|
552
|
+
} finally {
|
|
553
|
+
this.busy = ''
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
notify(message, type = 'error') {
|
|
558
|
+
this.notice = message
|
|
559
|
+
this.noticeType = type
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Validate the draft and add it.
|
|
564
|
+
*
|
|
565
|
+
* @return {Promise<void>}
|
|
566
|
+
* @spec openspec/changes/abstract-field-list/specs/field-list/spec.md#requirement-a-field-list-adds-and-removes-entries
|
|
567
|
+
*/
|
|
568
|
+
async add() {
|
|
569
|
+
const errors = {}
|
|
570
|
+
for (const field of this.addFields) {
|
|
571
|
+
const value = this.draft[field.key]
|
|
572
|
+
const empty = value === undefined || value === null || String(value).trim() === ''
|
|
573
|
+
if (field.required && empty) {
|
|
574
|
+
errors[field.key] = this.tr('Fill this in.')
|
|
575
|
+
} else if (!empty && field.pattern && !new RegExp(field.pattern).test(String(value).trim())) {
|
|
576
|
+
errors[field.key] = this.tr(field.patternMessage || 'This value is not valid.')
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
this.errors = errors
|
|
580
|
+
if (Object.keys(errors).length > 0) {
|
|
581
|
+
return
|
|
582
|
+
}
|
|
583
|
+
const entry = { ...((this.content.add && this.content.add.defaults) || {}) }
|
|
584
|
+
for (const field of this.addFields) {
|
|
585
|
+
const value = this.draft[field.key]
|
|
586
|
+
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
|
587
|
+
entry[field.key] = typeof value === 'string' ? value.trim() : value
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const unique = this.content.add && this.content.add.unique
|
|
591
|
+
const saved = await this.save((stored) => {
|
|
592
|
+
if (unique && stored.some((item) => item && String(readPath(item, unique)) === String(entry[unique]))) {
|
|
593
|
+
const error = new Error('duplicate')
|
|
594
|
+
error.userMessage = this.tr('This is already in the list.')
|
|
595
|
+
throw error
|
|
596
|
+
}
|
|
597
|
+
return [...stored, entry]
|
|
598
|
+
}, '*')
|
|
599
|
+
if (saved) {
|
|
600
|
+
this.resetDraft()
|
|
601
|
+
this.loadLive()
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Remove an entry by its key.
|
|
607
|
+
*
|
|
608
|
+
* @param {object} row The row.
|
|
609
|
+
* @return {Promise<void>}
|
|
610
|
+
*/
|
|
611
|
+
async remove(row) {
|
|
612
|
+
await this.save((stored) => stored.filter((item, index) => this.keyOf(item, index) !== row.key), row.key)
|
|
613
|
+
},
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Run a row action's request, then re-read the live state.
|
|
617
|
+
*
|
|
618
|
+
* @param {object} action The action.
|
|
619
|
+
* @param {object} row The row.
|
|
620
|
+
* @return {Promise<void>}
|
|
621
|
+
* @spec openspec/changes/abstract-field-list/specs/field-list/spec.md#requirement-a-field-list-row-can-run-a-configured-request
|
|
622
|
+
*/
|
|
623
|
+
async runAction(action, row) {
|
|
624
|
+
this.busy = row.key
|
|
625
|
+
this.notice = ''
|
|
626
|
+
try {
|
|
627
|
+
const { axios } = await this.http()
|
|
628
|
+
const method = String(action.request.method || 'POST').toLowerCase()
|
|
629
|
+
const payload = this.resolve(action.request.payload || {}, row.entry)
|
|
630
|
+
const response = method === 'get'
|
|
631
|
+
? await axios.get(prefixUrl(this.resolve(action.request.url, row.entry)))
|
|
632
|
+
: await axios[method](prefixUrl(this.resolve(action.request.url, row.entry)), payload)
|
|
633
|
+
const message = response && response.data && typeof response.data.message === 'string' ? response.data.message : ''
|
|
634
|
+
if (message) {
|
|
635
|
+
this.notify(message, 'info')
|
|
636
|
+
}
|
|
637
|
+
await this.loadLive()
|
|
638
|
+
} catch (e) {
|
|
639
|
+
this.notify(serverErrorMessage(e))
|
|
640
|
+
} finally {
|
|
641
|
+
this.busy = ''
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
}
|
|
646
|
+
</script>
|
|
647
|
+
|
|
648
|
+
<style scoped>
|
|
649
|
+
.cn-field-list-widget {
|
|
650
|
+
display: flex;
|
|
651
|
+
flex-direction: column;
|
|
652
|
+
gap: 12px;
|
|
653
|
+
min-width: 0;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.cn-field-list-widget__rows {
|
|
657
|
+
list-style: none;
|
|
658
|
+
margin: 0;
|
|
659
|
+
padding: 0;
|
|
660
|
+
display: flex;
|
|
661
|
+
flex-direction: column;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.cn-field-list-widget__row {
|
|
665
|
+
padding: 10px 0;
|
|
666
|
+
border-top: 1px solid var(--color-border);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.cn-field-list-widget__row:first-child {
|
|
670
|
+
border-top: none;
|
|
671
|
+
padding-top: 0;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.cn-field-list-widget__line {
|
|
675
|
+
display: flex;
|
|
676
|
+
align-items: center;
|
|
677
|
+
gap: 12px;
|
|
678
|
+
min-width: 0;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.cn-field-list-widget__avatar {
|
|
682
|
+
flex: 0 0 auto;
|
|
683
|
+
display: inline-flex;
|
|
684
|
+
align-items: center;
|
|
685
|
+
justify-content: center;
|
|
686
|
+
width: 32px;
|
|
687
|
+
height: 32px;
|
|
688
|
+
border-radius: 50%;
|
|
689
|
+
background: var(--color-primary-element-light);
|
|
690
|
+
color: var(--color-primary-element-light-text, var(--color-main-text));
|
|
691
|
+
font-size: 12px;
|
|
692
|
+
font-weight: 700;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.cn-field-list-widget__main {
|
|
696
|
+
display: flex;
|
|
697
|
+
flex-direction: column;
|
|
698
|
+
flex: 1 1 auto;
|
|
699
|
+
min-width: 0;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.cn-field-list-widget__title {
|
|
703
|
+
font-weight: 600;
|
|
704
|
+
overflow-wrap: anywhere;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.cn-field-list-widget__meta,
|
|
708
|
+
.cn-field-list-widget__aside,
|
|
709
|
+
.cn-field-list-widget__detail,
|
|
710
|
+
.cn-field-list-widget__hint,
|
|
711
|
+
.cn-field-list-widget__empty {
|
|
712
|
+
color: var(--color-text-maxcontrast);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.cn-field-list-widget__meta,
|
|
716
|
+
.cn-field-list-widget__aside,
|
|
717
|
+
.cn-field-list-widget__detail {
|
|
718
|
+
font-size: 13px;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
.cn-field-list-widget__aside {
|
|
722
|
+
white-space: nowrap;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.cn-field-list-widget__detail,
|
|
726
|
+
.cn-field-list-widget__hint,
|
|
727
|
+
.cn-field-list-widget__empty {
|
|
728
|
+
margin: 4px 0 0;
|
|
729
|
+
overflow-wrap: anywhere;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.cn-field-list-widget__add {
|
|
733
|
+
display: flex;
|
|
734
|
+
flex-wrap: wrap;
|
|
735
|
+
align-items: flex-end;
|
|
736
|
+
gap: 8px 12px;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.cn-field-list-widget__add > * {
|
|
740
|
+
flex: 1 1 180px;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.cn-field-list-widget__add > button {
|
|
744
|
+
flex: 0 0 auto;
|
|
745
|
+
}
|
|
746
|
+
</style>
|