| @@ -1633,6 +1633,18 @@ paths: | |||||
| style: form | style: form | ||||
| explode: true | explode: true | ||||
| allowReserved: false | allowReserved: false | ||||
| - | |||||
| name: product.name | |||||
| in: query | |||||
| description: '' | |||||
| required: false | |||||
| deprecated: false | |||||
| allowEmptyValue: true | |||||
| schema: | |||||
| type: string | |||||
| style: form | |||||
| explode: false | |||||
| allowReserved: false | |||||
| deprecated: false | deprecated: false | ||||
| post: | post: | ||||
| operationId: api_partner_products_post | operationId: api_partner_products_post | ||||
| @@ -2185,6 +2197,32 @@ paths: | |||||
| style: form | style: form | ||||
| explode: true | explode: true | ||||
| allowReserved: false | allowReserved: false | ||||
| - | |||||
| name: owner | |||||
| in: query | |||||
| description: '' | |||||
| required: false | |||||
| deprecated: false | |||||
| allowEmptyValue: true | |||||
| schema: | |||||
| type: string | |||||
| style: form | |||||
| explode: false | |||||
| allowReserved: false | |||||
| - | |||||
| name: 'owner[]' | |||||
| in: query | |||||
| description: '' | |||||
| required: false | |||||
| deprecated: false | |||||
| allowEmptyValue: true | |||||
| schema: | |||||
| type: array | |||||
| items: | |||||
| type: string | |||||
| style: form | |||||
| explode: true | |||||
| allowReserved: false | |||||
| - | - | ||||
| name: 'exists[contact]' | name: 'exists[contact]' | ||||
| in: query | in: query | ||||
| @@ -0,0 +1,32 @@ | |||||
| import {PageEvent} from "@angular/material/paginator"; | |||||
| import {error} from "@angular/compiler-cli/src/transformers/util"; | |||||
| export class ListComponent{ | |||||
| protected dataLength: number; | |||||
| protected pageEvent: PageEvent; | |||||
| protected pageSize: number; | |||||
| protected pageIndex: number; | |||||
| protected pageSizeOptions: number[]; | |||||
| constructor() { | |||||
| this.dataLength = 0; | |||||
| this.pageEvent = new PageEvent(); | |||||
| this.pageSize = 10; | |||||
| this.pageIndex = 0; | |||||
| this.pageSizeOptions = [10,20.30]; | |||||
| } | |||||
| getData() { | |||||
| error('implement in child class'); | |||||
| } | |||||
| handlePageEvent(e: PageEvent) { | |||||
| this.pageEvent = e; | |||||
| this.dataLength = e.length; | |||||
| this.pageIndex = e.pageIndex.valueOf(); | |||||
| this.pageSize = e.pageSize.valueOf(); | |||||
| this.getData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| <div class="spt-container"> | |||||
| <div class="contacts position-relative"> | |||||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewContact()">{{ 'basic.new-contact' | translate }} | |||||
| </button> | |||||
| <div class="row"> | |||||
| <div class="col-4" *ngFor="let contact of contacts"> | |||||
| <div class="card"> | |||||
| <div class="card-body row"> | |||||
| <div class="col-8"> | |||||
| <h2>{{ contact.firstName }} {{ contact.lastName }}</h2> | |||||
| <p><a href="mailto:{{contact.email}}">{{ contact.email }}</a><br/> | |||||
| {{ contact.phone }}<br/> | |||||
| {{ contact.position }}</p> | |||||
| </div> | |||||
| <div class="col-4"> | |||||
| <img *ngIf="contact.imageUrl !== null && contact.imageUrl !== undefined" | |||||
| ngSrc="{{contact.imageUrl}}" width="247" height="94" | |||||
| alt="{{contact.firstName}} {{contact.lastName}}" | |||||
| title="{{contact.firstName}} {{contact.lastName}}"/> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="d-flex justify-content-end mt-1 mb-4"> | |||||
| <span role="button" (click)="navigateToContactDetails(contact)" | |||||
| class="badge bg-secondary p-2">{{ 'basic.details' | translate }}</span> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <mat-paginator *ngIf="contactsLength > 0" class="rounded-1" | |||||
| [pageSizeOptions]="[6,12,18]" | |||||
| [length]="contactsLength" | |||||
| (page)="contactsHandlePageEvent($event)" | |||||
| [pageSize]="contactsPageSize" | |||||
| [pageIndex]="contactsPageIndex" | |||||
| showFirstLastButtons> | |||||
| </mat-paginator> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { ContactListComponent } from './contact-list.component'; | |||||
| describe('ContactsComponent', () => { | |||||
| let component: ContactListComponent; | |||||
| let fixture: ComponentFixture<ContactListComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [ContactListComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(ContactListComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,97 @@ | |||||
| import {ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||||
| import {Subscription} from "rxjs"; | |||||
| import {ContactJsonld, ContactService, PartnerJsonld} from "@app/core/api/v1"; | |||||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | |||||
| import {MatTableDataSource} from "@angular/material/table"; | |||||
| import {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact.component"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | |||||
| import {Router} from "@angular/router"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | |||||
| @Component({ | |||||
| selector: 'app-contact-list', | |||||
| templateUrl: './contact-list.component.html', | |||||
| styleUrl: './contact-list.component.scss' | |||||
| }) | |||||
| export class ContactListComponent implements OnInit { | |||||
| @Input() public partner!: PartnerJsonld; | |||||
| @ViewChild(MatPaginator) contactsPaginator: MatPaginator; | |||||
| protected contactsSub: Subscription; | |||||
| protected contacts: Array<ContactJsonld>; | |||||
| protected contactsDataSource; | |||||
| protected contactsLength: number; | |||||
| protected contactsPageEvent: PageEvent; | |||||
| protected contactsPageSize: number; | |||||
| protected contactsPageIndex: number; | |||||
| protected modalOptions: NgbModalOptions = { | |||||
| centered: true | |||||
| }; | |||||
| constructor( | |||||
| private router: Router, | |||||
| private modalService: NgbModal, | |||||
| private contactService: ContactService, | |||||
| protected apiConverter: ApiConverter | |||||
| ) { | |||||
| 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; | |||||
| } | |||||
| ngOnInit() { | |||||
| this.getContactsData(); | |||||
| } | |||||
| getContactsData() { | |||||
| this.contactsSub = this.contactService.contactsGetCollection( | |||||
| this.contactsPageIndex + 1, | |||||
| this.contactsPageSize, | |||||
| this.partner.id | |||||
| ).subscribe( | |||||
| data => { | |||||
| this.contacts = data["hydra:member"]; | |||||
| this.contactsLength = Number(data["hydra:totalItems"]); | |||||
| if (this.contactsPaginator !== undefined) { | |||||
| this.contactsPaginator.length = this.contactsLength; | |||||
| } | |||||
| console.log('getPartnerProducts done'); | |||||
| } | |||||
| ); | |||||
| } | |||||
| 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(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| navigateToContactDetails(element: any) { | |||||
| const contact: ContactJsonld = element as ContactJsonld; | |||||
| this.router.navigate(['/contacts', this.apiConverter.extractId(contact.id)]); | |||||
| } | |||||
| contactsHandlePageEvent(e: PageEvent) { | |||||
| this.contactsPageEvent = e; | |||||
| this.contactsLength = e.length; | |||||
| this.contactsPageIndex = e.pageIndex.valueOf(); | |||||
| this.contactsPageSize = e.pageSize.valueOf(); | |||||
| this.getContactsData(); | |||||
| } | |||||
| } | |||||
| @@ -4,13 +4,13 @@ import {Subscription} from "rxjs"; | |||||
| import {ActivatedRoute} from "@angular/router"; | import {ActivatedRoute} from "@angular/router"; | ||||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | ||||
| import {MatTableDataSource} from "@angular/material/table"; | import {MatTableDataSource} from "@angular/material/table"; | ||||
| import {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; | |||||
| import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; | |||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {NewContactComponent} from "@app/contacts/new-contact/new-contact.component"; | |||||
| import {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact.component"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {User} from "@app/_models"; | import {User} from "@app/_models"; | ||||
| import {AccountService} from "@app/_services"; | import {AccountService} from "@app/_services"; | ||||
| import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; | |||||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| import {constructorParametersDownlevelTransform} from "@angular/compiler-cli"; | import {constructorParametersDownlevelTransform} from "@angular/compiler-cli"; | ||||
| @@ -100,6 +100,8 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||||
| undefined, | undefined, | ||||
| undefined, | undefined, | ||||
| undefined, | undefined, | ||||
| undefined, | |||||
| undefined, | |||||
| false | false | ||||
| ).subscribe( | ).subscribe( | ||||
| data => { | data => { | ||||
| @@ -123,7 +125,7 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||||
| } | } | ||||
| openModalNewPosting() { | openModalNewPosting() { | ||||
| const modalRefPosting = this.modalService.open(NewPostingComponent, this.modalOptions); | |||||
| const modalRefPosting = this.modalService.open(NewPostComponent, this.modalOptions); | |||||
| let posting: PostJsonld = {} as PostJsonld; | let posting: PostJsonld = {} as PostJsonld; | ||||
| posting.contact = this.contact.id ?? null; | posting.contact = this.contact.id ?? null; | ||||
| posting.partner = this.contact.partner ?? null; | posting.partner = this.contact.partner ?? null; | ||||
| @@ -152,7 +154,7 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||||
| } | } | ||||
| openModalEditPosting(post: PostJsonld) { | openModalEditPosting(post: PostJsonld) { | ||||
| const modalRefPostingEdit = this.modalService.open(NewPostingComponent, this.modalOptions); | |||||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.modalOptions); | |||||
| modalRefPostingEdit.componentInstance.posting = post; | modalRefPostingEdit.componentInstance.posting = post; | ||||
| modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | ||||
| if (modalStatus === ModalStatus.Submitted) { | if (modalStatus === ModalStatus.Submitted) { | ||||
| @@ -8,10 +8,10 @@ import {MatTableDataSource, MatTableModule} from "@angular/material/table"; | |||||
| import {OrderFilter} from "@app/_models/orderFilter"; | import {OrderFilter} from "@app/_models/orderFilter"; | ||||
| import {DatePipe, NgIf} from "@angular/common"; | import {DatePipe, NgIf} from "@angular/common"; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {NewDocumentComponent} from "@app/documents/new-document/new-document.component"; | |||||
| import {NewDocumentComponent} from "@app/_views/documents/new-document/new-document.component"; | |||||
| import {TranslateModule} from "@ngx-translate/core"; | import {TranslateModule} from "@ngx-translate/core"; | ||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; | |||||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| @Component({ | @Component({ | ||||
| @@ -15,9 +15,9 @@ import { | |||||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {MatTableDataSource} from "@angular/material/table"; | import {MatTableDataSource} from "@angular/material/table"; | ||||
| 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 {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {NewTaskNoteComponent} from "@app/tasks/new-task-note/new-task-note.component"; | |||||
| import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| @Component({ | @Component({ | ||||
| @@ -1,5 +1,5 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="card"> | |||||
| <div *ngIf="partner" class="card"> | |||||
| <div class="card-body row"> | <div class="card-body row"> | ||||
| <div class="col-4"> | <div class="col-4"> | ||||
| <h1>{{ partner.name }}</h1> | <h1>{{ partner.name }}</h1> | ||||
| @@ -55,44 +55,7 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <app-toggle #toggleContacts [headline]="'basic.contacts' | translate"> | <app-toggle #toggleContacts [headline]="'basic.contacts' | translate"> | ||||
| <div class="spt-container"> | |||||
| <div class="contacts position-relative"> | |||||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewContact()">{{ 'basic.new-contact' | translate }} | |||||
| </button> | |||||
| <div class="row"> | |||||
| <div class="col-4" *ngFor="let contact of contacts"> | |||||
| <div class="card"> | |||||
| <div class="card-body row"> | |||||
| <div class="col-8"> | |||||
| <h2>{{ contact.firstName }} {{ contact.lastName }}</h2> | |||||
| <p><a href="mailto:{{contact.email}}">{{ contact.email }}</a><br/> | |||||
| {{ contact.phone }}<br/> | |||||
| {{ contact.position }}</p> | |||||
| </div> | |||||
| <div class="col-4"> | |||||
| <img *ngIf="contact.imageUrl !== null && contact.imageUrl !== undefined" | |||||
| ngSrc="{{contact.imageUrl}}" width="247" height="94" | |||||
| alt="{{contact.firstName}} {{contact.lastName}}" | |||||
| title="{{contact.firstName}} {{contact.lastName}}"/> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="d-flex justify-content-end mt-1 mb-4"> | |||||
| <span role="button" (click)="navigateToContactDetails(contact)" | |||||
| class="badge bg-secondary p-2">{{ 'basic.details' | translate }}</span> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <mat-paginator *ngIf="contacts.length > 0" class="rounded-1" | |||||
| [pageSizeOptions]="[6,12,18]" | |||||
| [length]="contactsLength" | |||||
| (page)="contactsHandlePageEvent($event)" | |||||
| [pageSize]="contactsPageSize" | |||||
| [pageIndex]="contactsPageIndex" | |||||
| showFirstLastButtons> | |||||
| </mat-paginator> | |||||
| </div> | |||||
| </div> | |||||
| <app-contact-list *ngIf="partner" #contactsComponent [partner]="partner"></app-contact-list> | |||||
| </app-toggle> | </app-toggle> | ||||
| <app-toggle #toggleTasks [headline]="'basic.tasks' | translate"> | <app-toggle #toggleTasks [headline]="'basic.tasks' | translate"> | ||||
| @@ -156,61 +119,5 @@ | |||||
| </div> | </div> | ||||
| </app-toggle> | </app-toggle> | ||||
| <app-toggle #togglePosts [headline]="'basic.posts' | translate"> | <app-toggle #togglePosts [headline]="'basic.posts' | translate"> | ||||
| <div class="spt-container"> | |||||
| <div class="posts position-relative"> | |||||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewPosting()">{{ 'basic.new-post' | translate }}</button> | |||||
| <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.ownerName }}</p> | |||||
| </div> | |||||
| <div> | |||||
| <h3>{{ post.headline }}</h3> | |||||
| <p class="m-0" [innerHTML]="apiConverter.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]="apiConverter.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> | |||||
| <mat-paginator *ngIf="posts.length > 0" class="rounded-1" | |||||
| [pageSizeOptions]="[10,20,30]" | |||||
| [length]="postsLength" | |||||
| (page)="postsHandlePageEvent($event)" | |||||
| [pageSize]="postsPageSize" | |||||
| [pageIndex]="postsPageIndex" | |||||
| showFirstLastButtons> | |||||
| </mat-paginator> | |||||
| </div> | |||||
| </div> | |||||
| <app-post-list *ngIf="partner" #postsComponent [partner]="partner" [existsContact]="false" [existsSale]="false"></app-post-list> | |||||
| </app-toggle> | </app-toggle> | ||||
| @@ -1,30 +1,25 @@ | |||||
| import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; | import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | 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 {ActivatedRoute, Router} from "@angular/router"; | ||||
| import { | import { | ||||
| CommentJsonld, | |||||
| ContactJsonld, | |||||
| ContactService, PartnerFollowJsonld, PartnerFollowService, | |||||
| PartnerFollowJsonld, PartnerFollowService, | |||||
| PartnerJsonld, PartnerProductJsonld, PartnerProductService, | PartnerJsonld, PartnerProductJsonld, PartnerProductService, | ||||
| PartnerService, | |||||
| PostJsonld, | |||||
| PostService, TaskJsonld, TaskNoteJsonld, TaskService | |||||
| PartnerService, TaskJsonld, TaskNoteJsonld, TaskService | |||||
| } from "@app/core/api/v1"; | } from "@app/core/api/v1"; | ||||
| import {Subscription} from "rxjs"; | import {Subscription} from "rxjs"; | ||||
| import {environment} from "@environments/environment"; | import {environment} from "@environments/environment"; | ||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | ||||
| import {MatTableDataSource} from "@angular/material/table"; | 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 {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {AccountService} from "@app/_services"; | import {AccountService} from "@app/_services"; | ||||
| import {User} from "@app/_models"; | 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 {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({ | @Component({ | ||||
| selector: 'app-partners-detail', | selector: 'app-partners-detail', | ||||
| @@ -33,11 +28,14 @@ import {ToggleComponent} from "@app/_components/toggle/toggle.component"; | |||||
| }) | }) | ||||
| export class PartnersDetailComponent implements OnInit, AfterViewInit { | export class PartnersDetailComponent implements OnInit, AfterViewInit { | ||||
| @ViewChild("toggleContacts", { static: true }) toggleContacts: ToggleComponent = new ToggleComponent(); | @ViewChild("toggleContacts", { static: true }) toggleContacts: ToggleComponent = new ToggleComponent(); | ||||
| @ViewChild("contactsComponent", { static: false }) contactsComponent!: ContactListComponent; | |||||
| @ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent(); | @ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent(); | ||||
| @ViewChild("togglePosts", { static: true }) togglePosts: 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) tasksPaginator: MatPaginator; | ||||
| @ViewChild(MatPaginator) postsPaginator: MatPaginator; | |||||
| protected user: User | null; | protected user: User | null; | ||||
| @@ -45,7 +43,7 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| protected id: string; | protected id: string; | ||||
| protected partnerDetailSub: Subscription; | protected partnerDetailSub: Subscription; | ||||
| protected partner: PartnerJsonld; | |||||
| protected partner!: PartnerJsonld; | |||||
| protected partnerProductSub: Subscription; | protected partnerProductSub: Subscription; | ||||
| protected partnerProducts: Array<PartnerProductJsonld>; | protected partnerProducts: Array<PartnerProductJsonld>; | ||||
| @@ -53,14 +51,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| protected partnerFollowSub: Subscription; | protected partnerFollowSub: Subscription; | ||||
| protected partnerFollow: PartnerFollowJsonld | null; | 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 tasksSub: Subscription; | ||||
| protected tasks: Array<TaskJsonld>; | protected tasks: Array<TaskJsonld>; | ||||
| protected tasksDataSource; | protected tasksDataSource; | ||||
| @@ -70,15 +60,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| protected tasksPageIndex: number; | protected tasksPageIndex: number; | ||||
| protected taskNotesVisibility: Map<string, boolean>; | 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 = { | protected modalOptions: NgbModalOptions = { | ||||
| centered: true | centered: true | ||||
| @@ -92,14 +73,12 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| private partnerService: PartnerService, | private partnerService: PartnerService, | ||||
| private partnerProductService: PartnerProductService, | private partnerProductService: PartnerProductService, | ||||
| private partnerFollowService: PartnerFollowService, | private partnerFollowService: PartnerFollowService, | ||||
| private contactService: ContactService, | |||||
| private postService: PostService, | |||||
| private taskService: TaskService, | private taskService: TaskService, | ||||
| protected apiConverter: ApiConverter | protected apiConverter: ApiConverter | ||||
| ) { | ) { | ||||
| this.id = ""; | this.id = ""; | ||||
| this.partnerDetailSub = new Subscription(); | this.partnerDetailSub = new Subscription(); | ||||
| this.partner = {} as PartnerJsonld; | |||||
| //this.partner = {} as PartnerJsonld; | |||||
| this.partnerProductSub = new Subscription(); | this.partnerProductSub = new Subscription(); | ||||
| this.partnerProducts = []; | this.partnerProducts = []; | ||||
| @@ -109,15 +88,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| this.user = this.accountService.userValue; | 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.tasksSub = new Subscription(); | ||||
| this.tasks = []; | this.tasks = []; | ||||
| this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); | this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); | ||||
| @@ -127,16 +97,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| this.tasksPageSize = 10; | this.tasksPageSize = 10; | ||||
| this.tasksPageIndex = 0; | this.tasksPageIndex = 0; | ||||
| this.taskNotesVisibility = new Map<string, boolean>(); | 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() { | ngOnInit() { | ||||
| @@ -145,16 +105,15 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| }); | }); | ||||
| this.getPartnerData(); | this.getPartnerData(); | ||||
| this.getPartnerProducts(); | this.getPartnerProducts(); | ||||
| this.getContactsData(); | |||||
| this.getPostsData(); | |||||
| this.getTasksData(); | this.getTasksData(); | ||||
| this.getPartnerFollowedStatus(); | this.getPartnerFollowedStatus(); | ||||
| console.log('ng init done'); | |||||
| } | } | ||||
| ngAfterViewInit() { | ngAfterViewInit() { | ||||
| this.contactsDataSource.paginator = this.contactsPaginator; | |||||
| console.log('ng after view init'); | |||||
| this.tasksDataSource.paginator = this.tasksPaginator; | this.tasksDataSource.paginator = this.tasksPaginator; | ||||
| this.postsDataSource.paginator = this.postsPaginator; | |||||
| } | } | ||||
| getPartnerData() { | getPartnerData() { | ||||
| @@ -163,59 +122,20 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| ).subscribe( | ).subscribe( | ||||
| data => { | data => { | ||||
| this.partner = data; | this.partner = data; | ||||
| console.log('getPartnerData done'); | |||||
| } | } | ||||
| ); | ); | ||||
| } | } | ||||
| getPartnerProducts() { | getPartnerProducts() { | ||||
| this.partnerProductSub = this.partnerProductService.partnerProductsGetCollection( | this.partnerProductSub = this.partnerProductService.partnerProductsGetCollection( | ||||
| this.contactsPageIndex + 1, | |||||
| this.contactsPageSize, | |||||
| 1, | |||||
| 50, | |||||
| this.id | this.id | ||||
| ).subscribe( | ).subscribe( | ||||
| data => { | data => { | ||||
| this.partnerProducts = data["hydra:member"]; | 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); | 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) { | tasksHandlePageEvent(e: PageEvent) { | ||||
| this.tasksPageEvent = e; | this.tasksPageEvent = e; | ||||
| this.tasksLength = e.length; | this.tasksLength = e.length; | ||||
| @@ -257,31 +170,6 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| this.getTasksData(); | 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() { | openModalNewTask() { | ||||
| const modalRefTask = this.modalService.open(NewTaskComponent, this.modalOptions); | 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) { | openModalEditTask(task: TaskJsonld) { | ||||
| const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.modalOptions); | const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.modalOptions); | ||||
| modalRefTaskEdit.componentInstance.task = task; | 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() { | openModalEditPartner() { | ||||
| const modalRef = this.modalService.open(NewPartnerComponent, this.modalOptions); | const modalRef = this.modalService.open(NewPartnerComponent, this.modalOptions); | ||||
| modalRef.componentInstance.partner = this.partner; | 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() { | getPartnerFollowedStatus() { | ||||
| this.partnerFollowSub = this.partnerFollowService.partnerFollowsGetCollection( | this.partnerFollowSub = this.partnerFollowService.partnerFollowsGetCollection( | ||||
| 1, | 1, | ||||
| @@ -9,7 +9,7 @@ import {OrderFilter} from "@app/_models/orderFilter"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| import {NgIf} from "@angular/common"; | import {NgIf} from "@angular/common"; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {NewPartnerComponent} from "@app/partners/new-partner/new-partner.component"; | |||||
| import {NewPartnerComponent} from "@app/_views/partners/new-partner/new-partner.component"; | |||||
| import {TranslateModule, TranslateService} from "@ngx-translate/core"; | import {TranslateModule, TranslateService} from "@ngx-translate/core"; | ||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import TypeEnum = PartnerJsonld.PartnerTypeEnum; | import TypeEnum = PartnerJsonld.PartnerTypeEnum; | ||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { NewPostComponent } from './new-post.component'; | |||||
| describe('NewPostComponent', () => { | |||||
| let component: NewPostComponent; | |||||
| let fixture: ComponentFixture<NewPostComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [NewPostComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(NewPostComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -8,11 +8,11 @@ import {ApiConverter} from "@app/_helpers/api.converter"; | |||||
| import {Subscription} from "rxjs"; | import {Subscription} from "rxjs"; | ||||
| @Component({ | @Component({ | ||||
| selector: 'app-new-posting', | |||||
| templateUrl: './new-posting.component.html', | |||||
| styleUrl: './new-posting.component.scss' | |||||
| selector: 'app-new-post', | |||||
| templateUrl: './new-post.component.html', | |||||
| styleUrl: './new-post.component.scss' | |||||
| }) | }) | ||||
| export class NewPostingComponent implements OnInit { | |||||
| export class NewPostComponent implements OnInit { | |||||
| @Input() public posting!: PostJsonld; | @Input() public posting!: PostJsonld; | ||||
| @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | ||||
| @@ -0,0 +1,57 @@ | |||||
| <div class="spt-container"> | |||||
| <div class="posts position-relative"> | |||||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewPosting()">{{ 'basic.new-post' | translate }}</button> | |||||
| <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.ownerName }}</p> | |||||
| </div> | |||||
| <div> | |||||
| <h3>{{ post.headline }}</h3> | |||||
| <p class="m-0" [innerHTML]="apiConverter.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]="apiConverter.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> | |||||
| <mat-paginator *ngIf="posts.length > 0" class="rounded-1" | |||||
| [pageSizeOptions]="this.pageSizeOptions" | |||||
| [length]="dataLength" | |||||
| (page)="handlePageEvent($event)" | |||||
| [pageSize]="pageSize" | |||||
| [pageIndex]="pageIndex" | |||||
| showFirstLastButtons> | |||||
| </mat-paginator> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { PostListComponent } from './post-list.component'; | |||||
| describe('PostsComponent', () => { | |||||
| let component: PostListComponent; | |||||
| let fixture: ComponentFixture<PostListComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [PostListComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(PostListComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,161 @@ | |||||
| import {AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||||
| import {Subscription} from "rxjs"; | |||||
| import { | |||||
| CommentJsonld, | |||||
| ContactJsonld, | |||||
| PartnerJsonld, | |||||
| PartnerProductJsonld, PartnerProductService, | |||||
| PostJsonld, | |||||
| PostService, | |||||
| SaleJsonld, UserJsonld | |||||
| } from "@app/core/api/v1"; | |||||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | |||||
| import {MatTableDataSource} from "@angular/material/table"; | |||||
| import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | |||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | |||||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||||
| import {ListComponent} from "@app/_components/list/list.component"; | |||||
| @Component({ | |||||
| selector: 'app-post-list', | |||||
| templateUrl: './post-list.component.html', | |||||
| styleUrl: './post-list.component.scss' | |||||
| }) | |||||
| export class PostListComponent extends ListComponent implements OnInit, AfterViewInit { | |||||
| @Input() public partner!: PartnerJsonld; | |||||
| @Input() public contact!: ContactJsonld; | |||||
| @Input() public sale!: SaleJsonld; | |||||
| @Input() public user!: UserJsonld; | |||||
| @Input() public existsContact!: boolean; | |||||
| @Input() public existsSale!: boolean; | |||||
| @ViewChild(MatPaginator) postsPaginator: MatPaginator; | |||||
| protected postsSub: Subscription; | |||||
| protected posts: Array<PostJsonld>; | |||||
| protected partnerProductsSub: Subscription; | |||||
| protected partnerProducts: Array<PartnerProductJsonld>; | |||||
| protected postsDataSource; | |||||
| protected postsLength: number; | |||||
| protected postsPageEvent: PageEvent; | |||||
| protected postsPageSize: number; | |||||
| protected postsPageIndex: number; | |||||
| protected commentsVisibility: Map<string, boolean>; | |||||
| protected modalOptions: NgbModalOptions = { | |||||
| centered: true | |||||
| }; | |||||
| constructor( | |||||
| private postService: PostService, | |||||
| private partnerProductService: PartnerProductService, | |||||
| private modalService: NgbModal, | |||||
| protected apiConverter: ApiConverter | |||||
| ) { | |||||
| super(); | |||||
| this.postsSub = new Subscription(); | |||||
| this.posts = []; | |||||
| this.partnerProductsSub = new Subscription(); | |||||
| this.partnerProducts = []; | |||||
| 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() { | |||||
| this.getData(); | |||||
| } | |||||
| ngAfterViewInit() { | |||||
| this.postsDataSource.paginator = this.postsPaginator; | |||||
| } | |||||
| override getData() { | |||||
| this.postsSub = this.postService.postsGetCollection( | |||||
| this.postsPageIndex + 1, | |||||
| this.postsPageSize, | |||||
| this.partner !== undefined ? this.partner.id : undefined, | |||||
| undefined, | |||||
| this.contact !== undefined ? this.contact.id : undefined, | |||||
| undefined, | |||||
| this.sale !== undefined ? this.sale.id : undefined, | |||||
| undefined, | |||||
| this.user !== undefined ? this.user.id : undefined, | |||||
| undefined, | |||||
| this.existsContact !== undefined ? this.existsContact : undefined, | |||||
| this.existsSale !== undefined ? this.existsContact : undefined | |||||
| ).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); | |||||
| } | |||||
| }); | |||||
| } | |||||
| ); | |||||
| } | |||||
| showComments(post: PostJsonld) { | |||||
| if (post.id) { | |||||
| const currentVisibility = this.commentsVisibility.get(post.id); | |||||
| this.commentsVisibility.set(post.id, !currentVisibility); | |||||
| } | |||||
| } | |||||
| openModalNewPosting() { | |||||
| const modalRefPosting = this.modalService.open(NewPostComponent, 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.getData(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| openModalEditPosting(post: PostJsonld) { | |||||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.modalOptions); | |||||
| modalRefPostingEdit.componentInstance.posting = post; | |||||
| modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||||
| if (modalStatus === ModalStatus.Submitted) { | |||||
| modalRefPostingEdit.dismiss(); | |||||
| this.getData(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| 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.getData(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| 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.getData(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| @@ -1,18 +1,18 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
| import { PostingsComponent } from './postings.component'; | |||||
| import { PostsComponent } from './posts.component'; | |||||
| describe('PostingsComponent', () => { | describe('PostingsComponent', () => { | ||||
| let component: PostingsComponent; | |||||
| let fixture: ComponentFixture<PostingsComponent>; | |||||
| let component: PostsComponent; | |||||
| let fixture: ComponentFixture<PostsComponent>; | |||||
| beforeEach(async () => { | beforeEach(async () => { | ||||
| await TestBed.configureTestingModule({ | await TestBed.configureTestingModule({ | ||||
| declarations: [PostingsComponent] | |||||
| declarations: [PostsComponent] | |||||
| }) | }) | ||||
| .compileComponents(); | .compileComponents(); | ||||
| fixture = TestBed.createComponent(PostingsComponent); | |||||
| fixture = TestBed.createComponent(PostsComponent); | |||||
| component = fixture.componentInstance; | component = fixture.componentInstance; | ||||
| fixture.detectChanges(); | fixture.detectChanges(); | ||||
| }); | }); | ||||
| @@ -0,0 +1,10 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-posts', | |||||
| templateUrl: './posts.component.html', | |||||
| styleUrl: './posts.component.scss' | |||||
| }) | |||||
| export class PostsComponent { | |||||
| } | |||||
| @@ -10,7 +10,7 @@ import { | |||||
| } from "@app/core/api/v1"; | } from "@app/core/api/v1"; | ||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {NewProductComponent} from "@app/products/new-product/new-product.component"; | |||||
| import {NewProductComponent} from "@app/_views/products/new-product/new-product.component"; | |||||
| import {User} from "@app/_models"; | import {User} from "@app/_models"; | ||||
| import {AccountService} from "@app/_services"; | import {AccountService} from "@app/_services"; | ||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| @@ -9,7 +9,7 @@ import {Router, RouterLink, RouterLinkActive} from "@angular/router"; | |||||
| import {NgIf} from "@angular/common"; | import {NgIf} from "@angular/common"; | ||||
| import {Subscription} from "rxjs"; | import {Subscription} from "rxjs"; | ||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {NewProductComponent} from "@app/products/new-product/new-product.component"; | |||||
| import {NewProductComponent} from "@app/_views/products/new-product/new-product.component"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {TranslateModule} from "@ngx-translate/core"; | import {TranslateModule} from "@ngx-translate/core"; | ||||
| @@ -10,4 +10,4 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | |||||
| </div> | |||||
| @@ -6,11 +6,11 @@ import {CommentJsonld, ContactJsonld, PostJsonld, PostService, SaleJsonld, SaleS | |||||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {User} from "@app/_models"; | import {User} from "@app/_models"; | ||||
| import {AccountService} from "@app/_services"; | import {AccountService} from "@app/_services"; | ||||
| import {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; | |||||
| import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; | |||||
| import {NewContactComponent} from "@app/contacts/new-contact/new-contact.component"; | |||||
| import {NewSaleComponent} from "@app/sales/new-sale/new-sale.component"; | |||||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||||
| import {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact.component"; | |||||
| import {NewSaleComponent} from "@app/_views/sales/new-sale/new-sale.component"; | |||||
| import {ActivatedRoute} from "@angular/router"; | import {ActivatedRoute} from "@angular/router"; | ||||
| import {ApiConverter} from "@app/_helpers/api.converter"; | import {ApiConverter} from "@app/_helpers/api.converter"; | ||||
| @@ -100,6 +100,8 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { | |||||
| this.id, | this.id, | ||||
| undefined, | undefined, | ||||
| undefined, | undefined, | ||||
| undefined, | |||||
| undefined, | |||||
| true | true | ||||
| ).subscribe( | ).subscribe( | ||||
| data => { | data => { | ||||
| @@ -124,7 +126,7 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { | |||||
| } | } | ||||
| openModalNewPosting() { | openModalNewPosting() { | ||||
| const modalRefPosting = this.modalService.open(NewPostingComponent, this.modalOptions); | |||||
| const modalRefPosting = this.modalService.open(NewPostComponent, this.modalOptions); | |||||
| let posting: PostJsonld = {} as PostJsonld; | let posting: PostJsonld = {} as PostJsonld; | ||||
| posting.sale = this.sale.id ?? null; | posting.sale = this.sale.id ?? null; | ||||
| posting.partner = this.sale.partner ?? null; | posting.partner = this.sale.partner ?? null; | ||||
| @@ -152,7 +154,7 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { | |||||
| } | } | ||||
| openModalEditPosting(post: PostJsonld) { | openModalEditPosting(post: PostJsonld) { | ||||
| const modalRefPostingEdit = this.modalService.open(NewPostingComponent, this.modalOptions); | |||||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.modalOptions); | |||||
| modalRefPostingEdit.componentInstance.posting = post; | modalRefPostingEdit.componentInstance.posting = post; | ||||
| modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | ||||
| if (modalStatus === ModalStatus.Submitted) { | if (modalStatus === ModalStatus.Submitted) { | ||||