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"
:class="{ center: release.photos.length < 2, preview: !me }"
:class="{ center: release.photos.length + release.scenesPhotos.length < 2, preview: !me }"
>
<div
v-if="release.trailer || release.teaser"
@ -72,23 +72,27 @@
</div>
<template v-if="release.covers && release.covers.length > 0">
<a
<div
v-for="cover in release.covers"
:key="`cover-${cover.id}`"
:href="getPath(cover)"
target="_blank"
rel="noopener noreferrer"
class="item-container"
>
<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
:href="getPath(cover)"
target="_blank"
rel="noopener noreferrer"
>
</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>
<div

View File

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

View File

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

View File

@ -3,6 +3,7 @@ const config = require('config');
exports.up = async (knex) => Promise.resolve()
.then(() => knex.raw(`
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) => {
table.integer('movie_id', 16)
@ -18,6 +19,20 @@ exports.up = async (knex) => Promise.resolve()
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(`
GRANT ALL ON ALL TABLES 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(`
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 series_scenes_photos(serie series) RENAME TO series_photos;
`);