@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
@@ -1,176 +0,0 @@
1
- <template>
2
- <section class="w-full">
3
- <button-secondary label="Inviter un membre" class="mb-6" @click="_openModalForm('create')" />
4
- <default-table
5
- v-if="!$route.params.event"
6
- :headers="TABLE_HEADERS"
7
- :filters="filters"
8
- :items="records"
9
- :actions="abilities"
10
- :pagination-size="limit"
11
- display-search-bar
12
- paginated-content
13
- @fetch-more="_fetchMore"
14
- @update="_openModalForm('update', $event)"
15
- @remove="_handle('remove', $event)"
16
- />
17
- </section>
18
- </template>
19
-
20
- <script setup>
21
- import buttonSecondary from '~/components/elements/buttons/secondary'
22
- import defaultTable from '~/components/data/lists/data-lists-table'
23
- import { useModalStore } from '~/store/layout/modal'
24
- import { useNotificationsStore } from '~/store/layout/notifications'
25
-
26
-
27
- definePageMeta({
28
- permissions: ['manage:all'],
29
- preFetch: ['User'],
30
- headings: {
31
- title: 'Membres',
32
- description: 'Retrouvez & managez ici toutes les membres de la plateforme.'
33
- }
34
- })
35
-
36
- const { User } = useModels()
37
- const $route = useRoute()
38
- const $modalStore = useModalStore()
39
- const notificationsStore = useNotificationsStore()
40
-
41
- // Prepare constants
42
- const TABLE_HEADERS = [
43
- {
44
- nestedValue: false,
45
- componentOptions: {
46
- titleKey: 'fullName',
47
- descriptionKey: 'emailAddress',
48
- },
49
- component: 'data-summary'
50
- },
51
- {
52
- title: 'Rôle',
53
- property: 'role',
54
- component: 'data-text'
55
- },
56
- {
57
- component: "data-spacer",
58
- grow: true
59
- },
60
- {
61
- component: 'actions',
62
- componentOptions: {
63
- options: [{ label: 'Voir', action: 'read' }, { label: 'Modifier', action: 'update' }, { label: 'Supprimer', action: 'remove' }]
64
- }
65
- },
66
- ]
67
-
68
- // Prepare reactive data
69
- const limit = ref(25)
70
-
71
- // Prepare computed
72
- const records = computed(() => User.repo.all())
73
- const filters = computed(() => [])
74
- const abilities = computed(() => ['update', 'remove'])
75
-
76
- // Prepare methods
77
- const _fetchMore = async (skip = 0) => {
78
- await User.list(undefined, undefined, { skip, limit: limit.value })
79
- }
80
-
81
- // Prepare methods
82
- const _handle = async (action, data = {}) => {
83
- const { _id } = data
84
- switch (action) {
85
- case 'create': {
86
- // Une INVITATION est émise : l'email part côté serveur, et le lien est
87
- // copié au presse-papier comme second recours.
88
- // L'origine vient du navigateur, jamais d'une URL cuite au build —
89
- // l'image d'instance est commune à tous les clients.
90
- const { token } = await User.create(data)
91
- const link = `${window.location.origin}/welcome/${token}`
92
- try {
93
- await navigator.clipboard.writeText(link)
94
- notificationsStore.add({
95
- icon: 'iconoir:mail-out',
96
- type: 'success',
97
- title: 'Lien d\'invitation copié dans le presse-papier (valable 7 jours).'
98
- })
99
- } catch {
100
- console.log('Lien d\'invitation :', link)
101
- notificationsStore.add({
102
- icon: 'iconoir:mail-out',
103
- type: 'success',
104
- title: 'Invitation créée — lien affiché dans la console (valable 7 jours).'
105
- })
106
- }
107
- await User.list()
108
- break
109
- }
110
- case 'update':
111
- await User.update(_id, data)
112
- break
113
- case 'remove':
114
- await User.remove(data._id)
115
- break
116
- default:
117
- throw new Error('E_UNHANDLED')
118
- }
119
- }
120
-
121
- const _openModalForm = (action, record) => {
122
- $modalStore.open({
123
- onSubmit: async (data) => _handle(action, data),
124
- details: {
125
- title: `${action === 'create' ? 'Inviter' : 'Modifier'} un membre`,
126
- subTitle: action === 'create'
127
- ? 'Un lien d\'invitation sera généré pour ce nouveau membre.'
128
- : 'Modifiez les informations du membre.',
129
- acceptButton: `${action === 'create' ? 'Inviter' : 'Modifier'}`,
130
- closeButton: 'Annuler'
131
- },
132
- attributes: action === 'create'
133
- ? [
134
- {
135
- property: 'emailAddress',
136
- componentOptions: {
137
- label: 'Adresse mail',
138
- name: 'emailAddress'
139
- },
140
- component: 'input-text'
141
- },
142
- {
143
- property: 'role',
144
- componentOptions: {
145
- label: 'Rôle',
146
- name: 'role',
147
- items: ['admin', 'redacteur'],
148
- object: false
149
- },
150
- component: 'select-enum'
151
- }
152
- ]
153
- : [
154
- {
155
- property: 'firstName',
156
- componentOptions: {
157
- label: 'Nom d\'affichage',
158
- name: 'firstName'
159
- },
160
- component: 'input-text'
161
- },
162
- {
163
- property: 'role',
164
- componentOptions: {
165
- label: 'Rôle',
166
- name: 'role',
167
- items: ['admin', 'redacteur'],
168
- object: false
169
- },
170
- component: 'select-enum'
171
- }
172
- ],
173
- record
174
- })
175
- }
176
- </script>
@@ -1,192 +0,0 @@
1
- <template>
2
- <div class="relative block w-full">
3
- <!-- Instance single-tenant : une seule collectivité par déploiement. -->
4
- <p class="mb-6 rounded-md bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800">
5
- Cette instance héberge une seule collectivité — la création d'organisations n'est plus disponible.
6
- </p>
7
-
8
- <data-list :items="sortedOrganizations" :density="1" :density-children="2" :group-by="'type'" :item-value="'type'" class="space-y-4 bg-gray-50 p-2 rounded-md">
9
- <template #item="{ item }">
10
- <h3 class="text-gray-400 text-sm font-medium mb-2 pl-2">
11
- @ {{ item.type }}
12
- </h3>
13
- </template>
14
- <template #item-child="{ item: itemChild }">
15
- <data-list-row
16
- :item="itemChild"
17
- :to="`/${itemChild._id}`"
18
- :headers="ROW_DEFINITION"
19
- class="border border-gray-100 bg-white shadow-sm rounded-lg"
20
- @click="_handleRowEvent"
21
- />
22
- </template>
23
- </data-list>
24
- </div>
25
- </template>
26
-
27
- <script setup>
28
- import ButtonSecondary from '~/components/elements/buttons/secondary'
29
- import dataList from '~/components/data/lists/data-list'
30
- import dataListRow from '~/components/data/display/row'
31
- import { useWorkspaceStore } from '~/store/layout/workspace'
32
- import { useModalStore } from '~/store/layout/modal'
33
-
34
- definePageMeta({
35
- permissions: ['manage:all'],
36
- preFetch: ['Organization'],
37
- headings: {
38
- title: 'Organisations',
39
- description: 'Retrouvez & managez ici toutes les organisations.'
40
- }
41
- })
42
-
43
- const { Organization } = useModels()
44
- const modalStore = useModalStore()
45
-
46
- // Prepare constants
47
- const ORGANIZATIONS_ORDER = ['customer', 'network', 'country', 'bu', 'root'];
48
- const ROW_DEFINITION = [
49
- {
50
- component: 'data-avatar',
51
- nestedValue: false
52
- },
53
- {
54
- nestedValue: false,
55
- componentOptions: {
56
- titleKey: 'name',
57
- descriptionKey: 'path',
58
- },
59
- component: 'data-summary'
60
- },
61
- {
62
- component: "data-spacer",
63
- grow: true
64
- },
65
- {
66
- component: 'actions',
67
- componentOptions: {
68
- options: [{ label: 'Voir', action: 'read' }]
69
- }
70
- }
71
- ]
72
-
73
- // Prepare data
74
- const { data: organizations } = await useAsyncData('overview', () => Organization.list())
75
-
76
- // Prepare computed
77
- const sortedOrganizations = computed(() => organizations.value.sort((a, b) => ORGANIZATIONS_ORDER.indexOf(a.type) - ORGANIZATIONS_ORDER.indexOf(b.type)))
78
-
79
- // Prepare methods
80
- const _handleRowEvent = async (eventName, value) => {
81
- console.log(eventName, value)
82
- }
83
- // import { UPDATE_ORGANIZATION } from '~/store/actions'
84
- // import buttonSecondary from '~/components/elements/buttons/secondary'
85
-
86
- // export default {
87
- // name: 'Organizations',
88
- // meta: {
89
- // permissions: ['entrance:self'],
90
- // preFetch: ['Organization'],
91
- // headings: {
92
- // title: 'Organisations',
93
- // description: 'Retrouvez & managez ici toutes les organisations.'
94
- // }
95
- // },
96
- // components: { buttonSecondary },
97
- // computed: {
98
- // organizations () {
99
- // return this.$api.Organization.all()
100
- // }
101
- // },
102
- // beforeDestroy () {
103
- // this.$nuxt.$off('modalCreateOrganization')
104
- // },
105
- // mounted () {
106
- // this.$nuxt.$on('modalCreateOrganization', this.createOrganization)
107
- // },
108
- // methods: {
109
- // async updateSelectedOrganization (organizationRecord) {
110
- // try {
111
- // await this.$store.dispatch(UPDATE_ORGANIZATION, organizationRecord)
112
- // this.$router.replace(`${organizationRecord.slug}/`)
113
- // } catch (err) {
114
- // console.log(err) // eslint-disable-line
115
- // }
116
- // },
117
- // openModalForm (record) {
118
- // this.$nuxt.$emit('openModalForm', {
119
- // submitEvent: 'modalCreateOrganization',
120
- // details: {
121
- // title: 'Créer une nouvelle organisation',
122
- // subTitle: 'Renseignez cette nouvelle entité.'
123
- // },
124
- // attributes: [
125
- // // directParent
126
- // {
127
- // property: 'directParent',
128
- // componentOptions: {
129
- // placeHolder: 'Parent de l\'organisation',
130
- // name: 'directParent',
131
- // model: 'Organization',
132
- // object: true,
133
- // itemKey: 'name',
134
- // itemValue: 'slug'
135
- // },
136
- // component: 'select-model'
137
- // },
138
- // {
139
- // property: 'type',
140
- // componentOptions: {
141
- // placeHolder: 'Type d\'organisation',
142
- // name: 'type',
143
- // items: [
144
- // 'bu',
145
- // 'country',
146
- // 'network',
147
- // 'customer'
148
- // ]
149
- // },
150
- // component: 'select-enum'
151
- // },
152
- // {
153
- // property: 'slug',
154
- // componentOptions: {
155
- // placeHolder: 'Identifiant de l\'organisation (slug)',
156
- // name: 'slug'
157
- // },
158
- // component: 'input-text'
159
- // },
160
- // {
161
- // property: 'name',
162
- // componentOptions: {
163
- // placeHolder: 'Nom de l\'organisation',
164
- // name: 'name'
165
- // },
166
- // component: 'input-text'
167
- // },
168
- // {
169
- // property: 'type',
170
- // componentOptions: {
171
- // placeHolder: 'Localisation',
172
- // name: 'organization'
173
- // },
174
- // component: 'input-location'
175
- // }
176
- // ],
177
- // record
178
- // })
179
- // },
180
- // async createOrganization (data = {}) {
181
- // this.$nuxt.$loading.start()
182
- // try {
183
- // await this.$api.Organization.create(data)
184
- // } catch (err) {
185
- // console.log(err)
186
- // } finally {
187
- // this.$nuxt.$loading.finish()
188
- // }
189
- // }
190
- // }
191
- // }
192
- </script>
@@ -1,183 +0,0 @@
1
- <template>
2
- <section class="w-full">
3
- <!-- Rôles figés par Open Commune (admin / rédacteur) : consultation seule. -->
4
- <p class="mb-6 rounded-md bg-amber-50 border border-amber-200 px-4 py-3 text-sm text-amber-800">
5
- Les rôles sont désormais prédéfinis (administrateur, rédacteur) et ne sont plus personnalisables.
6
- </p>
7
- <default-table
8
- v-if="!$route.params.event"
9
- :headers="TABLE_HEADERS"
10
- :filters="filters"
11
- :items="records"
12
- :actions="abilities"
13
- :pagination-size="limit"
14
- display-search-bar
15
- paginated-content
16
- @fetch-more="_fetchMore"
17
- @update="_openModalForm('update', $event)"
18
- @remove="_handle('remove', $event)"
19
- />
20
- </section>
21
- </template>
22
-
23
- <script setup>
24
- import buttonSecondary from '~/components/elements/buttons/secondary'
25
- import defaultTable from '~/components/data/lists/data-lists-table'
26
- import { useModalStore } from '~/store/layout/modal'
27
-
28
- definePageMeta({
29
- permissions: ['manage:all'],
30
- preFetch: ['Role'],
31
- headings: {
32
- title: 'Membres',
33
- description: 'Retrouvez & managez ici toutes les membres de la plateforme.'
34
- }
35
- })
36
-
37
- const { Role } = useModels()
38
- const $route = useRoute()
39
- const $modalStore = useModalStore()
40
-
41
- // Prepare constants
42
- const TABLE_HEADERS = [
43
- {
44
- title: 'Nom',
45
- property: 'name',
46
- component: 'data-text'
47
- },
48
- {
49
- title: '',
50
- component: 'actions'
51
- }
52
- ]
53
-
54
- // Prepare reactive data
55
- const limit = ref(25)
56
-
57
- // Prepare computed
58
- const records = computed(() => Role.repo.all())
59
- const filters = computed(() => [])
60
- // Rôles figés : aucune action d'édition/suppression proposée.
61
- const abilities = computed(() => [])
62
-
63
- // Prepare methods
64
- const _fetchMore = async (skip = 0) => {
65
- await Role.list(undefined, undefined, { skip, limit: limit.value })
66
- }
67
-
68
- // Prepare methods
69
- const _handle = async (action, data = {}) => {
70
- const { _id } = data
71
- switch (action) {
72
- case 'add':
73
- await Role.create(data)
74
- break
75
- case 'update':
76
- await Role.update(_id, data)
77
- break
78
- case 'remove':
79
- await Role.remove(_id)
80
- break
81
- default:
82
- throw new Error('E_UNHANDLED')
83
- }
84
- }
85
-
86
- const _openModalForm = (action, record) => {
87
- $modalStore.open({
88
- onSubmit: async (data) => _handle(action, data),
89
- details: {
90
- title: `${action === 'add' ? 'Ajouter' : 'Modifier'} un rôle`,
91
- subTitle: 'Reinseignez les informations de ce rôle.',
92
- acceptButton: `${action === 'add' ? 'Ajouter' : 'Modifier'}`,
93
- closeButton: 'Annuler'
94
- },
95
- attributes: [
96
- {
97
- property: 'name',
98
- componentOptions: {
99
- label: 'Nom du rôle',
100
- name: 'name'
101
- },
102
- component: 'input-text'
103
- },
104
- {
105
- property: 'description',
106
- componentOptions: {
107
- label: 'Description rôle',
108
- name: 'description'
109
- },
110
- component: 'input-text'
111
- },
112
- {
113
- property: 'permissions',
114
- componentOptions: {
115
- label: 'Permissions du rôle',
116
- name: 'permissions',
117
- items: [
118
- 'manage:all',
119
- 'read:deployments',
120
- 'create:deployments',
121
- 'admin:organizations',
122
- 'create:organizations',
123
- 'read:organizations',
124
- 'update:organizations',
125
- 'create:collections',
126
- 'read:collections',
127
- 'update:collections',
128
- 'delete:collections',
129
- 'publish:records',
130
- 'create:records',
131
- 'read:records',
132
- 'update:records',
133
- 'delete:records',
134
- 'create:media',
135
- 'read:media',
136
- 'update:media',
137
- 'delete:media',
138
- 'create:users',
139
- 'read:users',
140
- 'update:users',
141
- 'delete:users',
142
- 'create:roles',
143
- 'read:roles',
144
- 'update:roles',
145
- 'delete:roles',
146
- 'create:tokens',
147
- 'read:tokens',
148
- 'update:tokens',
149
- 'delete:tokens'
150
- ],
151
- enableMultiple: true,
152
- object: false,
153
- placeHolder: 'Ajouter une ou plusieurs permissions',
154
- },
155
- component: 'select-enum'
156
- },
157
- {
158
- property: 'onlyOwn',
159
- componentOptions: {
160
- label: 'Restriction créateur',
161
- description: 'Restreindre le champs d\'action d\'un utilisateur à ses propres ressources uniquement.',
162
- name: 'onlyOwn',
163
- property: 'onlyOwn',
164
- readOnly: true
165
- },
166
- component: 'input-toggle'
167
- },
168
- {
169
- property: 'mfa',
170
- componentOptions: {
171
- label: 'Authentification multi-facteur',
172
- description: 'Vérifier l\'authentification d\'un utilisateur via un facteur supplémentaire (authenticator, sms, ...).',
173
- name: 'mfa',
174
- property: 'mfa',
175
- readOnly: true
176
- },
177
- component: 'input-toggle'
178
- }
179
- ],
180
- record
181
- })
182
- }
183
- </script>