From 037e0f2174852b495e7944665eaba10577bf496e Mon Sep 17 00:00:00 2001 From: Maarten beute <150816290+ToMaarton@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:34:34 +0200 Subject: [PATCH] album tag counter (#887) * added total tag counters to album cover cards * added number of tagged photos out of total * added photo tag counter in album view * fixed lint * lint fix 2 * added unit test for feature * fixed lint for unit test * fixed lint for unit test again --- app/components/cards/photo-album-card.hbs | 7 ++++ app/models/photo-album.js | 12 +++++++ .../components/cards/photo-album-card.scss | 8 +++++ .../photo-albums/photo-album/photos/index.hbs | 12 +++++-- tests/unit/models/photo-album-test.js | 32 +++++++++++++++++++ yarn.lock | 22 +++---------- 6 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 tests/unit/models/photo-album-test.js diff --git a/app/components/cards/photo-album-card.hbs b/app/components/cards/photo-album-card.hbs index d205ca647..5d54d979c 100644 --- a/app/components/cards/photo-album-card.hbs +++ b/app/components/cards/photo-album-card.hbs @@ -5,11 +5,18 @@ src='{{album.albumMediumUrl}}' class='card-img-rounded' /> +
\ No newline at end of file diff --git a/app/models/photo-album.js b/app/models/photo-album.js index d1f4f98c2..f063eb8fb 100644 --- a/app/models/photo-album.js +++ b/app/models/photo-album.js @@ -35,6 +35,18 @@ export default class PhotoAlbum extends Model { return this.photos?.sortBy('exifDateTimeOriginal', 'createdAt'); } + get amountOfTaggedPhotos() { + var counter = 0; + this.photos.content.forEach((photo) => { + counter += photo.amountOfTags > 0 ? 1 : 0; + }); + return counter; + } + + get amountOfPhotos() { + return this.photos.length; + } + // Methods isOwner(user) { if (user.get('id') === this.author.get('id')) { diff --git a/app/styles/components/cards/photo-album-card.scss b/app/styles/components/cards/photo-album-card.scss index 6fa9418a4..8ec6541d8 100644 --- a/app/styles/components/cards/photo-album-card.scss +++ b/app/styles/components/cards/photo-album-card.scss @@ -19,4 +19,12 @@ .card-title { font-size: 1.5rem; } + + .album-tag-counter { + position: absolute; + bottom: 0; + margin-right: 15px; + margin-bottom: 1rem; + padding-left: 5px; + } } diff --git a/app/templates/photo-albums/photo-album/photos/index.hbs b/app/templates/photo-albums/photo-album/photos/index.hbs index 77d05cdae..bbab2ce02 100644 --- a/app/templates/photo-albums/photo-album/photos/index.hbs +++ b/app/templates/photo-albums/photo-album/photos/index.hbs @@ -21,10 +21,16 @@ @route='photo-albums.photo-album.photos.photo' @model={{photo.id}} > - {{#if photo.amountOfComments}} + {{#if (or photo.amountOfComments photo.amountOfTags)}} -