diff --git a/src/app/post/components/post-card/post-card.component.html b/src/app/post/components/post-card/post-card.component.html index 272aac44ef40d06bd2378110451d106e4d302107..4ba85dbbe2594f12e428e4bbc2656b2be42b4909 100644 --- a/src/app/post/components/post-card/post-card.component.html +++ b/src/app/post/components/post-card/post-card.component.html @@ -1,6 +1,12 @@ <div fxLayout="column" *ngIf="post" class="post" [ngClass]="class" fxLayoutGap="12px"> <div fxLayout="column" fxLayoutGap="4px"> - <div fxLayout="row" class="tag" fxLayoutAlign=" center" fxLayoutGap="12px" *ngIf="post.tags[0].slug != 'appels'"> + <div + fxLayout="row" + class="tag" + fxLayoutAlign=" center" + fxLayoutGap="12px" + *ngIf="post.tags[0].slug != tagEnum.appels" + > <app-svg-icon [iconClass]="'icon-32'" [iconColor]="'inherit'" diff --git a/src/app/post/components/post-card/post-card.component.ts b/src/app/post/components/post-card/post-card.component.ts index e73dd03b3457b0a4c090b7d131e4d1cdef9618b0..a7d648e31d3854aa5ec2e7cf97caa39a9e43da9d 100644 --- a/src/app/post/components/post-card/post-card.component.ts +++ b/src/app/post/components/post-card/post-card.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; +import { TagEnum } from '../../enum/tag.enum'; import { Post } from '../../models/post.model'; @Component({ @@ -9,6 +10,7 @@ import { Post } from '../../models/post.model'; export class PostCardComponent implements OnInit { @Input() post: Post; @Input() class: string; + public tagEnum = TagEnum; constructor() {} ngOnInit(): void {} 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 5b95ba4f8797af08a3b4733660c430cde1c57ba6..8a3a9688362dd0c3748a563cf227b36e40f9b92b 100644 --- a/src/app/post/components/post-list/post-list.component.ts +++ b/src/app/post/components/post-list/post-list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import { TagEnum } from '../../enum/tag.enum'; import { Post } from '../../models/post.model'; -import { PostWithMeta } from '../../models/postWithMeta.model'; import { PostService } from '../../services/post.service'; @Component({ @@ -10,18 +10,17 @@ import { PostService } from '../../services/post.service'; }) export class PostListComponent implements OnInit { constructor(private postService: PostService) {} - postsMobileView: Post[] = []; - leftColumnPosts: Post[] = []; - rightColumnPosts: Post[] = []; - projectsNew: Post[] = []; - bigNews: Post; + public postsMobileView: Post[] = []; + public leftColumnPosts: Post[] = []; + public rightColumnPosts: Post[] = []; + public projectsNew: Post[] = []; + public bigNews: Post; ngOnInit(): void { this.postService.getPosts().subscribe((news) => { news.posts.forEach((val, index) => { val = this.addAuthorToPost(val); this.postsMobileView.push(val); - if (index % 2 == 0) { this.leftColumnPosts.push(val); } else { @@ -29,10 +28,10 @@ export class PostListComponent implements OnInit { } }); }); - this.postService.getPosts(['a-la-une']).subscribe((news) => { + this.postService.getPosts([TagEnum.aLaUne]).subscribe((news) => { this.bigNews = this.addAuthorToPost(news.posts[0]); }); - this.postService.getPosts(['appels']).subscribe((news) => { + this.postService.getPosts([TagEnum.appels]).subscribe((news) => { let projectNews = news.posts; projectNews.forEach((news) => { news = this.addAuthorToPost(news); diff --git a/src/app/post/enum/tag.enum.ts b/src/app/post/enum/tag.enum.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b6c049d9c31201ed0765164d4fd649e990c1782 --- /dev/null +++ b/src/app/post/enum/tag.enum.ts @@ -0,0 +1,4 @@ +export enum TagEnum { + aLaUne = 'a-la-une', + appels = 'appels', +} diff --git a/src/app/post/services/post.service.ts b/src/app/post/services/post.service.ts index 848e6a58e1260b8b556a66fb522a59a3a23a235e..688b9c31b2624857ac7d00c3e93f2cb5b9abdb98 100644 --- a/src/app/post/services/post.service.ts +++ b/src/app/post/services/post.service.ts @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; +import { TagEnum } from '../enum/tag.enum'; import { PostWithMeta } from '../models/postWithMeta.model'; @Injectable({ @@ -14,7 +15,7 @@ export class PostService { public getPosts(tags?: string[]): Observable<PostWithMeta> { if (!tags) { return this.http - .get<PostWithMeta>(`${this.baseUrl}?include=tags,authors&filter=tag:-[appels,a-la-une]`) + .get<PostWithMeta>(`${this.baseUrl}?include=tags,authors&filter=tag:-[${TagEnum.aLaUne},${TagEnum.appels}]`) .pipe(map((item: PostWithMeta) => new PostWithMeta(item))); } let tagsString = '';