owntone-server/web-src/src/components/ListDirectories.vue

98 lines
2.4 KiB
Vue
Raw Normal View History

<template>
<div
v-if="$route.query.directory"
class="media is-align-items-center"
2024-03-26 03:13:17 +01:00
@click="open_parent()"
>
<figure class="media-left is-clickable">
<mdicon class="icon" name="subdirectory-arrow-left" size="16" />
</figure>
<div class="media-content is-clickable is-clipped">
<h1 class="title is-6">..</h1>
</div>
<div class="media-right">
<slot name="actions" />
</div>
</div>
2024-03-26 03:13:17 +01:00
<template v-for="item in items" :key="item.path">
<div class="media is-align-items-center" @click="open(item)">
<figure class="media-left is-clickable">
<mdicon class="icon" name="folder" size="16" />
</figure>
<div class="media-content is-clickable is-clipped">
<h1
class="title is-6"
2024-03-26 03:13:17 +01:00
v-text="item.path.substring(item.path.lastIndexOf('/') + 1)"
/>
2024-03-26 03:13:17 +01:00
<h2 class="subtitle is-7 has-text-grey" v-text="item.path" />
</div>
<div class="media-right">
2024-03-26 03:13:17 +01:00
<a @click.prevent.stop="open_dialog(item)">
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
</a>
</div>
</div>
</template>
<teleport to="#app">
<modal-dialog-directory
2024-03-26 03:13:17 +01:00
:item="selected_item"
:show="show_details_modal"
@close="show_details_modal = false"
/>
</teleport>
</template>
<script>
import ModalDialogDirectory from '@/components/ModalDialogDirectory.vue'
export default {
name: 'ListDirectories',
components: { ModalDialogDirectory },
2024-03-26 03:13:17 +01:00
props: { items: { required: true, type: Array } },
data() {
return {
2024-03-26 03:13:17 +01:00
selected_item: '',
2024-03-24 11:01:06 +01:00
show_details_modal: false
}
},
computed: {
2024-03-26 03:13:17 +01:00
current() {
2024-04-03 16:39:48 +02:00
return this.$route.query?.directory || '/'
}
},
methods: {
2024-03-26 03:13:17 +01:00
open(item) {
2024-03-24 11:01:06 +01:00
this.$router.push({
name: 'files',
2024-03-26 03:13:17 +01:00
query: { directory: item.path }
2024-03-24 11:01:06 +01:00
})
},
2024-03-26 03:13:17 +01:00
open_dialog(item) {
this.selected_item = item.path
this.show_details_modal = true
},
open_parent() {
const parent = this.current.slice(0, this.current.lastIndexOf('/'))
if (
parent === '' ||
2024-03-26 03:13:17 +01:00
this.$store.state.config.directories.includes(this.current)
) {
this.$router.push({ name: 'files' })
} else {
this.$router.push({
name: 'files',
query: {
2024-03-26 03:13:17 +01:00
directory: this.current.slice(0, this.current.lastIndexOf('/'))
}
})
}
}
}
}
</script>
<style></style>