[web] Simplify modal dialogs

This commit is contained in:
Alain Nussbaumer 2025-02-08 14:35:25 +01:00
parent a1e68a1aa6
commit bb8b2a72e4
21 changed files with 92 additions and 124 deletions

View File

@ -47,7 +47,7 @@
@remove-podcast="open_remove_podcast_dialog()" @remove-podcast="open_remove_podcast_dialog()"
@play-count-changed="play_count_changed()" @play-count-changed="play_count_changed()"
/> />
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show_remove_podcast_modal" :show="show_remove_podcast_modal"
:title="$t('page.podcast.remove-podcast')" :title="$t('page.podcast.remove-podcast')"
@ -64,20 +64,20 @@
</template> </template>
</i18n-t> </i18n-t>
</template> </template>
</modal-dialog-action> </modal-dialog>
</teleport> </teleport>
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import CoverArtwork from '@/components/CoverArtwork.vue'
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
import { useSettingsStore } from '@/stores/settings' import { useSettingsStore } from '@/stores/settings'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ListAlbums', name: 'ListAlbums',
components: { CoverArtwork, ModalDialogAction, ModalDialogAlbum }, components: { CoverArtwork, ModalDialog, ModalDialogAlbum },
props: { props: {
items: { required: true, type: Object }, items: { required: true, type: Object },
media_kind: { default: '', type: String } media_kind: { default: '', type: String }

View File

@ -5,10 +5,20 @@
<div class="modal-content"> <div class="modal-content">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<slot name="content" /> <p v-if="title" class="title is-4" v-text="title" />
<slot name="modal-content" />
</div> </div>
<footer class="card-footer"> <footer class="card-footer">
<slot name="footer" /> <a
v-for="action in actions"
:key="action.event"
class="card-footer-item"
:class="{ 'is-disabled': action.disabled }"
@click="$emit(action.event)"
>
<mdicon class="icon" :name="action.icon" size="16" />
<span class="is-size-7" v-text="action.label" />
</a>
</footer> </footer>
</div> </div>
</div> </div>
@ -18,9 +28,11 @@
<script> <script>
export default { export default {
name: 'ModalDialog', name: 'ModalDialogCombined',
props: { props: {
show: Boolean show: Boolean,
title: { type: String, default: '' },
actions: { type: Array, required: true }
}, },
emits: ['close'], emits: ['close'],
watch: { watch: {

View File

@ -1,44 +0,0 @@
<template>
<modal-dialog :show="show">
<template #content>
<p v-if="title" class="title is-4" v-text="title" />
<slot name="modal-content" />
</template>
<template #footer>
<a
v-for="action in actions"
:key="action.event"
class="card-footer-item"
:class="{ 'is-disabled': action.disabled }"
@click="$emit(action.event)"
>
<mdicon class="icon" :name="action.icon" size="16" />
<span class="is-size-7" v-text="action.label" />
</a>
</template>
</modal-dialog>
</template>
<script>
import ModalDialog from '@/components/ModalDialog.vue'
export default {
name: 'ModalDialogAction',
components: { ModalDialog },
props: {
actions: { type: Array, required: true },
show: Boolean,
title: { default: '', type: String }
},
watch: {
show() {
const { classList } = document.querySelector('html')
if (this.show) {
classList.add('is-clipped')
} else {
classList.remove('is-clipped')
}
}
}
}
</script>

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@cancel="$emit('close')" @cancel="$emit('close')"
@ -26,16 +26,16 @@
<p class="help" v-text="$t('dialog.add.rss.help')" /> <p class="help" v-text="$t('dialog.add.rss.help')" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogAddRss', name: 'ModalDialogAddRss',
components: { ModalDialogAction }, components: { ModalDialog },
props: { show: Boolean }, props: { show: Boolean },
emits: ['close', 'podcast-added'], emits: ['close', 'podcast-added'],
data() { data() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="add" @add="add"
@ -28,16 +28,16 @@
</div> </div>
</form> </form>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogAddUrlStream', name: 'ModalDialogAddUrlStream',
components: { ModalDialogAction }, components: { ModalDialog },
props: { show: Boolean }, props: { show: Boolean },
emits: ['close'], emits: ['close'],
data() { data() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -84,17 +84,17 @@
<div class="title is-6" v-text="$filters.datetime(item.time_added)" /> <div class="title is-6" v-text="$filters.datetime(item.time_added)" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import CoverArtwork from '@/components/CoverArtwork.vue'
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogAlbum', name: 'ModalDialogAlbum',
components: { ModalDialogAction, CoverArtwork }, components: { ModalDialog, CoverArtwork },
props: { props: {
item: { required: true, type: Object }, item: { required: true, type: Object },
media_kind: { default: '', type: String }, media_kind: { default: '', type: String },

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -43,17 +43,17 @@
<div class="title is-6" v-text="item.album_type" /> <div class="title is-6" v-text="item.album_type" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import CoverArtwork from '@/components/CoverArtwork.vue' import CoverArtwork from '@/components/CoverArtwork.vue'
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogAlbumSpotify', name: 'ModalDialogAlbumSpotify',
components: { ModalDialogAction, CoverArtwork }, components: { ModalDialog, CoverArtwork },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
data() { data() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -37,16 +37,16 @@
<div class="title is-6" v-text="$filters.datetime(item.time_added)" /> <div class="title is-6" v-text="$filters.datetime(item.time_added)" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogArtist', name: 'ModalDialogArtist',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -29,16 +29,16 @@
<div class="title is-6" v-text="item.genres.join(', ')" /> <div class="title is-6" v-text="item.genres.join(', ')" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogArtistSpotify', name: 'ModalDialogArtistSpotify',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -40,16 +40,16 @@
/> />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogComposer', name: 'ModalDialogComposer',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
:title="item" :title="item"
@ -11,12 +11,12 @@
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogDirectory', name: 'ModalDialogDirectory',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: String }, show: Boolean }, props: { item: { required: true, type: String }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -36,16 +36,16 @@
/> />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogGenre', name: 'ModalDialogGenre',
components: { ModalDialogAction }, components: { ModalDialog },
props: { props: {
item: { required: true, type: Object }, item: { required: true, type: Object },
media_kind: { required: true, type: String }, media_kind: { required: true, type: String },

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -33,16 +33,16 @@
<div class="title is-6" v-text="item.item_count" /> <div class="title is-6" v-text="item.item_count" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogPlaylist', name: 'ModalDialogPlaylist',
components: { ModalDialogAction }, components: { ModalDialog },
props: { props: {
item: { required: true, type: Object }, item: { required: true, type: Object },
show: Boolean, show: Boolean,

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@cancel="$emit('close')" @cancel="$emit('close')"
@ -27,16 +27,16 @@
</div> </div>
</form> </form>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogPlaylistSave', name: 'ModalDialogPlaylistSave',
components: { ModalDialogAction }, components: { ModalDialog },
props: { show: Boolean }, props: { show: Boolean },
emits: ['close'], emits: ['close'],
data() { data() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -33,16 +33,16 @@
<div class="title is-6" v-text="item.uri" /> <div class="title is-6" v-text="item.uri" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogPlaylistSpotify', name: 'ModalDialogPlaylistSpotify',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@remove="remove" @remove="remove"
@ -120,18 +120,18 @@
</div> </div>
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import SpotifyWebApi from 'spotify-web-api-js' import SpotifyWebApi from 'spotify-web-api-js'
import { useServicesStore } from '@/stores/services' import { useServicesStore } from '@/stores/services'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogQueueItem', name: 'ModalDialogQueueItem',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
setup() { setup() {

View File

@ -1,8 +1,8 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@cancel="cancel" @cancel="$emit('close')"
@close="$emit('close')" @close="$emit('close')"
@pair="pair" @pair="pair"
> >
@ -24,17 +24,17 @@
</div> </div>
</form> </form>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import { useRemotesStore } from '@/stores/remotes' import { useRemotesStore } from '@/stores/remotes'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogRemotePairing', name: 'ModalDialogRemotePairing',
components: { ModalDialogAction }, components: { ModalDialog },
props: { show: Boolean }, props: { show: Boolean },
emits: ['close'], emits: ['close'],
setup() { setup() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -157,18 +157,18 @@
<div class="title is-6" v-text="item.comment" /> <div class="title is-6" v-text="item.comment" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import SpotifyWebApi from 'spotify-web-api-js' import SpotifyWebApi from 'spotify-web-api-js'
import { useServicesStore } from '@/stores/services' import { useServicesStore } from '@/stores/services'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogTrack', name: 'ModalDialogTrack',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close', 'play-count-changed'], emits: ['close', 'play-count-changed'],
setup() { setup() {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
@add="queue_add" @add="queue_add"
@ -66,16 +66,16 @@
<div class="title is-6" v-text="item.uri" /> <div class="title is-6" v-text="item.uri" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogTrackSpotify', name: 'ModalDialogTrackSpotify',
components: { ModalDialogAction }, components: { ModalDialog },
props: { item: { required: true, type: Object }, show: Boolean }, props: { item: { required: true, type: Object }, show: Boolean },
emits: ['close'], emits: ['close'],
computed: { computed: {

View File

@ -1,5 +1,5 @@
<template> <template>
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show" :show="show"
:title="$t('dialog.update.title')" :title="$t('dialog.update.title')"
@ -39,19 +39,19 @@
<p class="mb-3" v-text="$t('dialog.update.progress')" /> <p class="mb-3" v-text="$t('dialog.update.progress')" />
</div> </div>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
<script> <script>
import ControlSwitch from '@/components/ControlSwitch.vue' import ControlSwitch from '@/components/ControlSwitch.vue'
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import { useLibraryStore } from '@/stores/library' import { useLibraryStore } from '@/stores/library'
import { useServicesStore } from '@/stores/services' import { useServicesStore } from '@/stores/services'
import webapi from '@/webapi' import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogUpdate', name: 'ModalDialogUpdate',
components: { ControlSwitch, ModalDialogAction }, components: { ControlSwitch, ModalDialog },
props: { show: Boolean }, props: { show: Boolean },
emits: ['close'], emits: ['close'],

View File

@ -46,7 +46,7 @@
@play-count-changed="reload_tracks" @play-count-changed="reload_tracks"
@remove-podcast="open_remove_podcast_dialog" @remove-podcast="open_remove_podcast_dialog"
/> />
<modal-dialog-action <modal-dialog
:actions="actions" :actions="actions"
:show="show_remove_podcast_modal" :show="show_remove_podcast_modal"
:title="$t('page.podcast.remove-podcast')" :title="$t('page.podcast.remove-podcast')"
@ -63,7 +63,7 @@
</template> </template>
</i18n-t> </i18n-t>
</template> </template>
</modal-dialog-action> </modal-dialog>
</template> </template>
</content-with-hero> </content-with-hero>
</div> </div>
@ -74,7 +74,7 @@ import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue' import CoverArtwork from '@/components/CoverArtwork.vue'
import { GroupedList } from '@/lib/GroupedList' import { GroupedList } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue' import ListTracks from '@/components/ListTracks.vue'
import ModalDialogAction from '@/components/ModalDialogAction.vue' import ModalDialog from '@/components/ModalDialog.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
import webapi from '@/webapi' import webapi from '@/webapi'
@ -98,7 +98,7 @@ export default {
ContentWithHero, ContentWithHero,
CoverArtwork, CoverArtwork,
ListTracks, ListTracks,
ModalDialogAction, ModalDialog,
ModalDialogAlbum ModalDialogAlbum
}, },