Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: simplified user attributes ui #590

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions agate-ui/src/components/UserAttributesList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<div>
<div class="text-bold">
{{ t('user.attributes.title') }}
</div>
<div class="text-hint q-mb-sm">
{{ t('user.attributes.hint') }}
</div>
<q-list>
<q-item v-for="(entry, idx) in attributes" :key="idx" class="q-pa-none">
<q-item-section>
<div class="row q-col-gutter-md">
<div class="col">
<q-input
v-model="entry.name"
:label="t('name')"
dense
lazy-rules
:rules="[(val) => !!val || t('required')]"
@update:model-value="onUpdate"
/>
</div>
<div class="col">
<q-input
v-model="entry.value"
:label="t('value')"
dense
lazy-rules
:rules="[(val) => !!val || t('required')]"
@update:model-value="onUpdate"
/>
</div>
</div>
</q-item-section>
<q-item-section side>
<q-btn flat icon="delete" color="accent" size="sm" @click="onDelete(idx)" />
</q-item-section>
</q-item>
</q-list>
<q-btn color="primary" icon="add" size="sm" @click="attributes.push({ name: '', value: '' })" />
</div>
</template>

<script setup lang="ts">
import type { AttributeDto } from 'src/models/Agate';

interface Props {
modelValue: AttributeDto[] | undefined;
}

const props = defineProps<Props>();
const emit = defineEmits(['update:modelValue']);
const { t } = useI18n();

const attributes = ref<AttributeDto[]>(props.modelValue ? [...props.modelValue] : []);

function onDelete(index: number) {
attributes.value.splice(index, 1);
emit('update:modelValue', attributes.value.filter((attr) => attr.name && attr.value));
}

function onUpdate() {
emit('update:modelValue', attributes.value.filter((attr) => attr.name && attr.value));
}
</script>
2 changes: 1 addition & 1 deletion agate-ui/src/components/UserDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
import { copyToClipboard } from 'quasar';
import type { UserDto } from 'src/models/Agate';
import { notifyError, notifyInfo, notifySuccess } from 'src/utils/notify';
import UserAttributesList from 'src/components/attributes/UserAttributesList.vue';
import UserAttributesList from 'src/components/UserAttributesList.vue';

const { t } = useI18n();
const userStore = useUserStore();
Expand Down
103 changes: 0 additions & 103 deletions agate-ui/src/components/attributes/UserAttributeDialog.vue

This file was deleted.

173 changes: 0 additions & 173 deletions agate-ui/src/components/attributes/UserAttributesList.vue

This file was deleted.

1 change: 1 addition & 0 deletions agate-ui/src/i18n/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default {
update_password: 'Update password',
attributes: {
title: 'User Attributes',
hint: 'Additional user information.',
add: 'Add User Attribute',
update: 'Update User Attribute',
updated: 'User attribute updated successfully',
Expand Down
1 change: 1 addition & 0 deletions agate-ui/src/i18n/fr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default {
update_password: 'Mettre à jour le mot de passe',
attributes: {
title: 'Attributs utilisateur',
hint: 'Informations additionnelles sur l\'usager.',
add: 'Ajouter un attribut d\'utilisateur',
update: "Mettre à Jour l'attribut d'utilisateur",
updated: 'Attribut utilisateur mis à jour avec succès',
Expand Down