refactor(front): Albums in channels
This commit is contained in:
parent
10eebb9456
commit
e0b24e10ee
|
@ -1,6 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Album } from '~/types'
|
import type { Album } from '~/types'
|
||||||
|
|
||||||
|
import AlbumCard from '~/components/album/Card.vue'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
album: Album
|
album: Album
|
||||||
}
|
}
|
||||||
|
@ -10,6 +12,5 @@ defineProps<Props>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
front/src/components/audio/album/Card.vue
|
<AlbumCard :album="album" />
|
||||||
<fw-album-card :album="album" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,6 +5,10 @@ import { computed, watch, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
|
import Input from '~/components/ui/Input.vue'
|
||||||
|
|
||||||
interface Events {
|
interface Events {
|
||||||
(e: 'submittable', value: boolean): void
|
(e: 'submittable', value: boolean): void
|
||||||
(e: 'loading', value: boolean): void
|
(e: 'loading', value: boolean): void
|
||||||
|
@ -52,14 +56,13 @@ defineExpose({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<form
|
<Layout form
|
||||||
:class="['ui', {loading: isLoading}, 'form']"
|
:class="['ui', {loading: isLoading}, 'form']"
|
||||||
@submit.stop.prevent
|
@submit.stop.prevent
|
||||||
>
|
>
|
||||||
<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.channels.AlbumForm.header.error') }}
|
{{ t('components.channels.AlbumForm.header.error') }}
|
||||||
|
@ -72,15 +75,15 @@ defineExpose({
|
||||||
{{ error }}
|
{{ error }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</Alert>
|
||||||
<div class="ui required field">
|
<div class="ui required field">
|
||||||
<label for="album-title">
|
<label for="album-title">
|
||||||
{{ t('components.channels.AlbumForm.label.albumTitle') }}
|
{{ t('components.channels.AlbumForm.label.albumTitle') }}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<Input
|
||||||
v-model="title"
|
v-model="title"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -53,10 +53,10 @@ defineExpose({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<Spacer h grow />
|
|
||||||
<Button
|
<Button
|
||||||
:is-loading="isLoading"
|
:is-loading="isLoading"
|
||||||
:disabled="!submittable"
|
:disabled="!submittable"
|
||||||
|
primary
|
||||||
@click.stop.prevent="albumForm.submit()"
|
@click.stop.prevent="albumForm.submit()"
|
||||||
>
|
>
|
||||||
{{ t('components.channels.AlbumModal.button.create') }}
|
{{ t('components.channels.AlbumModal.button.create') }}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Album, Content, Track, Actor } from '~/types'
|
import type { Album, Track, Actor } from '~/types'
|
||||||
|
|
||||||
import { i18n } from '~/init/locale'
|
import { i18n } from '~/init/locale'
|
||||||
|
|
||||||
|
@ -20,21 +20,10 @@ export type EditObject = (Partial<Album> | Partial<Track>) & { attributed_to: Ac
|
||||||
export type EditObjectType = 'album' | 'track'
|
export type EditObjectType = 'album' | 'track'
|
||||||
type Configs = Record<EditObjectType, { fields: (EditableConfigField|ConfigField)[] }>
|
type Configs = Record<EditObjectType, { fields: (EditableConfigField|ConfigField)[] }>
|
||||||
|
|
||||||
const getContentValueRepr = (val: Content) => val.text
|
|
||||||
|
|
||||||
// TODO: Get params from typescript type somehow?
|
// TODO: Get params from typescript type somehow?
|
||||||
export default (): Configs => {
|
export default (): Configs => {
|
||||||
const { t } = i18n.global
|
const { t } = i18n.global
|
||||||
|
|
||||||
const description: ConfigField = {
|
|
||||||
id: 'description',
|
|
||||||
type: 'content',
|
|
||||||
required: true,
|
|
||||||
label: t('composables.moderation.useEditConfigs.description.label'),
|
|
||||||
getValue: (obj) => obj.description ?? { text: '', content_type: 'text/markdown' },
|
|
||||||
getValueRepr: getContentValueRepr
|
|
||||||
}
|
|
||||||
|
|
||||||
const cover: ConfigField = {
|
const cover: ConfigField = {
|
||||||
id: 'cover',
|
id: 'cover',
|
||||||
type: 'attachment',
|
type: 'attachment',
|
||||||
|
@ -66,9 +55,9 @@ export default (): Configs => {
|
||||||
label: t('composables.moderation.useEditConfigs.album.title'),
|
label: t('composables.moderation.useEditConfigs.album.title'),
|
||||||
getValue: (album) => (album as Album).title
|
getValue: (album) => (album as Album).title
|
||||||
},
|
},
|
||||||
description,
|
|
||||||
{
|
{
|
||||||
id: 'release_date',
|
id: 'release_date',
|
||||||
|
// TODO: Change type to date and offer date select input in form
|
||||||
type: 'text',
|
type: 'text',
|
||||||
required: false,
|
required: false,
|
||||||
label: t('composables.moderation.useEditConfigs.album.releaseDate'),
|
label: t('composables.moderation.useEditConfigs.album.releaseDate'),
|
||||||
|
@ -87,7 +76,6 @@ export default (): Configs => {
|
||||||
label: t('composables.moderation.useEditConfigs.track.title'),
|
label: t('composables.moderation.useEditConfigs.track.title'),
|
||||||
getValue: (track) => (track as Track).title
|
getValue: (track) => (track as Track).title
|
||||||
},
|
},
|
||||||
description,
|
|
||||||
cover,
|
cover,
|
||||||
{
|
{
|
||||||
id: 'position',
|
id: 'position',
|
||||||
|
|
|
@ -192,7 +192,7 @@ const albumModal = ref()
|
||||||
class="actions"
|
class="actions"
|
||||||
>
|
>
|
||||||
<a @click.stop.prevent="albumModal.show = true">
|
<a @click.stop.prevent="albumModal.show = true">
|
||||||
<i class="plus icon" />
|
<i class="bi bi-plus" />
|
||||||
{{ t('views.channels.DetailOverview.link.addAlbum') }}
|
{{ t('views.channels.DetailOverview.link.addAlbum') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue