2023-01-02 18:00:11 +03:00
|
|
|
<script setup lang="ts">
|
2023-01-08 09:21:09 +03:00
|
|
|
import type { mastodon } from 'masto'
|
2023-01-02 18:00:11 +03:00
|
|
|
|
2023-08-01 12:43:55 +03:00
|
|
|
const form = defineModel<{
|
2024-01-09 11:56:15 +03:00
|
|
|
fieldsAttributes: NonNullable<mastodon.rest.v1.UpdateCredentialsParams['fieldsAttributes']>
|
2023-08-01 12:43:55 +03:00
|
|
|
}>({ required: true })
|
2024-02-21 18:20:08 +03:00
|
|
|
const dropdown = ref<any>()
|
2023-01-02 18:00:11 +03:00
|
|
|
|
|
|
|
const fieldIcons = computed(() =>
|
2023-01-10 11:33:20 +03:00
|
|
|
Array.from({ length: maxAccountFieldCount.value }, (_, i) =>
|
2024-03-05 17:48:58 +03:00
|
|
|
getAccountFieldIcon(form.value.fieldsAttributes[i].name)),
|
2023-01-02 18:00:11 +03:00
|
|
|
)
|
2023-01-03 00:09:15 +03:00
|
|
|
|
2024-02-21 18:20:08 +03:00
|
|
|
const fieldCount = computed(() => {
|
2023-01-10 11:33:20 +03:00
|
|
|
// find last non-empty field
|
|
|
|
const idx = [...form.value.fieldsAttributes].reverse().findIndex(f => f.name || f.value)
|
|
|
|
if (idx === -1)
|
|
|
|
return 1
|
|
|
|
return Math.min(
|
|
|
|
form.value.fieldsAttributes.length - idx + 1,
|
|
|
|
maxAccountFieldCount.value,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2023-03-30 22:01:24 +03:00
|
|
|
function chooseIcon(i: number, text: string) {
|
2023-01-03 00:09:15 +03:00
|
|
|
form.value.fieldsAttributes[i].name = text
|
2024-02-21 18:20:08 +03:00
|
|
|
dropdown.value[i]?.hide()
|
2023-01-03 00:09:15 +03:00
|
|
|
}
|
2023-01-02 18:00:11 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-10 11:33:20 +03:00
|
|
|
<div space-y-2>
|
|
|
|
<div font-medium>
|
|
|
|
{{ $t('settings.profile.appearance.profile_metadata') }}
|
|
|
|
</div>
|
|
|
|
<div text-sm text-secondary>
|
|
|
|
{{ $t('settings.profile.appearance.profile_metadata_desc', [maxAccountFieldCount]) }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div flex="~ col gap4">
|
|
|
|
<div v-for="i in fieldCount" :key="i" flex="~ gap3" items-center>
|
|
|
|
<CommonDropdown ref="dropdown" placement="left">
|
2023-02-15 22:15:11 +03:00
|
|
|
<CommonTooltip :content="$t('tooltip.pick_an_icon')">
|
2023-01-10 11:33:20 +03:00
|
|
|
<button type="button" btn-action-icon>
|
|
|
|
<div :class="fieldIcons[i - 1] || 'i-ri:question-mark'" />
|
|
|
|
</button>
|
|
|
|
</CommonTooltip>
|
|
|
|
<template #popper>
|
2023-03-07 23:02:00 +03:00
|
|
|
<div flex="~ wrap gap-1" max-w-60 m2 me1>
|
2023-01-10 11:33:20 +03:00
|
|
|
<CommonTooltip
|
|
|
|
v-for="(icon, text) in accountFieldIcons"
|
|
|
|
:key="icon"
|
|
|
|
:content="text"
|
|
|
|
>
|
|
|
|
<template v-if="text !== 'Joined'">
|
|
|
|
<button type="button" btn-action-icon @click="chooseIcon(i - 1, text)">
|
|
|
|
<div text-xl :class="icon" />
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</CommonTooltip>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</CommonDropdown>
|
|
|
|
<input
|
|
|
|
v-model="form.fieldsAttributes[i - 1].name"
|
2023-02-12 19:59:07 +03:00
|
|
|
type="text" placeholder-text-secondary
|
|
|
|
:placeholder="$t('settings.profile.appearance.profile_metadata_label')"
|
2023-01-10 11:33:20 +03:00
|
|
|
input-base
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model="form.fieldsAttributes[i - 1].value"
|
2023-02-12 19:59:07 +03:00
|
|
|
type="text" placeholder-text-secondary
|
|
|
|
:placeholder="$t('settings.profile.appearance.profile_metadata_value')"
|
2023-01-10 11:33:20 +03:00
|
|
|
input-base
|
|
|
|
>
|
|
|
|
</div>
|
2023-01-02 18:00:11 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|