| @@ -43,7 +43,7 @@ export class AppHelperService { | |||
| return { centered: true } as NgbModalOptions; | |||
| } | |||
| public openModal(component: any, data: any, callback?: () => void): Promise<ModalStatus> { | |||
| public openModal(component: any, data: any, callback?: (callbackParam?: any) => void, callbackParam?: any): Promise<ModalStatus> { | |||
| const modalRef = this.modalService.open(component); | |||
| for (const key in data) { | |||
| modalRef.componentInstance[key] = data[key]; | |||
| @@ -53,7 +53,7 @@ export class AppHelperService { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRef.dismiss(); | |||
| if (callback) { | |||
| callback(); | |||
| callback(callbackParam); | |||
| } | |||
| } | |||
| }); | |||
| @@ -12,11 +12,11 @@ | |||
| <div class="mb-3"> | |||
| <app-search-input #productSearchInput | |||
| [formId]="'product'" | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'partnerName'" | |||
| [dataField]="'productName'" | |||
| [documentForm]="postForm" | |||
| [documentFormField]="'partnerName'" | |||
| [documentFormField]="'productName'" | |||
| [fetchFunction]="fetchProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="product"/> | |||
| @@ -31,32 +31,34 @@ | |||
| data-action="edit" (click)="openModalEditPost(post)"></span> | |||
| <div class="spt-comments-box d-flex justify-content-end mt-1 position-absolute"> | |||
| <!-- <span *ngIf="post.comments?.length !== 0" role="button" class="badge bg-secondary p-2 me-2"--> | |||
| <!-- (click)="showComments(post)">--> | |||
| <!-- <ng-container--> | |||
| <!-- *ngIf="post.id && commentsVisibility.get(post.id)">{{ 'basic.hide-comments' | translate }}</ng-container>--> | |||
| <!-- <ng-container--> | |||
| <!-- *ngIf="post.id && !commentsVisibility.get(post.id)">{{ 'basic.show-comments' | translate }}</ng-container>--> | |||
| <!-- </span>--> | |||
| <!-- <span role="button" class="badge bg-secondary p-2"--> | |||
| <!-- (click)="openModalNewComment(post)">{{ 'basic.comment-it' | translate }}</span>--> | |||
| <span role="button" class="badge bg-secondary p-2 me-2" | |||
| (click)="showComments(post)"> | |||
| <ng-container | |||
| *ngIf="post.id && commentsVisibility.get(post.id)">{{ 'basic.hide-comments' | translate }}</ng-container> | |||
| <ng-container | |||
| *ngIf="post.id && !commentsVisibility.get(post.id)">{{ 'basic.show-comments' | translate }}</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" | |||
| (click)="openModalNewComment(post)">{{ 'basic.comment-it' | translate }}</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div *ngIf="post.id && commentsVisibility.get(post.id)" class="pb-1"> | |||
| <!-- <div class="card spt-comments" *ngFor="let comment of post.comments">--> | |||
| <!-- <div class="card-body">--> | |||
| <!-- <div class="d-flex justify-content-between align-items-center">--> | |||
| <!-- <p>{{ comment.createdAt | date:'dd.MM.YYYY' }}</p>--> | |||
| <!-- <p>{{ comment.ownerName }}</p>--> | |||
| <!-- </div>--> | |||
| <!-- <div>--> | |||
| <!-- <p [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p>--> | |||
| <!-- </div>--> | |||
| <!-- <span *ngIf="comment.owner === currentUser?.id" class="position-absolute bi bi-pencil p-2"--> | |||
| <!-- data-type="user-tool" data-action="edit" (click)="openModalEditComment(comment)"></span>--> | |||
| <!-- </div>--> | |||
| <!-- </div>--> | |||
| <div class="card spt-comments" *ngFor="let comment of comments.get(post.id)"> | |||
| <div class="card-body"> | |||
| <div class="d-flex justify-content-between align-items-center"> | |||
| <p>{{ comment.createdAt | date:'dd.MM.YYYY' }}</p> | |||
| <p>{{ comment.owner?.fullName }}</p> | |||
| </div> | |||
| <div> | |||
| <p [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p> | |||
| </div> | |||
| <span *ngIf="comment.owner === currentUser?.id" class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" (click)="openModalEditComment(comment)"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </app-paging> | |||
| @@ -1,7 +1,7 @@ | |||
| import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||
| import {Subscription} from "rxjs"; | |||
| import { | |||
| CommentJsonld, | |||
| CommentJsonld, CommentService, | |||
| ContactJsonld, | |||
| PartnerJsonld, | |||
| PartnerProductJsonld, | |||
| @@ -41,10 +41,13 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| protected partnerProducts: Array<PartnerProductJsonld>; | |||
| protected dataSource; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected commentsSub: Subscription; | |||
| protected comments: Map<string, CommentJsonld[]>; | |||
| constructor( | |||
| private postService: PostService, | |||
| private accountService: AccountService, | |||
| private commentService: CommentService, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| this.postsSub = new Subscription(); | |||
| @@ -54,6 +57,8 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| this.dataSource = new MatTableDataSource<PostJsonld>(this.posts); | |||
| this.commentsVisibility = new Map<string, boolean>(); | |||
| this.currentUser = this.accountService.userValue; | |||
| this.commentsSub = new Subscription(); | |||
| this.comments = new Map<string, CommentJsonld[]>(); | |||
| } | |||
| ngOnInit() { | |||
| @@ -81,11 +86,11 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| data => { | |||
| this.posts = data["hydra:member"]; | |||
| this.pagingComponent.dataLength = Number(data["hydra:totalItems"]); | |||
| this.posts.forEach(posts => { | |||
| if (posts.id) { | |||
| this.commentsVisibility.set(posts.id, false); | |||
| } | |||
| }); | |||
| // this.posts.forEach(posts => { | |||
| // if (posts.id) { | |||
| // this.commentsVisibility.set(posts.id, false); | |||
| // } | |||
| // }); | |||
| } | |||
| ); | |||
| } | |||
| @@ -94,6 +99,28 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| if (post.id) { | |||
| const currentVisibility = this.commentsVisibility.get(post.id); | |||
| this.commentsVisibility.set(post.id, !currentVisibility); | |||
| if (this.comments.get(post.id) === undefined) { | |||
| this.getComments(post); | |||
| } | |||
| } | |||
| } | |||
| getComments = (post: PostJsonld) => { | |||
| if (post.id) { | |||
| // TODO: Weiterblättern, 50 comments only | |||
| this.commentsSub = this.commentService.commentsGetCollection( | |||
| 1, | |||
| 50, | |||
| post.id | |||
| ).subscribe( | |||
| data => { | |||
| if (post.id) { | |||
| this.comments.set(post.id, data["hydra:member"]); | |||
| } | |||
| } | |||
| ); | |||
| } | |||
| } | |||
| @@ -110,7 +137,7 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| openModalNewComment(post: PostJsonld) { | |||
| let comment: CommentJsonld = {} as CommentJsonld; | |||
| comment.postIri = post.id; | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getData); | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getComments, post); | |||
| } | |||
| openModalEditComment(comment: CommentJsonld) { | |||
| @@ -18,9 +18,9 @@ | |||
| <app-search-input #productSearchInput | |||
| [formId]="'product'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'partnerName'" | |||
| [dataField]="'productName'" | |||
| [documentForm]="saleForm" | |||
| [documentFormField]="'partnerName'" | |||
| [documentFormField]="'productName'" | |||
| [fetchFunction]="fetchProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="product"/> | |||
| @@ -210,7 +210,7 @@ export class CommentService { | |||
| /** | |||
| * Retrieves a Comment resource. | |||
| * Retrieves a Comment resource. | |||
| * @param id Comment identifier | |||
| * @param id CommentApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -285,7 +285,7 @@ export class CommentService { | |||
| /** | |||
| * Updates the Comment resource. | |||
| * Updates the Comment resource. | |||
| * @param id Comment identifier | |||
| * @param id CommentApi identifier | |||
| * @param comment The updated Comment resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -198,7 +198,7 @@ export class ContactService { | |||
| /** | |||
| * Retrieves a Contact resource. | |||
| * Retrieves a Contact resource. | |||
| * @param id Contact identifier | |||
| * @param id ContactApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -273,7 +273,7 @@ export class ContactService { | |||
| /** | |||
| * Updates the Contact resource. | |||
| * Updates the Contact resource. | |||
| * @param id Contact identifier | |||
| * @param id ContactApi identifier | |||
| * @param contact The updated Contact resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -198,7 +198,7 @@ export class ContactPartnerProductService { | |||
| /** | |||
| * Removes the ContactPartnerProduct resource. | |||
| * Removes the ContactPartnerProduct resource. | |||
| * @param id ContactPartnerProduct identifier | |||
| * @param id ContactPartnerProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -269,7 +269,7 @@ export class ContactPartnerProductService { | |||
| /** | |||
| * Retrieves a ContactPartnerProduct resource. | |||
| * Retrieves a ContactPartnerProduct resource. | |||
| * @param id ContactPartnerProduct identifier | |||
| * @param id ContactPartnerProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -222,7 +222,7 @@ export class DocumentService { | |||
| /** | |||
| * Retrieves a Document resource. | |||
| * Retrieves a Document resource. | |||
| * @param id Document identifier | |||
| * @param id DocumentApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -297,7 +297,7 @@ export class DocumentService { | |||
| /** | |||
| * Updates the Document resource. | |||
| * Updates the Document resource. | |||
| * @param id Document identifier | |||
| * @param id DocumentApi identifier | |||
| * @param document The updated Document resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -218,7 +218,7 @@ export class PartnerService { | |||
| /** | |||
| * Retrieves a Partner resource. | |||
| * Retrieves a Partner resource. | |||
| * @param id Partner identifier | |||
| * @param id PartnerApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -293,7 +293,7 @@ export class PartnerService { | |||
| /** | |||
| * Updates the Partner resource. | |||
| * Updates the Partner resource. | |||
| * @param id Partner identifier | |||
| * @param id PartnerApi identifier | |||
| * @param partner The updated Partner resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -222,7 +222,7 @@ export class PartnerFollowService { | |||
| /** | |||
| * Removes the PartnerFollow resource. | |||
| * Removes the PartnerFollow resource. | |||
| * @param id PartnerFollow identifier | |||
| * @param id PartnerFollowApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -293,7 +293,7 @@ export class PartnerFollowService { | |||
| /** | |||
| * Retrieves a PartnerFollow resource. | |||
| * Retrieves a PartnerFollow resource. | |||
| * @param id PartnerFollow identifier | |||
| * @param id PartnerFollowApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -227,7 +227,7 @@ export class PartnerProductService { | |||
| /** | |||
| * Removes the PartnerProduct resource. | |||
| * Removes the PartnerProduct resource. | |||
| * @param id PartnerProduct identifier | |||
| * @param id PartnerProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -298,7 +298,7 @@ export class PartnerProductService { | |||
| /** | |||
| * Retrieves a PartnerProduct resource. | |||
| * Retrieves a PartnerProduct resource. | |||
| * @param id PartnerProduct identifier | |||
| * @param id PartnerProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -252,7 +252,7 @@ export class PostService { | |||
| /** | |||
| * Retrieves a Post resource. | |||
| * Retrieves a Post resource. | |||
| * @param id Post identifier | |||
| * @param id PostingApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -327,7 +327,7 @@ export class PostService { | |||
| /** | |||
| * Updates the Post resource. | |||
| * Updates the Post resource. | |||
| * @param id Post identifier | |||
| * @param id PostingApi identifier | |||
| * @param postPostingPatch The updated Post resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -196,7 +196,7 @@ export class ProductService { | |||
| /** | |||
| * Retrieves a Product resource. | |||
| * Retrieves a Product resource. | |||
| * @param id Product identifier | |||
| * @param id ProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -271,7 +271,7 @@ export class ProductService { | |||
| /** | |||
| * Updates the Product resource. | |||
| * Updates the Product resource. | |||
| * @param id Product identifier | |||
| * @param id ProductApi identifier | |||
| * @param product The updated Product resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -210,7 +210,7 @@ export class SaleService { | |||
| /** | |||
| * Retrieves a Sale resource. | |||
| * Retrieves a Sale resource. | |||
| * @param id Sale identifier | |||
| * @param id SaleApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -285,7 +285,7 @@ export class SaleService { | |||
| /** | |||
| * Updates the Sale resource. | |||
| * Updates the Sale resource. | |||
| * @param id Sale identifier | |||
| * @param id SaleApi identifier | |||
| * @param sale The updated Sale resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -222,7 +222,7 @@ export class TaskService { | |||
| /** | |||
| * Retrieves a Task resource. | |||
| * Retrieves a Task resource. | |||
| * @param id Task identifier | |||
| * @param id TaskApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -297,7 +297,7 @@ export class TaskService { | |||
| /** | |||
| * Updates the Task resource. | |||
| * Updates the Task resource. | |||
| * @param id Task identifier | |||
| * @param id TaskApi identifier | |||
| * @param task The updated Task resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -198,7 +198,7 @@ export class TaskNoteService { | |||
| /** | |||
| * Retrieves a TaskNote resource. | |||
| * Retrieves a TaskNote resource. | |||
| * @param id TaskNote identifier | |||
| * @param id TaskNoteApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -273,7 +273,7 @@ export class TaskNoteService { | |||
| /** | |||
| * Updates the TaskNote resource. | |||
| * Updates the TaskNote resource. | |||
| * @param id TaskNote identifier | |||
| * @param id TaskNoteApi identifier | |||
| * @param taskNote The updated TaskNote resource | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| @@ -196,7 +196,7 @@ export class UserService { | |||
| /** | |||
| * Retrieves a User resource. | |||
| * Retrieves a User resource. | |||
| * @param id User identifier | |||
| * @param id UserApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -215,7 +215,7 @@ export class UserProductService { | |||
| /** | |||
| * Removes the UserProduct resource. | |||
| * Removes the UserProduct resource. | |||
| * @param id UserProduct identifier | |||
| * @param id UserProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| @@ -286,7 +286,7 @@ export class UserProductService { | |||
| /** | |||
| * Retrieves a UserProduct resource. | |||
| * Retrieves a UserProduct resource. | |||
| * @param id UserProduct identifier | |||
| * @param id UserProductApi identifier | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||