diff --git a/CHANGELOG.md b/CHANGELOG.md index 26164cc720199f2c1004835e173373ae011b9b73..40fad222e896553dfc221e82404bc5c5ea059415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.16.1](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/compare/v1.16.0...v1.16.1) (2022-03-29) + + +### Features + +* **cicd:** temp remove of mr jobs ([5c9a74a](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/5c9a74ad2916b986a7626ffb8726db3260d8990a)) +* **posts:** add button to show more ([0211de8](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/0211de8fe54ad9c1b494b824ba59183041b9f91f)) +* **posts:** restore window scroll service ([3a4b521](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/3a4b521cf5106f8175897d2c09a8963d56d279dc)) + + +### Bug Fixes + +* default limit ([2a9a707](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/2a9a707fc98046d2313b64890485ecaef22439ee)) +* no display if empty post ([44f089f](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/44f089f9819b8d6dedafa39cd470adf38409a67b)) +* **posts:** load more posts with tag (cf. MR !225 ) ([2721c9e](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/2721c9e9f86610e43455a1e6ba9d12415c91f29e)) +* **posts:** remove scroll service from app component ([6a7d319](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/6a7d319061ee4c4ea6e6d4b32a32b86039844e14)) + ## [1.16.0](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/compare/v1.15.0...v1.16.0) (2022-03-18) diff --git a/package-lock.json b/package-lock.json index ab163b0bd00becd14f02b8621a4ab16128d53093..ba7b9b57360e243006531f6d1df57490ad24fd22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pamn", - "version": "1.16.0", + "version": "1.16.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 73da33c2450a09efa9d5ab39db06a9abadd19481..ff023eec40e9d54a7c7e637263528126dc0b0831 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pamn", - "version": "1.16.0", + "version": "1.16.1", "scripts": { "ng": "ng", "start": "ng serve --configuration=fr --proxy-config proxy.conf.json", diff --git a/src/app/app.component.html b/src/app/app.component.html index aa331e09ed89df3e4e5049eaa2a392e6d8d06e35..5ed476324c6bde79bdb697cd0cbdc3559c9416b3 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,6 +1,6 @@ <div class="app-container"> <app-header></app-header> - <div (scroll)="onScrollDown($event)" class="app-body"> + <div class="app-body"> <router-outlet></router-outlet> <router-outlet name="print"></router-outlet> <app-footer></app-footer> diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 86273beab844acdfb875abef1bb5d8f8e198f206..18b020c871714621fe5a113e798f8d958c594bd1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,7 +5,6 @@ import { AuthService } from './services/auth.service'; import { RouterListenerService } from './services/routerListener.service'; import { UpdateService } from './services/update.service'; import { PrintService } from './shared/service/print.service'; -import { WindowScrollService } from './shared/service/windowScroll.service'; @Component({ selector: 'app-root', @@ -19,7 +18,6 @@ export class AppComponent implements OnInit { public printService: PrintService, private authService: AuthService, private profilService: ProfileService, - private windowScrollService: WindowScrollService, private routerListener: RouterListenerService, private updateService: UpdateService, private router: Router @@ -52,7 +50,4 @@ export class AppComponent implements OnInit { const vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); } - public onScrollDown(event): void { - this.windowScrollService.scrollY.next(event); - } } diff --git a/src/app/post/components/post-list/post-list.component.html b/src/app/post/components/post-list/post-list.component.html index 01056ea4fe41fb4ec3421d2dbcc05e297ae26ec5..cc5dd6778a3406568f8512d23c3a9f897996da7b 100644 --- a/src/app/post/components/post-list/post-list.component.html +++ b/src/app/post/components/post-list/post-list.component.html @@ -1,8 +1,5 @@ <div class="section-container no-padding" fxLayout="row" fxLayoutGap="32px"> - <div *ngIf="isLoading" class="loader"> - <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt /> - </div> - <div *ngIf="!isLoading" fxLayout="column" class="list-container" fxLayoutGap="16px"> + <div fxLayout="column" class="list-container" fxLayoutGap="16px"> <!-- <div fxLayout="column" *ngIf="displayTags()"> <div fxLayout="row wrap" fxLayoutAlign="none center" fxLayoutGap="8px"> <div @@ -27,6 +24,14 @@ <app-post-card [post]="news" class="col" *ngFor="let news of allPosts"></app-post-card> </div> </div> + <div *ngIf="isLoading" class="loader"> + <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt /> + </div> + <div *ngIf="!isLastPage && !isLoading" fxLayout="row" fxLayoutAlign="center center"> + <button class="btn-primary small" (click)="loadMore()"> + <div class="rowBtn" fxLayout="row" fxLayoutAlign="center center">Voir plus</div> + </button> + </div> </div> </div> </div> diff --git a/src/app/post/components/post-list/post-list.component.scss b/src/app/post/components/post-list/post-list.component.scss index 6e13a58170bdc044eeee2bf5f6b922e0b2aef762..011bb3a8ad3dc0e11b97ef14418973b8a590de9e 100644 --- a/src/app/post/components/post-list/post-list.component.scss +++ b/src/app/post/components/post-list/post-list.component.scss @@ -27,9 +27,7 @@ h2 { } } .list-container { - @media #{$tablet} { - width: 100%; - } + width: 100%; h2 { @media #{$large-phone} { @@ -239,3 +237,6 @@ h2 { margin-bottom: 0; } } +.btn-primary { + margin-bottom: 20px; +} diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts index b5347b836010e4e086021289d777971eafbecb61..92293f28b31afc05debb5764bcaa1dbd32948ae6 100644 --- a/src/app/post/components/post-list/post-list.component.ts +++ b/src/app/post/components/post-list/post-list.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit } from '@angular/core'; -import { WindowScrollService } from '../../../shared/service/windowScroll.service'; import { TagEnum } from '../../enum/tag.enum'; import { Pagination } from '../../models/pagination.model'; import { Post } from '../../models/post.model'; @@ -24,21 +23,9 @@ export class PostListComponent implements OnInit { public pagination: Pagination; public isLoading = false; public isPublishMode = false; + public isLastPage: boolean; - constructor( - private postService: PostService, - private windowScrollService: WindowScrollService, - private route: ActivatedRoute, - private router: Router - ) { - this.windowScrollService.scrollY$.subscribe((evt: any) => { - if (evt && evt.target.offsetHeight + evt.target.scrollTop >= evt.target.scrollHeight - 200) { - if (!this.isLoading) { - this.loadMore(); - } - } - }); - } + constructor(private postService: PostService, private route: ActivatedRoute, private router: Router) {} ngOnInit(): void { this.isLoading = true; @@ -77,12 +64,15 @@ export class PostListComponent implements OnInit { */ public fillArticles(news: PostWithMeta): void { this.setNews(news); + news.meta.pagination.pages > news.meta.pagination.page ? (this.isLastPage = false) : (this.isLastPage = true); const headLineTag = this.allPosts.filter((post: Post) => post.tags.some((tag) => tag && tag.slug === TagEnum.aLaUne) ); - const headIndex = this.allPosts.findIndex((post) => post.id === headLineTag[0].id); - this.allPosts.splice(headIndex, 1); + if (headLineTag.length) { + const headIndex = this.allPosts.findIndex((post) => post.id === headLineTag[0].id); + this.allPosts.splice(headIndex, 1); + } this.allPosts = [...headLineTag, ..._.difference(this.allPosts, headLineTag)]; } @@ -127,12 +117,12 @@ export class PostListComponent implements OnInit { // Transform excerpt post to have a custom author. private addAuthorToPost(post: Post): Post { post.author = post.excerpt; - post.excerpt = post.html.replace(/<[^>]*>/g, ''); + if (post.html) post.excerpt = post.html.replace(/<[^>]*>/g, ''); return post; } // Load more news on scroll event. - private loadMore(): void { + public loadMore(): void { if (this.pagination && this.pagination.page < this.pagination.pages) { this.isLoading = true; if (this.filters) { @@ -148,10 +138,8 @@ export class PostListComponent implements OnInit { // Split news on two columns on desktop mode or one column in mobile mode. private setNews(news: PostWithMeta): void { this.pagination = news.meta.pagination; - const customIndex = this.allPosts.length; // For scroll loading, start with previous index. - const newPosts = news.posts.map((val, index) => { + const newPosts = news.posts.map((val) => { val = this.addAuthorToPost(val); - index += customIndex; return val; }); this.allPosts = [...this.allPosts, ...newPosts]; diff --git a/src/app/post/services/post.service.ts b/src/app/post/services/post.service.ts index e7f51cfd9178b10a31df187d2a2b8706cbe9f8f1..23447f183741a088b6a9fa8cbdf7062cdded75d3 100644 --- a/src/app/post/services/post.service.ts +++ b/src/app/post/services/post.service.ts @@ -22,9 +22,11 @@ export class PostService { ); } - public getPosts(page: number, tags?: string[]): Observable<PostWithMeta> { + /** + * 12 posts to fit new design (1 + 3 + 2 + 1 + 3 + 2) + */ + public getPosts(page: number, tags?: string[], limit: string = '12'): Observable<PostWithMeta> { let tagsFilter = ''; - if (tags) { let tagsString = ''; // Transform tab filters to string filters @@ -37,7 +39,7 @@ export class PostService { tagsFilter = `&filter=tags:${encodeURIComponent(tagsString)}`; } - return this.http.get<PostWithMeta>(`${this.baseUrl}?page=${page}&include=tags,authors${tagsFilter}`); + return this.http.get<PostWithMeta>(`${this.baseUrl}?page=${page}&include=tags,authors${tagsFilter}&limit=${limit}`); } public getTags(): Observable<TagWithMeta> { @@ -46,7 +48,7 @@ export class PostService { private addAuthorToPost(post: Post): Post { post.author = post.excerpt; - post.excerpt = post.html.replace(/<[^>]*>/g, ''); + if (post.html) post.excerpt = post.html.replace(/<[^>]*>/g, ''); return post; } }