@open-commune/web 0.2.14 → 0.2.15
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/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-auth.ts +56 -2
- package/composables/core/domains/use-definitions.ts +18 -5
- package/composables/core/domains/use-entries.ts +113 -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 +28 -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/package.json +3 -3
- package/pages/[collection]/index.vue +92 -79
- package/pages/account.vue +40 -0
- 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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Capability, RoleDefinition } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The roles of the admin space.
|
|
5
|
+
*
|
|
6
|
+
* Configurable roles gave way to a FIXED model: two roles, decided here and
|
|
7
|
+
* never in the database. This is not data anyone fetches — hence no composable
|
|
8
|
+
* for it.
|
|
9
|
+
*/
|
|
10
|
+
export const ROLES: readonly RoleDefinition[] = [
|
|
11
|
+
{
|
|
12
|
+
id: 'admin',
|
|
13
|
+
name: 'Administrateur',
|
|
14
|
+
description: 'Accès complet : contenus, médias, membres et réglages.',
|
|
15
|
+
permissions: ['manage:all'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'redacteur',
|
|
19
|
+
name: 'Rédacteur',
|
|
20
|
+
description: 'Les contenus, les médias et la publication du site.',
|
|
21
|
+
// Exactly the legacy « Éditeur de contenu » every commune agent carried:
|
|
22
|
+
// contents, their publication, the media library and publishing the site.
|
|
23
|
+
permissions: [
|
|
24
|
+
'entrance:self',
|
|
25
|
+
'read:organizations',
|
|
26
|
+
'read:collections',
|
|
27
|
+
'read:records',
|
|
28
|
+
'create:records',
|
|
29
|
+
'update:records',
|
|
30
|
+
'delete:records',
|
|
31
|
+
'publish:records',
|
|
32
|
+
'read:media',
|
|
33
|
+
'create:media',
|
|
34
|
+
'update:media',
|
|
35
|
+
'delete:media',
|
|
36
|
+
'read:deployments',
|
|
37
|
+
'create:deployments',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export const roleNamed = (id: string): RoleDefinition | undefined =>
|
|
43
|
+
ROLES.find((role) => role.id === id);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* What a role opens, said in the words of the job rather than in CASL.
|
|
47
|
+
*
|
|
48
|
+
* Each line names the ability that actually decides it, so a change to the
|
|
49
|
+
* permissions above shows up on the roles screen on its own — the screen READS
|
|
50
|
+
* the model, it does not describe it a second time.
|
|
51
|
+
*/
|
|
52
|
+
export const CAPABILITIES: readonly Capability[] = [
|
|
53
|
+
{ label: 'Tout le contenu, publication comprise', ability: 'update:records' },
|
|
54
|
+
{ label: 'Publication du site (déploiement)', ability: 'create:deployments' },
|
|
55
|
+
{ label: 'Membres et invitations', ability: 'admin:organization' },
|
|
56
|
+
{ label: 'Paramètres, collections, synchronisation', ability: 'manage:all' },
|
|
57
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SettingsSection } from '~/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The settings area, as one screen: the organization form's sections, each
|
|
5
|
+
* addressable by URL so a section can be bookmarked or linked. Members and
|
|
6
|
+
* roles, which used to live under /management, are two of them.
|
|
7
|
+
*
|
|
8
|
+
* Thematics left the settings: they are content, not configuration —
|
|
9
|
+
* written, published, referenced by entries — and the collection `labels`
|
|
10
|
+
* already gave them a screen with filters, search, counts and the publication
|
|
11
|
+
* chain. Two doors onto the same rows, the poorer one being the settings.
|
|
12
|
+
* `title` matches the section title declared in the organization form layout.
|
|
13
|
+
*/
|
|
14
|
+
export const SETTINGS_SECTIONS: readonly SettingsSection[] = [
|
|
15
|
+
{ title: 'General', label: 'Général', slug: '' },
|
|
16
|
+
{ title: 'Collections', label: 'Collections', slug: 'collections' },
|
|
17
|
+
{ title: 'Déploiement', label: 'Déploiement', slug: 'deploiement' },
|
|
18
|
+
{
|
|
19
|
+
title: 'Synchronisation des données',
|
|
20
|
+
|
|
21
|
+
label: 'Synchronisation',
|
|
22
|
+
slug: 'synchronisation',
|
|
23
|
+
},
|
|
24
|
+
{ title: 'Membres', label: 'Membres', slug: 'membres' },
|
|
25
|
+
{ title: 'Rôles', label: 'Rôles', slug: 'roles' },
|
|
26
|
+
];
|
package/constants/statuses.ts
CHANGED
|
@@ -5,7 +5,10 @@ import {
|
|
|
5
5
|
|
|
6
6
|
interface Presentation {
|
|
7
7
|
label: string;
|
|
8
|
+
/** Paints the filter dots. */
|
|
8
9
|
color: string;
|
|
10
|
+
/** The Nuxt UI colour the badge wears. */
|
|
11
|
+
ui: 'neutral' | 'warning' | 'info' | 'primary' | 'success';
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -14,11 +17,11 @@ interface Presentation {
|
|
|
14
17
|
* quietly ignores it.
|
|
15
18
|
*/
|
|
16
19
|
const PRESENTATION: Record<PublicationStatus, Presentation> = {
|
|
17
|
-
draft: { label: 'Brouillon', color: '#9ca3af' },
|
|
18
|
-
waiting: { label: 'À valider', color: '#facc15' },
|
|
19
|
-
ready: { label: 'Prêt', color: '#60a5fa' },
|
|
20
|
-
scheduled: { label: 'Programmé', color: '#c4b5fd' },
|
|
21
|
-
published: { label: 'Publié', color: '#34d399' },
|
|
20
|
+
draft: { label: 'Brouillon', color: '#9ca3af', ui: 'neutral' },
|
|
21
|
+
waiting: { label: 'À valider', color: '#facc15', ui: 'warning' },
|
|
22
|
+
ready: { label: 'Prêt', color: '#60a5fa', ui: 'info' },
|
|
23
|
+
scheduled: { label: 'Programmé', color: '#c4b5fd', ui: 'primary' },
|
|
24
|
+
published: { label: 'Publié', color: '#34d399', ui: 'success' },
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export const STATUSES = PUBLICATION_STATUSES.map((value) => ({
|
package/package.json
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@iconify/vue": "^5.0.3",
|
|
20
20
|
"@nuxt/kit": "^4.6.1",
|
|
21
21
|
"@nuxt/ui": "^4.12.0",
|
|
22
|
-
"@open-commune/core": "^0.2.
|
|
23
|
-
"@open-commune/editor": "^0.2.
|
|
22
|
+
"@open-commune/core": "^0.2.15",
|
|
23
|
+
"@open-commune/editor": "^0.2.15",
|
|
24
24
|
"@pinia-orm/nuxt": "^2.0.0",
|
|
25
25
|
"@pinia/nuxt": "^1.0.3",
|
|
26
26
|
"@tanstack/vue-query": "^5.104.3",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"description": "The Open Commune application: the admin interface and the server, on a single origin.",
|
|
44
44
|
"license": "AGPL-3.0-or-later",
|
|
45
|
-
"version": "0.2.
|
|
45
|
+
"version": "0.2.15",
|
|
46
46
|
"type": "module",
|
|
47
47
|
"main": "./nuxt.config.ts",
|
|
48
48
|
"files": [
|
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<section class="w-full">
|
|
2
|
+
<section v-if="isPending" class="w-full">
|
|
3
|
+
<div class="mb-4 flex flex-wrap items-center gap-2">
|
|
4
|
+
<USkeleton class="h-9 w-44 rounded-md" />
|
|
5
|
+
<USkeleton class="h-9 w-28 rounded-md" />
|
|
6
|
+
<USkeleton class="ml-auto size-9 rounded-md" />
|
|
7
|
+
</div>
|
|
8
|
+
<div class="space-y-2">
|
|
9
|
+
<USkeleton v-for="i in 5" :key="i" class="h-16 rounded-lg" />
|
|
10
|
+
</div>
|
|
11
|
+
</section>
|
|
12
|
+
|
|
13
|
+
<section v-else class="w-full">
|
|
3
14
|
<!-- Both controls narrow on the SERVER: a collection of several hundred
|
|
4
15
|
entries does not fit in the browser, and narrowing what is loaded only
|
|
5
16
|
ever finds what is already visible. -->
|
|
6
|
-
<div
|
|
17
|
+
<div class="mb-4 flex flex-wrap items-center gap-2">
|
|
7
18
|
<input-filter
|
|
8
|
-
v-if="
|
|
19
|
+
v-if="collection?.name"
|
|
9
20
|
label="Collection"
|
|
10
|
-
:value="
|
|
21
|
+
:value="collection.name"
|
|
11
22
|
disabled
|
|
12
23
|
/>
|
|
13
|
-
<input-filter-status v-model="
|
|
14
|
-
<input-search v-model="search" class="ml-auto" />
|
|
24
|
+
<input-filter-status v-model="filters.status" />
|
|
25
|
+
<input-search v-model="filters.search" class="ml-auto" />
|
|
15
26
|
</div>
|
|
16
27
|
|
|
17
|
-
<
|
|
18
|
-
v-if="
|
|
19
|
-
:key="narrowingKey"
|
|
20
|
-
:headers="headers"
|
|
28
|
+
<data-table
|
|
29
|
+
v-if="records.length"
|
|
21
30
|
:items="records"
|
|
22
|
-
|
|
23
|
-
:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@update="
|
|
27
|
-
@remove="
|
|
31
|
+
v-bind="listingKeys"
|
|
32
|
+
:actions="ACTIONS"
|
|
33
|
+
:loading="isFetching"
|
|
34
|
+
:on-select="_onRowSelect"
|
|
35
|
+
@update="_open"
|
|
36
|
+
@remove="_remove"
|
|
28
37
|
/>
|
|
29
38
|
|
|
30
39
|
<UEmpty
|
|
31
|
-
v-else
|
|
40
|
+
v-else
|
|
32
41
|
icon="i-lucide-inbox"
|
|
33
42
|
:title="narrowed ? 'Aucun résultat' : 'Aucune entrée'"
|
|
34
43
|
:description="narrowed
|
|
@@ -36,89 +45,93 @@
|
|
|
36
45
|
: 'Cette collection est vide pour le moment.'"
|
|
37
46
|
/>
|
|
38
47
|
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
<div v-if="records.length" class="mt-6 flex items-center justify-center gap-4">
|
|
49
|
+
<p class="text-sm text-dimmed">
|
|
50
|
+
{{ records.length }} affichée{{ records.length > 1 ? 's' : '' }} sur {{ total }}
|
|
51
|
+
</p>
|
|
52
|
+
<UButton
|
|
53
|
+
v-if="hasNextPage"
|
|
54
|
+
color="neutral"
|
|
55
|
+
variant="outline"
|
|
56
|
+
class="px-4"
|
|
57
|
+
label="Afficher plus"
|
|
58
|
+
:loading="isFetchingNextPage"
|
|
59
|
+
@click="fetchNextPage()"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
42
62
|
</section>
|
|
43
63
|
</template>
|
|
44
64
|
|
|
45
65
|
<script setup>
|
|
46
|
-
import
|
|
47
|
-
import inputFilter from '~/components/forms/
|
|
48
|
-
import inputFilterStatus from '~/components/forms/
|
|
49
|
-
import inputSearch from '~/components/forms/
|
|
50
|
-
import { ALL_STATUSES } from '
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
import dataTable from '~/components/data/lists/data-table'
|
|
67
|
+
import inputFilter from '~/components/forms/fields/input-filter'
|
|
68
|
+
import inputFilterStatus from '~/components/forms/fields/input-filter-status'
|
|
69
|
+
import inputSearch from '~/components/forms/fields/input-search'
|
|
70
|
+
import { ALL_STATUSES } from '~/constants/statuses'
|
|
71
|
+
import { listingKeysFor } from '~/utils/list-columns'
|
|
72
|
+
|
|
73
|
+
// Prepare constants
|
|
74
|
+
const PAGE_SIZE = 25
|
|
75
|
+
const ACTIONS = ['update', 'remove']
|
|
76
|
+
|
|
77
|
+
// Prepare composables
|
|
54
78
|
const $route = useRoute()
|
|
55
79
|
const $router = useRouter()
|
|
80
|
+
const $definitions = useDefinitions()
|
|
81
|
+
const $entries = useEntries()
|
|
82
|
+
const toast = useToast()
|
|
56
83
|
|
|
57
84
|
// Prepare page meta
|
|
58
85
|
definePageMeta({
|
|
59
|
-
permissions: [
|
|
60
|
-
preFetch: ['Record']
|
|
86
|
+
permissions: ['read:records'] // TODO handle collections
|
|
61
87
|
})
|
|
62
88
|
|
|
63
89
|
// Prepare reactive data
|
|
64
|
-
const
|
|
65
|
-
const search = ref('')
|
|
66
|
-
const statuses = ref([...ALL_STATUSES])
|
|
67
|
-
const total = ref(0)
|
|
90
|
+
const filters = ref({ status: [...ALL_STATUSES], search: '' })
|
|
68
91
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const abilities = computed(() => ['update', 'remove'])
|
|
92
|
+
// Fetch data
|
|
93
|
+
// A getter, not a snapshot: Nuxt REUSES this component from one collection to
|
|
94
|
+
// the next, and a slug read once at setup would name the previous one.
|
|
95
|
+
const { data: collection } = $definitions.get(() => $route.params.collection)
|
|
74
96
|
|
|
97
|
+
/** What narrows the listing, as the server takes it. */
|
|
75
98
|
const narrowing = computed(() => ({
|
|
76
|
-
search: search.
|
|
99
|
+
...(filters.value.search.trim() ? { search: filters.value.search.trim() } : {}),
|
|
77
100
|
// Keeping every status is not a filter: send nothing rather than all five.
|
|
78
|
-
|
|
101
|
+
...(filters.value.status.length === ALL_STATUSES.length ? {} : { status: filters.value.status }),
|
|
79
102
|
}))
|
|
80
103
|
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
// The listing is DESCRIBED, never fetched by hand: collection and filters are
|
|
105
|
+
// in its key, so it starts over whenever one of them moves, and the slices,
|
|
106
|
+
// the next one and their loading states are TanStack's.
|
|
107
|
+
const { records, total, isPending, isFetching, isFetchingNextPage, hasNextPage, fetchNextPage } = $entries.infinite(
|
|
108
|
+
() => collection.value?.id,
|
|
109
|
+
() => ({ ...narrowing.value, limit: PAGE_SIZE })
|
|
83
110
|
)
|
|
111
|
+
const { mutateAsync: removeEntry } = $entries.remove()
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
113
|
+
// Prepare computed
|
|
114
|
+
// The row is frozen in `data-table`; the definition only answers what it
|
|
115
|
+
// cannot guess: which fields hold the summary, the cover, the linked entries.
|
|
116
|
+
const listingKeys = computed(() => listingKeysFor(collection.value))
|
|
117
|
+
// An empty screen under a narrowed search is not an empty collection.
|
|
118
|
+
const narrowed = computed(() => Object.keys(narrowing.value).length > 0)
|
|
90
119
|
|
|
91
120
|
// Prepare methods
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
// `onSelect` is handed the event and the row: the table makes each line a
|
|
122
|
+
// button, keyboard included.
|
|
123
|
+
const _onRowSelect = (_event, row) => _open(row.original)
|
|
124
|
+
const _open = item => $router.push(`${$route.path}/${item.id}`)
|
|
125
|
+
|
|
126
|
+
const _remove = async (item) => {
|
|
127
|
+
try {
|
|
128
|
+
await removeEntry({ id: item.id, collectionId: collection.value.id })
|
|
129
|
+
} catch {
|
|
130
|
+
toast.add({
|
|
131
|
+
color: 'error',
|
|
132
|
+
title: "L'entrée n'a pas pu être supprimée",
|
|
133
|
+
description: 'Réessayez, et prévenez un administrateur si cela persiste.',
|
|
134
|
+
})
|
|
135
|
+
}
|
|
98
136
|
}
|
|
99
|
-
|
|
100
|
-
const _refreshTotal = async () => {
|
|
101
|
-
total.value = await Record.count($route.params.collection, narrowing.value)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const _fetchMoreRecords = async (skip = 0) => {
|
|
105
|
-
await _load(skip)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const _updateRecord = (item) => {
|
|
109
|
-
$router.push(`${$route.path}/${item._id}`)
|
|
110
|
-
}
|
|
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
137
|
</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/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
|
+
})
|