@conduction/nextcloud-vue 2.140.0 → 2.142.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/CnAssignDialog/CnAssignDialog.vue.js +1 -1
- package/dist/esm/components/CnAssignDialog/CnAssignDialog.vue2.js +10 -2
- package/dist/esm/components/CnAssignDialog/CnAssignDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnAssignDialog/CnAssignDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +24 -3
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +3 -3
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue2.js +12 -0
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue3.js +57 -40
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue.js +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +1 -0
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +26 -3
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +2 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +34 -3
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +43 -3
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +21 -1
- 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/CnIndexPage/useSelfFetchList.js +14 -0
- package/dist/esm/components/CnIndexPage/useSelfFetchList.js.map +1 -1
- package/dist/esm/components/CnIndexSidebar/CnIndexSidebar.vue2.js +65 -1
- package/dist/esm/components/CnIndexSidebar/CnIndexSidebar.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexSidebar/CnIndexSidebar.vue3.js +120 -69
- package/dist/esm/components/CnIndexSidebar/CnIndexSidebar.vue3.js.map +1 -1
- package/dist/esm/components/CnMapWidget/CnMapWidget.vue.js +1 -1
- package/dist/esm/components/CnMapWidget/CnMapWidget.vue2.js +47 -9
- package/dist/esm/components/CnMapWidget/CnMapWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnMapWidget/CnMapWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js +3 -3
- package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue.js +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js +3 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js +2 -1
- package/dist/esm/components/CnObjectSidebar/CnFilesTab.vue3.js.map +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue.js +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue2.js +31 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue2.js.map +1 -1
- package/dist/esm/components/CnPartyPicker/CnPartyPicker.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +2 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue2.js +10 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue3.js +34 -26
- package/dist/esm/components/CnRecordListWidget/CnRecordNoteRows.vue3.js.map +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue.js +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue2.js +52 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue3.js +119 -65
- package/dist/esm/integrations/builtin/contacts/CnContactsTab.vue3.js.map +1 -1
- package/dist/esm/integrations/builtin/deck/CnDeckCard.vue.js +1 -1
- package/dist/esm/integrations/builtin/deck/CnDeckCard.vue2.js +86 -4
- package/dist/esm/integrations/builtin/deck/CnDeckCard.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/deck/CnDeckCard.vue3.js +67 -5
- package/dist/esm/integrations/builtin/deck/CnDeckCard.vue3.js.map +1 -1
- package/dist/esm/l10n/en.json.js +11 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +12 -2
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1116 -686
- package/dist/esm/utils/buildViewTree.js +23 -8
- package/dist/esm/utils/buildViewTree.js.map +1 -1
- package/dist/esm/utils/groupSublines.js +120 -0
- package/dist/esm/utils/groupSublines.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +2023 -1239
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1116 -686
- package/l10n/en.json +11 -1
- package/l10n/nl.json +12 -2
- package/package.json +1 -1
- package/src/components/CnAssignDialog/CnAssignDialog.vue +10 -2
- package/src/components/CnCellRenderer/CnCellRenderer.vue +26 -4
- package/src/components/CnChartWidget/CnChartWidget.md +1 -0
- package/src/components/CnChartWidget/CnChartWidget.vue +49 -4
- package/src/components/CnDashboardPage/CnDashboardPage.vue +1 -0
- package/src/components/CnDataTable/CnDataTable.md +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +28 -4
- package/src/components/CnFactsWidget/CnFactsWidget.vue +34 -3
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +44 -4
- package/src/components/CnIndexPage/CnIndexPage.vue +22 -1
- package/src/components/CnIndexPage/useSelfFetchList.js +14 -0
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +101 -3
- package/src/components/CnMapWidget/CnMapWidget.vue +47 -9
- package/src/components/CnObjectListWidget/CnObjectListWidget.vue +3 -3
- package/src/components/CnObjectSidebar/CnFilesTab.vue +4 -1
- package/src/components/CnPartyPicker/CnPartyPicker.vue +31 -1
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +20 -1
- package/src/components/CnRecordListWidget/CnRecordNoteRows.vue +33 -9
- package/src/css/dialog.css +13 -1
- package/src/css/look-board-detail.css +107 -9
- package/src/css/look-board-index.css +143 -7
- package/src/css/look-board.css +109 -0
- package/src/css/table.css +12 -0
- package/src/integrations/builtin/contacts/CnContactsTab.vue +101 -26
- package/src/integrations/builtin/contacts/__tests__/CnContactsTabBoardRows.spec.js +67 -0
- package/src/integrations/builtin/deck/CnDeckCard.vue +121 -2
- package/src/integrations/builtin/deck/__tests__/CnDeckCardHeaderActions.spec.js +68 -0
- package/src/utils/buildViewTree.js +23 -8
- package/src/utils/groupSublines.js +125 -0
|
@@ -21,6 +21,22 @@
|
|
|
21
21
|
-->
|
|
22
22
|
<template>
|
|
23
23
|
<CnDetailCard :title="cardHeaderTitle" :icon="cardIcon" :collapsible="collapsible">
|
|
24
|
+
<!-- `headerActions`: the Deck tab's link and create flows in the title row (detail page). -->
|
|
25
|
+
<template v-if="shownHeaderActions.length > 0" #actions>
|
|
26
|
+
<NcButton
|
|
27
|
+
v-for="action in shownHeaderActions"
|
|
28
|
+
:key="action"
|
|
29
|
+
variant="secondary"
|
|
30
|
+
:data-testid="`cn-deck-card-${action}`"
|
|
31
|
+
@click.stop="action === 'create' ? (createOpen = true) : (pickerOpen = true)">
|
|
32
|
+
<template #icon>
|
|
33
|
+
<Plus v-if="action === 'create'" :size="20" />
|
|
34
|
+
<LinkVariant v-else :size="20" />
|
|
35
|
+
</template>
|
|
36
|
+
{{ action === 'create' ? createLabel : linkLabel }}
|
|
37
|
+
</NcButton>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
24
40
|
<NcLoadingIcon v-if="loading" />
|
|
25
41
|
|
|
26
42
|
<!-- single-entity surface: chip -->
|
|
@@ -102,13 +118,33 @@
|
|
|
102
118
|
</section>
|
|
103
119
|
</div>
|
|
104
120
|
</template>
|
|
121
|
+
|
|
122
|
+
<p v-if="actionError" class="cn-deck-card__action-error" role="alert">
|
|
123
|
+
{{ actionError }}
|
|
124
|
+
</p>
|
|
125
|
+
|
|
126
|
+
<CnDeckCardPicker
|
|
127
|
+
v-if="pickerOpen"
|
|
128
|
+
:apiBase="apiBase"
|
|
129
|
+
@close="pickerOpen = false"
|
|
130
|
+
@link="onLink" />
|
|
131
|
+
|
|
132
|
+
<CnDeckCardCreate
|
|
133
|
+
v-if="createOpen"
|
|
134
|
+
:apiBase="apiBase"
|
|
135
|
+
@close="createOpen = false"
|
|
136
|
+
@create="onCreate" />
|
|
105
137
|
</CnDetailCard>
|
|
106
138
|
</template>
|
|
107
139
|
|
|
108
140
|
<script>
|
|
109
141
|
import { translatePlural as n, translate as t } from '@nextcloud/l10n'
|
|
110
|
-
import { NcLoadingIcon } from '@nextcloud/vue'
|
|
142
|
+
import { NcButton, NcLoadingIcon } from '@nextcloud/vue'
|
|
143
|
+
import LinkVariant from 'vue-material-design-icons/LinkVariant.vue'
|
|
144
|
+
import Plus from 'vue-material-design-icons/Plus.vue'
|
|
111
145
|
import ViewColumnOutline from 'vue-material-design-icons/ViewColumnOutline.vue'
|
|
146
|
+
import CnDeckCardCreate from '../../../components/CnDeckCardCreate/CnDeckCardCreate.vue'
|
|
147
|
+
import CnDeckCardPicker from '../../../components/CnDeckCardPicker/CnDeckCardPicker.vue'
|
|
112
148
|
import CnDetailCard from '../../../components/CnDetailCard/CnDetailCard.vue'
|
|
113
149
|
import { buildHeaders, prefixUrl, safeHref } from '../../../utils/index.js'
|
|
114
150
|
|
|
@@ -123,7 +159,7 @@ const VALID_SURFACES = ['user-dashboard', 'app-dashboard', 'detail-page', 'singl
|
|
|
123
159
|
export default {
|
|
124
160
|
name: 'CnDeckCard',
|
|
125
161
|
|
|
126
|
-
components: { CnDetailCard, NcLoadingIcon, ViewColumnOutline },
|
|
162
|
+
components: { CnDeckCardCreate, CnDeckCardPicker, CnDetailCard, LinkVariant, NcButton, NcLoadingIcon, Plus, ViewColumnOutline },
|
|
127
163
|
|
|
128
164
|
props: {
|
|
129
165
|
/** Stable integration id (forwarded from the registry — always `'deck'`). */
|
|
@@ -157,6 +193,16 @@ export default {
|
|
|
157
193
|
unavailableLabel: { type: String, default: () => t('nextcloud-vue', 'NC Deck is currently unavailable.') },
|
|
158
194
|
/** URL of the NC Deck app entry. */
|
|
159
195
|
deckAppUrl: { type: String, default: '/index.php/apps/deck' },
|
|
196
|
+
/**
|
|
197
|
+
* Buttons in the card's title row on a detail page: `link` links an
|
|
198
|
+
* existing Deck card, `create` makes a new one linked to the object.
|
|
199
|
+
* In the order given; none by default.
|
|
200
|
+
*/
|
|
201
|
+
headerActions: { type: Array, default: () => [] },
|
|
202
|
+
/** Label of the `link` button. */
|
|
203
|
+
linkLabel: { type: String, default: () => t('nextcloud-vue', 'Link an existing card') },
|
|
204
|
+
/** Label of the `create` button. */
|
|
205
|
+
createLabel: { type: String, default: () => t('nextcloud-vue', 'New card') },
|
|
160
206
|
},
|
|
161
207
|
|
|
162
208
|
data() {
|
|
@@ -165,10 +211,26 @@ export default {
|
|
|
165
211
|
entity: null,
|
|
166
212
|
loading: false,
|
|
167
213
|
degraded: '',
|
|
214
|
+
pickerOpen: false,
|
|
215
|
+
createOpen: false,
|
|
216
|
+
actionError: '',
|
|
168
217
|
}
|
|
169
218
|
},
|
|
170
219
|
|
|
171
220
|
computed: {
|
|
221
|
+
/**
|
|
222
|
+
* The title-row buttons to draw: only on a detail page with an
|
|
223
|
+
* object, only the known ones, in the order given.
|
|
224
|
+
*
|
|
225
|
+
* @return {Array<string>}
|
|
226
|
+
*/
|
|
227
|
+
shownHeaderActions() {
|
|
228
|
+
if (this.surface !== 'detail-page' || !this.objectId || !Array.isArray(this.headerActions)) {
|
|
229
|
+
return []
|
|
230
|
+
}
|
|
231
|
+
return this.headerActions.filter((action, index, all) => ['create', 'link'].includes(action) && all.indexOf(action) === index)
|
|
232
|
+
},
|
|
233
|
+
|
|
172
234
|
cardHeaderTitle() {
|
|
173
235
|
return this.title || this.integrationId
|
|
174
236
|
},
|
|
@@ -263,6 +325,58 @@ export default {
|
|
|
263
325
|
},
|
|
264
326
|
|
|
265
327
|
methods: {
|
|
328
|
+
/** @return {string} The object's Deck endpoint the link and create flows post to. */
|
|
329
|
+
deckEndpoint() {
|
|
330
|
+
return `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/deck`
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Link the picked card, then read the list again.
|
|
335
|
+
*
|
|
336
|
+
* @param {object} payload `{ cardId }` from the picker.
|
|
337
|
+
*/
|
|
338
|
+
async onLink(payload) {
|
|
339
|
+
this.pickerOpen = false
|
|
340
|
+
await this.post(this.deckEndpoint(), payload, t('nextcloud-vue', 'Could not link card.'))
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Create the card linked to the object, then read the list again.
|
|
345
|
+
*
|
|
346
|
+
* @param {object} payload `{ boardId, stackId, title, ... }` from the form.
|
|
347
|
+
*/
|
|
348
|
+
async onCreate(payload) {
|
|
349
|
+
this.createOpen = false
|
|
350
|
+
await this.post(`${this.deckEndpoint()}/new`, payload, t('nextcloud-vue', 'Could not create card.'))
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* POST one flow's payload and reload on success.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} url The endpoint.
|
|
357
|
+
* @param {object} payload The body.
|
|
358
|
+
* @param {string} failure The sentence shown when it fails.
|
|
359
|
+
*/
|
|
360
|
+
async post(url, payload, failure) {
|
|
361
|
+
this.actionError = ''
|
|
362
|
+
try {
|
|
363
|
+
const response = await fetch(prefixUrl(url), {
|
|
364
|
+
method: 'POST',
|
|
365
|
+
headers: { ...buildHeaders(), 'Content-Type': 'application/json' },
|
|
366
|
+
body: JSON.stringify(payload),
|
|
367
|
+
})
|
|
368
|
+
if (response.ok) {
|
|
369
|
+
await this.fetchList()
|
|
370
|
+
} else if (response.status === 409) {
|
|
371
|
+
this.actionError = t('nextcloud-vue', 'This card is already linked.')
|
|
372
|
+
} else {
|
|
373
|
+
this.actionError = failure
|
|
374
|
+
}
|
|
375
|
+
} catch {
|
|
376
|
+
this.actionError = failure
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
|
|
266
380
|
baseUrl() {
|
|
267
381
|
return `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/integrations/${this.integrationId}`
|
|
268
382
|
},
|
|
@@ -366,6 +480,11 @@ export default {
|
|
|
366
480
|
</script>
|
|
367
481
|
|
|
368
482
|
<style scoped>
|
|
483
|
+
.cn-deck-card__action-error {
|
|
484
|
+
margin: 8px 0 0;
|
|
485
|
+
color: var(--color-error-text, var(--color-error));
|
|
486
|
+
}
|
|
487
|
+
|
|
369
488
|
.cn-deck-card__empty {
|
|
370
489
|
color: var(--color-text-maxcontrast);
|
|
371
490
|
font-size: 0.9em;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CnDeckCard `headerActions` (DqZaakTaken "Kaarten": "Bestaande kaart
|
|
3
|
+
* koppelen" and "Nieuwe kaart" in the title row): on a detail page with an
|
|
4
|
+
* object, the card offers the Deck tab's link and create flows and reloads
|
|
5
|
+
* after either.
|
|
6
|
+
*
|
|
7
|
+
* @spec openspec/changes/deck-card-header-actions/specs/deck-card/spec.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { flushPromises, mount } = require('@vue/test-utils')
|
|
11
|
+
const CnDeckCard = require('../CnDeckCard.vue').default
|
|
12
|
+
|
|
13
|
+
const PROPS = { register: 'reg', schema: 'case', objectId: 'obj-1', surface: 'detail-page' }
|
|
14
|
+
|
|
15
|
+
function ok(body = { results: [] }) {
|
|
16
|
+
return { ok: true, status: 200, json: () => Promise.resolve(body) }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('CnDeckCard headerActions', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
global.fetch = jest.fn().mockResolvedValue(ok())
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
delete global.fetch
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('draws no buttons by default', async () => {
|
|
29
|
+
const w = mount(CnDeckCard, { props: PROPS })
|
|
30
|
+
await flushPromises()
|
|
31
|
+
expect(w.find('[data-testid="cn-deck-card-link"]').exists()).toBe(false)
|
|
32
|
+
expect(w.find('[data-testid="cn-deck-card-create"]').exists()).toBe(false)
|
|
33
|
+
w.unmount()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('draws link and create in the order given, only on a detail page', async () => {
|
|
37
|
+
const w = mount(CnDeckCard, { props: { ...PROPS, headerActions: ['link', 'create'] } })
|
|
38
|
+
await flushPromises()
|
|
39
|
+
const buttons = w.findAll('[data-testid^="cn-deck-card-"]').filter((b) => ['cn-deck-card-link', 'cn-deck-card-create'].includes(b.attributes('data-testid')))
|
|
40
|
+
expect(buttons.map((b) => b.attributes('data-testid'))).toEqual(['cn-deck-card-link', 'cn-deck-card-create'])
|
|
41
|
+
await w.setProps({ surface: 'user-dashboard' })
|
|
42
|
+
expect(w.find('[data-testid="cn-deck-card-link"]').exists()).toBe(false)
|
|
43
|
+
w.unmount()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('links a picked card through the deck endpoint and reloads', async () => {
|
|
47
|
+
const w = mount(CnDeckCard, { props: { ...PROPS, headerActions: ['link'] } })
|
|
48
|
+
await flushPromises()
|
|
49
|
+
global.fetch.mockClear()
|
|
50
|
+
await w.vm.onLink({ cardId: 7 })
|
|
51
|
+
await flushPromises()
|
|
52
|
+
expect(global.fetch.mock.calls[0][0]).toContain('/objects/reg/case/obj-1/deck')
|
|
53
|
+
expect(global.fetch.mock.calls[0][1].method).toBe('POST')
|
|
54
|
+
expect(global.fetch.mock.calls[1][0]).toContain('/integrations/deck')
|
|
55
|
+
w.unmount()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('creates a card through the deck endpoint and reloads', async () => {
|
|
59
|
+
const w = mount(CnDeckCard, { props: { ...PROPS, headerActions: ['create'] } })
|
|
60
|
+
await flushPromises()
|
|
61
|
+
global.fetch.mockClear()
|
|
62
|
+
await w.vm.onCreate({ boardId: 1, stackId: 2, title: 'Offerte' })
|
|
63
|
+
await flushPromises()
|
|
64
|
+
expect(global.fetch.mock.calls[0][0]).toContain('/objects/reg/case/obj-1/deck/new')
|
|
65
|
+
expect(global.fetch.mock.calls[1][0]).toContain('/integrations/deck')
|
|
66
|
+
w.unmount()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
@@ -164,15 +164,15 @@ export function buildViewTree({ views = [], labelFilter = '', maxDepth = 3 } = {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
// Seeded roots first,
|
|
168
|
-
//
|
|
169
|
-
// can build a habit with.
|
|
167
|
+
// Seeded roots first, in the order the app declares them, then the
|
|
168
|
+
// reader's own in the order they were saved (DqFilterBeheren). Both are
|
|
169
|
+
// stable between two openings, so a person can build a habit with them.
|
|
170
170
|
const seededRoots = roots.filter(({ view }) => view?.seeded === true)
|
|
171
171
|
const ownRoots = roots.filter(({ view }) => view?.seeded !== true)
|
|
172
|
-
for (const { view, orphaned } of
|
|
172
|
+
for (const { view, orphaned } of seededRoots) {
|
|
173
173
|
emit(view, 0, orphaned)
|
|
174
174
|
}
|
|
175
|
-
for (const { view, orphaned } of
|
|
175
|
+
for (const { view, orphaned } of sortRootsBySaved(ownRoots)) {
|
|
176
176
|
emit(view, 0, orphaned)
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -228,11 +228,26 @@ function sortByName(views) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
* Root entries
|
|
231
|
+
* Root entries in the order their views were saved (`created`, oldest
|
|
232
|
+
* first); views without a saved time follow, by name.
|
|
232
233
|
*
|
|
233
234
|
* @param {Array<object>} roots - The root entries.
|
|
234
235
|
* @return {Array<object>} The same entries, sorted.
|
|
235
236
|
*/
|
|
236
|
-
function
|
|
237
|
-
|
|
237
|
+
function sortRootsBySaved(roots) {
|
|
238
|
+
const savedAt = (entry) => (typeof entry.view?.created === 'string' ? entry.view.created : '')
|
|
239
|
+
return [...roots].sort((left, right) => {
|
|
240
|
+
const a = savedAt(left)
|
|
241
|
+
const b = savedAt(right)
|
|
242
|
+
if (a !== b) {
|
|
243
|
+
if (a === '') {
|
|
244
|
+
return 1
|
|
245
|
+
}
|
|
246
|
+
if (b === '') {
|
|
247
|
+
return -1
|
|
248
|
+
}
|
|
249
|
+
return a < b ? -1 : 1
|
|
250
|
+
}
|
|
251
|
+
return String(left.view?.name ?? '').localeCompare(String(right.view?.name ?? ''))
|
|
252
|
+
})
|
|
238
253
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line under a team in a picker: how many members it has and what it is
|
|
3
|
+
* for ("6 leden · bezwaar, beroep en Woo-advies", board DqOverdragen).
|
|
4
|
+
*
|
|
5
|
+
* The count comes from Nextcloud's group details; that endpoint answers
|
|
6
|
+
* administrators and group admins only, so for anyone else the count is left
|
|
7
|
+
* out rather than guessed. Nextcloud keeps no description for a group, so the
|
|
8
|
+
* text comes from an app's own records when the app names them (`describe`:
|
|
9
|
+
* `{ register, schema, groupField?, textField? }`, by default the record's
|
|
10
|
+
* `ncGroupId` and `description`).
|
|
11
|
+
*
|
|
12
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
13
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
14
|
+
*
|
|
15
|
+
* @module utils/groupSublines
|
|
16
|
+
* @spec openspec/changes/assign-team-option-subline/specs/assign-dialog/spec.md
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import axios from '@nextcloud/axios'
|
|
20
|
+
import { translatePlural as n } from '@nextcloud/l10n'
|
|
21
|
+
import { generateOcsUrl } from '@nextcloud/router'
|
|
22
|
+
import { fetchReferenceObjects } from './boardReferenceColumns.js'
|
|
23
|
+
|
|
24
|
+
const descriptionCache = new Map()
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Member counts by group id for the groups a search finds. Fails soft to `{}`.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} query The search term.
|
|
30
|
+
* @return {Promise<Record<string, number>>} Counts by group id.
|
|
31
|
+
* @spec openspec/changes/assign-team-option-subline/specs/assign-dialog/spec.md
|
|
32
|
+
*/
|
|
33
|
+
async function memberCounts(query) {
|
|
34
|
+
try {
|
|
35
|
+
const response = await axios.get(generateOcsUrl('cloud/groups/details'), {
|
|
36
|
+
headers: { 'OCS-APIRequest': 'true', Accept: 'application/json' },
|
|
37
|
+
params: { search: query || '', limit: 50 },
|
|
38
|
+
})
|
|
39
|
+
const data = response && response.data && response.data.ocs ? response.data.ocs.data : (response && response.data)
|
|
40
|
+
const groups = data && Array.isArray(data.groups) ? data.groups : []
|
|
41
|
+
const out = {}
|
|
42
|
+
for (const group of groups) {
|
|
43
|
+
const count = Number(group && group.usercount)
|
|
44
|
+
if (group && group.id && Number.isFinite(count)) {
|
|
45
|
+
out[String(group.id)] = count
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out
|
|
49
|
+
} catch {
|
|
50
|
+
return {}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Descriptions by group id from the app's records. Read once per source.
|
|
56
|
+
*
|
|
57
|
+
* @param {{register?: string, schema?: string, groupField?: string, textField?: string}|null} describe The source.
|
|
58
|
+
* @return {Promise<Record<string, string>>} Descriptions by group id.
|
|
59
|
+
* @spec openspec/changes/assign-team-option-subline/specs/assign-dialog/spec.md
|
|
60
|
+
*/
|
|
61
|
+
async function descriptions(describe) {
|
|
62
|
+
if (!describe || !describe.register || !describe.schema) {
|
|
63
|
+
return {}
|
|
64
|
+
}
|
|
65
|
+
const groupField = describe.groupField || 'ncGroupId'
|
|
66
|
+
const textField = describe.textField || 'description'
|
|
67
|
+
const key = [describe.register, describe.schema, groupField, textField].join('/')
|
|
68
|
+
if (!descriptionCache.has(key)) {
|
|
69
|
+
descriptionCache.set(key, fetchReferenceObjects({ register: describe.register, schema: describe.schema, limit: 500 })
|
|
70
|
+
.then((rows) => {
|
|
71
|
+
const out = {}
|
|
72
|
+
for (const row of rows) {
|
|
73
|
+
const gid = row && row[groupField]
|
|
74
|
+
const text = row && typeof row[textField] === 'string' ? row[textField].trim() : ''
|
|
75
|
+
if (gid && text && out[String(gid)] === undefined) {
|
|
76
|
+
out[String(gid)] = text
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return out
|
|
80
|
+
})
|
|
81
|
+
.catch(() => {
|
|
82
|
+
descriptionCache.delete(key)
|
|
83
|
+
return {}
|
|
84
|
+
}))
|
|
85
|
+
}
|
|
86
|
+
return descriptionCache.get(key)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The line under each group: its member count and its description, joined by
|
|
91
|
+
* " · ", either left out when unknown.
|
|
92
|
+
*
|
|
93
|
+
* @param {string[]} ids The group ids to describe.
|
|
94
|
+
* @param {string} query The search the groups came from.
|
|
95
|
+
* @param {object|null} [describe] Where the app keeps a group's description.
|
|
96
|
+
* @return {Promise<Record<string, string>>} The line by group id ('' when nothing is known).
|
|
97
|
+
* @spec openspec/changes/assign-team-option-subline/specs/assign-dialog/spec.md
|
|
98
|
+
*/
|
|
99
|
+
export async function groupSublines(ids, query, describe = null) {
|
|
100
|
+
if (!Array.isArray(ids) || ids.length === 0) {
|
|
101
|
+
return {}
|
|
102
|
+
}
|
|
103
|
+
const [counts, texts] = await Promise.all([memberCounts(query), descriptions(describe)])
|
|
104
|
+
const out = {}
|
|
105
|
+
for (const id of ids) {
|
|
106
|
+
const parts = []
|
|
107
|
+
if (counts[id] !== undefined) {
|
|
108
|
+
parts.push(n('nextcloud-vue', '{count} member', '{count} members', counts[id], { count: counts[id] }))
|
|
109
|
+
}
|
|
110
|
+
if (texts[id]) {
|
|
111
|
+
parts.push(texts[id])
|
|
112
|
+
}
|
|
113
|
+
out[id] = parts.join(' · ')
|
|
114
|
+
}
|
|
115
|
+
return out
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Forget the cached descriptions (tests, or after the source changed).
|
|
120
|
+
*
|
|
121
|
+
* @return {void}
|
|
122
|
+
*/
|
|
123
|
+
export function clearGroupSublineCache() {
|
|
124
|
+
descriptionCache.clear()
|
|
125
|
+
}
|