Skip to content

Commit

Permalink
merged events & blog
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Jul 6, 2024
1 parent 239d7db commit 269a8ce
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<nav class="nav">
<a class="not" routerLink="/blog" routerLinkActive="selected">
<!-- <app-icon-s class="nav-icon"/>-->
<span class="label" i18n>Blog</span>
<span class="label" i18n>News &amp; Events</span>
</a>
<a class="not" routerLink="/network" routerLinkActive="selected">
<span class="label" i18n>Network</span>
Expand Down
13 changes: 7 additions & 6 deletions src/app/pages/blog/blog-list/blog-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
<div class="header">
<h1 i18n>Blog</h1>
<feel-button class="event-button" i18n-label label="Events!" link="/event">
<app-icon-send/>
<app-icon-send />
</feel-button>
</div>
<div *ngIf="(keywords | async) as keywords" class="keywords">
<button (click)="toggleKeyword(keyword)" *ngFor="let keyword of keywords"
[class.selected]="isSelected(keyword) | async"
class="keyword">{{ keyword }}
[class.selected]="isSelected(keyword) | async" class="keyword">
{{ keyword }}
</button>
</div>
</div>

<ul class="not news">
<li *ngFor="let post of posts | async">
<app-blog-card [post]="post"/>
<li *ngFor="let entry of entries | async">
<app-blog-card *ngIf="!isEvent(entry)" [post]="castPost(entry)" />
<app-event-card *ngIf="isEvent(entry)" [event]="castEvent(entry)" />
</li>
</ul>

<app-card>
<div class="mailing-list">
<app-mailing-list [listId]="3" [listName]="'News'"/>
<app-mailing-list [listId]="3" [listName]="'News'" />
</div>
</app-card>
43 changes: 32 additions & 11 deletions src/app/pages/blog/blog-list/blog-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {BlogService} from "../../../api/blog.service";
import {BehaviorSubject, map, Observable, switchMap} from "rxjs";
import {AsyncPipe, NgForOf, NgIf} from "@angular/common";
import {BlogCardComponent} from "../../../core/blog-card/blog-card.component";
import {CardComponent} from "../../../core/card/card.component";
import {MailingListComponent} from "../../../core/mailing-list/mailing-list.component";
import {ButtonComponent} from "@feel/form";
import {IconSendComponent} from "../../../icons/icon-send/icon-send.component";
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BlogService } from "../../../api/blog.service";
import { BehaviorSubject, combineLatest, map, Observable, switchMap } from "rxjs";
import { AsyncPipe, NgForOf, NgIf } from "@angular/common";
import { BlogCardComponent } from "../../../core/blog-card/blog-card.component";
import { CardComponent } from "../../../core/card/card.component";
import { MailingListComponent } from "../../../core/mailing-list/mailing-list.component";
import { ButtonComponent } from "@feel/form";
import { IconSendComponent } from "../../../icons/icon-send/icon-send.component";
import { EventCardComponent } from "../../../core/event-card/event-card.component";
import { SmallBlogPost, SmallEvent } from '../../../api/blog.domain';

@Component({
selector: 'app-blog-list',
Expand All @@ -22,13 +24,20 @@ import {IconSendComponent} from "../../../icons/icon-send/icon-send.component";
CardComponent,
MailingListComponent,
ButtonComponent,
IconSendComponent
IconSendComponent,
EventCardComponent
]
})
export class BlogListComponent {

protected readonly selectedKeywords = new BehaviorSubject<string[]>([]);
protected readonly posts = this.selectedKeywords.pipe(switchMap(keywords => this.blogService.getBlogPosts(keywords)));
protected readonly entries = combineLatest({
events: this.blogService.getEventPosts(),
posts: this.selectedKeywords.pipe(switchMap(keywords => this.blogService.getBlogPosts(keywords)))
})
.pipe(map(({ events, posts }) =>
([...events, ...posts].sort(eventOrPost => Date.parse(eventOrPost.published)))
));
protected readonly keywords = this.blogService.getBlogKeywords();

constructor(
Expand All @@ -47,4 +56,16 @@ export class BlogListComponent {
this.selectedKeywords.next(this.selectedKeywords.value.filter(existing => existing !== keyword));
}
}

protected isEvent(eventOrPost: SmallEvent | SmallBlogPost): boolean {
return 'start_time' in eventOrPost;
}

protected castEvent(eventOrPost: SmallEvent | SmallBlogPost): SmallEvent {
return eventOrPost as SmallEvent;
}

protected castPost(eventOrPost: SmallEvent | SmallBlogPost): SmallBlogPost {
return eventOrPost as SmallBlogPost;
}
}
25 changes: 14 additions & 11 deletions src/locales/en_devel.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@
<context context-type="linenumber">82,83</context>
</context-group>
</trans-unit>
<trans-unit id="7751010942038334793" datatype="html">
<source>Blog</source>
<trans-unit id="5948442423891185229" datatype="html">
<source>News &amp; Events</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.component.html</context>
<context context-type="linenumber">10,11</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.routes.ts</context>
<context context-type="linenumber">15</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/blog/blog-list/blog-list.component.html</context>
<context context-type="linenumber">3,4</context>
<context context-type="linenumber">10</context>
</context-group>
</trans-unit>
<trans-unit id="6718726533481404495" datatype="html">
Expand Down Expand Up @@ -273,6 +265,17 @@
<context context-type="linenumber">3,4</context>
</context-group>
</trans-unit>
<trans-unit id="7751010942038334793" datatype="html">
<source>Blog</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.routes.ts</context>
<context context-type="linenumber">15</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/blog/blog-list/blog-list.component.html</context>
<context context-type="linenumber">3,4</context>
</context-group>
</trans-unit>
<trans-unit id="3304972143698843178" datatype="html">
<source>Event</source>
<context-group purpose="location">
Expand Down

0 comments on commit 269a8ce

Please sign in to comment.