[WIP] refactor(front): Playlist Editor
This commit is contained in:
parent
e2bb166707
commit
2021330eca
|
@ -14,6 +14,9 @@ import draggable from 'vuedraggable'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import PlaylistForm from '~/components/playlists/Form.vue'
|
import PlaylistForm from '~/components/playlists/Form.vue'
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
|
import Button from '~/components/ui/Button.vue'
|
||||||
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
|
|
||||||
interface Events {
|
interface Events {
|
||||||
(e: 'update:playlistTracks', value: PlaylistTrack[]): void
|
(e: 'update:playlistTracks', value: PlaylistTrack[]): void
|
||||||
|
@ -163,7 +166,7 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="ui text container component-playlist-editor">
|
<Layout stack>
|
||||||
<playlist-form
|
<playlist-form
|
||||||
v-model:playlist="playlist"
|
v-model:playlist="playlist"
|
||||||
:title="undefined"
|
:title="undefined"
|
||||||
|
@ -171,7 +174,6 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
<h3 class="ui top attached header">
|
<h3 class="ui top attached header">
|
||||||
{{ t('components.playlists.Editor.header.editor') }}
|
{{ t('components.playlists.Editor.header.editor') }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="ui attached segment">
|
|
||||||
<template v-if="status === 'loading'">
|
<template v-if="status === 'loading'">
|
||||||
<div class="ui active tiny inline loader" />
|
<div class="ui active tiny inline loader" />
|
||||||
{{ t('components.playlists.Editor.loading.sync') }}
|
{{ t('components.playlists.Editor.loading.sync') }}
|
||||||
|
@ -179,10 +181,10 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
<template v-else-if="status === 'errored'">
|
<template v-else-if="status === 'errored'">
|
||||||
<i class="dangerclose icon" />
|
<i class="dangerclose icon" />
|
||||||
{{ t('components.playlists.Editor.error.sync') }}
|
{{ t('components.playlists.Editor.error.sync') }}
|
||||||
<div
|
<Alert
|
||||||
|
red
|
||||||
v-if="errors.length > 0"
|
v-if="errors.length > 0"
|
||||||
role="alert"
|
role="alert"
|
||||||
class="ui negative message"
|
|
||||||
>
|
>
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
<li
|
<li
|
||||||
|
@ -192,12 +194,12 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
{{ error }}
|
{{ error }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</Alert>
|
||||||
</template>
|
</template>
|
||||||
<div
|
<Alert
|
||||||
|
red
|
||||||
v-else-if="status === 'confirmDuplicateAdd'"
|
v-else-if="status === 'confirmDuplicateAdd'"
|
||||||
role="alert"
|
role="alert"
|
||||||
class="ui warning message"
|
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
{{ t('components.playlists.Editor.warning.duplicate') }}
|
{{ t('components.playlists.Editor.warning.duplicate') }}
|
||||||
|
@ -211,28 +213,27 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
{{ track }}
|
{{ track }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button
|
<Button
|
||||||
class="ui small success button"
|
primary
|
||||||
@click="insertMany(queueTracks, true)"
|
@click="insertMany(queueTracks, true)"
|
||||||
>
|
>
|
||||||
{{ t('components.playlists.Editor.button.addDuplicate') }}
|
{{ t('components.playlists.Editor.button.addDuplicate') }}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</Alert>
|
||||||
<template v-else-if="status === 'saved'">
|
<template v-else-if="status === 'saved'">
|
||||||
<i class="success check icon" />
|
<i class="success bi- bi-check" />
|
||||||
{{ t('components.playlists.Editor.message.sync') }}
|
{{ t('components.playlists.Editor.message.sync') }}
|
||||||
</template>
|
</template>
|
||||||
</div>
|
<Button
|
||||||
<div class="ui bottom attached segment">
|
|
||||||
<button
|
|
||||||
:disabled="queueTracks.length === 0"
|
:disabled="queueTracks.length === 0"
|
||||||
|
primary
|
||||||
:class="['ui', {disabled: queueTracks.length === 0}, 'labeled', 'icon', 'button']"
|
:class="['ui', {disabled: queueTracks.length === 0}, 'labeled', 'icon', 'button']"
|
||||||
:title="labels.copyTitle"
|
:title="labels.copyTitle"
|
||||||
|
icon="bi-plus"
|
||||||
@click="insertMany(queueTracks, false)"
|
@click="insertMany(queueTracks, false)"
|
||||||
>
|
>
|
||||||
<i class="plus icon" />
|
|
||||||
{{ t('components.playlists.Editor.button.insertFromQueue', queueTracks.length) }}
|
{{ t('components.playlists.Editor.button.insertFromQueue', queueTracks.length) }}
|
||||||
</button>
|
</Button>
|
||||||
|
|
||||||
<dangerous-button
|
<dangerous-button
|
||||||
:disabled="tracks.length === 0"
|
:disabled="tracks.length === 0"
|
||||||
|
@ -263,6 +264,7 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
{{ t('components.playlists.Editor.help.reorder') }}
|
{{ t('components.playlists.Editor.help.reorder') }}
|
||||||
</p>
|
</p>
|
||||||
<div class="table-wrapper">
|
<div class="table-wrapper">
|
||||||
|
<!-- TODO: Use activity.vue -->
|
||||||
<table class="ui compact very basic unstackable table">
|
<table class="ui compact very basic unstackable table">
|
||||||
<draggable
|
<draggable
|
||||||
v-model="tracks"
|
v-model="tracks"
|
||||||
|
@ -309,6 +311,5 @@ const insertMany = async (insertedTracks: number[], allowDuplicates: boolean) =>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</Layout>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -12,6 +12,11 @@ import $ from 'jquery'
|
||||||
import useSharedLabels from '~/composables/locale/useSharedLabels'
|
import useSharedLabels from '~/composables/locale/useSharedLabels'
|
||||||
import useLogger from '~/composables/useLogger'
|
import useLogger from '~/composables/useLogger'
|
||||||
|
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
|
import Button from '~/components/ui/Button.vue'
|
||||||
|
import Input from '~/components/ui/Input.vue'
|
||||||
|
|
||||||
interface Events {
|
interface Events {
|
||||||
(e: 'update:playlist', value: Playlist): void
|
(e: 'update:playlist', value: Playlist): void
|
||||||
}
|
}
|
||||||
|
@ -103,19 +108,17 @@ const submit = async () => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<form
|
<Layout form
|
||||||
class="ui form"
|
|
||||||
@submit.prevent="submit()"
|
@submit.prevent="submit()"
|
||||||
>
|
>
|
||||||
<h4
|
<h4
|
||||||
v-if="title"
|
v-if="title"
|
||||||
class="ui header"
|
|
||||||
>
|
>
|
||||||
{{ t('components.playlists.Form.header.createPlaylist') }}
|
{{ t('components.playlists.Form.header.createPlaylist') }}
|
||||||
</h4>
|
</h4>
|
||||||
<div
|
<Alert
|
||||||
v-if="success"
|
v-if="success"
|
||||||
class="ui positive message"
|
green
|
||||||
>
|
>
|
||||||
<h4 class="header">
|
<h4 class="header">
|
||||||
<template v-if="playlist">
|
<template v-if="playlist">
|
||||||
|
@ -125,11 +128,11 @@ const submit = async () => {
|
||||||
{{ t('components.playlists.Form.header.createSuccess') }}
|
{{ t('components.playlists.Form.header.createSuccess') }}
|
||||||
</template>
|
</template>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</Alert>
|
||||||
<div
|
<Alert
|
||||||
v-if="errors.length > 0"
|
v-if="errors.length > 0"
|
||||||
|
red
|
||||||
role="alert"
|
role="alert"
|
||||||
class="ui negative message"
|
|
||||||
>
|
>
|
||||||
<h4 class="header">
|
<h4 class="header">
|
||||||
{{ t('components.playlists.Form.header.createFailure') }}
|
{{ t('components.playlists.Form.header.createFailure') }}
|
||||||
|
@ -142,18 +145,18 @@ const submit = async () => {
|
||||||
{{ error }}
|
{{ error }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</Alert>
|
||||||
<div class="three fields">
|
<div class="three fields">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="playlist-name">{{ t('components.playlists.Form.label.name') }}</label>
|
<label for="playlist-name">{{ t('components.playlists.Form.label.name') }}</label>
|
||||||
<input
|
<Input
|
||||||
id="playlist-name"
|
id="playlist-name"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
name="name"
|
name="name"
|
||||||
required
|
required
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="labels.placeholder"
|
:placeholder="labels.placeholder"
|
||||||
>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="playlist-visibility">{{ t('components.playlists.Form.label.visibility') }}</label>
|
<label for="playlist-visibility">{{ t('components.playlists.Form.label.visibility') }}</label>
|
||||||
|
@ -173,7 +176,8 @@ const submit = async () => {
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<span id="updatePlaylistLabel" />
|
<span id="updatePlaylistLabel" />
|
||||||
<button
|
<Button
|
||||||
|
primary
|
||||||
:class="['ui', 'fluid', {'loading': isLoading}, 'button']"
|
:class="['ui', 'fluid', {'loading': isLoading}, 'button']"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
|
@ -183,8 +187,8 @@ const submit = async () => {
|
||||||
<template v-else>
|
<template v-else>
|
||||||
{{ t('components.playlists.Form.button.create') }}
|
{{ t('components.playlists.Form.button.create') }}
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue