Skip to content

Commit

Permalink
feat: mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmoser committed Jun 26, 2024
1 parent dbca41c commit 1dff125
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ <h4 class="text-sm grow md:grow-0 flex items-center">
<div>
<div class="mt-2">
<h3 class="text-lg" *ngIf="post.name">{{ post.name }}</h3>
<div [innerHTML]="post.content"></div>
<div class="cursor-pointer" (click)="this.handleContentClick($event, 'content')" [innerHTML]="post.content"></div>
<div class="mt-4 text-md">
<span class="mr-4">0 Replies</span >
<span class="mr-4">{{ post.replies.totalItems | i18nPlural : totalRepliesMap }}</span >
<button class="btn btn-sm mr-4" (click)="isPosting = true">Reply</button>
<a class="btn btn-sm mr-4">Edit</a>
<a class="btn btn-sm mr-4">Delete</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ export class NoteComponent {
@Input() public displayAuthor: boolean = true;
@Input() public excludeAuthors?: string | string[];
@Output() public onReply = new EventEmitter<{reply: NoteCreateDto, result$: Subject<boolean>}>();
@Output() public onContentClick = new EventEmitter<{event: MouseEvent, content: string, post: ObjectDto}>();

public isPosting = false;
public readonly totalRepliesMap = {
'=0': "No replies",
'=1': "1 reply",
other: "# replies"
}

constructor(
protected appService: AppService,
Expand Down Expand Up @@ -104,4 +110,8 @@ export class NoteComponent {
}
});
}

public handleContentClick(event: MouseEvent, content: string) {
this.onContentClick.emit({event, content, post: this.post});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

<div>
<div *ngFor="let post of posts$ | async" class="mb-3">
<app-note [post]="post" [excludeAuthors]="(forum$ | async)?.id" (onReply)="this.onReply($event)"></app-note>
<app-note [post]="post" [excludeAuthors]="(forum$ | async)?.id" (onReply)="this.onReply($event)" (onContentClick)="onContentClick($event)"></app-note>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ export class ForumIndexComponent {
}
});
}

onContentClick(event: any) {
}
}
4 changes: 2 additions & 2 deletions projects/test-app/src/app/modules/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<main role="main">
<app-actor-header [actor]="user$"></app-actor-header>

<div class="sticky top-20 bg-base-100 bg-opacity-70 mb-2 p-2 rounded">
<div class="sticky top-20 bg-base-100 bg-opacity-95 mb-2 p-2 rounded-lg">
<div class="flex">
<div class="flex flex-grow items-center">
@if (isLoadingError) {
Expand Down Expand Up @@ -64,7 +64,7 @@
</div>
}
@else {
@for (post of posts$ | async; track $index) {
@for (post of posts$ | async; track post.id) {
<app-note [post]="post" [displayAuthor]="false" [excludeAuthors]="(user$ | async)?.id" (onReply)="this.onReply($event)"></app-note>
}
}
Expand Down
1 change: 1 addition & 0 deletions projects/test-app/src/app/modules/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class UserComponent implements OnInit, OnDestroy {
const totalPages = this.totalItems % this.limit === 0 ? this.totalItems / this.limit : Math.floor(this.totalItems / this.limit) + 1;
this.pagination = this.appService.generatePagination(totalPages || 1, this.currentPage + 1);
this.isLoadingError = false;

return response.items;
}),
shareReplay(),
Expand Down

0 comments on commit 1dff125

Please sign in to comment.