|
|
|
@@ -12,6 +12,8 @@ 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 {ModalStatus} from "@app/_helpers/modal.states"; |
|
|
|
import {AccountService} from "@app/_services"; |
|
|
|
import {User} from "@app/_models"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-partners-detail', |
|
|
|
@@ -21,7 +23,9 @@ import {ModalStatus} from "@app/_helpers/modal.states"; |
|
|
|
export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
@ViewChild(MatPaginator) contactsPaginator: MatPaginator; |
|
|
|
// @ViewChild(MatPaginator) tasksPaginator: MatPaginator; |
|
|
|
// @ViewChild(MatPaginator) postsPaginator: MatPaginator; |
|
|
|
@ViewChild(MatPaginator) postsPaginator: MatPaginator; |
|
|
|
|
|
|
|
protected user: User | null; |
|
|
|
|
|
|
|
protected readonly environment = environment; |
|
|
|
protected id: string; |
|
|
|
@@ -42,19 +46,20 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
// protected tasksPageEvent: PageEvent; |
|
|
|
// protected tasksPageSize: number; |
|
|
|
// protected tasksPageIndex: number; |
|
|
|
// |
|
|
|
// protected postsSub: Subscription; |
|
|
|
// protected posts: Array<PostJsonld>; |
|
|
|
// protected postsDataSource; |
|
|
|
// protected postsLength: number; |
|
|
|
// protected postsPageEvent: PageEvent; |
|
|
|
// protected postsPageSize: number; |
|
|
|
// protected postsPageIndex: number; |
|
|
|
|
|
|
|
protected postsSub: Subscription; |
|
|
|
protected posts: Array<PostJsonld>; |
|
|
|
protected postsDataSource; |
|
|
|
protected postsLength: number; |
|
|
|
protected postsPageEvent: PageEvent; |
|
|
|
protected postsPageSize: number; |
|
|
|
protected postsPageIndex: number; |
|
|
|
|
|
|
|
protected readonly ModalComponent = ModalComponent; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private router: Router, |
|
|
|
private accountService: AccountService, |
|
|
|
private modalService: NgbModal, |
|
|
|
private route: ActivatedRoute, |
|
|
|
private partnerService: PartnerService, |
|
|
|
@@ -65,6 +70,8 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
this.partnerDetailSub = new Subscription(); |
|
|
|
this.partner = {} as PartnerJsonld; |
|
|
|
|
|
|
|
this.user = this.accountService.userValue; |
|
|
|
|
|
|
|
this.contactsSub = new Subscription(); |
|
|
|
this.contacts = []; |
|
|
|
this.contactsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
@@ -82,15 +89,14 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
// this.tasksPageSize = 10; |
|
|
|
// this.tasksPageIndex = 0; |
|
|
|
|
|
|
|
// TODO: Change Jsonld |
|
|
|
// this.postsSub = new Subscription(); |
|
|
|
// this.posts = []; |
|
|
|
// this.postsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
// this.postsDataSource = new MatTableDataSource<ContactJsonld>(this.contacts); |
|
|
|
// this.postsLength = 0; |
|
|
|
// this.postsPageEvent = new PageEvent(); |
|
|
|
// this.postsPageSize = 30; |
|
|
|
// this.postsPageIndex = 0; |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
@@ -105,7 +111,7 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
ngAfterViewInit() { |
|
|
|
this.contactsDataSource.paginator = this.contactsPaginator; |
|
|
|
// this.tasksDataSource.paginator = this.tasksPaginator; |
|
|
|
// this.postsDataSource.paginator = this.postsPaginator; |
|
|
|
this.postsDataSource.paginator = this.postsPaginator; |
|
|
|
} |
|
|
|
|
|
|
|
getPartnerData() { |
|
|
|
@@ -135,17 +141,17 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
} |
|
|
|
|
|
|
|
getPostsData() { |
|
|
|
// this.postsSub = this.postService.postsGetCollection( |
|
|
|
// this.postsPageIndex + 1, |
|
|
|
// 10, |
|
|
|
// this.id |
|
|
|
// ).subscribe( |
|
|
|
// data => { |
|
|
|
// this.posts = data["hydra:member"]; |
|
|
|
// this.postsLength = Number(data["hydra:totalItems"]); |
|
|
|
// this.postsPaginator.length = this.postsLength; |
|
|
|
// } |
|
|
|
// ); |
|
|
|
this.postsSub = this.postService.postsGetCollection( |
|
|
|
this.postsPageIndex + 1, |
|
|
|
this.postsPageSize, |
|
|
|
this.id |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.posts = data["hydra:member"]; |
|
|
|
this.postsLength = Number(data["hydra:totalItems"]); |
|
|
|
// this.postsPaginator.length = this.postsLength; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
contactsHandlePageEvent(e: PageEvent) { |
|
|
|
@@ -165,11 +171,11 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
} |
|
|
|
|
|
|
|
postsHandlePageEvent(e: PageEvent) { |
|
|
|
// this.postsPageEvent = e; |
|
|
|
// this.postsLength = e.length; |
|
|
|
// this.postsPageIndex = e.pageIndex.valueOf(); |
|
|
|
// this.postsPageSize = e.pageSize.valueOf(); |
|
|
|
// this.getPostsData(); |
|
|
|
this.postsPageEvent = e; |
|
|
|
this.postsLength = e.length; |
|
|
|
this.postsPageIndex = e.pageIndex.valueOf(); |
|
|
|
this.postsPageSize = e.pageSize.valueOf(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
|
|
|
|
navigateToContactDetails(element: any) { |
|
|
|
@@ -178,23 +184,40 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewContact() { |
|
|
|
const modalRef = this.modalService.open(NewContactComponent); |
|
|
|
const modalRefContact = this.modalService.open(NewContactComponent); |
|
|
|
let contact: ContactJsonld = {} as ContactJsonld; |
|
|
|
contact.partner = this.partner.id ?? null; |
|
|
|
modalRef.componentInstance.contact = contact; |
|
|
|
modalRef.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
modalRefContact.componentInstance.contact = contact; |
|
|
|
modalRefContact.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRef.dismiss(); |
|
|
|
modalRefContact.dismiss(); |
|
|
|
this.getContactsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewPosting() { |
|
|
|
// TODO |
|
|
|
const modalRef = this.modalService.open(ModalComponent); |
|
|
|
modalRef.componentInstance.dynamicComponent = NewPostingComponent; |
|
|
|
const modalRefPosting = this.modalService.open(NewPostingComponent); |
|
|
|
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(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalEditPosting(post: PostJsonld) { |
|
|
|
const modalRefPostingEdit = this.modalService.open(NewPostingComponent); |
|
|
|
modalRefPostingEdit.componentInstance.posting = post; |
|
|
|
modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { |
|
|
|
if (modalStatus === ModalStatus.Submitted) { |
|
|
|
modalRefPostingEdit.dismiss(); |
|
|
|
this.getPostsData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
openModalNewTask() { |
|
|
|
|