refactor(front): create channel modal in user profile

This commit is contained in:
ArneBo 2025-02-12 13:06:58 +01:00
parent 1740cf485d
commit 10eebb9456
4 changed files with 55 additions and 68 deletions

View File

@ -9,6 +9,11 @@ import axios from 'axios'
import AttachmentInput from '~/components/common/AttachmentInput.vue' import AttachmentInput from '~/components/common/AttachmentInput.vue'
import TagsSelector from '~/components/library/TagsSelector.vue' import TagsSelector from '~/components/library/TagsSelector.vue'
import Layout from '~/components/ui/Layout.vue'
import Alert from '~/components/ui/Alert.vue'
import Input from '~/components/ui/Input.vue'
import Pills from '~/components/ui/Pills.vue'
interface Events { interface Events {
(e: 'category', contentCategory: ContentCategory): void (e: 'category', contentCategory: ContentCategory): void
(e: 'submittable', value: boolean): void (e: 'submittable', value: boolean): void
@ -41,6 +46,10 @@ const newValues = reactive({
metadata: { ...(props.object?.metadata ?? {}) } metadata: { ...(props.object?.metadata ?? {}) }
}) })
const tagList = computed(() => ({
custom: newValues.tags
}))
const creating = computed(() => props.object === null) const creating = computed(() => props.object === null)
const categoryChoices = computed(() => [ const categoryChoices = computed(() => [
{ {
@ -155,14 +164,12 @@ defineExpose({
</script> </script>
<template> <template>
<form <Layout form
class="ui form"
@submit.prevent.stop="submit" @submit.prevent.stop="submit"
> >
<div <Alert
v-if="errors.length > 0" v-if="errors.length > 0"
role="alert" red
class="ui negative message"
> >
<h4 class="header"> <h4 class="header">
{{ t('components.audio.ChannelForm.header.error') }} {{ t('components.audio.ChannelForm.header.error') }}
@ -175,7 +182,7 @@ defineExpose({
{{ error }} {{ error }}
</li> </li>
</ul> </ul>
</div> </Alert>
<template v-if="metadataChoices"> <template v-if="metadataChoices">
<fieldset <fieldset
v-if="creating && step === 1" v-if="creating && step === 1"
@ -199,7 +206,7 @@ defineExpose({
:value="choice.value" :value="choice.value"
> >
<label :for="`category-${choice.value}`"> <label :for="`category-${choice.value}`">
<span :class="['right floated', 'placeholder', 'image', {circular: choice.value === 'music'}]" /> <span :class="['right floated', 'placeholder', 'image', 'shifted', {circular: choice.value === 'music'}]" />
<strong>{{ choice.label }}</strong> <strong>{{ choice.label }}</strong>
<div class="ui small hidden divider" /> <div class="ui small hidden divider" />
{{ choice.helpText }} {{ choice.helpText }}
@ -207,34 +214,26 @@ defineExpose({
</div> </div>
</div> </div>
</fieldset> </fieldset>
<template v-if="!creating || step === 2"> <template v-if="!creating || step === 2">
<div class="ui required field"> <div class="ui required field">
<label for="channel-name"> <Input
{{ t('components.audio.ChannelForm.label.name') }}
</label>
<input
v-model="newValues.name" v-model="newValues.name"
type="text" type="text"
required required
:placeholder="labels.namePlaceholder" :placeholder="labels.namePlaceholder"
> :label="t('components.audio.ChannelForm.label.name')"
/>
</div> </div>
<div class="ui required field"> <div class="ui required field">
<label for="channel-username"> <Input
{{ t('components.audio.ChannelForm.label.username') }} v-model="newValues.username"
</label> type="text"
<div class="ui left labeled input"> :required="creating"
<div class="ui basic label"> :disabled="!creating"
<span class="at symbol" /> :placeholder="labels.usernamePlaceholder"
</div> :label="t('components.audio.ChannelForm.label.username')"
<input />
v-model="newValues.username"
type="text"
:required="creating"
:disabled="!creating"
:placeholder="labels.usernamePlaceholder"
>
</div>
<template v-if="creating"> <template v-if="creating">
<div class="ui small hidden divider" /> <div class="ui small hidden divider" />
<p> <p>
@ -255,13 +254,9 @@ defineExpose({
<div class="ui stackable grid row"> <div class="ui stackable grid row">
<div class="ten wide column"> <div class="ten wide column">
<div class="ui field"> <div class="ui field">
<label for="channel-tags"> <Pills
{{ t('components.audio.ChannelForm.label.tags') }} v-model="tagList"
</label> :label="t('components.audio.ChannelForm.label.tags')"
<tags-selector
id="channel-tags"
v-model="newValues.tags"
:required="false"
/> />
</div> </div>
</div> </div>
@ -369,10 +364,10 @@ defineExpose({
maxlength="255" maxlength="255"
> >
</div> </div>
<p>
{{ t('components.audio.ChannelForm.help.podcastFields') }}
</p>
</div> </div>
<p>
{{ t('components.audio.ChannelForm.help.podcastFields') }}
</p>
</template> </template>
</template> </template>
<div <div
@ -383,5 +378,5 @@ defineExpose({
{{ t('components.audio.ChannelForm.loader.loading') }} {{ t('components.audio.ChannelForm.loader.loading') }}
</div> </div>
</div> </div>
</form> </Layout>
</template> </template>

View File

@ -1,8 +1,8 @@
.placeholder.image { .placeholder.image {
background-color: rgba(0,0,0,.08); background-color: rgba(0,0,0,.08);
width: 3em; width: 48px;
height: 3em; height: 48px;
&.large { &.large {
width: 8em; width: 8em;
height: 8em; height: 8em;
@ -15,6 +15,9 @@
&.static { &.static {
animation: none; animation: none;
} }
&.shifted {
margin-top: -15px;
}
} }
.component-placeholder { .component-placeholder {

View File

@ -124,6 +124,11 @@
display: block; display: block;
padding: 1.5em; padding: 1.5em;
&.selected { &.selected {
background-color: rgba(0, 0, 0, 0.05); @include light-theme {
background-color: rgba(0, 0, 0, 0.05);
}
@include dark-theme {
background-color: rgba(255, 255, 255, 0.05);
}
} }
} }

View File

@ -39,16 +39,6 @@ const createForm = ref()
<template> <template>
<section> <section>
<div v-if="store.getters['ui/layoutVersion'] === 'small'">
<rendered-description
:content="object?.summary"
:field-name="'summary'"
:update-url="`users/${store.state.auth.username}/`"
:can-update="store.state.auth.authenticated && object?.full_username === store.state.auth.fullUsername"
@updated="emit('updated', $event)"
/>
<div class="ui hidden divider" />
</div>
<div> <div>
<h2 class="ui with-actions header"> <h2 class="ui with-actions header">
{{ t('views.auth.ProfileOverview.header.channels') }} {{ t('views.auth.ProfileOverview.header.channels') }}
@ -95,24 +85,18 @@ const createForm = ref()
'artist.header' 'artist.header'
}`)" }`)"
> >
<div <channel-form
ref="modalContent" ref="createForm"
class="scrolling content" :object="null"
> :step="step"
<channel-form @loading="loading = $event"
ref="createForm" @submittable="submittable = $event"
:object="null" @category="category = $event"
:step="step" @errored="modalContent.scrollTop = 0"
@loading="loading = $event" @created="router.push({name: 'channels.detail', params: {id: $event.actor.preferred_username}})"
@submittable="submittable = $event" />
@category="category = $event"
@errored="modalContent.scrollTop = 0"
@created="router.push({name: 'channels.detail', params: {id: $event.actor.preferred_username}})"
/>
<div class="ui hidden divider" />
</div>
<template #actions> <template #actions>
<Button destructive <Button secondary
v-if="step === 1" v-if="step === 1"
autofocus autofocus
> >