Upgraded dependencies, bumped to Node 24.
This commit is contained in:
@@ -1,3 +1,30 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import Dialog from '#/components/dialog/dialog.vue';
|
||||
|
||||
import { post } from '#/src/api.js';
|
||||
|
||||
const emit = defineEmits(['created', 'close']);
|
||||
|
||||
const stashName = ref(null);
|
||||
const stashNameInput = ref(null);
|
||||
|
||||
async function createStash() {
|
||||
const newStash = await post('/stashes', {
|
||||
name: stashName.value,
|
||||
public: false,
|
||||
}, {
|
||||
successFeedback: `Stash '${stashName.value}' created`,
|
||||
errorFeedback: `Failed to create stash '${stashName.value}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
emit('created', newStash);
|
||||
stashName.value = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog
|
||||
title="New stash"
|
||||
@@ -23,33 +50,6 @@
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { post } from '#/src/api.js';
|
||||
|
||||
import Dialog from '#/components/dialog/dialog.vue';
|
||||
|
||||
const emit = defineEmits(['created', 'close']);
|
||||
|
||||
const stashName = ref(null);
|
||||
const stashNameInput = ref(null);
|
||||
|
||||
async function createStash() {
|
||||
const newStash = await post('/stashes', {
|
||||
name: stashName.value,
|
||||
public: false,
|
||||
}, {
|
||||
successFeedback: `Stash '${stashName.value}' created`,
|
||||
errorFeedback: `Failed to create stash '${stashName.value}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
emit('created', newStash);
|
||||
stashName.value = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-body {
|
||||
padding: 1rem;
|
||||
|
||||
@@ -1,3 +1,204 @@
|
||||
<script setup>
|
||||
import { computed, inject, ref, useId } from 'vue';
|
||||
|
||||
import AlertDialog from '#/components/alerts/create.vue';
|
||||
import Icon from '#/components/icon/icon.vue';
|
||||
|
||||
import StashDialog from '#/components/stashes/create.vue';
|
||||
import StashMenu from '#/components/stashes/menu.vue';
|
||||
import { del, get, post } from '#/src/api.js';
|
||||
import ellipsis from '#/utils/ellipsis.js';
|
||||
|
||||
const props = defineProps({
|
||||
domain: {
|
||||
type: String,
|
||||
default: 'scenes',
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
showSecondary: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['stashed', 'unstashed']);
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const pageStash = pageContext.pageProps.stash;
|
||||
const user = pageContext.user;
|
||||
|
||||
const stashes = ref(pageContext.assets?.stashes);
|
||||
const primaryStash = pageContext.assets?.primaryStash;
|
||||
const itemStashes = ref(props.item.stashes);
|
||||
const itemAlerts = ref(props.item.alerts);
|
||||
const itemAlerted = ref(props.item.alerts?.only.length > 0);
|
||||
const hasSecondaryStash = computed(() => itemStashes.value.some((itemStash) => !itemStash.isPrimary));
|
||||
|
||||
const done = ref(true);
|
||||
const stashMenuDropdownId = useId();
|
||||
const stashTogglesDropdownId = useId();
|
||||
const showStashes = ref(false);
|
||||
const showStashDialog = ref(false);
|
||||
const showAlertDialog = ref(false);
|
||||
const feedbackCutoff = 20;
|
||||
|
||||
const itemKeys = {
|
||||
scenes: 'sceneId',
|
||||
actors: 'actorId',
|
||||
movies: 'movieId',
|
||||
};
|
||||
|
||||
async function stashItem(stash) {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stashState = itemStashes.value;
|
||||
|
||||
done.value = false;
|
||||
itemStashes.value = itemStashes.value.concat(stash);
|
||||
|
||||
try {
|
||||
await post(`/stashes/${stash.id}/${props.domain}`, { [itemKeys[props.domain]]: props.item.id }, {
|
||||
successFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" stashed to ${stash.name}`,
|
||||
errorFeedback: `Failed to stash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" to ${stash.name}`,
|
||||
});
|
||||
|
||||
emit('stashed', stash);
|
||||
}
|
||||
catch (error) {
|
||||
itemStashes.value = stashState;
|
||||
}
|
||||
finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function unstashItem(stash) {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stashState = itemStashes.value;
|
||||
|
||||
done.value = false;
|
||||
itemStashes.value = itemStashes.value.filter((itemStash) => itemStash.id !== stash.id);
|
||||
|
||||
try {
|
||||
await del(`/stashes/${stash.id}/${props.domain}/${props.item.id}`, {
|
||||
undoFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" unstashed from ${stash.name}`,
|
||||
errorFeedback: `Failed to unstash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" from ${stash.name}`,
|
||||
});
|
||||
|
||||
emit('unstashed', stash);
|
||||
}
|
||||
catch (error) {
|
||||
itemStashes.value = stashState;
|
||||
}
|
||||
finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function alertItem() {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const alertLabel = props.item.title || props.item.name;
|
||||
|
||||
done.value = false;
|
||||
itemAlerted.value = true;
|
||||
|
||||
try {
|
||||
const newAlert = await post('/alerts', {
|
||||
...(props.domain === 'actors' && { actors: [props.item.id] }),
|
||||
...(props.domain === 'tags' && { tags: [props.item.id] }),
|
||||
...(props.domain === 'entities' && { entities: [props.item.id] }),
|
||||
notify: true,
|
||||
email: false,
|
||||
preset: true,
|
||||
}, {
|
||||
successFeedback: `Alert set for '${alertLabel}'`,
|
||||
errorFeedback: `Failed to set alert for '${alertLabel}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(newAlert.id);
|
||||
}
|
||||
catch (error) {
|
||||
itemAlerted.value = false;
|
||||
}
|
||||
finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function removeAlert() {
|
||||
if (done.value === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
const alertLabel = props.item.title || props.item.name;
|
||||
const alertIds = itemAlerts.value.only;
|
||||
|
||||
done.value = false;
|
||||
|
||||
itemAlerted.value = false;
|
||||
itemAlerts.value.only = itemAlerts.value.only.filter((alertId) => !alertIds.includes(alertId));
|
||||
|
||||
try {
|
||||
await del(`/alerts/${alertIds.join(',')}`, {
|
||||
undoFeedback: `Removed alert for '${alertLabel}'`,
|
||||
errorFeedback: `Failed to remove alert for '${alertLabel}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
itemAlerted.value = true;
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(alertIds);
|
||||
}
|
||||
finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function setAlerted(alert) {
|
||||
// only set alerted status if the current item is the only one in the new stash
|
||||
const items = [...alert.actors, ...alert.tags, ...alert.entities, ...alert.matches];
|
||||
|
||||
if (items.length === 1 && alert[props.domain][0]?.id === props.item.id) {
|
||||
itemAlerted.value = true;
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(alert.id);
|
||||
}
|
||||
else {
|
||||
itemAlerts.value.multi = itemAlerts.value.multi.concat(alert.id);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleShowStashes(state) {
|
||||
if (props.showSecondary) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
showStashes.value = state;
|
||||
return;
|
||||
}
|
||||
|
||||
showStashes.value = !showStashes.value;
|
||||
}
|
||||
|
||||
async function reloadStashes(newStash) {
|
||||
stashes.value = await get(`/users/${user.id}/stashes`);
|
||||
|
||||
await stashItem(newStash);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="user"
|
||||
@@ -37,6 +238,7 @@
|
||||
|
||||
<VDropdown
|
||||
v-if="itemStashes && (showSecondary || (hasSecondaryStash && pageStash?.user.id !== user.id))"
|
||||
:aria-id="stashMenuDropdownId"
|
||||
:shown="showStashes"
|
||||
@hide="showStashes = false"
|
||||
>
|
||||
@@ -60,6 +262,7 @@
|
||||
|
||||
<VDropdown
|
||||
v-if="itemStashes && (showSecondary || !hasSecondaryStash || pageStash?.user.id === user.id)"
|
||||
:aria-id="stashTogglesDropdownId"
|
||||
:triggers="[]"
|
||||
:shown="showStashes"
|
||||
:disabled="showSecondary"
|
||||
@@ -70,7 +273,7 @@
|
||||
v-if="itemStashes.some((itemStash) => itemStash.id === pageStash.id)"
|
||||
:icon="pageStash.isPrimary ? 'heart7' : 'folder-heart'"
|
||||
class="heart favorited noselect"
|
||||
@click.native.stop="unstashItem(pageStash)"
|
||||
@click.stop="unstashItem(pageStash)"
|
||||
@contextmenu.prevent="toggleShowStashes(true)"
|
||||
/>
|
||||
|
||||
@@ -78,7 +281,7 @@
|
||||
v-else
|
||||
:icon="pageStash.isPrimary ? 'heart8' : 'folder-heart'"
|
||||
class="heart noselect"
|
||||
@click.native.stop="stashItem(pageStash)"
|
||||
@click.stop="stashItem(pageStash)"
|
||||
@contextmenu.prevent="toggleShowStashes(true)"
|
||||
/>
|
||||
</template>
|
||||
@@ -88,7 +291,7 @@
|
||||
v-if="itemStashes.some((itemStash) => itemStash.id === primaryStash.id)"
|
||||
icon="heart7"
|
||||
class="heart favorited noselect"
|
||||
@click.native.stop="unstashItem(primaryStash)"
|
||||
@click.stop="unstashItem(primaryStash)"
|
||||
@contextmenu.prevent="toggleShowStashes(true)"
|
||||
/>
|
||||
|
||||
@@ -96,7 +299,7 @@
|
||||
v-else
|
||||
icon="heart8"
|
||||
class="heart noselect"
|
||||
@click.native.stop="stashItem(primaryStash)"
|
||||
@click.stop="stashItem(primaryStash)"
|
||||
@contextmenu.prevent="toggleShowStashes(true)"
|
||||
/>
|
||||
</template>
|
||||
@@ -127,196 +330,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject } from 'vue';
|
||||
|
||||
import { get, post, del } from '#/src/api.js';
|
||||
import ellipsis from '#/utils/ellipsis.js';
|
||||
|
||||
import Icon from '#/components/icon/icon.vue';
|
||||
import StashMenu from '#/components/stashes/menu.vue';
|
||||
import StashDialog from '#/components/stashes/create.vue';
|
||||
import AlertDialog from '#/components/alerts/create.vue';
|
||||
|
||||
const props = defineProps({
|
||||
domain: {
|
||||
type: String,
|
||||
default: 'scenes',
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
showSecondary: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['stashed', 'unstashed']);
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const pageStash = pageContext.pageProps.stash;
|
||||
const user = pageContext.user;
|
||||
|
||||
const stashes = ref(pageContext.assets?.stashes);
|
||||
const primaryStash = pageContext.assets?.primaryStash;
|
||||
const itemStashes = ref(props.item.stashes);
|
||||
const itemAlerts = ref(props.item.alerts);
|
||||
const itemAlerted = ref(props.item.alerts?.only.length > 0);
|
||||
const hasSecondaryStash = computed(() => itemStashes.value.some((itemStash) => !itemStash.isPrimary));
|
||||
|
||||
const done = ref(true);
|
||||
const showStashes = ref(false);
|
||||
const showStashDialog = ref(false);
|
||||
const showAlertDialog = ref(false);
|
||||
const feedbackCutoff = 20;
|
||||
|
||||
const itemKeys = {
|
||||
scenes: 'sceneId',
|
||||
actors: 'actorId',
|
||||
movies: 'movieId',
|
||||
};
|
||||
|
||||
async function stashItem(stash) {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stashState = itemStashes.value;
|
||||
|
||||
done.value = false;
|
||||
itemStashes.value = itemStashes.value.concat(stash);
|
||||
|
||||
try {
|
||||
await post(`/stashes/${stash.id}/${props.domain}`, { [itemKeys[props.domain]]: props.item.id }, {
|
||||
successFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" stashed to ${stash.name}`,
|
||||
errorFeedback: `Failed to stash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" to ${stash.name}`,
|
||||
});
|
||||
|
||||
emit('stashed', stash);
|
||||
} catch (error) {
|
||||
itemStashes.value = stashState;
|
||||
} finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function unstashItem(stash) {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stashState = itemStashes.value;
|
||||
|
||||
done.value = false;
|
||||
itemStashes.value = itemStashes.value.filter((itemStash) => itemStash.id !== stash.id);
|
||||
|
||||
try {
|
||||
await del(`/stashes/${stash.id}/${props.domain}/${props.item.id}`, {
|
||||
undoFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" unstashed from ${stash.name}`,
|
||||
errorFeedback: `Failed to unstash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" from ${stash.name}`,
|
||||
});
|
||||
|
||||
emit('unstashed', stash);
|
||||
} catch (error) {
|
||||
itemStashes.value = stashState;
|
||||
} finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function alertItem() {
|
||||
if (!done.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const alertLabel = props.item.title || props.item.name;
|
||||
|
||||
done.value = false;
|
||||
itemAlerted.value = true;
|
||||
|
||||
try {
|
||||
const newAlert = await post('/alerts', {
|
||||
...(props.domain === 'actors' && { actors: [props.item.id] }),
|
||||
...(props.domain === 'tags' && { tags: [props.item.id] }),
|
||||
...(props.domain === 'entities' && { entities: [props.item.id] }),
|
||||
notify: true,
|
||||
email: false,
|
||||
preset: true,
|
||||
}, {
|
||||
successFeedback: `Alert set for '${alertLabel}'`,
|
||||
errorFeedback: `Failed to set alert for '${alertLabel}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(newAlert.id);
|
||||
} catch (error) {
|
||||
itemAlerted.value = false;
|
||||
} finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function removeAlert() {
|
||||
if (done.value === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
const alertLabel = props.item.title || props.item.name;
|
||||
const alertIds = itemAlerts.value.only;
|
||||
|
||||
done.value = false;
|
||||
|
||||
itemAlerted.value = false;
|
||||
itemAlerts.value.only = itemAlerts.value.only.filter((alertId) => !alertIds.includes(alertId));
|
||||
|
||||
try {
|
||||
await del(`/alerts/${alertIds.join(',')}`, {
|
||||
undoFeedback: `Removed alert for '${alertLabel}'`,
|
||||
errorFeedback: `Failed to remove alert for '${alertLabel}'`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
} catch (error) {
|
||||
itemAlerted.value = true;
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(alertIds);
|
||||
} finally {
|
||||
done.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function setAlerted(alert) {
|
||||
// only set alerted status if the current item is the only one in the new stash
|
||||
const items = [...alert.actors, ...alert.tags, ...alert.entities, ...alert.matches];
|
||||
|
||||
if (items.length === 1 && alert[props.domain][0]?.id === props.item.id) {
|
||||
itemAlerted.value = true;
|
||||
itemAlerts.value.only = itemAlerts.value.only.concat(alert.id);
|
||||
} else {
|
||||
itemAlerts.value.multi = itemAlerts.value.multi.concat(alert.id);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleShowStashes(state) {
|
||||
if (props.showSecondary) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
showStashes.value = state;
|
||||
return;
|
||||
}
|
||||
|
||||
showStashes.value = !showStashes.value;
|
||||
}
|
||||
|
||||
async function reloadStashes(newStash) {
|
||||
stashes.value = await get(`/users/${user.id}/stashes`);
|
||||
|
||||
await stashItem(newStash);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bookmarks {
|
||||
display: flex;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
<script setup>
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
|
||||
defineProps({
|
||||
stashes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
itemStashes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['stash', 'unstash', 'create']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="stash-menu nolist noselect">
|
||||
<li
|
||||
@@ -26,23 +43,6 @@
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
|
||||
defineProps({
|
||||
stashes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
itemStashes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['stash', 'unstash', 'create']);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.menu-item {
|
||||
display: flex;
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
import Domains from '#/components/domains/domains.vue';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const { routeParams } = pageContext;
|
||||
|
||||
const domain = routeParams.domain;
|
||||
const stash = pageContext.pageProps.stash;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="stash">
|
||||
<div class="header">
|
||||
@@ -44,18 +56,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
import Domains from '#/components/domains/domains.vue';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const { routeParams } = pageContext;
|
||||
|
||||
const domain = routeParams.domain;
|
||||
const stash = pageContext.pageProps.stash;
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.stash {
|
||||
display: flex;
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
<script setup>
|
||||
import { inject, ref } from 'vue';
|
||||
|
||||
import StashDialog from '#/components/stashes/create.vue';
|
||||
import StashTile from '#/components/stashes/tile.vue';
|
||||
|
||||
import { get } from '#/src/api.js';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
const user = pageContext.user;
|
||||
const stashes = ref(pageContext.pageProps.stashes);
|
||||
const profile = ref(pageContext.pageProps.profile);
|
||||
|
||||
const showStashDialog = ref(false);
|
||||
|
||||
async function reloadStashes() {
|
||||
// profile.value = await get(`/users/${profile.value.id}`);
|
||||
stashes.value = await get(`/users/${profile.value.id}/stashes`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="profile-section">
|
||||
<div class="section-header">
|
||||
@@ -34,28 +56,6 @@
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, inject } from 'vue';
|
||||
|
||||
import StashTile from '#/components/stashes/tile.vue';
|
||||
import StashDialog from '#/components/stashes/create.vue';
|
||||
|
||||
import { get } from '#/src/api.js';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
const user = pageContext.user;
|
||||
const stashes = ref(pageContext.pageProps.stashes);
|
||||
const profile = ref(pageContext.pageProps.profile);
|
||||
|
||||
const showStashDialog = ref(false);
|
||||
|
||||
async function reloadStashes() {
|
||||
// profile.value = await get(`/users/${profile.value.id}`);
|
||||
stashes.value = await get(`/users/${profile.value.id}/stashes`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.stashes {
|
||||
display: grid;
|
||||
|
||||
@@ -1,3 +1,98 @@
|
||||
<script setup>
|
||||
import { inject, ref, useId } from 'vue';
|
||||
|
||||
import Dialog from '#/components/dialog/dialog.vue';
|
||||
import { del, patch } from '#/src/api.js';
|
||||
|
||||
import abbreviateNumber from '#/src/utils/abbreviate-number.js';
|
||||
|
||||
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);
|
||||
const privateTooltipId = useId();
|
||||
const menuDropdownId = useId();
|
||||
|
||||
const domainCounts = {
|
||||
scenes: props.stash.stashedScenes,
|
||||
actors: props.stash.stashedActors,
|
||||
movies: props.stash.stashedMovies,
|
||||
};
|
||||
|
||||
const primaryDomain = Object.entries(domainCounts).toSorted((domainA, domainB) => domainB[1] - domainA[1])[0][0];
|
||||
|
||||
async function setPublic(isPublic) {
|
||||
if (done.value === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
done.value = false;
|
||||
|
||||
await patch(`/stashes/${props.stash.id}`, { isPublic }, {
|
||||
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-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>
|
||||
|
||||
<template>
|
||||
<div class="stash">
|
||||
<div class="stash-header">
|
||||
@@ -16,12 +111,12 @@
|
||||
|
||||
<Icon
|
||||
v-if="!stash.isPublic"
|
||||
v-tooltip="'This stash is private'"
|
||||
v-tooltip="{ content: 'This stash is private', ariaId: privateTooltipId }"
|
||||
icon="eye-blocked"
|
||||
class="private noselect"
|
||||
/>
|
||||
|
||||
<VDropdown>
|
||||
<VDropdown :aria-id="menuDropdownId">
|
||||
<Icon
|
||||
v-if="profile.id === user?.id"
|
||||
icon="more2"
|
||||
@@ -122,99 +217,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, inject } from 'vue';
|
||||
|
||||
import { del, patch } from '#/src/api.js';
|
||||
import abbreviateNumber from '#/src/utils/abbreviate-number.js';
|
||||
|
||||
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);
|
||||
|
||||
const domainCounts = {
|
||||
scenes: props.stash.stashedScenes,
|
||||
actors: props.stash.stashedActors,
|
||||
movies: props.stash.stashedMovies,
|
||||
};
|
||||
|
||||
const primaryDomain = Object.entries(domainCounts).toSorted((domainA, domainB) => domainB[1] - domainA[1])[0][0];
|
||||
|
||||
async function setPublic(isPublic) {
|
||||
if (done.value === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
done.value = false;
|
||||
|
||||
await patch(`/stashes/${props.stash.id}`, { isPublic }, {
|
||||
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%;
|
||||
|
||||
Reference in New Issue
Block a user