Skip to content
Snippets Groups Projects
Commit ec604132 authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(post) : fix review ENUM logic + type properties

parent 6bce4fe4
Branches
Tags
3 merge requests!103Recette,!102Dev,!87Feat/posts list
<div fxLayout="column" *ngIf="post" class="post" [ngClass]="class" fxLayoutGap="12px"> <div fxLayout="column" *ngIf="post" class="post" [ngClass]="class" fxLayoutGap="12px">
<div fxLayout="column" fxLayoutGap="4px"> <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 <app-svg-icon
[iconClass]="'icon-32'" [iconClass]="'icon-32'"
[iconColor]="'inherit'" [iconColor]="'inherit'"
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { TagEnum } from '../../enum/tag.enum';
import { Post } from '../../models/post.model'; import { Post } from '../../models/post.model';
@Component({ @Component({
...@@ -9,6 +10,7 @@ import { Post } from '../../models/post.model'; ...@@ -9,6 +10,7 @@ import { Post } from '../../models/post.model';
export class PostCardComponent implements OnInit { export class PostCardComponent implements OnInit {
@Input() post: Post; @Input() post: Post;
@Input() class: string; @Input() class: string;
public tagEnum = TagEnum;
constructor() {} constructor() {}
ngOnInit(): void {} ngOnInit(): void {}
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { TagEnum } from '../../enum/tag.enum';
import { Post } from '../../models/post.model'; import { Post } from '../../models/post.model';
import { PostWithMeta } from '../../models/postWithMeta.model';
import { PostService } from '../../services/post.service'; import { PostService } from '../../services/post.service';
@Component({ @Component({
...@@ -10,18 +10,17 @@ import { PostService } from '../../services/post.service'; ...@@ -10,18 +10,17 @@ import { PostService } from '../../services/post.service';
}) })
export class PostListComponent implements OnInit { export class PostListComponent implements OnInit {
constructor(private postService: PostService) {} constructor(private postService: PostService) {}
postsMobileView: Post[] = []; public postsMobileView: Post[] = [];
leftColumnPosts: Post[] = []; public leftColumnPosts: Post[] = [];
rightColumnPosts: Post[] = []; public rightColumnPosts: Post[] = [];
projectsNew: Post[] = []; public projectsNew: Post[] = [];
bigNews: Post; public bigNews: Post;
ngOnInit(): void { ngOnInit(): void {
this.postService.getPosts().subscribe((news) => { this.postService.getPosts().subscribe((news) => {
news.posts.forEach((val, index) => { news.posts.forEach((val, index) => {
val = this.addAuthorToPost(val); val = this.addAuthorToPost(val);
this.postsMobileView.push(val); this.postsMobileView.push(val);
if (index % 2 == 0) { if (index % 2 == 0) {
this.leftColumnPosts.push(val); this.leftColumnPosts.push(val);
} else { } else {
...@@ -29,10 +28,10 @@ export class PostListComponent implements OnInit { ...@@ -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.bigNews = this.addAuthorToPost(news.posts[0]);
}); });
this.postService.getPosts(['appels']).subscribe((news) => { this.postService.getPosts([TagEnum.appels]).subscribe((news) => {
let projectNews = news.posts; let projectNews = news.posts;
projectNews.forEach((news) => { projectNews.forEach((news) => {
news = this.addAuthorToPost(news); news = this.addAuthorToPost(news);
......
export enum TagEnum {
aLaUne = 'a-la-une',
appels = 'appels',
}
...@@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'; ...@@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { TagEnum } from '../enum/tag.enum';
import { PostWithMeta } from '../models/postWithMeta.model'; import { PostWithMeta } from '../models/postWithMeta.model';
@Injectable({ @Injectable({
...@@ -14,7 +15,7 @@ export class PostService { ...@@ -14,7 +15,7 @@ export class PostService {
public getPosts(tags?: string[]): Observable<PostWithMeta> { public getPosts(tags?: string[]): Observable<PostWithMeta> {
if (!tags) { if (!tags) {
return this.http 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))); .pipe(map((item: PostWithMeta) => new PostWithMeta(item)));
} }
let tagsString = ''; let tagsString = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment