2024-03-26 23:06:03 +00:00
< template >
< div class = "stash" >
< div class = "stash-header" >
< a
: href = "`/stash/${profile.username}/${stash.slug}`"
class = "stash-name ellipsis nolink"
>
< span class = "ellipsis" > { { stash . name } } < / span >
< Icon
v - if = "stash.isPrimary"
icon = "heart7"
class = "primary"
/ >
< / a >
< Icon
2024-08-26 04:15:22 +00:00
v - if = "!stash.isPublic"
2024-03-26 23:06:03 +00:00
v - tooltip = "'This stash is private'"
icon = "eye-blocked"
class = "private noselect"
/ >
< VDropdown >
< Icon
v - if = "profile.id === user?.id"
icon = "more2"
class = "stash-more noselect"
/ >
< template # popper >
< ul class = "stash-menu nolist" >
< li
2024-08-26 04:15:22 +00:00
v - if = "stash.isPublic"
2024-03-26 23:06:03 +00:00
class = "menu-item"
@ click = "setPublic(false)"
>
< Icon
icon = "eye-blocked"
class = "noselect"
/ > S e t p r i v a t e
< / li >
< li
v - else
class = "menu-item"
@ click = "setPublic(true)"
>
< Icon
icon = "eye"
class = "noselect"
/ > S e t p u b l i c
< / li >
< li
v - if = "!stash.isPrimary"
v - close - popper
class = "menu-item"
@ click = "showRenameDialog = true"
>
< Icon
icon = "pencil5"
class = "noselect"
/ > R e n a m e
< / li >
< li
v - if = "!stash.isPrimary"
class = "menu-item remove"
@ click = "remove()"
>
< Icon
icon = "bin"
class = "noselect"
/ > R e m o v e
< / li >
< / ul >
< / template >
< / VDropdown >
< / div >
< div class = "stash-counts" >
< a
: href = "`/stash/${profile.username}/${stash.slug}/scenes`"
class = "stash-count nolink"
> < Icon icon = "clapboard-play" / > { { abbreviateNumber ( stash . stashedScenes ) } } < / a >
< a
: href = "`/stash/${profile.username}/${stash.slug}/actors`"
class = "stash-count nolink"
> < Icon icon = "star" / > { { abbreviateNumber ( stash . stashedActors ) } } < / a >
< a
: href = "`/stash/${profile.username}/${stash.slug}/movies`"
class = "stash-count nolink"
> < Icon icon = "movie" / > { { abbreviateNumber ( stash . stashedMovies ) } } < / a >
< / div >
< Dialog
v - if = "showRenameDialog"
title = "Rename stash"
@ close = "showRenameDialog = false"
@ open = "stashNameInput?.focus()"
>
< form
class = "dialog-body"
@ submit . prevent = "rename"
>
< input
ref = "stashNameInput"
v - model = "stashName"
class = "input"
placeholder = "Stash name"
maxlength = "24"
>
< button
class = "button button-submit"
> Rename stash < / button >
< / form >
< / Dialog >
< / div >
< / template >
< script setup >
import { ref , inject } from 'vue' ;
import { del , patch } from '#/src/api.js' ;
2024-03-28 00:28:41 +00:00
import abbreviateNumber from '#/src/utils/abbreviate-number.js' ;
2024-03-26 23:06:03 +00:00
import Dialog from '#/components/dialog/dialog.vue' ;
const props = defineProps ( {
stash : {
type : Object ,
default : null ,
} ,
profile : {
type : Object ,
default : null ,
} ,
} ) ;
const emit = defineEmits ( [ 'reload' ] ) ;
const pageContext = inject ( 'pageContext' ) ;
const user = pageContext . user ;
const stashName = ref ( props . stash . name ) ;
const stashNameInput = ref ( null ) ;
const showRenameDialog = ref ( false ) ;
const done = ref ( true ) ;
async function setPublic ( isPublic ) {
if ( done . value === false ) {
return ;
}
done . value = false ;
2024-08-26 04:15:22 +00:00
await patch ( ` /stashes/ ${ props . stash . id } ` , { isPublic } , {
2024-03-26 23:06:03 +00:00
undoFeedback : ! isPublic && ` Stash ' ${ props . stash . name } ' set to private ` ,
successFeedback : isPublic && ` Stash ' ${ props . stash . name } ' set to public ` ,
errorFeedback : 'Failed to update stash' ,
appendErrorMessage : true ,
} ) . finally ( ( ) => { done . value = true ; } ) ;
emit ( 'reload' ) ;
}
async function remove ( ) {
if ( done . value === false ) {
return ;
}
if ( ! confirm ( ` Are you sure you want to remove the stash ' ${ props . stash . name } ' and all its scenes, movies and actors? This is permament, it cannot be undone by you or staff! ` ) ) { // eslint-disable-line no-restricted-globals, no-alert
return ;
}
done . value = false ;
await del ( ` /stashes/ ${ props . stash . id } ` , {
undoFeedback : ` Stash ' ${ props . stash . name } ' removed ` ,
errorFeedback : 'Failed to remove stash' ,
appendErrorMessage : true ,
} ) . finally ( ( ) => { done . value = true ; } ) ;
emit ( 'reload' ) ;
}
async function rename ( ) {
if ( done . value === false ) {
return ;
}
done . value = false ;
await patch ( ` /stashes/ ${ props . stash . id } ` , { name : stashName . value } , {
successFeedback : ` Stash renamed to ${ stashName . value } ` ,
errorFeedback : 'Failed to rename stash' ,
appendErrorMessage : true ,
} ) . finally ( ( ) => { done . value = true ; } ) ;
emit ( 'reload' ) ;
showRenameDialog . value = false ;
}
< / script >
< style scoped >
. stash {
width : 100 % ;
border - radius : .25 rem ;
2024-06-10 01:24:48 +00:00
background : var ( -- background - base ) ;
2024-03-26 23:06:03 +00:00
box - shadow : 0 0 3 px var ( -- shadow - weak - 30 ) ;
& : hover {
box - shadow : 0 0 3 px var ( -- shadow - weak - 20 ) ;
}
}
. stash - header {
display : flex ;
align - items : stretch ;
2024-06-10 01:24:48 +00:00
border - bottom : solid 1 px var ( -- glass - weak - 30 ) ;
2024-03-26 23:06:03 +00:00
font - weight : bold ;
}
. stash - more {
display : flex ;
height : 100 % ;
padding : 0 .75 rem ;
2024-06-10 01:24:48 +00:00
fill : var ( -- glass ) ;
2024-03-26 23:06:03 +00:00
& : hover {
cursor : pointer ;
2024-06-10 01:24:48 +00:00
fill : var ( -- glass - strong - 30 ) ;
2024-03-26 23:06:03 +00:00
}
}
. stash - name {
display : flex ;
flex - grow : 1 ;
padding : .5 rem ;
overflow : hidden ;
. icon {
margin - left : .75 rem ;
}
. icon . primary {
fill : var ( -- primary ) ;
transform : translateY ( 1 px ) ;
}
}
. stash - counts {
display : flex ;
justify - content : space - between ;
}
. stash - count {
display : inline - flex ;
align - items : center ;
padding : .5 rem ;
flex - grow : 1 ;
font - size : .9 rem ;
. icon {
margin - right : .5 rem ;
2024-06-10 01:24:48 +00:00
fill : var ( -- glass ) ;
2024-03-26 23:06:03 +00:00
}
& : hover {
color : var ( -- primary ) ;
. icon {
fill : var ( -- primary ) ;
}
}
}
. icon . private {
display : flex ;
height : auto ;
2024-06-10 01:24:48 +00:00
fill : var ( -- glass - weak - 20 ) ;
2024-03-26 23:06:03 +00:00
padding - left : .5 rem ;
}
. menu - item {
display : flex ;
align - items : center ;
padding : .75 rem ;
. icon {
display : flex ;
margin - right : .75 rem ;
2024-06-10 01:24:48 +00:00
fill : var ( -- glass ) ;
2024-03-26 23:06:03 +00:00
}
& . remove {
. icon {
fill : var ( -- error ) ;
}
}
& : hover {
color : var ( -- primary ) ;
cursor : pointer ;
& . remove {
color : var ( -- error ) ;
}
. icon {
fill : var ( -- primary ) ;
}
}
}
. dialog - body {
padding : 1 rem ;
. input {
margin - bottom : .5 rem ;
}
}
< / style >