Added dedicated serie photos table, renamed serie scene photo function. Fixed covers and scene photos in banner and album.

This commit is contained in:
DebaucheryLibrarian 2022-03-28 00:22:57 +02:00
parent 1c3ee75d3b
commit 9e2eaef9d1
4 changed files with 39 additions and 17 deletions

View File

@ -2,7 +2,7 @@
<div class="media-container"> <div class="media-container">
<div <div
class="media" class="media"
:class="{ center: release.photos.length < 2, preview: !me }" :class="{ center: release.photos.length + release.scenesPhotos.length < 2, preview: !me }"
> >
<div <div
v-if="release.trailer || release.teaser" v-if="release.trailer || release.teaser"
@ -72,23 +72,27 @@
</div> </div>
<template v-if="release.covers && release.covers.length > 0"> <template v-if="release.covers && release.covers.length > 0">
<a <div
v-for="cover in release.covers" v-for="cover in release.covers"
:key="`cover-${cover.id}`" :key="`cover-${cover.id}`"
:href="getPath(cover)" class="item-container"
target="_blank"
rel="noopener noreferrer"
> >
<img <a
:src="getPath(cover, 'thumbnail')" :href="getPath(cover)"
:style="{ 'background-image': getBgPath(cover, 'lazy') }" target="_blank"
:width="cover.thumbnailWidth" rel="noopener noreferrer"
:height="cover.thumbnailHeight"
class="item cover"
loading="lazy"
@load="$emit('load', $event)"
> >
</a> <img
:src="getPath(cover, 'thumbnail')"
:style="{ 'background-image': getBgPath(cover, 'lazy') }"
:width="cover.thumbnailWidth"
:height="cover.thumbnailHeight"
class="item cover"
loading="lazy"
@load="$emit('load', $event)"
>
</a>
</div>
</template> </template>
<div <div

View File

@ -21,7 +21,7 @@
<Details :release="release" /> <Details :release="release" />
<button <button
v-if="release.photos.length > 0" v-if="release.photos?.length > 0 || release.scenesPhotos?.length > 0"
class="album-toggle" class="album-toggle"
@click="$router.push({ hash: '#album' })" @click="$router.push({ hash: '#album' })"
><Icon icon="grid3" />View album</button> ><Icon icon="grid3" />View album</button>
@ -287,7 +287,7 @@ function pageTitle() {
} }
function showAlbum() { function showAlbum() {
return this.release.photos?.length > 0 && this.$route.hash === '#album'; return (this.release.photos?.length > 0 || this.release.scenesPhotos?.length > 0) && this.$route.hash === '#album';
} }
export default { export default {

View File

@ -227,7 +227,7 @@ function initReleasesActions(store, router) {
slug slug
name name
} }
photos: moviesPhotos { photos: ${type === 'series' ? 'seriesPhotosBySerieId' : 'moviesPhotos'} {
${mediaFragment} ${mediaFragment}
} }
scenesPhotos { scenesPhotos {

View File

@ -3,6 +3,7 @@ const config = require('config');
exports.up = async (knex) => Promise.resolve() exports.up = async (knex) => Promise.resolve()
.then(() => knex.raw(` .then(() => knex.raw(`
ALTER FUNCTION movies_photos(movie movies) RENAME TO movies_scenes_photos; ALTER FUNCTION movies_photos(movie movies) RENAME TO movies_scenes_photos;
ALTER FUNCTION series_photos(serie series) RENAME TO series_scenes_photos;
`)) `))
.then(() => knex.schema.createTable('movies_photos', (table) => { .then(() => knex.schema.createTable('movies_photos', (table) => {
table.integer('movie_id', 16) table.integer('movie_id', 16)
@ -18,6 +19,20 @@ exports.up = async (knex) => Promise.resolve()
table.unique(['movie_id', 'media_id']); table.unique(['movie_id', 'media_id']);
})) }))
.then(() => knex.schema.createTable('series_photos', (table) => {
table.integer('serie_id', 16)
.notNullable()
.references('id')
.inTable('series')
.onDelete('cascade');
table.text('media_id', 21)
.notNullable()
.references('id')
.inTable('media');
table.unique(['serie_id', 'media_id']);
}))
.then(() => knex.raw(` .then(() => knex.raw(`
GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor; GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :visitor; GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :visitor;
@ -27,5 +42,8 @@ exports.up = async (knex) => Promise.resolve()
exports.down = async (knex) => knex.raw(` exports.down = async (knex) => knex.raw(`
DROP TABLE IF EXISTS movies_photos CASCADE; DROP TABLE IF EXISTS movies_photos CASCADE;
DROP TABLE IF EXISTS series_photos CASCADE;
ALTER FUNCTION movies_scenes_photos(movie movies) RENAME TO movies_photos; ALTER FUNCTION movies_scenes_photos(movie movies) RENAME TO movies_photos;
ALTER FUNCTION series_scenes_photos(serie series) RENAME TO series_photos;
`); `);