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' /> +

{{album.title}}

{{moment-format album.date 'DD-MM-YYYY'}}

+ {{#if album.amountOfTaggedPhotos}} + + + {{album.amountOfTaggedPhotos}}/{{album.amountOfPhotos}} + + {{/if}}
\ 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)}} - - {{photo.amountOfComments}} + {{#if photo.amountOfComments}} + + {{photo.amountOfComments}} + {{/if}} + {{#if photo.amountOfTags}} + + {{photo.amountOfTags}} + {{/if}} {{/if}} diff --git a/tests/unit/models/photo-album-test.js b/tests/unit/models/photo-album-test.js new file mode 100644 index 000000000..7cbef4cec --- /dev/null +++ b/tests/unit/models/photo-album-test.js @@ -0,0 +1,32 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +let album; +let photos = []; + +module('Unit | Model | photo-album', function (hooks) { + setupTest(hooks); + + hooks.beforeEach(function () { + const store = this.owner.lookup('service:store'); + photos = [ + store.createRecord('Photo'), + store.createRecord('Photo'), + store.createRecord('Photo'), + ]; + album = store.createRecord('PhotoAlbum', { photos }); + }); + + test('Photo count', function (assert) { + assert.expect(2); + photos[0].amountOfTags = 0; + photos[1].amountOfTags = 1; + photos[2].amountOfTags = 5; + assert.equal(album.amountOfPhotos, 3, 'Amount of photos is correct'); + assert.equal( + album.amountOfTaggedPhotos, + 2, + 'Amount of tagged photos in album is correct' + ); + }); +}); diff --git a/yarn.lock b/yarn.lock index 1f111a5f8..c3e9592c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8827,24 +8827,10 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30000844, caniuse-lite@npm:^1.0.30001313": - version: 1.0.30001458 - resolution: "caniuse-lite@npm:1.0.30001458" - checksum: 258cc5a25babbbfe483bf788c6f321a19400ff80b2bf156b360bac09a6f9f4da44516350d187a30395667cb142c682d9ea96577ea0df236d35f76234b07ccb41 - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001449": - version: 1.0.30001485 - resolution: "caniuse-lite@npm:1.0.30001485" - checksum: 2db8a9e5facf8df5275c96e44714a6caf3b9485813be1fe0aa5a72a7ced974137adeeed806a9a97f713d2f6d1b5c342949b88355ee0323ba35656bfa00d57fea - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001541": - version: 1.0.30001547 - resolution: "caniuse-lite@npm:1.0.30001547" - checksum: ec0fc2b46721887f6f4aca1f3902f03d9a1a07416d16a86b7cd4bfba60e7b6b03ab3969659d3ea0158cc2f298972c80215c06c9457eb15c649d7780e8f5e91a7 +"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30000844, caniuse-lite@npm:^1.0.30001313, caniuse-lite@npm:^1.0.30001449, caniuse-lite@npm:^1.0.30001541": + version: 1.0.30001668 + resolution: "caniuse-lite@npm:1.0.30001668" + checksum: ce6996901b5883454a8ddb3040f82342277b6a6275876dfefcdecb11f7e472e29877f34cae47c2b674f08f2e71971dd4a2acb9bc01adfe8421b7148a7e9e8297 languageName: node linkType: hard