@conduction/nextcloud-vue 2.165.0 → 2.166.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.vue.js +1 -1
- package/dist/esm/components/CnActionButtons/CnActionButtons.vue2.js +7 -0
- package/dist/esm/components/CnActionButtons/CnActionButtons.vue2.js.map +1 -1
- package/dist/esm/components/CnActionButtons/CnActionButtons.vue3.js.map +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue.js +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js +10 -0
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js.map +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js.map +1 -1
- package/dist/esm/components/CnChipListManager/CnChipListManager.vue.js +1 -1
- package/dist/esm/components/CnChipListManager/CnChipListManager.vue2.js.map +1 -1
- package/dist/esm/components/CnChipListManager/CnChipListManager.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js +50 -7
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue3.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +13 -0
- 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 +39 -4
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +2 -1
- package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
- package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue.js +1 -1
- package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue2.js.map +1 -1
- package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue3.js.map +1 -1
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue.js +9 -0
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue.js.map +1 -0
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue2.js +232 -0
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue3.js +61 -0
- package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnFieldGroupsWidget/index.js +28 -0
- package/dist/esm/components/CnFieldGroupsWidget/index.js.map +1 -0
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue.js +1 -1
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js +80 -6
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js +361 -289
- package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js +9 -0
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js +2 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue2.js +21 -0
- package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue3.js +12 -2
- package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +17 -0
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +6 -3
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
- package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue2.js +33 -2
- package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue2.js.map +1 -1
- package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue3.js +2 -2
- package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +83 -8
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +2 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue.js +9 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue2.js +187 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue2.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue3.js +106 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue3.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue.js +9 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue2.js +421 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue2.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue3.js +131 -0
- package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue3.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/index.js +29 -0
- package/dist/esm/components/CnObjectLinksWidget/index.js.map +1 -0
- package/dist/esm/components/CnObjectLinksWidget/objectLinks.js +22 -0
- package/dist/esm/components/CnObjectLinksWidget/objectLinks.js.map +1 -0
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js +48 -13
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js +44 -20
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnPagination/CnPagination.vue2.js +26 -0
- package/dist/esm/components/CnPagination/CnPagination.vue2.js.map +1 -1
- package/dist/esm/components/CnPagination/CnPagination.vue3.js +40 -37
- package/dist/esm/components/CnPagination/CnPagination.vue3.js.map +1 -1
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +2 -0
- package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
- package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue.js +1 -1
- package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue2.js +4 -0
- package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue2.js.map +1 -1
- package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue3.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +18 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +18 -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 +635 -329
- package/dist/esm/utils/actionsDispatcher.js +9 -5
- package/dist/esm/utils/actionsDispatcher.js.map +1 -1
- package/dist/esm/utils/libraryWidgetKeys.js +2 -0
- package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
- package/dist/esm/utils/objectParties.js +68 -1
- package/dist/esm/utils/objectParties.js.map +1 -1
- package/dist/esm/utils/overlayInset.js +60 -0
- package/dist/esm/utils/overlayInset.js.map +1 -0
- package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
- package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
- package/dist/esm/utils/widgetDispatch.js +4 -1
- package/dist/esm/utils/widgetDispatch.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +8444 -6584
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +635 -329
- package/l10n/en.json +18 -1
- package/l10n/nl.json +18 -1
- package/package.json +1 -1
- package/src/components/CnActionButtons/CnActionButtons.vue +7 -0
- package/src/components/CnAuditTrailCard/CnAuditTrailCard.vue +11 -1
- package/src/components/CnChipListManager/CnChipListManager.vue +4 -1
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +50 -7
- package/src/components/CnDataTable/CnDataTable.md +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +14 -0
- package/src/components/CnDetailPage/CnDetailPage.md +1 -0
- package/src/components/CnDetailPage/CnDetailPage.vue +40 -4
- package/src/components/CnExpandableRow/CnExpandableRow.vue +7 -4
- package/src/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue +287 -0
- package/src/components/CnFieldGroupsWidget/index.js +27 -0
- package/src/components/CnFieldListWidget/CnFieldListWidget.vue +162 -7
- package/src/components/CnFlowDetail/CnFlowDetail.vue +10 -0
- package/src/components/CnFlowDetail/CnFlowRunSummary.vue +26 -1
- package/src/components/CnFlowsPage/CnFlowBoard.vue +90 -4
- package/src/components/CnGraphCanvas/CnGraphCanvas.vue +35 -4
- package/src/components/CnIndexPage/CnIndexPage.md +1 -1
- package/src/components/CnIndexPage/CnIndexPage.vue +83 -7
- package/src/components/CnObjectLinksWidget/CnObjectLinkDialog.vue +267 -0
- package/src/components/CnObjectLinksWidget/CnObjectLinksWidget.vue +532 -0
- package/src/components/CnObjectLinksWidget/index.js +28 -0
- package/src/components/CnObjectLinksWidget/objectLinks.js +19 -0
- package/src/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue +65 -15
- package/src/components/CnPagination/CnPagination.md +1 -0
- package/src/components/CnPagination/CnPagination.vue +27 -1
- package/src/components/CnWidgetGrid/registerDashboardWidgets.js +2 -0
- package/src/components/CnWidgetObjectTable/CnWidgetObjectTable.vue +4 -0
- package/src/components/index.js +2 -0
- package/src/css/dialog.css +25 -3
- package/src/css/index-page.css +22 -8
- package/src/css/look-board-detail.css +41 -0
- package/src/css/look-board-index.css +52 -1
- package/src/css/look-board.css +17 -0
- package/src/index.js +2 -0
- package/src/schemas/app-manifest-v2.schema.json +3 -3
- package/src/utils/actionsDispatcher.js +9 -5
- package/src/utils/libraryWidgetKeys.js +2 -0
- package/src/utils/objectParties.js +67 -0
- package/src/utils/overlayInset.js +57 -0
- package/src/utils/validateManifestV2.compiled.js +2 -2
- package/src/utils/widgetDispatch.js +4 -1
|
@@ -1265,6 +1265,7 @@
|
|
|
1265
1265
|
v-else-if="effectivePagination && (effectivePagination.pages > 1 || (isBoardLook && effectivePagination.total > 0))"
|
|
1266
1266
|
:variant="isBoardLook ? 'board' : ''"
|
|
1267
1267
|
:footerNote="effectiveFooterNote"
|
|
1268
|
+
:pagerOnOnePage="pagerOnOnePage"
|
|
1268
1269
|
:currentPage="effectivePagination.page || 1"
|
|
1269
1270
|
:totalPages="effectivePagination.pages || 1"
|
|
1270
1271
|
:totalItems="effectivePagination.total || 0"
|
|
@@ -1603,6 +1604,26 @@ function declaredFilterFields(props) {
|
|
|
1603
1604
|
return declared
|
|
1604
1605
|
}
|
|
1605
1606
|
|
|
1607
|
+
/**
|
|
1608
|
+
* Fill a count line template: `{shown}`, `{total}`, `{term}`, `{view}`,
|
|
1609
|
+
* `{myTeam}` and the `countValues` names, after the app's translate.
|
|
1610
|
+
*
|
|
1611
|
+
* @param {object} vm The index page.
|
|
1612
|
+
* @param {string} template The template, untranslated.
|
|
1613
|
+
* @param {number} shown The rows on this page.
|
|
1614
|
+
* @param {number} total All rows.
|
|
1615
|
+
* @return {string} The line.
|
|
1616
|
+
*/
|
|
1617
|
+
function fillCountText(vm, template, shown, total) {
|
|
1618
|
+
const translated = vm.cnTranslate(template)
|
|
1619
|
+
return fillMyTeamToken(translated, translated.includes('{myTeam}') ? (peekMyTeamName() || '') : '')
|
|
1620
|
+
.replace('{shown}', String(shown))
|
|
1621
|
+
.replace('{total}', String(total))
|
|
1622
|
+
.replace(/\{term\}/g, vm.sourceTerm)
|
|
1623
|
+
.replace(/\{view\}/g, vm.appliedViewConditionsText)
|
|
1624
|
+
.replace(/\{(\w+)\|[^}]*\}|\{(\w+)\}/g, (token, a, b) => vm.countValueToken(token, a || b))
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1606
1627
|
/**
|
|
1607
1628
|
* Read a named-source page's sidebar filters back out of `$route.query`.
|
|
1608
1629
|
*
|
|
@@ -2266,6 +2287,21 @@ export default {
|
|
|
2266
2287
|
default: '',
|
|
2267
2288
|
},
|
|
2268
2289
|
|
|
2290
|
+
/**
|
|
2291
|
+
* The count line while a filter narrows the list (from the address,
|
|
2292
|
+
* the side panel, a filter strip or a quick filter), in either look:
|
|
2293
|
+
* a template with the `countText` tokens (`{shown}`, `{total}`,
|
|
2294
|
+
* `countValues` names), such as `"{read} of {total} read"` over the
|
|
2295
|
+
* messages of one sending. Manifest key `config.countTextFiltered`.
|
|
2296
|
+
* Empty (the default) keeps the count line as it is.
|
|
2297
|
+
*
|
|
2298
|
+
* @spec openspec/changes/index-count-text-filtered/specs/index-page/spec.md#requirement-the-count-line-can-differ-while-a-filter-narrows-the-list
|
|
2299
|
+
*/
|
|
2300
|
+
countTextFiltered: {
|
|
2301
|
+
type: String,
|
|
2302
|
+
default: '',
|
|
2303
|
+
},
|
|
2304
|
+
|
|
2269
2305
|
/**
|
|
2270
2306
|
* Board look: the count line while a saved view is applied (manifest
|
|
2271
2307
|
* `config.savedViewCountText`), a template as `countText` that may name
|
|
@@ -2393,6 +2429,18 @@ export default {
|
|
|
2393
2429
|
default: '',
|
|
2394
2430
|
},
|
|
2395
2431
|
|
|
2432
|
+
/**
|
|
2433
|
+
* Board look: whether a list that fits on one page still draws its
|
|
2434
|
+
* count and the "1" with an inert Next (manifest `config.pagerOnOnePage`).
|
|
2435
|
+
* Off, it ends in its `footerNote` alone, as PqWachtrij does.
|
|
2436
|
+
*
|
|
2437
|
+
* @spec openspec/changes/index-footer-note-on-one-page/specs/index-list-board-look/spec.md#requirement-a-board-list-on-one-page-can-end-in-its-note-alone
|
|
2438
|
+
*/
|
|
2439
|
+
pagerOnOnePage: {
|
|
2440
|
+
type: Boolean,
|
|
2441
|
+
default: true,
|
|
2442
|
+
},
|
|
2443
|
+
|
|
2396
2444
|
/**
|
|
2397
2445
|
* Board look: the footer note per view (manifest
|
|
2398
2446
|
* `config.footerNoteByView`), `{ table?, cards?, list?, board?, map? }`,
|
|
@@ -9171,6 +9219,37 @@ export default {
|
|
|
9171
9219
|
return base ? `${base} · ${onMap}` : onMap
|
|
9172
9220
|
},
|
|
9173
9221
|
|
|
9222
|
+
/**
|
|
9223
|
+
* Whether a filter narrows the list now: an active filter (the
|
|
9224
|
+
* address, the side panel, a filter strip) or a selected quick filter
|
|
9225
|
+
* tab that carries a filter.
|
|
9226
|
+
*
|
|
9227
|
+
* @return {boolean}
|
|
9228
|
+
* @spec openspec/changes/index-count-text-filtered/specs/index-page/spec.md#requirement-the-count-line-can-differ-while-a-filter-narrows-the-list
|
|
9229
|
+
*/
|
|
9230
|
+
listIsNarrowed() {
|
|
9231
|
+
const active = Object.values(this.effectiveActiveFilters || {})
|
|
9232
|
+
.some((value) => !(value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)))
|
|
9233
|
+
return active || this.quickFilterNarrows
|
|
9234
|
+
},
|
|
9235
|
+
|
|
9236
|
+
/**
|
|
9237
|
+
* Whether a selected quick filter tab carries a filter (an "All" tab
|
|
9238
|
+
* does not).
|
|
9239
|
+
*
|
|
9240
|
+
* @return {boolean}
|
|
9241
|
+
*/
|
|
9242
|
+
quickFilterNarrows() {
|
|
9243
|
+
const tabs = this.tabStripEntries || []
|
|
9244
|
+
const indices = this.quickFilterMultiple
|
|
9245
|
+
? (this.selectedQuickFilterIndices || [])
|
|
9246
|
+
: [this.activeQuickFilterIndex]
|
|
9247
|
+
return indices.some((index) => {
|
|
9248
|
+
const filter = typeof index === 'number' && tabs[index] ? tabs[index].filter : null
|
|
9249
|
+
return Boolean(filter && typeof filter === 'object' && Object.keys(filter).length > 0)
|
|
9250
|
+
})
|
|
9251
|
+
},
|
|
9252
|
+
|
|
9174
9253
|
/**
|
|
9175
9254
|
* The count line template: a scope's own, else the open view's
|
|
9176
9255
|
* (`countTextByView`), else the page's `countText`.
|
|
@@ -9226,6 +9305,9 @@ export default {
|
|
|
9226
9305
|
|
|
9227
9306
|
headerDescriptionBase() {
|
|
9228
9307
|
const total = this.effectivePagination?.total
|
|
9308
|
+
if (this.countTextFiltered && this.listIsNarrowed && typeof total === 'number' && total >= 0) {
|
|
9309
|
+
return fillCountText(this, this.countTextFiltered, this.effectiveObjects.length, total)
|
|
9310
|
+
}
|
|
9229
9311
|
// Board look: the count line is a template over the rows on this page
|
|
9230
9312
|
// and all rows, "{shown} of {total}" unless the page says otherwise.
|
|
9231
9313
|
if (this.isBoardLook && typeof total === 'number' && total >= 0) {
|
|
@@ -9242,13 +9324,7 @@ export default {
|
|
|
9242
9324
|
return t('nextcloud-vue', '{shown} of {total}', { shown, total })
|
|
9243
9325
|
}
|
|
9244
9326
|
if (countText) {
|
|
9245
|
-
|
|
9246
|
-
return fillMyTeamToken(translated, translated.includes('{myTeam}') ? (peekMyTeamName() || '') : '')
|
|
9247
|
-
.replace('{shown}', String(shown))
|
|
9248
|
-
.replace('{total}', String(total))
|
|
9249
|
-
.replace(/\{term\}/g, this.sourceTerm)
|
|
9250
|
-
.replace(/\{view\}/g, this.appliedViewConditionsText)
|
|
9251
|
-
.replace(/\{(\w+)\|[^}]*\}|\{(\w+)\}/g, (token, a, b) => this.countValueToken(token, a || b))
|
|
9327
|
+
return fillCountText(this, countText, shown, total)
|
|
9252
9328
|
}
|
|
9253
9329
|
return this.countLine(this.countSubtitle, total, shown)
|
|
9254
9330
|
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
- SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
-->
|
|
5
|
+
<template>
|
|
6
|
+
<CnDialog
|
|
7
|
+
:name="dialogTitle"
|
|
8
|
+
width="form"
|
|
9
|
+
:noClose="busy"
|
|
10
|
+
data-testid="cn-object-link-dialog"
|
|
11
|
+
@closing="close">
|
|
12
|
+
<div class="cn-object-link-dialog">
|
|
13
|
+
<CnSearchSelect
|
|
14
|
+
:modelValue="picked ? picked.id : null"
|
|
15
|
+
:inputLabel="targetLabel"
|
|
16
|
+
:labelOutside="false"
|
|
17
|
+
:options="options"
|
|
18
|
+
:loading="searching"
|
|
19
|
+
:filterable="false"
|
|
20
|
+
data-testid="cn-object-link-dialog-target"
|
|
21
|
+
@search="onSearch"
|
|
22
|
+
@update:modelValue="onPick" />
|
|
23
|
+
<NcSelect
|
|
24
|
+
v-model="type"
|
|
25
|
+
:inputLabel="typeLabel"
|
|
26
|
+
:options="typeOptions"
|
|
27
|
+
:reduce="(option) => option.value"
|
|
28
|
+
:clearable="false"
|
|
29
|
+
label="label"
|
|
30
|
+
data-testid="cn-object-link-dialog-type" />
|
|
31
|
+
<template v-for="field in fields" :key="field.key">
|
|
32
|
+
<NcTextArea
|
|
33
|
+
v-if="field.type === 'textarea'"
|
|
34
|
+
v-model="values[field.key]"
|
|
35
|
+
:label="field.label"
|
|
36
|
+
:rows="2"
|
|
37
|
+
resize="vertical"
|
|
38
|
+
:data-testid="`cn-object-link-dialog-field-${field.key}`" />
|
|
39
|
+
<NcTextField
|
|
40
|
+
v-else
|
|
41
|
+
v-model="values[field.key]"
|
|
42
|
+
:label="field.label"
|
|
43
|
+
:type="field.type === 'date' ? 'date' : 'text'"
|
|
44
|
+
:data-testid="`cn-object-link-dialog-field-${field.key}`" />
|
|
45
|
+
</template>
|
|
46
|
+
<p v-if="refusal"
|
|
47
|
+
class="cn-object-link-dialog__error"
|
|
48
|
+
role="alert"
|
|
49
|
+
data-testid="cn-object-link-dialog-refusal">
|
|
50
|
+
{{ refusal }}
|
|
51
|
+
</p>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<template #actions>
|
|
55
|
+
<NcButton :disabled="busy" data-testid="cn-object-link-dialog-cancel" @click="close">
|
|
56
|
+
{{ tr('Cancel') }}
|
|
57
|
+
</NcButton>
|
|
58
|
+
<NcButton
|
|
59
|
+
variant="primary"
|
|
60
|
+
:disabled="busy || !picked || !type"
|
|
61
|
+
data-testid="cn-object-link-dialog-save"
|
|
62
|
+
@click="confirm">
|
|
63
|
+
{{ tr('Save') }}
|
|
64
|
+
</NcButton>
|
|
65
|
+
</template>
|
|
66
|
+
</CnDialog>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
import { NcButton, NcSelect, NcTextArea, NcTextField } from '@nextcloud/vue'
|
|
71
|
+
import { prefixUrl } from '../../utils/headers.js'
|
|
72
|
+
import { readPath } from '../../utils/readPath.js'
|
|
73
|
+
import { CnDialog } from '../CnDialog/index.js'
|
|
74
|
+
import { CnSearchSelect } from '../CnSearchSelect/index.js'
|
|
75
|
+
import { objectsUrl } from './objectLinks.js'
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* CnObjectLinkDialog: the add dialog of the `object-links` widget: search the
|
|
79
|
+
* records a link may point at (every target schema, this record left out),
|
|
80
|
+
* pick the link type, fill the extra fields, and save through the widget's
|
|
81
|
+
* `save`, which answers `{ ok, message? }`. A refusal stays in the dialog in
|
|
82
|
+
* the server's words.
|
|
83
|
+
*
|
|
84
|
+
* @spec openspec/changes/contact-side-cards-generic/specs/contact-side-cards-generic/spec.md#requirement-a-records-links-to-other-records-are-listed-added-and-removed
|
|
85
|
+
*/
|
|
86
|
+
export default {
|
|
87
|
+
name: 'CnObjectLinkDialog',
|
|
88
|
+
|
|
89
|
+
components: { CnDialog, CnSearchSelect, NcButton, NcSelect, NcTextArea, NcTextField },
|
|
90
|
+
|
|
91
|
+
inject: {
|
|
92
|
+
cnTranslate: { default: () => (key) => key },
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
props: {
|
|
96
|
+
/** The `object-links` widget content. */
|
|
97
|
+
content: {
|
|
98
|
+
type: Object,
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/** The id of the record the link starts from; left out of the search. */
|
|
103
|
+
objectId: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: '',
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/** Writes the link: `({ target, type, values }) => Promise<{ ok, message? }>`. */
|
|
109
|
+
save: {
|
|
110
|
+
type: Function,
|
|
111
|
+
required: true,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
emits: ['close'],
|
|
116
|
+
|
|
117
|
+
data() {
|
|
118
|
+
return {
|
|
119
|
+
options: [],
|
|
120
|
+
picked: null,
|
|
121
|
+
type: null,
|
|
122
|
+
values: {},
|
|
123
|
+
searching: false,
|
|
124
|
+
busy: false,
|
|
125
|
+
refusal: '',
|
|
126
|
+
searchTimer: null,
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
computed: {
|
|
131
|
+
dialogTitle() {
|
|
132
|
+
return this.tr(this.content.add?.dialogTitle || this.content.add?.ariaLabel || this.content.add?.label || 'Add')
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
targetLabel() {
|
|
136
|
+
return this.tr(this.content.targetLabel || 'Linked record')
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
typeLabel() {
|
|
140
|
+
return this.tr(this.content.typeLabel || 'Type')
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
targets() {
|
|
144
|
+
return Array.isArray(this.content.targets) ? this.content.targets.filter((target) => target && target.register && target.schema) : []
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/** The type choices, each with its group in brackets (`groupLabel`, else `group`). */
|
|
148
|
+
typeOptions() {
|
|
149
|
+
return (Array.isArray(this.content.types) ? this.content.types : [])
|
|
150
|
+
.filter((type) => type && type.value !== undefined)
|
|
151
|
+
.map((type) => ({
|
|
152
|
+
value: type.value,
|
|
153
|
+
label: this.groupWords(type) ? `${this.tr(type.label || String(type.value))} (${this.groupWords(type)})` : this.tr(type.label || String(type.value)),
|
|
154
|
+
}))
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
fields() {
|
|
158
|
+
return (Array.isArray(this.content.fields) ? this.content.fields : [])
|
|
159
|
+
.filter((field) => field && field.key)
|
|
160
|
+
.map((field) => ({ ...field, label: this.tr(field.label || field.key) }))
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
beforeUnmount() {
|
|
165
|
+
clearTimeout(this.searchTimer)
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
methods: {
|
|
169
|
+
tr(text) {
|
|
170
|
+
if (typeof text !== 'string' || text === '') {
|
|
171
|
+
return ''
|
|
172
|
+
}
|
|
173
|
+
return typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A type's group in words: `groupLabel`, else the stored `group`, translated.
|
|
178
|
+
*
|
|
179
|
+
* @param {{group?: string, groupLabel?: string}} type The type.
|
|
180
|
+
* @return {string}
|
|
181
|
+
*/
|
|
182
|
+
groupWords(type) {
|
|
183
|
+
return this.tr(type.groupLabel || type.group || '')
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
onSearch(query) {
|
|
187
|
+
clearTimeout(this.searchTimer)
|
|
188
|
+
if (typeof query !== 'string' || query.trim().length < 2) {
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
this.searchTimer = setTimeout(() => this.search(query.trim()), 300)
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Search every target schema for the query.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} query What was typed.
|
|
198
|
+
* @return {Promise<void>}
|
|
199
|
+
*/
|
|
200
|
+
async search(query) {
|
|
201
|
+
this.searching = true
|
|
202
|
+
try {
|
|
203
|
+
const { default: axios } = await import('@nextcloud/axios')
|
|
204
|
+
const lists = await Promise.all(this.targets.map(async (target) => {
|
|
205
|
+
try {
|
|
206
|
+
const { data } = await axios.get(prefixUrl(objectsUrl(target.register, target.schema)), { params: { _search: query, _limit: 10 } })
|
|
207
|
+
const results = Array.isArray(data?.results) ? data.results : []
|
|
208
|
+
return results.map((item) => ({
|
|
209
|
+
id: String(item.id ?? item.uuid),
|
|
210
|
+
label: String(readPath(item, target.titleField || 'name') || item.id),
|
|
211
|
+
secondary: this.tr(target.label || ''),
|
|
212
|
+
type: target.type,
|
|
213
|
+
}))
|
|
214
|
+
} catch {
|
|
215
|
+
return []
|
|
216
|
+
}
|
|
217
|
+
}))
|
|
218
|
+
this.options = lists.flat().filter((option) => option.id !== this.objectId)
|
|
219
|
+
} finally {
|
|
220
|
+
this.searching = false
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
onPick(id) {
|
|
225
|
+
this.picked = this.options.find((option) => option.id === id) || null
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
async confirm() {
|
|
229
|
+
if (!this.picked || !this.type) {
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
this.busy = true
|
|
233
|
+
this.refusal = ''
|
|
234
|
+
try {
|
|
235
|
+
const values = Object.fromEntries(Object.entries(this.values).filter(([, value]) => value !== '' && value !== null && value !== undefined))
|
|
236
|
+
const result = await this.save({ target: { id: this.picked.id, type: this.picked.type }, type: this.type, values })
|
|
237
|
+
if (result && result.ok) {
|
|
238
|
+
this.$emit('close')
|
|
239
|
+
} else {
|
|
240
|
+
this.refusal = (result && result.message) || this.tr('This link could not be saved.')
|
|
241
|
+
}
|
|
242
|
+
} finally {
|
|
243
|
+
this.busy = false
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
close() {
|
|
248
|
+
if (!this.busy) {
|
|
249
|
+
this.$emit('close')
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<style scoped>
|
|
257
|
+
.cn-object-link-dialog {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
gap: 12px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.cn-object-link-dialog__error {
|
|
264
|
+
margin: 0;
|
|
265
|
+
color: var(--color-error-text, var(--color-error));
|
|
266
|
+
}
|
|
267
|
+
</style>
|