diff --git a/agate-ui/src/components/HtmlAnchorHint.vue b/agate-ui/src/components/HtmlAnchorHint.vue new file mode 100644 index 00000000..de18bfec --- /dev/null +++ b/agate-ui/src/components/HtmlAnchorHint.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/agate-ui/src/components/SystemProperties.vue b/agate-ui/src/components/SystemProperties.vue index 4ddb8b19..dfd5cbd2 100644 --- a/agate-ui/src/components/SystemProperties.vue +++ b/agate-ui/src/components/SystemProperties.vue @@ -134,18 +134,12 @@ + + diff --git a/agate-ui/src/components/SystemUserAttributesDialog.vue b/agate-ui/src/components/SystemUserAttributesDialog.vue new file mode 100644 index 00000000..e4a471b6 --- /dev/null +++ b/agate-ui/src/components/SystemUserAttributesDialog.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/agate-ui/src/i18n/en/index.js b/agate-ui/src/i18n/en/index.js index a8579072..7906a51b 100644 --- a/agate-ui/src/i18n/en/index.js +++ b/agate-ui/src/i18n/en/index.js @@ -234,6 +234,22 @@ export default { APP: 'Mobile app', ANY: 'Email or mobile app', }, + attributes: { + title: 'User Attributes', + hint: 'Attributes extend user description fields as wel as join requests. Localize each attribute by creating a key for each locale prefixed by user-info. in the {url} section.', + values_hint: 'Comma separated values', + add: 'Add Attribute', + update: 'Update Attribute', + remove: 'Remove Attribute', + remove_confirm: 'Please confirm the removal of the attribute: {name}', + name_exists: 'Attribute name already exists', + types: { + STRING: 'String', + NUMBER: 'Number', + BOOLEAN: 'Boolean', + INTEGER: 'Integer', + } + } }, ticket: { events: 'Events', @@ -283,8 +299,11 @@ export default { source_code: 'Source Code', status: 'Status', tickets: 'Tickets', + translations: 'Translations', type: 'Type', username: 'Username', users_caption: 'Manage users, assign role and groups to grant applications access', users: 'Users', + value: 'Value', + values: 'Values', }; diff --git a/agate-ui/src/i18n/fr/index.js b/agate-ui/src/i18n/fr/index.js index 7791d9b2..852fce4b 100644 --- a/agate-ui/src/i18n/fr/index.js +++ b/agate-ui/src/i18n/fr/index.js @@ -234,6 +234,22 @@ export default { APP: 'Application mobile', ANY: 'Courriel ou application mobile', }, + attributes: { + title: 'Attributs Utilisateur', + hint: 'Les attributs étendent les champs de description de l\'utilisateur ainsi que les demandes d\'adhésion. Localisez chaque attribut en créant une clé pour chaque langue, préfixée par user-info. dans la section {url}.', + values_hint: 'Valeurs séparées par des virgules', + add: 'Ajouter un Attribut', + update: 'Mettre à Jour l\'Attribut', + remove: 'Supprimer l\'Attribut', + remove_confirm: 'Veuillez confirmer la suppression de l\'attribut : {name}', + name_exists: 'Le nom de l\'attribut existe déjà', + types: { + STRING: 'Chaîne', + NUMBER: 'Nombre', + BOOLEAN: 'Booléen', + INTEGER: 'Entier', + } + }, }, ticket: { events: 'Événements', @@ -283,8 +299,11 @@ export default { source_code: 'Code source', status: 'Statut', tickets: 'Tickets', + translations: 'Traductions', type: 'Type', username: "Nom d'usager", users_caption: 'Gérer les utilisateurs, les rôles et les accès aux applications', users: 'Utilisateurs', + value: 'Valeur', + values: 'Valeurs', }; diff --git a/agate-ui/src/pages/SettingsPage.vue b/agate-ui/src/pages/SettingsPage.vue index a7e2a340..d25df788 100644 --- a/agate-ui/src/pages/SettingsPage.vue +++ b/agate-ui/src/pages/SettingsPage.vue @@ -9,12 +9,21 @@
{{ t('properties') }}
+
diff --git a/agate-ui/src/stores/system.ts b/agate-ui/src/stores/system.ts index 662142e3..ff4214ab 100644 --- a/agate-ui/src/stores/system.ts +++ b/agate-ui/src/stores/system.ts @@ -1,10 +1,11 @@ import { defineStore } from 'pinia'; import { api } from 'src/boot/api'; -import type { PublicConfigurationDto, ConfigurationDto } from 'src/models/Agate'; +import type { PublicConfigurationDto, ConfigurationDto, AttributeConfigurationDto } from 'src/models/Agate'; export const useSystemStore = defineStore('system', () => { const configurationPublic = ref({} as PublicConfigurationDto); const configuration = ref({} as ConfigurationDto); + const userAttributes = ref([]); async function initPub() { return api.get('/config/_public').then((response) => { @@ -19,11 +20,44 @@ export const useSystemStore = defineStore('system', () => { return api.get('/config').then((response) => { if (response.status === 200) { configuration.value = response.data; + userAttributes.value = configuration.value.userAttributes; } return response; }); } + async function addAttribute(attribute: AttributeConfigurationDto) { + if (attribute) { + if (!userAttributes.value) { + configuration.value.userAttributes = []; + userAttributes.value = configuration.value.userAttributes; + } + + userAttributes.value.push(attribute); + return save({ ...configuration.value }); + } + } + + async function updateAttribute(attribute: AttributeConfigurationDto) { + if (attribute) { + const index = userAttributes.value.findIndex(attr => attr.name === attribute.name); + if (index !== -1) { + userAttributes.value[index] = attribute; + return save({ ...configuration.value }); + } else { + throw new Error('Attribute not found'); + } + } + } + + async function removeAttribute(attribute: AttributeConfigurationDto) { + const index = userAttributes.value.indexOf(attribute); + if (index !== -1) { + userAttributes.value.splice(index, 1); + return save({ ...configuration.value }); + } + } + async function save(config: ConfigurationDto) { return api.put('/config', config).then((response) => { configuration.value = { ...config }; @@ -33,9 +67,13 @@ export const useSystemStore = defineStore('system', () => { return { configuration, + userAttributes, configurationPublic, init, initPub, + addAttribute, + updateAttribute, + removeAttribute, save, }; });