@open-commune/web 0.2.14 → 0.2.16
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/app.config.ts +7 -0
- package/components/audience/audience-bar-list.vue +29 -0
- package/components/audience/audience-panel.vue +230 -0
- package/components/data/lists/data-table.vue +203 -0
- package/components/data/lists/row-actions.vue +41 -0
- package/components/elements/badges/status-badge.vue +23 -0
- package/components/elements/media/media-image.vue +26 -0
- package/components/forms/fields/input-files-media.vue +87 -0
- package/components/forms/{inputs → fields}/input-filter-status.vue +2 -2
- package/components/forms/{inputs → fields}/input-search.vue +8 -2
- package/components/forms/fields/input-text-area.vue +86 -0
- package/components/forms/fields/input-text.vue +47 -0
- package/components/forms/fields/select-enum.vue +69 -0
- package/components/forms/handlers/handler-collections.vue +100 -170
- package/components/forms/handlers/handler-list.vue +187 -0
- package/components/forms/handlers/handler-members.vue +171 -0
- package/components/forms/handlers/handler-password-reset.vue +45 -0
- package/components/forms/handlers/handler-roles.vue +28 -166
- package/components/forms/handlers/handler-sessions.vue +77 -0
- package/components/forms/handlers/handler-tokens.vue +54 -69
- package/components/forms/layouts/form-default.vue +99 -0
- package/components/forms/layouts/form.vue +4 -0
- package/components/forms/layouts/forms-layout.vue +236 -0
- package/components/forms/layouts/forms-section.vue +186 -0
- package/components/forms/layouts/layout.vue +4 -0
- package/components/forms/layouts/modal.vue +4 -0
- package/components/forms/layouts/section.vue +4 -0
- package/components/layout/shell/shell-account-menu.vue +10 -2
- package/composables/core/domains/use-api-tokens.ts +80 -0
- package/composables/core/domains/use-audience.ts +26 -0
- package/composables/core/domains/use-auth.ts +56 -2
- package/composables/core/domains/use-definitions.ts +18 -5
- package/composables/core/domains/use-entries.ts +125 -3
- package/composables/core/domains/use-media.ts +24 -1
- package/composables/core/domains/use-members.ts +68 -0
- package/composables/core/domains/use-organization.ts +53 -0
- package/composables/use-models.js +1 -7
- package/constants/errors.ts +29 -0
- package/constants/forms/account.ts +62 -0
- package/constants/forms/collections.ts +39 -0
- package/constants/forms/members.ts +40 -0
- package/constants/forms/organization.ts +188 -0
- package/constants/forms/tokens.ts +15 -0
- package/constants/roles.ts +57 -0
- package/constants/settings.ts +26 -0
- package/constants/statuses.ts +8 -5
- package/nuxt.config.ts +4 -1
- package/package.json +4 -3
- package/pages/[collection]/[record]/index.vue +7 -0
- package/pages/[collection]/index.vue +117 -97
- package/pages/account.vue +40 -0
- package/pages/overview.vue +106 -2
- package/pages/settings.vue +26 -181
- package/plugins/01.validation.client.ts +23 -0
- package/store/layout/workspace.js +4 -28
- package/utils/colors.ts +26 -0
- package/utils/errors.ts +13 -0
- package/utils/forms.ts +67 -0
- package/utils/list-columns.ts +90 -0
- package/utils/settings.ts +38 -0
- package/utils/statuses.ts +4 -0
- package/models/role.js +0 -66
- package/models/token.js +0 -56
- package/models/user.js +0 -97
- package/pages/management/index.vue +0 -15
- package/pages/management/members.vue +0 -176
- package/pages/management/organizations.vue +0 -192
- package/pages/management/roles.vue +0 -183
- /package/components/forms/{inputs → fields}/input-filter.vue +0 -0
|
@@ -1,124 +1,144 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<div v-if="!$route.params.event" class="mb-4 flex flex-wrap items-center gap-2">
|
|
7
|
-
<input-filter
|
|
8
|
-
v-if="collectionRecord?.name"
|
|
9
|
-
label="Collection"
|
|
10
|
-
:value="collectionRecord.name"
|
|
11
|
-
disabled
|
|
12
|
-
/>
|
|
13
|
-
<input-filter-status v-model="statuses" />
|
|
14
|
-
<input-search v-model="search" class="ml-auto" />
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<default-table
|
|
18
|
-
v-if="!$route.params.event && records.length"
|
|
19
|
-
:key="narrowingKey"
|
|
20
|
-
:headers="headers"
|
|
21
|
-
:items="records"
|
|
22
|
-
:actions="abilities"
|
|
23
|
-
:pagination-size="limit"
|
|
24
|
-
paginated-content
|
|
25
|
-
@fetch-more="_fetchMoreRecords"
|
|
26
|
-
@update="_updateRecord"
|
|
27
|
-
@remove="_removeRecord"
|
|
2
|
+
<div class="w-full">
|
|
3
|
+
<audience-panel
|
|
4
|
+
:collection="{ id: String($route.params.collection), slug: String($route.params.collection) }"
|
|
5
|
+
class="mb-6"
|
|
28
6
|
/>
|
|
7
|
+
<section v-if="isPending" class="w-full">
|
|
8
|
+
<div class="mb-4 flex flex-wrap items-center gap-2">
|
|
9
|
+
<USkeleton class="h-9 w-44 rounded-md" />
|
|
10
|
+
<USkeleton class="h-9 w-28 rounded-md" />
|
|
11
|
+
<USkeleton class="ml-auto size-9 rounded-md" />
|
|
12
|
+
</div>
|
|
13
|
+
<div class="space-y-2">
|
|
14
|
+
<USkeleton v-for="i in 5" :key="i" class="h-16 rounded-lg" />
|
|
15
|
+
</div>
|
|
16
|
+
</section>
|
|
17
|
+
|
|
18
|
+
<section v-else class="w-full">
|
|
19
|
+
<!-- Both controls narrow on the SERVER: a collection of several hundred
|
|
20
|
+
entries does not fit in the browser, and narrowing what is loaded only
|
|
21
|
+
ever finds what is already visible. -->
|
|
22
|
+
<div class="mb-4 flex flex-wrap items-center gap-2">
|
|
23
|
+
<input-filter
|
|
24
|
+
v-if="collection?.name"
|
|
25
|
+
label="Collection"
|
|
26
|
+
:value="collection.name"
|
|
27
|
+
disabled
|
|
28
|
+
/>
|
|
29
|
+
<input-filter-status v-model="filters.status" />
|
|
30
|
+
<input-search v-model="filters.search" class="ml-auto" />
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<data-table
|
|
34
|
+
v-if="records.length"
|
|
35
|
+
:items="records"
|
|
36
|
+
v-bind="listingKeys"
|
|
37
|
+
:actions="ACTIONS"
|
|
38
|
+
:loading="isFetching"
|
|
39
|
+
:on-select="_onRowSelect"
|
|
40
|
+
@update="_open"
|
|
41
|
+
@remove="_remove"
|
|
42
|
+
/>
|
|
29
43
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
<UEmpty
|
|
45
|
+
v-else
|
|
46
|
+
icon="i-lucide-inbox"
|
|
47
|
+
:title="narrowed ? 'Aucun résultat' : 'Aucune entrée'"
|
|
48
|
+
:description="narrowed
|
|
49
|
+
? 'Aucune entrée ne correspond à cette recherche ou à ces statuts.'
|
|
50
|
+
: 'Cette collection est vide pour le moment.'"
|
|
51
|
+
/>
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
<div v-if="records.length" class="mt-6 flex items-center justify-center gap-4">
|
|
54
|
+
<p class="text-sm text-dimmed">
|
|
55
|
+
{{ records.length }} affichée{{ records.length > 1 ? 's' : '' }} sur {{ total }}
|
|
56
|
+
</p>
|
|
57
|
+
<UButton
|
|
58
|
+
v-if="hasNextPage"
|
|
59
|
+
color="neutral"
|
|
60
|
+
variant="outline"
|
|
61
|
+
class="px-4"
|
|
62
|
+
label="Afficher plus"
|
|
63
|
+
:loading="isFetchingNextPage"
|
|
64
|
+
@click="fetchNextPage()"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</section>
|
|
68
|
+
</div>
|
|
43
69
|
</template>
|
|
44
70
|
|
|
45
71
|
<script setup>
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
import AudiencePanel from '~/components/audience/audience-panel.vue'
|
|
73
|
+
import dataTable from '~/components/data/lists/data-table'
|
|
74
|
+
import inputFilter from '~/components/forms/fields/input-filter'
|
|
75
|
+
import inputFilterStatus from '~/components/forms/fields/input-filter-status'
|
|
76
|
+
import inputSearch from '~/components/forms/fields/input-search'
|
|
77
|
+
import { ALL_STATUSES } from '~/constants/statuses'
|
|
78
|
+
import { listingKeysFor } from '~/utils/list-columns'
|
|
79
|
+
|
|
80
|
+
// Prepare constants
|
|
81
|
+
const PAGE_SIZE = 25
|
|
82
|
+
const ACTIONS = ['update', 'remove']
|
|
83
|
+
|
|
84
|
+
// Prepare composables
|
|
54
85
|
const $route = useRoute()
|
|
55
86
|
const $router = useRouter()
|
|
87
|
+
const $definitions = useDefinitions()
|
|
88
|
+
const $entries = useEntries()
|
|
89
|
+
const toast = useToast()
|
|
56
90
|
|
|
57
91
|
// Prepare page meta
|
|
58
92
|
definePageMeta({
|
|
59
|
-
permissions: [
|
|
60
|
-
preFetch: ['Record']
|
|
93
|
+
permissions: ['read:records'] // TODO handle collections
|
|
61
94
|
})
|
|
62
95
|
|
|
63
96
|
// Prepare reactive data
|
|
64
|
-
const
|
|
65
|
-
const search = ref('')
|
|
66
|
-
const statuses = ref([...ALL_STATUSES])
|
|
67
|
-
const total = ref(0)
|
|
97
|
+
const filters = ref({ status: [...ALL_STATUSES], search: '' })
|
|
68
98
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const abilities = computed(() => ['update', 'remove'])
|
|
99
|
+
// Fetch data
|
|
100
|
+
// A getter, not a snapshot: Nuxt REUSES this component from one collection to
|
|
101
|
+
// the next, and a slug read once at setup would name the previous one.
|
|
102
|
+
const { data: collection } = $definitions.get(() => $route.params.collection)
|
|
74
103
|
|
|
104
|
+
/** What narrows the listing, as the server takes it. */
|
|
75
105
|
const narrowing = computed(() => ({
|
|
76
|
-
search: search.
|
|
106
|
+
...(filters.value.search.trim() ? { search: filters.value.search.trim() } : {}),
|
|
77
107
|
// Keeping every status is not a filter: send nothing rather than all five.
|
|
78
|
-
|
|
108
|
+
...(filters.value.status.length === ALL_STATUSES.length ? {} : { status: filters.value.status }),
|
|
79
109
|
}))
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
// The listing is DESCRIBED, never fetched by hand: collection and filters are
|
|
112
|
+
// in its key, so it starts over whenever one of them moves, and the slices,
|
|
113
|
+
// the next one and their loading states are TanStack's.
|
|
114
|
+
const { records, total, isPending, isFetching, isFetchingNextPage, hasNextPage, fetchNextPage } = $entries.infinite(
|
|
115
|
+
() => collection.value?.id,
|
|
116
|
+
() => ({ ...narrowing.value, limit: PAGE_SIZE })
|
|
83
117
|
)
|
|
118
|
+
const { mutateAsync: removeEntry } = $entries.remove()
|
|
84
119
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
120
|
+
// Prepare computed
|
|
121
|
+
// The row is frozen in `data-table`; the definition only answers what it
|
|
122
|
+
// cannot guess: which fields hold the summary, the cover, the linked entries.
|
|
123
|
+
const listingKeys = computed(() => listingKeysFor(collection.value))
|
|
124
|
+
// An empty screen under a narrowed search is not an empty collection.
|
|
125
|
+
const narrowed = computed(() => Object.keys(narrowing.value).length > 0)
|
|
90
126
|
|
|
91
127
|
// Prepare methods
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const _updateRecord = (item) => {
|
|
109
|
-
$router.push(`${$route.path}/${item._id}`)
|
|
128
|
+
// `onSelect` is handed the event and the row: the table makes each line a
|
|
129
|
+
// button, keyboard included.
|
|
130
|
+
const _onRowSelect = (_event, row) => _open(row.original)
|
|
131
|
+
const _open = item => $router.push(`${$route.path}/${item.id}`)
|
|
132
|
+
|
|
133
|
+
const _remove = async (item) => {
|
|
134
|
+
try {
|
|
135
|
+
await removeEntry({ id: item.id, collectionId: collection.value.id })
|
|
136
|
+
} catch {
|
|
137
|
+
toast.add({
|
|
138
|
+
color: 'error',
|
|
139
|
+
title: "L'entrée n'a pas pu être supprimée",
|
|
140
|
+
description: 'Réessayez, et prévenez un administrateur si cela persiste.',
|
|
141
|
+
})
|
|
142
|
+
}
|
|
110
143
|
}
|
|
111
|
-
|
|
112
|
-
const _removeRecord = async (item) => {
|
|
113
|
-
await Record.remove(item._id, $route.params.collection)
|
|
114
|
-
await _refreshTotal()
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Prepare watchers
|
|
118
|
-
watch(narrowing, async () => {
|
|
119
|
-
await _load(0)
|
|
120
|
-
await _refreshTotal()
|
|
121
|
-
}, { deep: true })
|
|
122
|
-
|
|
123
|
-
onMounted(_refreshTotal)
|
|
124
144
|
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<forms-layout v-bind="{ record, ...accountForm }" :schema="updateOwnProfileDto" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { updateOwnProfileDto } from '@open-commune/core/dtos'
|
|
7
|
+
import formsLayout from '~/components/forms/layouts/forms-layout'
|
|
8
|
+
import { ACCOUNT_FORM } from '~/constants/forms/account'
|
|
9
|
+
|
|
10
|
+
// Prepare composables
|
|
11
|
+
const $session = useSession()
|
|
12
|
+
const { mutateAsync: updateOwnProfile } = useAuth().updateOwnProfile()
|
|
13
|
+
const $toast = useToast()
|
|
14
|
+
|
|
15
|
+
definePageMeta({
|
|
16
|
+
permissions: ['entrance:self'],
|
|
17
|
+
headings: {
|
|
18
|
+
title: 'Mon compte',
|
|
19
|
+
description: 'Votre nom, votre mot de passe et vos appareils connectés.'
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Prepare computed
|
|
24
|
+
const accountForm = computed(() => ({
|
|
25
|
+
layout: ACCOUNT_FORM.layout.map(tab => ({
|
|
26
|
+
...tab,
|
|
27
|
+
sections: tab.sections.map(section => ({
|
|
28
|
+
...section,
|
|
29
|
+
componentOptions: { ...section.componentOptions, onSave: _save }
|
|
30
|
+
}))
|
|
31
|
+
}))
|
|
32
|
+
}))
|
|
33
|
+
const record = computed(() => $session.user.value ?? {})
|
|
34
|
+
|
|
35
|
+
// Prepare methods
|
|
36
|
+
const _save = async (changes) => {
|
|
37
|
+
await updateOwnProfile(changes.name)
|
|
38
|
+
$toast.add({ title: 'Votre nom est à jour.' })
|
|
39
|
+
}
|
|
40
|
+
</script>
|
package/pages/overview.vue
CHANGED
|
@@ -1,10 +1,85 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<!-- Today's look keeps today's home: a greeting, and only the audience when an instance measures it. -->
|
|
3
|
+
<div v-if="plain" class="relative block w-full max-w-4xl">
|
|
4
|
+
<audience-panel />
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div v-else class="space-y-8">
|
|
8
|
+
<!-- Said only of a site that has an address: an instance without one has
|
|
9
|
+
nothing online to announce. -->
|
|
10
|
+
<section
|
|
11
|
+
v-if="siteUrl"
|
|
12
|
+
class="flex flex-wrap items-center justify-between gap-4 rounded-lg bg-elevated px-5 py-4 shadow-card"
|
|
13
|
+
>
|
|
14
|
+
<div class="flex items-center gap-3">
|
|
15
|
+
<span class="inline-flex items-center gap-2 text-xs font-semibold tracking-wider text-success uppercase">
|
|
16
|
+
<span class="size-1.5 rounded-full bg-success" />
|
|
17
|
+
Site en ligne
|
|
18
|
+
</span>
|
|
19
|
+
<NuxtLink
|
|
20
|
+
:to="siteUrl"
|
|
21
|
+
target="_blank"
|
|
22
|
+
external
|
|
23
|
+
class="inline-flex items-center gap-1.5 text-sm text-muted hover:text-highlighted"
|
|
24
|
+
>
|
|
25
|
+
{{ siteHost }}
|
|
26
|
+
<UIcon name="i-lucide-external-link" class="size-3.5" />
|
|
27
|
+
</NuxtLink>
|
|
28
|
+
</div>
|
|
29
|
+
<p class="text-xs text-dimmed">
|
|
30
|
+
Le site se met à jour chaque nuit, ou immédiatement avec « Publier le site ».
|
|
31
|
+
</p>
|
|
32
|
+
</section>
|
|
33
|
+
|
|
34
|
+
<audience-panel />
|
|
3
35
|
|
|
36
|
+
<section>
|
|
37
|
+
<h2 class="mb-3 text-xs font-semibold tracking-widest text-muted uppercase">
|
|
38
|
+
Dernières modifications
|
|
39
|
+
</h2>
|
|
40
|
+
<div class="divide-y divide-default overflow-hidden rounded-lg bg-elevated shadow-card">
|
|
41
|
+
<template v-if="pending">
|
|
42
|
+
<div v-for="i in RECENT" :key="i" class="px-5 py-3.5">
|
|
43
|
+
<USkeleton class="h-5 w-2/3" />
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
<p v-else-if="!recent.length" class="px-5 py-6 text-sm text-muted">
|
|
47
|
+
Aucune modification pour le moment.
|
|
48
|
+
</p>
|
|
49
|
+
<NuxtLink
|
|
50
|
+
v-for="entry in recent"
|
|
51
|
+
:key="entry.id"
|
|
52
|
+
:to="`/${entry.collection.slug}/${entry.id}`"
|
|
53
|
+
class="group flex items-center justify-between gap-4 px-5 py-3.5"
|
|
54
|
+
>
|
|
55
|
+
<div class="min-w-0">
|
|
56
|
+
<p class="truncate text-sm text-highlighted group-hover:underline">{{ entry.title }}</p>
|
|
57
|
+
<p class="text-xs text-dimmed">{{ entry.collection.name }}</p>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="flex shrink-0 items-center gap-3">
|
|
60
|
+
<status-badge :status="entry.status" />
|
|
61
|
+
<span class="w-28 text-right text-xs text-dimmed">{{ _fromNow(entry.updatedAt) }}</span>
|
|
62
|
+
</div>
|
|
63
|
+
</NuxtLink>
|
|
64
|
+
</div>
|
|
65
|
+
</section>
|
|
4
66
|
</div>
|
|
5
67
|
</template>
|
|
6
68
|
|
|
7
69
|
<script setup>
|
|
70
|
+
import { DateTime } from 'luxon'
|
|
71
|
+
import AudiencePanel from '~/components/audience/audience-panel.vue'
|
|
72
|
+
import statusBadge from '~/components/elements/badges/status-badge'
|
|
73
|
+
|
|
74
|
+
// Prepare constants
|
|
75
|
+
const RECENT = 5
|
|
76
|
+
|
|
77
|
+
// Prepare composables
|
|
78
|
+
const $organization = useOrganization()
|
|
79
|
+
const $definitions = useDefinitions()
|
|
80
|
+
const $entries = useEntries()
|
|
81
|
+
const { public: { appearance } } = useRuntimeConfig()
|
|
82
|
+
|
|
8
83
|
definePageMeta({
|
|
9
84
|
permissions: ['entrance:self'],
|
|
10
85
|
headings: {
|
|
@@ -12,4 +87,33 @@ definePageMeta({
|
|
|
12
87
|
description: ''
|
|
13
88
|
}
|
|
14
89
|
})
|
|
15
|
-
|
|
90
|
+
|
|
91
|
+
// Prepare constants
|
|
92
|
+
// The home of today's look shows nothing, and asks the server for nothing.
|
|
93
|
+
const plain = appearance === 'plain'
|
|
94
|
+
|
|
95
|
+
// Fetch data
|
|
96
|
+
const { data: organization } = $organization.query()
|
|
97
|
+
const { data: definitions, isPending: isDefinitionsPending } = $definitions.list()
|
|
98
|
+
const { data: entries, isPending: isEntriesPending } = $entries.recent(RECENT, { enabled: !plain })
|
|
99
|
+
|
|
100
|
+
// Prepare computed
|
|
101
|
+
const pending = computed(() => isDefinitionsPending.value || isEntriesPending.value)
|
|
102
|
+
// An entry is shown with its collection, and reached through it: one whose
|
|
103
|
+
// collection is not in the list has no address to offer.
|
|
104
|
+
const recent = computed(() => (entries.value ?? [])
|
|
105
|
+
.map(entry => ({
|
|
106
|
+
...entry,
|
|
107
|
+
collection: definitions.value?.find(({ id }) => id === entry.collectionId),
|
|
108
|
+
}))
|
|
109
|
+
.filter(({ collection }) => collection))
|
|
110
|
+
const siteUrl = computed(() => {
|
|
111
|
+
const url = organization.value?.deployment?.url
|
|
112
|
+
if (!url) return ''
|
|
113
|
+
return url.startsWith('http') ? url : `https://${url}`
|
|
114
|
+
})
|
|
115
|
+
const siteHost = computed(() => (siteUrl.value ? new URL(siteUrl.value).host : ''))
|
|
116
|
+
|
|
117
|
+
// Prepare methods
|
|
118
|
+
const _fromNow = value => (value ? DateTime.fromISO(value).setLocale('fr').toRelative() : '')
|
|
119
|
+
</script>
|
package/pages/settings.vue
CHANGED
|
@@ -1,197 +1,42 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<forms-layout
|
|
3
|
-
v-bind="{ record, ...ORGANIZATION_FORM }"
|
|
4
|
-
class="mt-4"
|
|
5
|
-
/>
|
|
2
|
+
<forms-layout v-bind="{ record, layout }" :schema="organizationUpdateDto" :active-tab="activeTab" one-page />
|
|
6
3
|
</template>
|
|
7
4
|
|
|
8
5
|
<script setup>
|
|
9
|
-
import {
|
|
10
|
-
import formsLayout from '~/components/forms/layouts/layout'
|
|
6
|
+
import { organizationUpdateDto } from '@open-commune/core/dtos'
|
|
7
|
+
import formsLayout from '~/components/forms/layouts/forms-layout'
|
|
8
|
+
import { ORGANIZATION_FORM } from '~/constants/forms/organization'
|
|
9
|
+
import { SETTINGS_SECTIONS } from '~/constants/settings'
|
|
10
|
+
import { layerSectionTab, sectionRoute, sectionTitleFromSlug } from '~/utils/settings'
|
|
11
|
+
|
|
12
|
+
// Prepare composables
|
|
13
|
+
const $route = useRoute()
|
|
14
|
+
const $organization = useOrganization()
|
|
15
|
+
const { settings } = useAppConfig()
|
|
11
16
|
|
|
12
17
|
definePageMeta({
|
|
13
18
|
permissions: ['manage:all'],
|
|
14
|
-
preFetch: ['Organization'],
|
|
15
19
|
headings: {
|
|
16
20
|
title: 'Paramètres',
|
|
17
21
|
description: 'Retrouvez ici tous les paramètres de l\'organisation.'
|
|
18
22
|
}
|
|
19
23
|
})
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
layout: [
|
|
24
|
-
{
|
|
25
|
-
icon: '',
|
|
26
|
-
sections: [
|
|
27
|
-
{
|
|
28
|
-
componentOptions: {
|
|
29
|
-
title: 'Logo de l\'organization',
|
|
30
|
-
description: 'Cliquez sur votre logo pour ajouter une image depuis vos fichiers.',
|
|
31
|
-
hint: 'Le logo est optionnel mais fortement recommandé.',
|
|
32
|
-
attributes: [
|
|
33
|
-
{
|
|
34
|
-
property: 'logo',
|
|
35
|
-
componentOptions: {
|
|
36
|
-
name: 'cover',
|
|
37
|
-
limit: 1,
|
|
38
|
-
label: 'Logo de l\'organization'
|
|
39
|
-
},
|
|
40
|
-
component: 'input-files-media'
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
component: 'form-section-default'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
componentOptions: {
|
|
48
|
-
title: 'Nom de l\'organization',
|
|
49
|
-
description: 'Ces informations seront visibles publiquement, soyez donc attentif avec ce que vous partagerez.',
|
|
50
|
-
hint: 'Merci de ne pas dépasser 128 charactères.',
|
|
51
|
-
attributes: [
|
|
52
|
-
{
|
|
53
|
-
property: 'name',
|
|
54
|
-
componentOptions: {
|
|
55
|
-
previewSlug: false,
|
|
56
|
-
editableSlug: false,
|
|
57
|
-
trim: true,
|
|
58
|
-
placeHolder: 'Nom de l\'organisation',
|
|
59
|
-
required: true
|
|
60
|
-
},
|
|
61
|
-
component: 'input-text'
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
component: 'form-section-default'
|
|
66
|
-
}
|
|
67
|
-
// {
|
|
68
|
-
// componentOptions: {
|
|
69
|
-
// title: 'Localisation de l\'organization',
|
|
70
|
-
// description: 'Ces informations seront visibles publiquement, soyez donc attentif avec ce que vous partagerez.',
|
|
71
|
-
// attributes: [
|
|
72
|
-
// {
|
|
73
|
-
// property: 'location',
|
|
74
|
-
// componentOptions: {
|
|
75
|
-
// placeHolder: 'Localisation de l\'organisation',
|
|
76
|
-
// name: 'organization'
|
|
77
|
-
// },
|
|
78
|
-
// component: 'input-location'
|
|
79
|
-
// }
|
|
80
|
-
// ]
|
|
81
|
-
// },
|
|
82
|
-
// component: 'form-section-default'
|
|
83
|
-
// }
|
|
84
|
-
],
|
|
85
|
-
title: 'General'
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
icon: '',
|
|
89
|
-
sections: [
|
|
90
|
-
{
|
|
91
|
-
componentOptions: {
|
|
92
|
-
title: 'Collections',
|
|
93
|
-
description: 'Ces collections permettent de définir les différents jeux de données de l\'organisation.',
|
|
94
|
-
hint: '🚦 Soyez vigilant lorsque vous modifiez ce champs.',
|
|
95
|
-
attributes: [
|
|
96
|
-
{
|
|
97
|
-
property: 'collections',
|
|
98
|
-
componentOptions: {},
|
|
99
|
-
component: 'handler-collections'
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
noAction: true
|
|
103
|
-
},
|
|
104
|
-
component: 'form-section-default'
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
title: 'Collections'
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
icon: '',
|
|
111
|
-
sections: [
|
|
112
|
-
{
|
|
113
|
-
componentOptions: {
|
|
114
|
-
title: 'Les thématiques',
|
|
115
|
-
description: 'Vous pouvez modifier ici les thématiques de cette organisation.',
|
|
116
|
-
attributes: [
|
|
117
|
-
{
|
|
118
|
-
componentOptions: {
|
|
119
|
-
collection: 'labels',
|
|
120
|
-
alwaysPublish: true
|
|
121
|
-
},
|
|
122
|
-
component: 'handler-records'
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
noAction: true
|
|
126
|
-
},
|
|
127
|
-
component: 'form-section-default'
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
title: 'Thématiques'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
icon: '',
|
|
134
|
-
sections: [
|
|
135
|
-
{
|
|
136
|
-
componentOptions: {
|
|
137
|
-
title: 'Deployment settings',
|
|
138
|
-
description: 'Renseignez la définition du déploiement.',
|
|
139
|
-
attributes: [
|
|
140
|
-
{
|
|
141
|
-
property: 'deployment',
|
|
142
|
-
componentOptions: {
|
|
143
|
-
label: 'Paramètres de déploiement',
|
|
144
|
-
name: 'deployment'
|
|
145
|
-
},
|
|
146
|
-
component: 'input-json'
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
|
-
component: 'form-section-default'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
componentOptions: {
|
|
154
|
-
title: 'Tokens de déploiement',
|
|
155
|
-
description: 'Ces tokens permettent d\'autres applications à accéder à un contenu restreint de cette organisation.Soyez attentif!',
|
|
156
|
-
attributes: [
|
|
157
|
-
{
|
|
158
|
-
componentOptions: {},
|
|
159
|
-
component: 'handler-tokens'
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
noAction: true
|
|
163
|
-
},
|
|
164
|
-
component: 'form-section-default'
|
|
165
|
-
}
|
|
166
|
-
],
|
|
167
|
-
title: 'Déploiement'
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
icon: '',
|
|
171
|
-
sections: [
|
|
172
|
-
{
|
|
173
|
-
componentOptions: {
|
|
174
|
-
title: 'Configuration de l\'injecteur',
|
|
175
|
-
description: 'Définissez les différentes pipelines de données ici',
|
|
176
|
-
attributes: [
|
|
177
|
-
{
|
|
178
|
-
property: 'injector',
|
|
179
|
-
componentOptions: {
|
|
180
|
-
label: 'Définition de l\'injecteur',
|
|
181
|
-
name: 'injector'
|
|
182
|
-
},
|
|
183
|
-
component: 'input-json'
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
component: 'form-section-default'
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
title: 'Synchronisation des données'
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
})
|
|
25
|
+
// Fetch data
|
|
26
|
+
const { data: record } = $organization.query()
|
|
194
27
|
|
|
195
28
|
// Prepare computed
|
|
196
|
-
|
|
29
|
+
// One page, and each section still an address: the rail links to it, and the
|
|
30
|
+
// page scrolls there, so a section can be bookmarked or sent.
|
|
31
|
+
// The product's sections, then the ones a layer declares in its app config.
|
|
32
|
+
const sections = computed(() => [
|
|
33
|
+
...SETTINGS_SECTIONS,
|
|
34
|
+
...settings.sections.map(({ label, slug }) => ({ title: label, label, slug })),
|
|
35
|
+
])
|
|
36
|
+
const layout = computed(() => [...ORGANIZATION_FORM.layout, ...settings.sections.map(layerSectionTab)].map((tab) => {
|
|
37
|
+
const section = sections.value.find(({ title }) => title === tab.title)
|
|
38
|
+
return { ...tab, label: section?.label, anchor: section?.slug || 'general', to: sectionRoute(section?.slug ?? '') }
|
|
39
|
+
}))
|
|
40
|
+
// Nothing to scroll to on a bare /settings: the page opens at its top.
|
|
41
|
+
const activeTab = computed(() => ($route.query.section ? sectionTitleFromSlug($route.query.section, sections.value) : ''))
|
|
197
42
|
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { config } from 'zod/v4/core'
|
|
2
|
+
import fr from 'zod/v4/locales/fr.js'
|
|
3
|
+
|
|
4
|
+
// The forms validate with the core's own schemas, and Zod words its refusals:
|
|
5
|
+
// in French, like the rest of the admin. The one locale, by its own path — the
|
|
6
|
+
// `z.locales` namespace would ship them all.
|
|
7
|
+
//
|
|
8
|
+
// Three refusals are reworded: they are the ones a form meets every day, and
|
|
9
|
+
// Zod describes them as a type error (« chaîne de caractères attendu, indéfini
|
|
10
|
+
// reçu ») where a person left a field empty.
|
|
11
|
+
export default defineNuxtPlugin(() => {
|
|
12
|
+
config({
|
|
13
|
+
...fr(),
|
|
14
|
+
customError: (issue) => {
|
|
15
|
+
const empty = issue.input === undefined || issue.input === null || issue.input === ''
|
|
16
|
+
if (empty && (issue.code === 'invalid_type' || issue.code === 'too_small' || issue.code === 'invalid_value')) {
|
|
17
|
+
return 'Ce champ est requis.'
|
|
18
|
+
}
|
|
19
|
+
if (issue.code === 'invalid_value') return 'Choisissez une valeur de la liste.'
|
|
20
|
+
return undefined
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
})
|