diff --git a/assets/components/users/actor-preview.vue b/assets/components/users/actor-preview.vue index 3a8e513d..0236b76e 100644 --- a/assets/components/users/actor-preview.vue +++ b/assets/components/users/actor-preview.vue @@ -24,8 +24,6 @@ + + diff --git a/assets/components/users/user.vue b/assets/components/users/user.vue index 82aa2ab5..640a471e 100644 --- a/assets/components/users/user.vue +++ b/assets/components/users/user.vue @@ -19,70 +19,11 @@ :key="stash.id" class="stash" > -
- -

{{ stash.name }}

-
- - -
- - - - + @@ -90,9 +31,7 @@ @@ -172,69 +99,6 @@ export default { box-shadow: 0 0 3px var(--shadow-weak); } -.stash-section { - display: flex; - align-items: center; - padding: .5rem; - - &:not(:last-child) { - border-bottom: solid 1px var(--shadow-hint); - } -} - -.stash-header { - justify-content: space-between; - padding: 0; -} - -.stash-link { - flex-grow: 1; - display: inline-block; - text-decoration: none; -} - -.stash-public { - display: flex; - align-items: center; - padding: .5rem; - cursor: pointer; - - .icon { - fill: var(--shadow-strong); - margin: 0 .5rem 0 0; - } -} - -.stash-name { - padding: .5rem; - margin: 0; - color: var(--shadow-strong); -} - -.stash-actors, -.stash-scenes { - display: flex; - overflow-x: auto; - grid-gap: .5rem; - scroll-behavior: smooth; - scrollbar-width: none; - - &::-webkit-scrollbar { - display: none; - } -} - -.stash-scenes { - height: 8rem; -} - -.stash-actor, -.stash-scene { - height: 100%; - flex-shrink: 0; - font-size: 0; -} - @media(max-width: $breakpoint-kilo) { .stashes { grid-template-columns: 1fr; diff --git a/assets/js/stashes/actions.js b/assets/js/stashes/actions.js index 2690efc2..8dd578ed 100644 --- a/assets/js/stashes/actions.js +++ b/assets/js/stashes/actions.js @@ -67,6 +67,12 @@ function initStashesActions(store, _router) { return curateStash(stash); } + async function createStash(context, stash) { + const newStash = await post('/stashes', stash); + + return newStash; + } + async function updateStash(context, { stashId, stash }) { const newStash = await patch(`/stashes/${stashId}`, stash); @@ -98,6 +104,7 @@ function initStashesActions(store, _router) { } return { + createStash, fetchStash, stashActor, stashScene, diff --git a/src/stashes.js b/src/stashes.js index a0951f63..0c83b31d 100644 --- a/src/stashes.js +++ b/src/stashes.js @@ -2,6 +2,7 @@ const knex = require('./knex'); const { HttpError } = require('./errors'); +const slugify = require('./utils/slugify'); function curateStash(stash) { if (!stash) { @@ -17,6 +18,17 @@ function curateStash(stash) { return curatedStash; } +function curateStashEntry(stash, user) { + const curatedStashEntry = { + user_id: user.id, + name: stash.name, + slug: slugify(stash.name), + public: false, + }; + + return curatedStashEntry; +} + async function fetchStash(stashId, sessionUser) { if (!sessionUser) { throw new HttpError('You are not authenthicated', 401); @@ -36,6 +48,18 @@ async function fetchStash(stashId, sessionUser) { return curateStash(stash); } +async function createStash(newStash, sessionUser) { + if (!sessionUser) { + throw new HttpError('You are not authenthicated', 401); + } + + const stash = await knex('stashes') + .insert(curateStashEntry(newStash, sessionUser)) + .returning('*'); + + return curateStash(stash); +} + async function updateStash(stashId, newStash, sessionUser) { if (!sessionUser) { throw new HttpError('You are not authenthicated', 401); @@ -123,6 +147,7 @@ async function unstashMovie(movieId, stashId, sessionUser) { } module.exports = { + createStash, curateStash, stashActor, stashScene, diff --git a/src/web/server.js b/src/web/server.js index d8195ce8..b50e19bd 100644 --- a/src/web/server.js +++ b/src/web/server.js @@ -44,6 +44,7 @@ const { } = require('./tags'); const { + createStash, stashActor, stashScene, stashMovie, @@ -84,6 +85,7 @@ async function initServer() { router.post('/api/users', signup); + router.post('/api/stashes', createStash); router.patch('/api/stashes/:stashId', updateStash); router.post('/api/stashes/:stashId/actors', stashActor); diff --git a/src/web/stashes.js b/src/web/stashes.js index b1030b06..70c52db6 100644 --- a/src/web/stashes.js +++ b/src/web/stashes.js @@ -1,6 +1,7 @@ 'use strict'; const { + createStash, stashActor, stashScene, stashMovie, @@ -10,6 +11,12 @@ const { updateStash, } = require('../stashes'); +async function createStashApi(req, res) { + const stash = await createStash(req.body, req.session.user); + + res.send(stash); +} + async function updateStashApi(req, res) { const stash = await updateStash(req.params.stashId, req.body, req.session.user); @@ -53,6 +60,7 @@ async function unstashMovieApi(req, res) { } module.exports = { + createStash: createStashApi, stashActor: stashActorApi, stashScene: stashSceneApi, stashMovie: stashMovieApi,