| @@ -5,10 +5,9 @@ | |||
| <img src="/assets/images/icons/product.svg" class="icon-mini" alt="" /><a href="/product/{{this.appHelperService.extractId(product.id)}}">{{product.name}}</a> | |||
| </span> | |||
| <span *ngIf="contact"> | |||
| <!-- change here for contact --> | |||
| <img src="/assets/images/icons/contact.svg" class="icon-mini" alt="" /><a href="/contact/{{this.appHelperService.extractId(contact.id)}}">{{contact.firstName}} {{contact.lastName}}</a> | |||
| <!-- TODO: We need a Contact Icon --> | |||
| <img src="/assets/images/icons/user.svg" class="icon-mini" alt="" /><a href="/contact/{{this.appHelperService.extractId(contact.id)}}">{{contact.firstName}} {{contact.lastName}}</a> | |||
| </span> | |||
| <span *ngIf="user"> | |||
| <!-- change here for contact --> | |||
| <img src="/assets/images/icons/profile.svg" class="icon-mini" alt="" /><a href="/user/{{this.appHelperService.extractId(user.id)}}">{{user.firstName}} {{user.lastName}}</a> | |||
| <img src="/assets/images/icons/user.svg" class="icon-mini" alt="" /><a href="/user/{{this.appHelperService.extractId(user.id)}}">{{user.firstName}} {{user.lastName}}</a> | |||
| </span> | |||
| @@ -11,7 +11,7 @@ | |||
| </div> | |||
| <div class="mb-3"> | |||
| <app-search-input #productSearchInput | |||
| <app-search-input *ngIf="this.posting.id === null || this.posting.id === undefined" #productSearchInput | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'productName'" | |||
| @@ -19,7 +19,8 @@ | |||
| [documentFormField]="'productName'" | |||
| [fetchFunction]="fetchProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="product"/> | |||
| <input type="hidden" *ngIf="this.posting.id === null || this.posting.id === undefined" formControlName="product"/> | |||
| <input type="text" *ngIf="this.posting.id !== null && this.posting.id !== undefined" class="form-control" disabled value="{{posting.product?.name}}" /> | |||
| </div> | |||
| <div class="mb-3"> | |||
| @@ -4,7 +4,7 @@ | |||
| <button class="btn btn-primary" (click)="openModalNewPost()">+ {{ 'basic.new-post' | translate }}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getData" | |||
| [getDataFunction]="getPostsData" | |||
| [dataSource]="dataSource" | |||
| > | |||
| <div class="post pb-1" *ngFor="let post of posts"> | |||
| @@ -21,23 +21,23 @@ | |||
| <h3 class="m-0" *ngIf="post.product"> | |||
| <app-linked-label [product]="post.product"></app-linked-label> | |||
| </h3> | |||
| <p>{{ post.owner?.firstName }} {{ post.owner?.lastName }}</p> | |||
| <p>{{ post.owner?.fullName }}</p> | |||
| </div> | |||
| <div class="spt-border col-8"> | |||
| <h2 class="m-0">{{ post.headline }}</h2> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(post.message)"></p> | |||
| <span *ngIf="post.owner === currentUser?.id" class="position-absolute bi bi-pencil p-2" | |||
| <span *ngIf="post.owner?.id === currentUser?.id" class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" | |||
| 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"--> | |||
| <span role="button" class="badge bg-secondary p-2 me-2" | |||
| <span *ngIf="post.numComments !== 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> | |||
| *ngIf="post.id && !commentsVisibility.get(post.id)">{{ 'basic.show-comments' | translate }} ({{post.numComments}})</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" | |||
| (click)="openModalNewComment(post)">{{ 'basic.comment-it' | translate }}</span> | |||
| @@ -55,7 +55,7 @@ | |||
| <div> | |||
| <p [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p> | |||
| </div> | |||
| <span *ngIf="comment.owner === currentUser?.id" class="position-absolute bi bi-pencil p-2" | |||
| <span *ngIf="comment.owner?.id === currentUser?.id" class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" (click)="openModalEditComment(comment)"></span> | |||
| </div> | |||
| </div> | |||
| @@ -43,6 +43,7 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected commentsSub: Subscription; | |||
| protected comments: Map<string, CommentJsonld[]>; | |||
| protected postSub: Subscription; | |||
| constructor( | |||
| private postService: PostService, | |||
| @@ -59,6 +60,7 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| this.currentUser = this.accountService.userValue; | |||
| this.commentsSub = new Subscription(); | |||
| this.comments = new Map<string, CommentJsonld[]>(); | |||
| this.postSub = new Subscription(); | |||
| } | |||
| ngOnInit() { | |||
| @@ -68,7 +70,7 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| this.pagingComponent.getData(); | |||
| } | |||
| getData = () => { | |||
| getPostsData = () => { | |||
| this.postsSub = this.postService.postsGetCollection( | |||
| this.pagingComponent.getPageIndex(), | |||
| this.pagingComponent.getPageSize(), | |||
| @@ -86,11 +88,20 @@ 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); | |||
| // } | |||
| // }); | |||
| } | |||
| ); | |||
| } | |||
| getPostData = (postIri: string) => { | |||
| this.postSub = this.postService.postsIdGet(this.appHelperService.extractId(postIri)).subscribe( | |||
| data => { | |||
| for (let index = 0; index < this.posts.length; index++) { | |||
| const item = this.posts[index]; | |||
| if (data.id === item.id) { | |||
| this.posts[index] = data; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| ); | |||
| } | |||
| @@ -100,48 +111,47 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| const currentVisibility = this.commentsVisibility.get(post.id); | |||
| this.commentsVisibility.set(post.id, !currentVisibility); | |||
| if (this.comments.get(post.id) === undefined) { | |||
| this.getComments(post); | |||
| this.getComments(post.id); | |||
| } | |||
| } | |||
| } | |||
| getComments = (post: PostJsonld) => { | |||
| if (post.id) { | |||
| getComments = (postIri: string) => { | |||
| // TODO: Weiterblättern, 50 comments only | |||
| this.commentsSub = this.commentService.commentsGetCollection( | |||
| 1, | |||
| 50, | |||
| post.id | |||
| postIri | |||
| ).subscribe( | |||
| data => { | |||
| if (post.id) { | |||
| this.comments.set(post.id, data["hydra:member"]); | |||
| } | |||
| this.comments.set(postIri, data["hydra:member"]); | |||
| } | |||
| ); | |||
| } | |||
| } | |||
| afterCommentCreation = (postIri: string) => { | |||
| this.getComments(postIri); | |||
| this.getPostData(postIri); | |||
| } | |||
| openModalNewPost() { | |||
| let post: PostJsonld = {} as PostJsonld; | |||
| post.partnerIri = this.partner.id; | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getData); | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getPostsData); | |||
| } | |||
| openModalEditPost(post: PostJsonld) { | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getData); | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getPostsData); | |||
| } | |||
| openModalNewComment(post: PostJsonld) { | |||
| let comment: CommentJsonld = {} as CommentJsonld; | |||
| comment.postIri = post.id; | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getComments, post); | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.afterCommentCreation, post.id); | |||
| } | |||
| openModalEditComment(comment: CommentJsonld) { | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getData); | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.afterCommentCreation, comment.postIri); | |||
| } | |||
| @@ -24,7 +24,7 @@ | |||
| {{ 'overview.sale-user' | translate }} | |||
| </th> | |||
| <td mat-cell *matCellDef="let element"> | |||
| <a [routerLink]="['/user', appHelperService.extractId(element.owner)]">{{ element.ownerName }}</a> | |||
| <a [routerLink]="['/user', appHelperService.extractId(element.owner.id)]">{{ element.owner.fullName }}</a> | |||
| </td> | |||
| </ng-container> | |||
| @@ -34,7 +34,7 @@ | |||
| {{ 'overview.sale-partner' | translate }} | |||
| </th> | |||
| <td mat-cell *matCellDef="let element"> | |||
| <a [routerLink]="['/customer', appHelperService.extractId(element.partner)]">{{ element.partnerName }}</a> | |||
| <a [routerLink]="['/customer', appHelperService.extractId(element.partner.id)]">{{ element.partner.name }}</a> | |||
| </td> | |||
| </ng-container> | |||
| @@ -44,7 +44,7 @@ | |||
| {{ 'overview.productname' | translate }} | |||
| </th> | |||
| <td mat-cell *matCellDef="let element"> | |||
| <a [routerLink]="['/product', appHelperService.extractId(element.product)]">{{ element.productName }}</a> | |||
| <a [routerLink]="['/product', appHelperService.extractId(element.product.id)]">{{ element.product.name }}</a> | |||
| </td> | |||
| </ng-container> | |||
| @@ -24,56 +24,7 @@ | |||
| </div> | |||
| <app-toggle #togglePosts [headline]="'basic.posts' | translate"> | |||
| <div *ngIf="togglePosts.isOpened" class="spt-container"> | |||
| <div class="posts"> | |||
| <div class="top-btn"> | |||
| <button class="btn btn-primary" (click)="openModalNewPosting()">+ {{'basic.new-post' | translate}}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getPostsData" | |||
| [dataSource]="dataSource" | |||
| > | |||
| <div class="post mb-3" *ngFor="let post of posts"> | |||
| <div class="card"> | |||
| <div class="card-body"> | |||
| <div class="d-flex justify-content-between align-items-center"> | |||
| <p>{{ post.createdAt | date:'dd.MM.YYYY' }}</p> | |||
| <p>{{ post.owner?.fullName }}</p> | |||
| </div> | |||
| <div> | |||
| <h3>{{ post.headline }}</h3> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(post.message)"></p> | |||
| </div> | |||
| <span *ngIf="post.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| data-action="edit" (click)="openModalEditPosting(post)"></span> | |||
| </div> | |||
| </div> | |||
| <div *ngIf="post.id && commentsVisibility.get(post.id)"> | |||
| <!-- <div class="card ms-5" *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 class="m-0" [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p>--> | |||
| <!-- </div>--> | |||
| <!-- <span *ngIf="comment.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool"--> | |||
| <!-- data-action="edit" (click)="openModalEditComment(comment)"></span>--> | |||
| <!-- </div>--> | |||
| <!-- </div>--> | |||
| </div> | |||
| <div class="d-flex justify-content-end mt-1"> | |||
| <!-- <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>--> | |||
| </div> | |||
| </div> | |||
| </app-paging> | |||
| </div> | |||
| </div> | |||
| </app-toggle> | |||
| <app-post-list *ngIf="togglePosts.isOpened" #postListComponent | |||
| [sale]="sale" | |||
| ></app-post-list> | |||
| </app-toggle> | |||
| @@ -68,7 +68,7 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { | |||
| ).subscribe( | |||
| data => { | |||
| this.sale = data; | |||
| this.pagingComponent.getData(); | |||
| // this.pagingComponent.getData(); | |||
| } | |||
| ); | |||
| } | |||