traxxx/assets/components/stashes/stash.vue

236 lines
4.0 KiB
Vue
Raw Normal View History

<template>
<div
v-if="stash"
class="stash content"
>
<div class="stash-header">
<h2
:title="stash.name"
class="stash-name"
>{{ stash.name }}</h2>
<span class="header-section">
2021-03-20 22:03:13 +00:00
<router-link
v-if="stash.user"
:to="{ name: 'user', params: { username: stash.user.username } }"
class="header-item stash-username nolink"
><Icon icon="user3" /><span class="username-name">{{ stash.user.username }}</span></router-link>
2021-03-20 22:03:13 +00:00
<label
v-if="isMine"
v-tooltip="'Public'"
:class="{ public: stash.public }"
class="header-item stash-public"
>
<Icon
v-show="stash.public"
icon="eye"
/>
<Icon
v-show="!stash.public"
icon="eye-blocked"
/>
<Toggle
:checked="stash.public"
class="light"
@change="checked => publishStash(checked)"
/>
</label>
2021-03-20 22:03:13 +00:00
<Icon
v-if="isMine && !stash.primary"
2021-03-20 22:03:13 +00:00
icon="bin"
class="stash-remove"
@click.native="showRemoveStash = true"
/>
<RemoveStash
v-if="showRemoveStash"
:stash="stash"
@close="removeStash"
/>
</span>
</div>
<div class="content-inner">
<Releases
v-if="stash.scenes?.length > 0"
:releases="stash.scenes.map(item => item.scene)"
class="stash-section stash-scenes"
@stash="fetchStash"
/>
<ul
v-if="stash.actors?.length > 0"
class="stash-section stash-actors nolist"
>
<li
v-for="item in stash.actors"
:key="item.id"
><Actor :actor="item.actor" /></li>
</ul>
</div>
</div>
</template>
<script>
import Actor from '../actors/tile.vue';
import Releases from '../releases/releases.vue';
2021-04-04 22:48:03 +00:00
import RemoveStash from './remove.vue';
import Toggle from '../form/toggle.vue';
async function fetchStash() {
this.stash = await this.$store.dispatch('fetchStash', this.$route.params.stashId);
this.isMine = this.stash.user?.id === this.$store.state.auth.user?.id;
}
async function publishStash(isPublic) {
await this.$store.dispatch('updateStash', {
stashId: this.stash.id,
stash: { public: isPublic },
});
this.fetchStash();
}
2021-03-20 22:03:13 +00:00
async function removeStash(removed) {
this.showRemoveStash = false;
if (removed && this.stash.user) {
this.$router.replace({ name: 'user', params: { username: this.stash.user.username } });
return;
}
if (removed) {
this.$router.replace({ name: 'home' });
}
}
async function mounted() {
this.fetchStash();
}
export default {
components: {
Actor,
Releases,
2021-03-20 22:03:13 +00:00
RemoveStash,
Toggle,
},
data() {
return {
stash: null,
2021-03-20 22:03:13 +00:00
showRemoveStash: false,
isMine: false,
};
},
mounted,
methods: {
fetchStash,
publishStash,
2021-03-20 22:03:13 +00:00
removeStash,
},
};
</script>
<style lang="scss" scoped>
@import 'breakpoints';
.stash-header {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--profile);
color: var(--text-light);
.icon {
fill: var(--text-light);
margin: -.1rem .5rem 0 0;
}
}
.header-section,
.header-item {
height: 100%;
display: flex;
align-items: center;
}
.stash-name,
.stash-username {
box-sizing: border-box;
padding: .5rem 1rem;
font-weight: bold;
}
.stash-username {
display: inline-flex;
align-items: center;
margin: 0 .5rem 0 0;
}
.stash-name {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
}
.stash-public {
cursor: pointer;
margin: 0 .5rem 0 0;
.icon {
margin: 0 .75rem 0 0;
cursor: pointer;
}
}
2021-03-20 22:03:13 +00:00
.stash-remove.icon {
height: 100%;
padding: 0 1rem;
fill: var(--lighten-strong);
&:hover {
fill: var(--text-light);
cursor: pointer;
}
}
.stash-section:not(:last-child) {
border-bottom: solid 1px var(--shadow-hint);
}
.stash-actors {
display: grid;
grid-gap: .5rem;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
flex-grow: 1;
padding: 1rem;
}
.stash-scenes {
flex-grow: 0;
.tiles {
grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
}
}
@media(max-width: $breakpoint-small) {
.stash-name {
font-size: 1.25rem;
}
.username-name {
display: none;
}
.stash-username {
margin: 0;
}
}
</style>