@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.
Files changed (69) hide show
  1. package/app.config.ts +7 -0
  2. package/components/audience/audience-bar-list.vue +29 -0
  3. package/components/audience/audience-panel.vue +230 -0
  4. package/components/data/lists/data-table.vue +203 -0
  5. package/components/data/lists/row-actions.vue +41 -0
  6. package/components/elements/badges/status-badge.vue +23 -0
  7. package/components/elements/media/media-image.vue +26 -0
  8. package/components/forms/fields/input-files-media.vue +87 -0
  9. package/components/forms/{inputs → fields}/input-filter-status.vue +2 -2
  10. package/components/forms/{inputs → fields}/input-search.vue +8 -2
  11. package/components/forms/fields/input-text-area.vue +86 -0
  12. package/components/forms/fields/input-text.vue +47 -0
  13. package/components/forms/fields/select-enum.vue +69 -0
  14. package/components/forms/handlers/handler-collections.vue +100 -170
  15. package/components/forms/handlers/handler-list.vue +187 -0
  16. package/components/forms/handlers/handler-members.vue +171 -0
  17. package/components/forms/handlers/handler-password-reset.vue +45 -0
  18. package/components/forms/handlers/handler-roles.vue +28 -166
  19. package/components/forms/handlers/handler-sessions.vue +77 -0
  20. package/components/forms/handlers/handler-tokens.vue +54 -69
  21. package/components/forms/layouts/form-default.vue +99 -0
  22. package/components/forms/layouts/form.vue +4 -0
  23. package/components/forms/layouts/forms-layout.vue +236 -0
  24. package/components/forms/layouts/forms-section.vue +186 -0
  25. package/components/forms/layouts/layout.vue +4 -0
  26. package/components/forms/layouts/modal.vue +4 -0
  27. package/components/forms/layouts/section.vue +4 -0
  28. package/components/layout/shell/shell-account-menu.vue +10 -2
  29. package/composables/core/domains/use-api-tokens.ts +80 -0
  30. package/composables/core/domains/use-audience.ts +26 -0
  31. package/composables/core/domains/use-auth.ts +56 -2
  32. package/composables/core/domains/use-definitions.ts +18 -5
  33. package/composables/core/domains/use-entries.ts +125 -3
  34. package/composables/core/domains/use-media.ts +24 -1
  35. package/composables/core/domains/use-members.ts +68 -0
  36. package/composables/core/domains/use-organization.ts +53 -0
  37. package/composables/use-models.js +1 -7
  38. package/constants/errors.ts +29 -0
  39. package/constants/forms/account.ts +62 -0
  40. package/constants/forms/collections.ts +39 -0
  41. package/constants/forms/members.ts +40 -0
  42. package/constants/forms/organization.ts +188 -0
  43. package/constants/forms/tokens.ts +15 -0
  44. package/constants/roles.ts +57 -0
  45. package/constants/settings.ts +26 -0
  46. package/constants/statuses.ts +8 -5
  47. package/nuxt.config.ts +4 -1
  48. package/package.json +4 -3
  49. package/pages/[collection]/[record]/index.vue +7 -0
  50. package/pages/[collection]/index.vue +117 -97
  51. package/pages/account.vue +40 -0
  52. package/pages/overview.vue +106 -2
  53. package/pages/settings.vue +26 -181
  54. package/plugins/01.validation.client.ts +23 -0
  55. package/store/layout/workspace.js +4 -28
  56. package/utils/colors.ts +26 -0
  57. package/utils/errors.ts +13 -0
  58. package/utils/forms.ts +67 -0
  59. package/utils/list-columns.ts +90 -0
  60. package/utils/settings.ts +38 -0
  61. package/utils/statuses.ts +4 -0
  62. package/models/role.js +0 -66
  63. package/models/token.js +0 -56
  64. package/models/user.js +0 -97
  65. package/pages/management/index.vue +0 -15
  66. package/pages/management/members.vue +0 -176
  67. package/pages/management/organizations.vue +0 -192
  68. package/pages/management/roles.vue +0 -183
  69. /package/components/forms/{inputs → fields}/input-filter.vue +0 -0
