| @@ -1,17 +1,13 @@ | |||
| import {AfterViewInit, Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; | |||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| import {FormGroup} from "@angular/forms"; | |||
| import {SearchInputColDef} from "@app/_components/search-input/search-input-col-def"; | |||
| import {MatSort, Sort} from "@angular/material/sort"; | |||
| import {OrderFilter} from "@app/_models/orderFilter"; | |||
| import {ListComponent} from "@app/_components/list/list.component"; | |||
| import {ListColDefinition} from "@app/_components/list/list-col-definition"; | |||
| import {Observable} from "rxjs"; | |||
| @Component({ | |||
| selector: 'app-search-select', | |||
| templateUrl: './search-select.component.html', | |||
| styleUrl: './search-select.component.scss' | |||
| selector: 'app-search-select', | |||
| templateUrl: './search-select.component.html', | |||
| styleUrl: './search-select.component.scss' | |||
| }) | |||
| export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| @Input() public formId!: string; | |||
| @@ -24,8 +20,8 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| @Input() public displayedDataSubResource!: string; | |||
| @Input() public listColDefinitions!: ListColDefinition[]; | |||
| @Output() rowSelected = new EventEmitter<any>(); | |||
| @ViewChild('paragraphRef', { static: false }) paragraphRef!: ElementRef; | |||
| @ViewChild("listComponent", { static: false }) listComponent!: ListComponent; | |||
| @ViewChild('paragraphRef', {static: false}) paragraphRef!: ElementRef; | |||
| @ViewChild("listComponent", {static: false}) listComponent!: ListComponent; | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected selectedRowIndex: number | null = null; | |||
| @@ -47,7 +43,7 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| ngAfterViewInit(): void { | |||
| if (this.dataSet !== undefined) { | |||
| this.paragraphRef.nativeElement.textContent = this.dataSet[this.displayedDataField]; | |||
| this.paragraphRef.nativeElement.textContent = this.dataSet[this.displayedDataField]; | |||
| } | |||
| } | |||
| @@ -103,7 +103,10 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| } | |||
| openModalEditContact() { | |||
| let data: any = {'contact': this.contact} | |||
| let data: any = { | |||
| 'contact': this.contact, | |||
| 'partner': this.partner | |||
| } | |||
| if (this.contact.birthday !== undefined) { | |||
| data.birthdayValue = this.appHelperService.convertDate(this.contact.birthday); | |||
| } | |||
| @@ -17,8 +17,8 @@ | |||
| <div class="mb-3"> | |||
| <label for="product" class="form-label">{{ 'form.product' | translate }}:</label> | |||
| <ng-container *ngIf="posting.saleIri === null || posting.saleIri === undefined"> | |||
| <app-search-select *ngIf="posting.id === null || posting.id === undefined" | |||
| <ng-container *ngIf="posting.saleIri === undefined"> | |||
| <app-search-select *ngIf="posting.id === undefined" | |||
| #productSearchSelect | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| @@ -28,13 +28,13 @@ | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | |||
| > | |||
| </app-search-select> | |||
| <input id="product" type="hidden" *ngIf="posting.id === null || posting.id === undefined" | |||
| <input id="product" type="hidden" *ngIf="posting.id === undefined" | |||
| formControlName="product"/> | |||
| </ng-container> | |||
| <input type="text" | |||
| *ngIf="posting.saleIri !== null && posting.saleIri !== undefined && (posting.id === null || posting.id === undefined)" | |||
| *ngIf="posting.saleIri !== undefined && (posting.id === undefined)" | |||
| class="form-control" disabled value="{{product.name}}"/> | |||
| <input type="text" *ngIf="posting.id !== null && posting.id !== undefined" class="form-control" | |||
| <input type="text" *ngIf="posting.id !== undefined" class="form-control" | |||
| disabled value="{{posting.product?.name}}"/> | |||
| </div> | |||
| @@ -1,7 +1,7 @@ | |||
| <div class="spt-container"> | |||
| <div class="posts"> | |||
| <div *ngIf="!this.user" class="top-btn"> | |||
| <button class="btn btn-primary" (click)="openModalNewPost()">+ {{ 'basic.new-post' | translate }}</button> | |||
| <button class="btn btn-primary" (click)="openModalNewEditPost()">+ {{ 'basic.new-post' | translate }}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getPostsData" | |||
| @@ -31,7 +31,7 @@ | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(post.message)"></p> | |||
| <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> | |||
| data-action="edit" (click)="openModalNewEditPost(post)"></span> | |||
| <div class="spt-comments-box d-flex justify-content-end mt-1 position-absolute"> | |||
| <span *ngIf="post?.numComments !== undefined && post?.numComments !== null && post?.numComments !== 0" | |||
| role="button" class="badge bg-secondary p-2 me-2" | |||
| @@ -43,7 +43,7 @@ | |||
| ({{ post.numComments }})</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" | |||
| (click)="openModalNewComment(post)">{{ 'basic.comment-it' | translate }}</span> | |||
| (click)="openModalNewEditComment(post)">{{ 'basic.comment-it' | translate }}</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -61,7 +61,7 @@ | |||
| <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> | |||
| (click)="openModalNewEditComment(undefined, comment)"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -2,7 +2,7 @@ import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core' | |||
| import {Subscription} from "rxjs"; | |||
| import { | |||
| CommentJsonld, CommentService, | |||
| ContactJsonld, | |||
| ContactJsonld, DocumentJsonld, | |||
| PartnerJsonld, | |||
| PartnerProductJsonld, | |||
| PostJsonld, | |||
| @@ -16,6 +16,7 @@ import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||
| import {User} from "@app/_models"; | |||
| import {AccountService} from "@app/_services"; | |||
| import {NewDocumentComponent} from "@app/_views/documents/new-document/new-document.component"; | |||
| @Component({ | |||
| selector: 'app-post-list', | |||
| @@ -133,40 +134,34 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| this.getPostData(postIri); | |||
| } | |||
| openModalNewPost() { | |||
| let postInputs: any = {}; | |||
| let post: PostJsonld = {} as PostJsonld; | |||
| openModalNewEditPost(post?: PostJsonld) { | |||
| const postInputs: any = {}; | |||
| const posting: PostJsonld = post || {} as PostJsonld; | |||
| if (this.partner !== undefined) { | |||
| post.partnerIri = this.partner?.id; | |||
| postInputs['partner'] = this.partner; | |||
| } | |||
| if (this.contact !== undefined) { | |||
| post.contactIri = this.contact.id; | |||
| } | |||
| if (this.sale !== undefined) { | |||
| post.partnerIri = this.sale?.partnerIri; | |||
| post.productIri = this.sale?.productIri; | |||
| post.saleIri = this.sale?.id; | |||
| postInputs['product'] = this.sale.product; | |||
| if (!post) { | |||
| if (this.partner) { | |||
| posting.partnerIri = this.partner.id; | |||
| postInputs['partner'] = this.partner; | |||
| } | |||
| if (this.contact) { | |||
| posting.contactIri = this.contact.id; | |||
| } | |||
| if (this.sale) { | |||
| posting.partnerIri = this.sale.partnerIri; | |||
| posting.productIri = this.sale.productIri; | |||
| posting.saleIri = this.sale.id; | |||
| postInputs['product'] = this.sale.product; | |||
| } | |||
| } | |||
| postInputs['posting'] = post; | |||
| this.appHelperService.openModal(NewPostComponent, postInputs, this.getPostsData); | |||
| } | |||
| openModalEditPost(post: PostJsonld) { | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getPostsData); | |||
| postInputs['posting'] = posting; | |||
| this.appHelperService.openModal(NewPostComponent, postInputs, this.getPostsData); | |||
| } | |||
| openModalNewComment(post: PostJsonld) { | |||
| let comment: CommentJsonld = {} as CommentJsonld; | |||
| comment.postIri = post.id; | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.afterCommentCreation, post.id); | |||
| } | |||
| openModalNewEditComment(post?: PostJsonld, comment?: CommentJsonld) { | |||
| const commentData: CommentJsonld = comment || { postIri: post?.id } as CommentJsonld; | |||
| const postId = comment ? comment.postIri : post?.id; | |||
| openModalEditComment(comment: CommentJsonld) { | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.afterCommentCreation, comment.postIri); | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': commentData }, this.afterCommentCreation, postId); | |||
| } | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| <div class="spt-container"> | |||
| <div class="top-btn"> | |||
| <button *ngIf="partner" class="btn btn-primary" (click)="openModalNewTask()"> | |||
| <button *ngIf="partner" class="btn btn-primary" (click)="openModalNewEditTask()"> | |||
| + {{ 'basic.new-task' | translate }} | |||
| </button> | |||
| </div> | |||
| @@ -29,7 +29,7 @@ | |||
| class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" | |||
| data-action="edit" | |||
| (click)="openModalEditTask(task)" | |||
| (click)="openModalNewEditTask(task)" | |||
| > | |||
| </span> | |||
| <span class="importance" [attr.data-importance]="task.prio"></span> | |||
| @@ -65,7 +65,7 @@ | |||
| ({{ task.numTaskNotes }})</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" | |||
| (click)="openModalNewTaskNote(task)">{{ 'basic.comment-it' | translate }}</span> | |||
| (click)="openModalNewEditTaskNote(task)">{{ 'basic.comment-it' | translate }}</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -92,7 +92,7 @@ | |||
| <span *ngIf="task.createdBy?.id === currentUser?.id" | |||
| class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" | |||
| (click)="openModalEditTask(task)"></span> | |||
| (click)="openModalNewEditTask(task)"></span> | |||
| <div class="spt-comments-box d-flex justify-content-end mt-1 position-absolute"> | |||
| <span *ngIf="task.numTaskNotes !== undefined && task.numTaskNotes !== null && task.numTaskNotes > 0" | |||
| role="button" class="spt-btn-low badge bg-secondary p-2 me-2" | |||
| @@ -104,7 +104,7 @@ | |||
| ({{ task.numTaskNotes }})</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" | |||
| (click)="openModalNewTaskNote(task)">{{ 'basic.comment-it' | translate }}</span> | |||
| (click)="openModalNewEditTaskNote(task)">{{ 'basic.comment-it' | translate }}</span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -132,7 +132,7 @@ | |||
| <span *ngIf="taskNote.owner?.id === currentUser?.id" | |||
| class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" | |||
| (click)="openModalEditTaskNote(taskNote, task)"></span> | |||
| (click)="openModalNewEditTaskNote(task, taskNote)"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -131,33 +131,23 @@ export class TaskListComponent implements OnInit, AfterViewInit { | |||
| this.getTaskData(taskIri); | |||
| } | |||
| openModalNewTask() { | |||
| let postInputs: any = {}; | |||
| let task: TaskJsonld = {} as TaskJsonld; | |||
| task.partnerIri = this.partner.id; | |||
| task.completed = false; | |||
| if (this.partner !== undefined) { | |||
| postInputs['partner'] = this.partner; | |||
| } | |||
| postInputs['task'] = task; | |||
| this.appHelperService.openModal(NewTaskComponent, postInputs, this.getTasksData); | |||
| } | |||
| openModalEditTask(task: TaskJsonld) { | |||
| this.appHelperService.openModal(NewTaskComponent, {'task': task}, this.getTasksData); | |||
| openModalNewEditTask(task?: TaskJsonld) { | |||
| const taskInputs: any = { | |||
| partner: this.partner, | |||
| task: task || { | |||
| partnerIri: this.partner?.id, | |||
| completed: false | |||
| } as TaskJsonld | |||
| }; | |||
| this.appHelperService.openModal(NewTaskComponent, taskInputs, this.getTasksData); | |||
| } | |||
| openModalNewTaskNote(task: TaskJsonld) { | |||
| let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld; | |||
| taskNote.taskIri = task.id ?? null; | |||
| this.appHelperService.openModal( | |||
| NewTaskNoteComponent, {'taskNote': taskNote, 'task': task}, this.afterCommentCreation, task.id | |||
| ); | |||
| } | |||
| openModalNewEditTaskNote(task: TaskJsonld, taskNote?: TaskNoteJsonld) { | |||
| const taskNoteData: TaskNoteJsonld = taskNote || { taskIri: task.id ?? null } as TaskNoteJsonld; | |||
| openModalEditTaskNote(taskNote: TaskNoteJsonld, task: TaskJsonld) { | |||
| this.appHelperService.openModal( | |||
| NewTaskNoteComponent, {'taskNote': taskNote, 'task': task}, this.afterCommentCreation, task.id | |||
| NewTaskNoteComponent, { 'taskNote': taskNoteData, 'task': task }, this.afterCommentCreation, task.id | |||
| ); | |||
| } | |||