Skip to content

Commit

Permalink
add signals
Browse files Browse the repository at this point in the history
  • Loading branch information
asliayk committed Jan 23, 2025
1 parent 4bc01b6 commit 59b114f
Show file tree
Hide file tree
Showing 9 changed files with 739 additions and 610 deletions.
1 change: 1 addition & 0 deletions src/main/webapp/app/shared/metis/metis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export class MetisService implements OnDestroy {
const indexToUpdate = this.cachedPosts.findIndex((cachedPost) => cachedPost.id === updatedPost.id);
if (indexToUpdate > -1) {
updatedPost.answers = [...(this.cachedPosts[indexToUpdate].answers ?? [])];
updatedPost.authorRole = this.cachedPosts[indexToUpdate].authorRole;
this.cachedPosts[indexToUpdate] = updatedPost;
this.posts$.next(this.cachedPosts);
this.totalNumberOfPosts$.next(this.cachedTotalNumberOfPosts);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
@if (postingContentPart.contentBeforeReference) {
@if (postingContentPart()?.contentBeforeReference) {
<span
class="markdown-preview"
style="white-space: pre-wrap"
[innerHTML]="processedContentBeforeReference | htmlForPostingMarkdown: true : allowedHtmlTags : allowedHtmlAttributes"
></span>
}
@if (postingContentPart.linkToReference) {
<a class="reference" [routerLink]="postingContentPart.linkToReference" [queryParams]="postingContentPart.queryParams">
<fa-icon class="px-1" [icon]="referenceIcon(postingContentPart.referenceType!)" />{{ postingContentPart.referenceStr }}
@if (postingContentPart()?.linkToReference) {
<a class="reference" [routerLink]="postingContentPart()?.linkToReference" [queryParams]="postingContentPart()?.queryParams">
<fa-icon class="px-1" [icon]="referenceIcon(postingContentPart()?.referenceType!)" />{{ postingContentPart()?.referenceStr }}
</a>
}
@if (postingContentPart.referenceType === ReferenceType.POST && !postingContentPart.linkToReference) {
<a class="reference"> <fa-icon class="px-1" [icon]="referenceIcon(postingContentPart.referenceType!)" />{{ postingContentPart.referenceStr }} </a>
@if (postingContentPart()?.referenceType === ReferenceType.POST && !postingContentPart()?.linkToReference) {
<a class="reference"> <fa-icon class="px-1" [icon]="referenceIcon(postingContentPart()?.referenceType!)" />{{ postingContentPart()?.referenceStr }} </a>
}
@if (postingContentPart.referenceType === ReferenceType.USER) {
<a class="reference" (click)="onClickUserReference(postingContentPart.queryParams?.referenceUserLogin)">
<fa-icon class="px-1" [icon]="faAt" />{{ postingContentPart.referenceStr }}
@if (postingContentPart()?.referenceType === ReferenceType.USER) {
<a class="reference" (click)="onClickUserReference(postingContentPart()?.queryParams?.referenceUserLogin)">
<fa-icon class="px-1" [icon]="faAt" />{{ postingContentPart()?.referenceStr }}
</a>
}
@if (postingContentPart.referenceType === ReferenceType.CHANNEL) {
<a class="reference" (click)="onClickChannelReference(postingContentPart.queryParams?.channelId)">
<fa-icon class="px-1" [icon]="faHashtag" />{{ postingContentPart.referenceStr }}
@if (postingContentPart()?.referenceType === ReferenceType.CHANNEL) {
<a class="reference" (click)="onClickChannelReference(postingContentPart()?.queryParams?.channelId)">
<fa-icon class="px-1" [icon]="faHashtag" />{{ postingContentPart()?.referenceStr }}
</a>
}
@if (postingContentPart.attachmentToReference) {
<a class="reference" (click)="openAttachment(postingContentPart.attachmentToReference)"> <fa-icon class="px-1" [icon]="faFile" />{{ postingContentPart.referenceStr }} </a>
@if (postingContentPart()?.attachmentToReference) {
<a class="reference" (click)="openAttachment(postingContentPart()?.attachmentToReference || '')">
<fa-icon class="px-1" [icon]="faFile" />{{ postingContentPart()?.referenceStr }}
</a>
}
@if (postingContentPart.slideToReference) {
@if (postingContentPart()?.slideToReference) {
<div style="max-width: 400px">
<a class="reference" (click)="enlargeImage(postingContentPart.slideToReference)">
@if (postingContentPart.slideToReference && !imageNotFound) {
<a class="reference" (click)="enlargeImage(postingContentPart()?.slideToReference || '')">
@if (postingContentPart()?.slideToReference && !imageNotFound) {
<img
class="img-fluid rounded-sm border mt-1 mb-1"
[src]="postingContentPart.slideToReference"
[alt]="postingContentPart.referenceStr"
[title]="postingContentPart.referenceStr"
[src]="postingContentPart()?.slideToReference"
[alt]="postingContentPart()?.referenceStr"
[title]="postingContentPart()?.referenceStr"
(error)="toggleImageNotFound()"
height="auto"
width="100%"
Expand All @@ -49,15 +51,15 @@ <h5 class="card-body"><fa-icon class="px-1" [icon]="faBan" /><span jhiTranslate=
</div>
}

@if (postingContentPart.imageToReference) {
@if (postingContentPart()?.imageToReference) {
<div [style.user-select]="'none'" [style.max-width.px]="400">
@if (postingContentPart.imageToReference && !imageNotFound) {
<a class="reference" (click)="enlargeImage(postingContentPart.imageToReference)">
@if (postingContentPart()?.imageToReference && !imageNotFound) {
<a class="reference" (click)="enlargeImage(postingContentPart()?.imageToReference || '')">
<img
class="img-fluid rounded-sm border mt-1 mb-1"
[src]="postingContentPart.imageToReference"
[alt]="postingContentPart.referenceStr"
[title]="postingContentPart.referenceStr"
[src]="postingContentPart()?.imageToReference"
[alt]="postingContentPart()?.referenceStr"
[title]="postingContentPart()?.referenceStr"
(error)="toggleImageNotFound()"
height="auto"
width="100%"
Expand All @@ -71,7 +73,7 @@ <h5 class="card-body"><fa-icon class="px-1" [icon]="faBan" /><span jhiTranslate=
</div>
}

@if (postingContentPart.contentAfterReference) {
@if (postingContentPart()?.contentAfterReference) {
<span
class="markdown-preview"
style="white-space: pre-wrap"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, inject } from '@angular/core';
import { Component, OnChanges, OnInit, inject, input, output } from '@angular/core';
import { PostingContentPart, ReferenceType } from '../../metis.util';
import { FileService } from 'app/shared/http/file.service';

Expand Down Expand Up @@ -36,9 +36,9 @@ export class PostingContentPartComponent implements OnInit, OnChanges {
private dialog = inject(MatDialog);
private accountService = inject(AccountService);

@Input() postingContentPart: PostingContentPart;
@Output() userReferenceClicked = new EventEmitter<string>();
@Output() channelReferenceClicked = new EventEmitter<number>();
postingContentPart = input<PostingContentPart>();
userReferenceClicked = output<string>();
channelReferenceClicked = output<number>();

imageNotFound = false;
hasClickedUserReference = false;
Expand Down Expand Up @@ -80,13 +80,13 @@ export class PostingContentPartComponent implements OnInit, OnChanges {
}

processContent() {
if (this.postingContentPart.contentBeforeReference) {
this.processedContentBeforeReference = this.escapeNumberedList(this.postingContentPart.contentBeforeReference);
if (this.postingContentPart()?.contentBeforeReference) {
this.processedContentBeforeReference = this.escapeNumberedList(this.postingContentPart()?.contentBeforeReference || '');
this.processedContentBeforeReference = this.escapeUnorderedList(this.processedContentBeforeReference);
}

if (this.postingContentPart.contentAfterReference) {
this.processedContentAfterReference = this.escapeNumberedList(this.postingContentPart.contentAfterReference);
if (this.postingContentPart()?.contentAfterReference) {
this.processedContentAfterReference = this.escapeNumberedList(this.postingContentPart()?.contentAfterReference || '');
this.processedContentAfterReference = this.escapeUnorderedList(this.processedContentAfterReference);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</span>
} @else {
<!-- in preview mode (showing similar posts during creation): content can be expanded and collapsed shown -->
@if (previewMode) {
@if (previewMode()) {
<div class="pb-1">
<span class="clickable p-0">
<fa-icon [icon]="showContent ? faAngleUp : faAngleDown" [size]="'xs'" [ngStyle]="{ color: '#6a737d' }" (click)="showContent = !showContent" />
Expand All @@ -23,15 +23,15 @@
(channelReferenceClicked)="channelReferenceClicked.emit($event)"
/>
}
@if (isEdited) {
@if (isEdited()) {
<span class="edited-text" jhiTranslate="artemisApp.metis.edited"></span>
}
</div>
}
</div>
}
<!-- not in preview mode: content always shown -->
@if (!previewMode) {
@if (!previewMode()) {
<div class="pb-1">
@for (postingContentPart of postingContentParts(); track contentPartTrack($index)) {
<jhi-posting-content-part
Expand All @@ -40,10 +40,10 @@
(channelReferenceClicked)="channelReferenceClicked.emit($event)"
/>
}
@if (isEdited) {
@if (isEdited()) {
<span class="edited-text" jhiTranslate="artemisApp.metis.edited"></span>
}
<jhi-link-preview-container [data]="content" [author]="author" [posting]="posting" [isEdited]="isEdited" [isReply]="isReply" />
<jhi-link-preview-container [data]="content()" [author]="author()" [posting]="posting()" [isEdited]="isEdited()" [isReply]="isReply()" />
</div>
}
}
Loading

0 comments on commit 59b114f

Please sign in to comment.