@@ -0,0 +1,39 @@
1
+ import type { FormControl } from '~/types';
2
+
3
+ /**
4
+ * The collection modal, described the way the other forms are.
5
+ *
6
+ * Creating and editing a collection ask for the SAME five fields — only the
7
+ * title and the buttons change with the gesture, and those the handler builds
8
+ * from the action it was given.
9
+ */
10
+ export const COLLECTION_FORM: FormControl[] = [
11
+ {
12
+ property: 'name',
13
+ component: 'input-text',
14
+ componentOptions: { name: 'name', label: 'Titre de la collection' },
15
+ },
16
+ {
17
+ property: 'slug',
18
+ component: 'input-text',
19
+ componentOptions: { name: 'slug', label: 'Slug de la collection' },
20
+ },
21
+ {
22
+ property: 'description',
23
+ component: 'input-text-area',
24
+ componentOptions: { name: 'description', label: 'Description de la collection' },
25
+ },
26
+ {
27
+ // `fields` is what the server knows (`definitionCreateDto` requires at
28
+ // least one) — the legacy model called this `attributes`, and the stale
29
+ // name made every create fail and every field edit a silent no-op.
30
+ property: 'fields',
31
+ component: 'input-text-area',
32
+ componentOptions: { format: 'json', name: 'fields', label: 'Champ(s) de la collection' },
33
+ },
34
+ {
35
+ property: 'editor',
36
+ component: 'input-text-area',
37
+ componentOptions: { format: 'json', name: 'editor', label: 'Editeur de la collection' },
38
+ },
39
+ ];
@@ -0,0 +1,40 @@
1
+ import type { FormControl } from '~/types';
2
+ import { ROLES } from '~/constants/roles';
3
+
4
+ /**
5
+ * The two member modals: inviting somebody, and editing somebody already here.
6
+ *
7
+ * They differ by their FIRST field — an address to write to, or a display name
8
+ * to correct — which is why they are two descriptions and not one with a
9
+ * condition.
10
+ *
11
+ * The offered roles come from the frozen list, never from a table copied here.
12
+ */
13
+ const ROLE_CONTROL: FormControl = {
14
+ property: 'role',
15
+ component: 'select-enum',
16
+ componentOptions: {
17
+ name: 'role',
18
+ label: 'Rôle',
19
+ items: ROLES.map(({ id }) => id),
20
+ object: false,
21
+ },
22
+ };
23
+
24
+ export const MEMBER_INVITE_FORM: FormControl[] = [
25
+ {
26
+ property: 'email',
27
+ component: 'input-text',
28
+ componentOptions: { name: 'email', type: 'email', autoComplete: 'off', label: 'Adresse mail' },
29
+ },
30
+ ROLE_CONTROL,
31
+ ];
32
+
33
+ export const MEMBER_UPDATE_FORM: FormControl[] = [
34
+ {
35
+ property: 'name',
36
+ component: 'input-text',
37
+ componentOptions: { name: 'name', label: "Nom d'affichage" },
38
+ },
39
+ ROLE_CONTROL,
40
+ ];
@@ -0,0 +1,188 @@
1
+ import type { FormTab } from '~/types';
2
+
3
+ /**
4
+ * The organization form, as the settings screen renders it — the same shape a
5
+ * collection's stored `editor` has, written by hand because the organization
6
+ * is not a collection.
7
+ *
8
+ * It lives here rather than inside the page because it is DATA: a hundred
9
+ * lines of layout that change when a setting is added, not when the screen
10
+ * behaves differently.
11
+ */
12
+ export const ORGANIZATION_FORM: { layout: FormTab[] } = {
13
+ layout: [
14
+ {
15
+ icon: '',
16
+ sections: [
17
+ {
18
+ componentOptions: {
19
+ title: "Logo de l'organisation",
20
+ description: 'Cliquez sur votre logo pour ajouter une image depuis vos fichiers.',
21
+ attributes: [
22
+ {
23
+ property: 'logo',
24
+ componentOptions: {
25
+ name: 'cover',
26
+ limit: 1,
27
+ label: "Logo de l'organisation",
28
+ },
29
+ component: 'input-files-media',
30
+ },
31
+ ],
32
+ },
33
+ component: 'form-section-default',
34
+ },
35
+ {
36
+ componentOptions: {
37
+ title: "Nom de l'organisation",
38
+ description:
39
+ 'Ces informations seront visibles publiquement, soyez donc attentif avec ce que vous partagerez.',
40
+ attributes: [
41
+ {
42
+ property: 'name',
43
+ componentOptions: {
44
+ previewSlug: false,
45
+ editableSlug: false,
46
+ trim: true,
47
+ placeHolder: "Nom de l'organisation",
48
+ required: true,
49
+ },
50
+ component: 'input-text',
51
+ },
52
+ ],
53
+ },
54
+ component: 'form-section-default',
55
+ },
56
+ ],
57
+ title: 'General',
58
+ },
59
+ {
60
+ icon: '',
61
+ sections: [
62
+ {
63
+ componentOptions: {
64
+ title: 'Collections',
65
+ description: 'Les types de contenu du site et leurs champs.',
66
+ attributes: [
67
+ {
68
+ property: 'collections',
69
+ componentOptions: {},
70
+ component: 'handler-collections',
71
+ },
72
+ ],
73
+ noAction: true,
74
+ },
75
+ component: 'form-section-default',
76
+ },
77
+ ],
78
+ title: 'Collections',
79
+ },
80
+ {
81
+ icon: '',
82
+ sections: [
83
+ {
84
+ componentOptions: {
85
+ title: 'Paramètres de déploiement',
86
+ description: 'Renseignez la définition du déploiement.',
87
+ attributes: [
88
+ {
89
+ property: 'deployment',
90
+ componentOptions: {
91
+ format: 'json',
92
+ label: 'Paramètres de déploiement',
93
+ name: 'deployment',
94
+ },
95
+ component: 'input-text-area',
96
+ },
97
+ ],
98
+ },
99
+ component: 'form-section-default',
100
+ },
101
+ {
102
+ componentOptions: {
103
+ title: 'Tokens de déploiement',
104
+ description:
105
+ "Ces tokens permettent d'autres applications à accéder à un contenu restreint de cette organisation.Soyez attentif!",
106
+ attributes: [
107
+ {
108
+ componentOptions: {},
109
+ component: 'handler-tokens',
110
+ },
111
+ ],
112
+ noAction: true,
113
+ },
114
+ component: 'form-section-default',
115
+ },
116
+ ],
117
+ title: 'Déploiement',
118
+ },
119
+ {
120
+ icon: '',
121
+ sections: [
122
+ {
123
+ componentOptions: {
124
+ title: "Configuration de l'injecteur",
125
+ description: 'Définissez les différentes pipelines de données ici',
126
+ attributes: [
127
+ {
128
+ property: 'injector',
129
+ componentOptions: {
130
+ format: 'json',
131
+ label: "Définition de l'injecteur",
132
+ name: 'injector',
133
+ },
134
+ component: 'input-text-area',
135
+ },
136
+ ],
137
+ },
138
+ component: 'form-section-default',
139
+ },
140
+ ],
141
+ title: 'Synchronisation des données',
142
+ },
143
+ {
144
+ icon: '',
145
+ sections: [
146
+ {
147
+ componentOptions: {
148
+ title: 'Membres',
149
+ description: "Les comptes ayant accès à cet espace d'administration.",
150
+ attributes: [
151
+ {
152
+ componentOptions: {},
153
+ component: 'handler-members',
154
+ },
155
+ ],
156
+ noAction: true,
157
+ },
158
+ component: 'form-section-default',
159
+ },
160
+ ],
161
+ title: 'Membres',
162
+ },
163
+ {
164
+ icon: '',
165
+ sections: [
166
+ {
167
+ componentOptions: {
168
+ title: 'Rôles',
169
+ description:
170
+ 'Deux rôles, en consultation : ils sont fixés par Commun et ne se modifient pas depuis cet écran.',
171
+ attributes: [
172
+ {
173
+ componentOptions: {},
174
+ component: 'handler-roles',
175
+ },
176
+ ],
177
+ noAction: true,
178
+ // `handler-roles` draws its own cards: a framed section would sit
179
+ // them inside a second one.
180
+ frameless: true,
181
+ },
182
+ component: 'form-section-default',
183
+ },
184
+ ],
185
+ title: 'Rôles',
186
+ },
187
+ ],
188
+ };
@@ -0,0 +1,15 @@
1
+ import type { FormControl } from '~/types';
2
+
3
+ /**
4
+ * The token modal: a name, and nothing else.
5
+ *
6
+ * The token itself is never asked for — the server draws it, and hands the
7
+ * plaintext back once, in the creation answer.
8
+ */
9
+ export const TOKEN_FORM: FormControl[] = [
10
+ {
11
+ property: 'name',
12
+ component: 'input-text',
13
+ componentOptions: { name: 'name', placeHolder: 'ex : site public, application mobile…' },
14
+ },
15
+ ];
@@ -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
+ ];
@@ -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/nuxt.config.ts CHANGED
@@ -107,7 +107,10 @@ export default defineNuxtConfig({
107
107
  // Scan nested composables (composables/core/domains/*).
108
108
  imports: { dirs: [join(layerDir, 'composables/**')] },
109
109
  // Session auth lives in use-session + middleware/00.auth (no auth module).
110
- modules: ['@nuxt/ui', '@pinia/nuxt', '@pinia-orm/nuxt', '@vueuse/nuxt'],
110
+ modules: ['@nuxt/ui', '@pinia/nuxt', '@pinia-orm/nuxt', '@vueuse/nuxt', 'nuxt-charts'],
111
+ // The charts the admin draws (the audience panels), themed by Nuxt UI. Only
112
+ // those it uses are registered, so the others stay out of the bundle.
113
+ nuxtCharts: { include: ['AreaChart'] },
111
114
  vite: {
112
115
  resolve: {
113
116
  // Sous le layout node_modules de Bun, Vite retombe sur l'entrée CJS
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.14",
23
- "@open-commune/editor": "^0.2.14",
22
+ "@open-commune/core": "^0.2.16",
23
+ "@open-commune/editor": "^0.2.16",
24
24
  "@pinia-orm/nuxt": "^2.0.0",
25
25
  "@pinia/nuxt": "^1.0.3",
26
26
  "@tanstack/vue-query": "^5.104.3",
@@ -35,6 +35,7 @@
35
35
  "h3": "^1.15.11",
36
36
  "luxon": "^3.4.4",
37
37
  "mapbox-gl": "^3.33.0",
38
+ "nuxt-charts": "^3.2.0",
38
39
  "ofetch": "^1.3.3",
39
40
  "pinia-orm": "^2.0.0",
40
41
  "tailwindcss": "^4.3.2",
@@ -42,7 +43,7 @@
42
43
  },
43
44
  "description": "The Open Commune application: the admin interface and the server, on a single origin.",
44
45
  "license": "AGPL-3.0-or-later",
45
- "version": "0.2.14",
46
+ "version": "0.2.16",
46
47
  "type": "module",
47
48
  "main": "./nuxt.config.ts",
48
49
  "files": [
@@ -1,5 +1,11 @@
1
1
  <template>
2
2
  <div>
3
+ <audience-panel
4
+ v-if="!isCreating"
5
+ :collection="{ id: String($route.params.collection), slug: String($route.params.collection) }"
6
+ :entry="String($route.params.record)"
7
+ class="mt-4"
8
+ />
3
9
  <!-- <alert
4
10
  v-if="alertSort"
5
11
  :sort="alertSort"
@@ -17,6 +23,7 @@
17
23
  <script setup>
18
24
  // import alert from '@/components/template/content-section/Alert'
19
25
  import formsLayout from '~/components/forms/layouts/layout'
26
+ import AudiencePanel from '~/components/audience/audience-panel.vue'
20
27
 
21
28
  definePageMeta({
22
29
  permissions: ['read:records'],