|
|
|
@@ -1,30 +1,25 @@ |
|
|
|
import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; |
|
|
|
import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; |
|
|
|
import {NewContactComponent} from "@app/contacts/new-contact/new-contact.component"; |
|
|
|
import {ActivatedRoute, Router} from "@angular/router"; |
|
|
|
import { |
|
|
|
CommentJsonld, |
|
|
|
ContactJsonld, |
|
|
|
ContactService, PartnerFollowJsonld, PartnerFollowService, |
|
|
|
PartnerFollowJsonld, PartnerFollowService, |
|
|
|
PartnerJsonld, PartnerProductJsonld, PartnerProductService, |
|
|
|
PartnerService, |
|
|
|
PostJsonld, |
|
|
|
PostService, TaskJsonld, TaskNoteJsonld, TaskService |
|
|
|
PartnerService, TaskJsonld, TaskNoteJsonld, TaskService |
|
|
|
} from "@app/core/api/v1"; |
|
|
|
import {Subscription} from "rxjs"; |
|
|
|
import {environment} from "@environments/environment"; |
|
|
|
import {ApiConverter} from "@app/_helpers/api.converter"; |
|
|
|
import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; |
|
|
|
import {MatTableDataSource} from "@angular/material/table"; |
|
|
|
import {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; |
|
|
|
import {NewTaskComponent} from "@app/tasks/new-task/new-task.component"; |
|
|
|
import {NewTaskComponent} from "@app/_views/tasks/new-task/new-task.component"; |
|
|
|
import {ModalStatus} from "@app/_helpers/modal.states"; |
|
|
|
import {AccountService} from "@app/_services"; |
|
|
|
import {User} from "@app/_models"; |
|
|
|
import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; |
|
|
|
import {NewPartnerComponent} from "@app/partners/new-partner/new-partner.component"; |
|
|
|
import {NewTaskNoteComponent} from "@app/tasks/new-task-note/new-task-note.component"; |
|
|
|
import {NewPartnerComponent} from "@app/_views/partners/new-partner/new-partner.component"; |
|
|
|
import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; |
|
|
|
import {ToggleComponent} from "@app/_components/toggle/toggle.component"; |
|
|
|
import {PostListComponent} from "@app/_views/posts/post-list/post-list.component"; |
|
|
|
import {ContactListComponent} from "@app/_views/contacts/contact-list/contact-list.component"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-partners-detail', |
|
|
|
@@ -33,11 +28,14 @@ import {ToggleComponent} from "@app/_components/toggle/toggle.component"; |
|
|
|
}) |
|
|
|
export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
@ViewChild("toggleContacts", { static: true }) toggleContacts: ToggleComponent = new ToggleComponent(); |
|
|
|
@ViewChild("contactsComponent", { static: false }) contactsComponent!: ContactListComponent; |
|
|
|
|
|
|
|
@ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent(); |
|
|
|
|
|
|
|
@ViewChild("togglePosts", { static: true }) togglePosts: ToggleComponent = new ToggleComponent(); |
|
|
|
@ViewChild(MatPaginator) contactsPaginator: MatPaginator; |
|
|
|
@ViewChild("postsComponent", { static: false }) postsComponent!: PostListComponent; |
|
|
|
|
|
|
|
@ViewChild(MatPaginator) tasksPaginator: MatPaginator; |
|
|
|
@ViewChild(MatPaginator) postsPaginator: MatPaginator; |
|
|
|
|
|
|
|
protected user: User | null; |
|
|
|
|
|
|
|
@@ -45,7 +43,7 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
protected id: string; |
|
|
|
|
|
|
|
protected partnerDetailSub: Subscription; |
|
|
|
protected partner: PartnerJsonld; |
|
|
|
protected partner!: PartnerJsonld; |
|
|
|
|
|
|
|
protected partnerProductSub: Subscription; |
|
|
|
protected partnerProducts: Array<PartnerProductJsonld>; |
|
|
|
@@ -53,14 +51,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
protected partnerFollowSub: Subscription; |
|
|
|
protected partnerFollow: PartnerFollowJsonld | null; |
|
|
|
|
|
|
|
protected contactsSub: Subscription; |
|
|
|
protected contacts: Array<ContactJsonld>; |
|
|
|
protected contactsDataSource; |
|
|
|
protected contactsLength: number; |
|
|
|
protected contactsPageEvent: PageEvent; |
|
|
|
protected contactsPageSize: number; |
|
|
|
protected contactsPageIndex: number; |
|
|
|
|
|
|
|
protected tasksSub: Subscription; |
|
|
|
protected tasks: Array<TaskJsonld>; |
|
|
|
protected tasksDataSource; |
|
|
|
@@ -70,15 +60,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
protected tasksPageIndex: number; |
|
|
|
|
|
|
|
protected taskNotesVisibility: Map<string, boolean>; |
|
|
|
protected commentsVisibility: Map<string, boolean>; |
|
|
|
|
|
|
|
protected postsSub: Subscription; |
|
|
|
protected posts: Array<PostJsonld>; |
|
|
|
protected postsDataSource; |
|
|
|
protected postsLength: number; |
|
|
|
protected postsPageEvent: PageEvent; |
|
|
|
protected postsPageSize: number; |
|
|
|
protected postsPageIndex: number; |
|
|
|
|
|
|
|
protected modalOptions: NgbModalOptions = { |
|
|
|
centered: true |
|
|
|
@@ -92,14 +73,12 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
private partnerService: PartnerService, |
|
|
|
private partnerProductService: PartnerProductService, |
|
|
|
private partnerFollowService: PartnerFollowService, |
|
|
|
private contactService: ContactService, |
|
|
|
private postService: PostService, |
|
|
|
private taskService: TaskService, |
|
|
|
protected apiConverter: ApiConverter |
|
|
|
) { |
|
|
|
this.id = ""; |
|
|
|
this.partnerDetailSub = new Subscription(); |
|
|
|
this.partner = {} as PartnerJsonld; |
|
|
|
//this.partner = {} as PartnerJsonld; |
|
|
|
|
|
|
|
this.partnerProductSub = new Subscription(); |
|
|
|
this.partnerProducts = []; |
|
|
|
@@ -109,15 +88,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
|
|
|
|
this.user = this.accountService.userValue; |
|
|
|
|
|
|
|
this.contactsSub = new Subscription(); |
|
|
|
this.contacts = []; |
|
|
|
this.contactsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
this.contactsDataSource = new MatTableDataSource<ContactJsonld>(this.contacts); |
|
|
|
this.contactsLength = 0; |
|
|
|
this.contactsPageEvent = new PageEvent(); |
|
|
|
this.contactsPageSize = 6; |
|
|
|
this.contactsPageIndex = 0; |
|
|
|
|
|
|
|
this.tasksSub = new Subscription(); |
|
|
|
this.tasks = []; |
|
|
|
this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
@@ -127,16 +97,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
this.tasksPageSize = 10; |
|
|
|
this.tasksPageIndex = 0; |
|
|
|
this.taskNotesVisibility = new Map<string, boolean>(); |
|
|
|
|
|
|
|
this.postsSub = new Subscription(); |
|
|
|
this.posts = []; |
|
|
|
this.postsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
this.postsDataSource = new MatTableDataSource<PostJsonld>(this.posts); |
|
|
|
this.postsLength = 0; |
|
|
|
this.postsPageEvent = new PageEvent(); |
|
|
|
this.postsPageSize = 10; |
|
|
|
this.postsPageIndex = 0; |
|
|
|
this.commentsVisibility = new Map<string, boolean>(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
@@ -145,16 +105,15 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
}); |
|
|
|
this.getPartnerData(); |
|
|
|
this.getPartnerProducts(); |
|
|
|
this.getContactsData(); |
|
|
|
this.getPostsData(); |
|
|
|
this.getTasksData(); |
|
|
|
this.getPartnerFollowedStatus(); |
|
|
|
|
|
|
|
console.log('ng init done'); |
|
|
|
} |
|
|
|
|
|
|
|
ngAfterViewInit() { |
|
|
|
this.contactsDataSource.paginator = this.contactsPaginator; |
|
|
|
console.log('ng after view init'); |
|
|
|
this.tasksDataSource.paginator = this.tasksPaginator; |
|
|
|
this.postsDataSource.paginator = this.postsPaginator; |
|
|
|
} |
|
|
|
|
|
|
|
getPartnerData() { |
|
|
|
@@ -163,59 +122,20 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.partner = data; |
|
|
|
console.log('getPartnerData done'); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
getPartnerProducts() { |
|
|
|
this.partnerProductSub = this.partnerProductService.partnerProductsGetCollection( |
|
|
|
this.contactsPageIndex + 1, |
|
|
|
this.contactsPageSize, |
|
|
|
1, |
|
|
|
50, |
|
|
|
this.id |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.partnerProducts = data["hydra:member"]; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
getContactsData() { |
|
|
|
this.contactsSub = this.contactService.contactsGetCollection( |
|
|
|
this.contactsPageIndex + 1, |
|
|
|
this.contactsPageSize, |
|
|
|
this.id |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.contacts = data["hydra:member"]; |
|
|
|
this.contactsLength = Number(data["hydra:totalItems"]); |
|
|
|
if (this.contactsPaginator !== undefined) { |
|
|
|
this.contactsPaginator.length = this.contactsLength; |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
getPostsData() { |
|
|
|
this.postsSub = this.postService.postsGetCollection( |
|
|
|
this.postsPageIndex + 1, |
|
|
|
this.postsPageSize, |
|
|
|
this.id, |
|
|
|
undefined, |
|
|
|
undefined, |
|
|
|
undefined, |
|
|
|
undefined, |
|
|
|
undefined, |
|
|
|
false, |
|
|
|
false |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.posts = data["hydra:member"]; |
|
|
|
this.postsLength = Number(data["hydra:totalItems"]); |
|
|
|
this.posts.forEach(posts => { |
|
|
|
if (posts.id) { |
|
|
|
this.commentsVisibility.set(posts.id, false); |
|
|
|
} |
|
|
|
}); |
|
|
|
console.log('getPartnerProducts done'); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
@@ -237,18 +157,11 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
this.taskNotesVisibility.set(task.id, false); |
|
|
|
} |
|
|
|
}); |
|
|
|
console.log('getTasksData done'); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
contactsHandlePageEvent(e: PageEvent) { |
|
|
|
this.contactsPageEvent = e; |
|
|
|
this.contactsLength = e.length; |
|
|
|
this.contactsPageIndex = e.pageIndex.valueOf(); |
|
|
|
this.contactsPageSize = e.pageSize.valueOf(); |
|
|
|
this.getContactsData(); |
|
|
|
} |
|
|
|
|
|
|
|
tasksHandlePageEvent(e: PageEvent) { |
|
|
|
this.tasksPageEvent = e; |
|
|
|
this.tasksLength = e.length; |
|
|
|
@@ -257,31 +170,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
this.getTasksData(); |
|
|
|
} |
|
|
|
|
|
|
|
postsHandlePageEvent(e: PageEvent) { |
|
|
|
this.postsPageEvent = e; |
|
|
|
this.postsLength = e.length; |
|
|
|
this.postsPageIndex = e.pageIndex.valueOf(); |
|
|
|
this.postsPageSize = e.pageSize.valueOf(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
|
|
|
|
navigateToContactDetails(element: any) { |
|
|
|
const contact: ContactJsonld = element as ContactJsonld; |
|
|
|
this.router.navigate(['/contacts', this.apiConverter.extractId(contact.id)]); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewContact() { |
|
|
|
const modalRefContact = this.modalService.open(NewContactComponent, this.modalOptions); |
|
|
|
let contact: ContactJsonld = {} as ContactJsonld; |
|
|
|
contact.partner = this.partner.id ?? null; |
|
|
|
modalRefContact.componentInstance.contact = contact; |
|
|
|
modalRefContact.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefContact.dismiss(); |
|
|
|
this.getContactsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewTask() { |
|
|
|
const modalRefTask = this.modalService.open(NewTaskComponent, this.modalOptions); |
|
|
|
@@ -310,32 +198,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewPosting() { |
|
|
|
const modalRefPosting = this.modalService.open(NewPostingComponent, this.modalOptions); |
|
|
|
let posting: PostJsonld = {} as PostJsonld; |
|
|
|
posting.partner = this.partner.id ?? null; |
|
|
|
modalRefPosting.componentInstance.posting = posting; |
|
|
|
modalRefPosting.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefPosting.dismiss(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewComment(post: PostJsonld) { |
|
|
|
const modalRefComment = this.modalService.open(NewCommentComponent, this.modalOptions); |
|
|
|
let comment: CommentJsonld = {} as CommentJsonld; |
|
|
|
comment.post = post.id ?? null; |
|
|
|
modalRefComment.componentInstance.comment = comment; |
|
|
|
modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefComment.dismiss(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalEditTask(task: TaskJsonld) { |
|
|
|
const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.modalOptions); |
|
|
|
modalRefTaskEdit.componentInstance.task = task; |
|
|
|
@@ -359,28 +221,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalEditPosting(post: PostJsonld) { |
|
|
|
const modalRefPostingEdit = this.modalService.open(NewPostingComponent, this.modalOptions); |
|
|
|
modalRefPostingEdit.componentInstance.posting = post; |
|
|
|
modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefPostingEdit.dismiss(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalEditComment(comment: CommentJsonld) { |
|
|
|
const modalRefComment = this.modalService.open(NewCommentComponent, this.modalOptions); |
|
|
|
modalRefComment.componentInstance.comment = comment; |
|
|
|
modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefComment.dismiss(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalEditPartner() { |
|
|
|
const modalRef = this.modalService.open(NewPartnerComponent, this.modalOptions); |
|
|
|
modalRef.componentInstance.partner = this.partner; |
|
|
|
@@ -399,13 +239,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
showComments(post: PostJsonld) { |
|
|
|
if (post.id) { |
|
|
|
const currentVisibility = this.commentsVisibility.get(post.id); |
|
|
|
this.commentsVisibility.set(post.id, !currentVisibility); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getPartnerFollowedStatus() { |
|
|
|
this.partnerFollowSub = this.partnerFollowService.partnerFollowsGetCollection( |
|
|
|
1, |