| @@ -42,6 +42,11 @@ export class PagingComponent implements OnInit { | |||
| ngAfterViewInit() { | |||
| this.dataSource = this.paginator; | |||
| console.log('paging after init'); | |||
| //this.getDataFunction(); | |||
| } | |||
| initData() { | |||
| this.getDataFunction(); | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| import {Component, Input, ViewChild} from '@angular/core'; | |||
| import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||
| import {Subscription} from "rxjs"; | |||
| import {ContactJsonld, ContactService, PartnerJsonld} from "@app/core/api/v1"; | |||
| import {MatTableDataSource} from "@angular/material/table"; | |||
| @@ -12,10 +12,10 @@ import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| templateUrl: './contact-list.component.html', | |||
| styleUrl: './contact-list.component.scss' | |||
| }) | |||
| export class ContactListComponent { | |||
| export class ContactListComponent implements OnInit, AfterViewInit { | |||
| @Input() public partner!: PartnerJsonld; | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent: PagingComponent = new PagingComponent(); | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | |||
| protected contactsSub: Subscription; | |||
| protected contacts: Array<ContactJsonld>; | |||
| @@ -31,6 +31,13 @@ export class ContactListComponent { | |||
| this.dataSource = new MatTableDataSource<ContactJsonld>(this.contacts); | |||
| } | |||
| ngOnInit(): void { | |||
| } | |||
| ngAfterViewInit(): void { | |||
| this.pagingComponent.initData(); | |||
| } | |||
| getData = () => { | |||
| this.contactsSub = this.contactService.contactsGetCollection( | |||
| this.pagingComponent.getPageIndex(), | |||
| @@ -20,7 +20,15 @@ | |||
| alt="{{contact.firstName}} {{contact.lastName}}" title="{{contact.firstName}} {{contact.lastName}}"/> | |||
| </div> | |||
| <span class="position-absolute bi bi-pencil p-2" data-type="user-tool" data-action="edit" | |||
| (click)="openModalEditContact()"></span> | |||
| (click)="openModalEditContact()"> | |||
| </span> | |||
| <div class="card-body row" *ngIf="contactPartnerProducts"> | |||
| <div class="col-12"> | |||
| <ul *ngFor="let contactPartnerProduct of contactPartnerProducts"> | |||
| <li><a href="/products/{{this.appHelperService.extractId(contactPartnerProduct.productName)}}">{{contactPartnerProduct.productName}}</a></li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -1,26 +1,16 @@ | |||
| import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; | |||
| import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; | |||
| import { | |||
| CommentJsonld, | |||
| ContactJsonld, | |||
| ContactJsonld, ContactPartnerProduct, ContactPartnerProductService, | |||
| ContactService, | |||
| PartnerJsonld, | |||
| PartnerService, | |||
| PostJsonld, | |||
| PostService | |||
| } from "@app/core/api/v1"; | |||
| import {Subscription} from "rxjs"; | |||
| import {ActivatedRoute} from "@angular/router"; | |||
| 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 {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | |||
| import {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact.component"; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| import {User} from "@app/_models"; | |||
| import {AccountService} from "@app/_services"; | |||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {constructorParametersDownlevelTransform} from "@angular/compiler-cli"; | |||
| import {PostListComponent} from "@app/_views/posts/post-list/post-list.component"; | |||
| import {ToggleComponent} from "@app/_components/toggle/toggle.component"; | |||
| @@ -39,16 +29,17 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| protected contact!: ContactJsonld; | |||
| protected contactSub: Subscription; | |||
| protected partner!: PartnerJsonld; | |||
| protected contactPartnerProducts: Array<ContactPartnerProduct>; | |||
| protected partnerSub: Subscription; | |||
| protected contactProductSub: Subscription; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected modalOptions: NgbModalOptions = { | |||
| centered: true | |||
| }; | |||
| constructor( | |||
| private contactService: ContactService, | |||
| private partnerService: PartnerService, | |||
| private accountService: AccountService, | |||
| private contactProductService: ContactPartnerProductService, | |||
| private route: ActivatedRoute, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| @@ -56,6 +47,8 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| this.contactSub = new Subscription(); | |||
| this.commentsVisibility = new Map<string, boolean>(); | |||
| this.partnerSub = new Subscription(); | |||
| this.contactProductSub = new Subscription(); | |||
| this.contactPartnerProducts = []; | |||
| } | |||
| ngOnInit() { | |||
| @@ -76,12 +69,14 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| ).subscribe( | |||
| data => { | |||
| this.contact = data; | |||
| this.getPartnerData() | |||
| this.getPartnerData(); | |||
| this.getContactProducts(); | |||
| } | |||
| ); | |||
| } | |||
| getPartnerData() { | |||
| getPartnerData = () => { | |||
| this.partnerSub = this.partnerService.partnersIdGet( | |||
| this.appHelperService.extractId(this.contact.partner) | |||
| ).subscribe( | |||
| @@ -91,6 +86,18 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| ) | |||
| } | |||
| getContactProducts() { | |||
| this.contactProductSub = this.contactProductService.contactPartnerProductsGetCollection( | |||
| 1, | |||
| 50, | |||
| this.contact.id | |||
| ).subscribe( | |||
| data => { | |||
| this.contactPartnerProducts = data["hydra:member"]; | |||
| } | |||
| ); | |||
| } | |||
| openModalEditContact() { | |||
| let data: any = { 'contact': this.contact } | |||
| if (this.contact.birthday !== undefined) { | |||
| @@ -2,7 +2,7 @@ import {ChangeDetectorRef, Component, ViewChild} from '@angular/core'; | |||
| import {MatSort, MatSortModule, Sort} from "@angular/material/sort"; | |||
| import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; | |||
| import {Subscription} from "rxjs"; | |||
| import {DocumentJsonld, DocumentService, ProductJsonld} from "@app/core/api/v1"; | |||
| import {DocumentJsonld, DocumentService} from "@app/core/api/v1"; | |||
| import {Router, RouterLink, RouterLinkActive} from "@angular/router"; | |||
| import {MatTableDataSource, MatTableModule} from "@angular/material/table"; | |||
| import {OrderFilter} from "@app/_models/orderFilter"; | |||
| @@ -0,0 +1 @@ | |||
| <p>partner-list works!</p> | |||
| @@ -0,0 +1,23 @@ | |||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||
| import { PartnerListComponent } from './partner-list.component'; | |||
| describe('PartnerListComponent', () => { | |||
| let component: PartnerListComponent; | |||
| let fixture: ComponentFixture<PartnerListComponent>; | |||
| beforeEach(async () => { | |||
| await TestBed.configureTestingModule({ | |||
| declarations: [PartnerListComponent] | |||
| }) | |||
| .compileComponents(); | |||
| fixture = TestBed.createComponent(PartnerListComponent); | |||
| component = fixture.componentInstance; | |||
| fixture.detectChanges(); | |||
| }); | |||
| it('should create', () => { | |||
| expect(component).toBeTruthy(); | |||
| }); | |||
| }); | |||
| @@ -0,0 +1,26 @@ | |||
| import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; | |||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| @Component({ | |||
| selector: 'app-partner-list', | |||
| templateUrl: './partner-list.component.html', | |||
| styleUrl: './partner-list.component.scss' | |||
| }) | |||
| export class PartnerListComponent implements OnInit, AfterViewInit { | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | |||
| constructor( | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| } | |||
| ngOnInit(): void { | |||
| } | |||
| ngAfterViewInit(): void { | |||
| this.pagingComponent.initData(); | |||
| } | |||
| } | |||
| @@ -10,6 +10,18 @@ | |||
| </div> | |||
| </div> | |||
| <div class="mb-3"> | |||
| <app-search-input #partnerProductSearchInput | |||
| [formId]="'product'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'partnerName'" | |||
| [documentForm]="postForm" | |||
| [documentFormField]="'partnerName'" | |||
| [fetchFunction]="fetchPartnerProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="product"/> | |||
| </div> | |||
| <div class="mb-3"> | |||
| <label for="message" class="form-label">{{'form.message' | translate}}:</label> | |||
| <textarea class="form-control" id="message" formControlName="message" cols="50" rows="5"></textarea> | |||
| @@ -1,11 +1,13 @@ | |||
| import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; | |||
| import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| import {FormGroup} from "@angular/forms"; | |||
| import {postForm} from "@app/_forms/apiForms"; | |||
| import {PartnerJsonld, PostJsonld, PostService} from "@app/core/api/v1"; | |||
| import {PartnerJsonld, PartnerProductService, PostJsonld, PostService} from "@app/core/api/v1"; | |||
| import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; | |||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {Subscription} from "rxjs"; | |||
| import {Observable, Subscription} from "rxjs"; | |||
| import {SearchInputComponent} from "@app/_components/search-input/search-input.component"; | |||
| import {map} from "rxjs/operators"; | |||
| @Component({ | |||
| selector: 'app-new-post', | |||
| @@ -15,12 +17,14 @@ import {Subscription} from "rxjs"; | |||
| export class NewPostComponent implements OnInit { | |||
| @Input() public posting!: PostJsonld; | |||
| @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | |||
| @ViewChild('partnerProductSearchInput', { static: false }) $partnerProductSearchInput!: SearchInputComponent; | |||
| protected postForm: FormGroup; | |||
| protected postSub: Subscription; | |||
| constructor( | |||
| private postService: PostService, | |||
| private partnerProductService: PartnerProductService, | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| this.postForm = postForm; | |||
| @@ -32,6 +36,22 @@ export class NewPostComponent implements OnInit { | |||
| console.log(this.posting); | |||
| } | |||
| fetchPartnerProducts = (term: string): Observable<{ id: any; name: any }[]> => { | |||
| return this.partnerProductService.partnerProductsGetCollection( | |||
| 1, | |||
| 50, | |||
| String(this.posting.partner), | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| term | |||
| ).pipe( | |||
| map((response) => | |||
| response['hydra:member'].map( | |||
| partnerProduct => ({id: partnerProduct.product, name: partnerProduct.productName}))), | |||
| ); | |||
| } | |||
| onSubmit() { | |||
| if (this.postForm.valid) { | |||
| if (this.posting.id === null || this.posting.id === undefined) { | |||
| @@ -3,7 +3,7 @@ | |||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewPost()">{{ 'basic.new-post' | translate }}</button> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getData" | |||
| [dataSource]="postsDataSource" | |||
| [dataSource]="dataSource" | |||
| > | |||
| <div class="post mb-3" *ngFor="let post of posts"> | |||
| <div class="card"> | |||
| @@ -1,4 +1,4 @@ | |||
| import {AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||
| import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core'; | |||
| import {Subscription} from "rxjs"; | |||
| import { | |||
| CommentJsonld, | |||
| @@ -9,14 +9,12 @@ import { | |||
| PostService, | |||
| SaleJsonld, UserJsonld | |||
| } from "@app/core/api/v1"; | |||
| import {MatPaginator, MatPaginatorIntl} 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 {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; | |||
| @Component({ | |||
| selector: 'app-post-list', | |||
| @@ -32,14 +30,13 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| @Input() public existsContact!: boolean; | |||
| @Input() public existsSale!: boolean; | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent: PagingComponent = new PagingComponent(); | |||
| @ViewChild(MatPaginator) postsPaginator: MatPaginator; | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | |||
| protected postsSub: Subscription; | |||
| protected posts: Array<PostJsonld>; | |||
| protected partnerProductsSub: Subscription; | |||
| protected partnerProducts: Array<PartnerProductJsonld>; | |||
| protected postsDataSource; | |||
| protected dataSource; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected modalOptions: NgbModalOptions = { | |||
| centered: true | |||
| @@ -54,17 +51,15 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| this.posts = []; | |||
| this.partnerProductsSub = new Subscription(); | |||
| this.partnerProducts = []; | |||
| this.postsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); | |||
| this.postsDataSource = new MatTableDataSource<PostJsonld>(this.posts); | |||
| this.dataSource = new MatTableDataSource<PostJsonld>(this.posts); | |||
| this.commentsVisibility = new Map<string, boolean>(); | |||
| } | |||
| ngOnInit() { | |||
| this.getData(); | |||
| } | |||
| ngAfterViewInit() { | |||
| this.postsDataSource.paginator = this.postsPaginator; | |||
| this.pagingComponent.initData(); | |||
| } | |||
| getData = () => { | |||
| @@ -102,50 +97,24 @@ export class PostListComponent implements OnInit, AfterViewInit { | |||
| } | |||
| openModalNewPost() { | |||
| const modalRefPosting = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| 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(); | |||
| } | |||
| }); | |||
| let post: PostJsonld = {} as PostJsonld; | |||
| post.partner = this.partner.id ?? null; | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getData); | |||
| } | |||
| openModalEditPost(post: PostJsonld) { | |||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| 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.appHelperService.getModalOptions()); | |||
| modalRefComment.componentInstance.comment = comment; | |||
| modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefComment.dismiss(); | |||
| this.getData(); | |||
| } | |||
| }); | |||
| this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getData); | |||
| } | |||
| openModalNewComment(post: PostJsonld) { | |||
| const modalRefComment = this.modalService.open(NewCommentComponent, this.appHelperService.getModalOptions()); | |||
| 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(); | |||
| } | |||
| }); | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getData); | |||
| } | |||
| openModalEditComment(comment: CommentJsonld) { | |||
| this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getData); | |||
| } | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| <div class="spt-container"> | |||
| <div class="card"> | |||
| <div class="card-body row pb-5"> | |||
| <div *ngIf="sale" class="card-body row pb-5"> | |||
| <div class="col-8"> | |||
| <h1>{{'overview.sale-user' | translate }}: {{ sale.ownerName }}</h1> | |||
| <dl> | |||
| @@ -27,54 +27,51 @@ | |||
| <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]="appHelperService.getSafeLongtext(post.message)"></p> | |||
| </div> | |||
| <span *ngIf="post.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| data-action="edit" (click)="openModalEditPosting(post)"></span> | |||
| </div> | |||
| </div> | |||
| <div *ngIf="post.id && commentsVisibility.get(post.id)"> | |||
| <div class="card ms-5" *ngFor="let comment of post.comments"> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getPostsData" | |||
| [dataSource]="dataSource" | |||
| > | |||
| <div class="post mb-3" *ngFor="let post of posts"> | |||
| <div class="card"> | |||
| <div class="card-body"> | |||
| <div class="d-flex justify-content-between align-items-center"> | |||
| <p>{{ comment.createdAt | date:'dd.MM.YYYY' }}</p> | |||
| <p>{{ comment.ownerName }}</p> | |||
| <p>{{ post.createdAt | date:'dd.MM.YYYY' }}</p> | |||
| <p>{{ post.ownerName }}</p> | |||
| </div> | |||
| <div> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p> | |||
| <h3>{{ post.headline }}</h3> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(post.message)"></p> | |||
| </div> | |||
| <span *ngIf="post.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| data-action="edit" (click)="openModalEditPosting(post)"></span> | |||
| </div> | |||
| </div> | |||
| <div *ngIf="post.id && commentsVisibility.get(post.id)"> | |||
| <div class="card ms-5" *ngFor="let comment of post.comments"> | |||
| <div class="card-body"> | |||
| <div class="d-flex justify-content-between align-items-center"> | |||
| <p>{{ comment.createdAt | date:'dd.MM.YYYY' }}</p> | |||
| <p>{{ comment.ownerName }}</p> | |||
| </div> | |||
| <div> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(comment.message)"></p> | |||
| </div> | |||
| <span *ngIf="comment.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| data-action="edit" (click)="openModalEditComment(comment)"></span> | |||
| </div> | |||
| <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 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> | |||
| </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> | |||
| </app-paging> | |||
| </div> | |||
| </div> | |||
| </app-toggle> | |||
| @@ -1,18 +1,17 @@ | |||
| import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; | |||
| import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; | |||
| import {Subscription} from "rxjs"; | |||
| import {MatTableDataSource} from "@angular/material/table"; | |||
| import {CommentJsonld, ContactJsonld, PostJsonld, PostService, SaleJsonld, SaleService} from "@app/core/api/v1"; | |||
| import {CommentJsonld, PostJsonld, PostService, SaleJsonld, SaleService} from "@app/core/api/v1"; | |||
| import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; | |||
| import {User} from "@app/_models"; | |||
| import {AccountService} from "@app/_services"; | |||
| import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| 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 {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| @Component({ | |||
| selector: 'app-sales-detail', | |||
| @@ -20,177 +19,157 @@ import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| styleUrl: './sales-detail.component.scss' | |||
| }) | |||
| export class SalesDetailComponent implements OnInit, AfterViewInit { | |||
| @ViewChild(MatPaginator) postsPaginator: MatPaginator; | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | |||
| protected user: User | null; | |||
| protected user: User | null; | |||
| protected id: string; | |||
| protected sale: SaleJsonld; | |||
| protected saleSub: Subscription; | |||
| protected saleId: string; | |||
| protected sale!: SaleJsonld; | |||
| protected saleSub: Subscription; | |||
| protected postsSub: Subscription; | |||
| protected posts: Array<PostJsonld>; | |||
| protected postsDataSource; | |||
| protected postsLength: number; | |||
| protected postsPageEvent: PageEvent; | |||
| protected postsPageSize: number; | |||
| protected postsPageIndex: number; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected postsSub: Subscription; | |||
| protected posts: Array<PostJsonld>; | |||
| protected dataSource; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| protected modalOptions: NgbModalOptions = { | |||
| protected modalOptions: NgbModalOptions = { | |||
| centered: true | |||
| }; | |||
| constructor( | |||
| private accountService: AccountService, | |||
| private saleService: SaleService, | |||
| private route: ActivatedRoute, | |||
| private postService: PostService, | |||
| private modalService: NgbModal, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| this.user = this.accountService.userValue; | |||
| this.id = ""; | |||
| this.sale = {} as SaleJsonld; | |||
| this.saleSub = new Subscription(); | |||
| 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() { | |||
| this.route.params.subscribe(params => { | |||
| this.id = params['id']; | |||
| }); | |||
| this.getSaleData(); | |||
| } | |||
| ngAfterViewInit() { | |||
| this.postsDataSource.paginator = this.postsPaginator; | |||
| } | |||
| getSaleData() { | |||
| console.log(this.id); | |||
| this.saleSub = this.saleService.salesIdGet( | |||
| this.id | |||
| ).subscribe( | |||
| data => { | |||
| this.sale = data; | |||
| this.getPostsData(); | |||
| } | |||
| ); | |||
| } | |||
| getPostsData() { | |||
| this.postsSub = this.postService.postsGetCollection( | |||
| this.postsPageIndex + 1, | |||
| this.postsPageSize, | |||
| this.sale.partner + '', | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| this.id, | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| true | |||
| ).subscribe( | |||
| data => { | |||
| this.posts = data["hydra:member"]; | |||
| console.log(this.posts); | |||
| this.postsLength = Number(data["hydra:totalItems"]); | |||
| this.posts.forEach(posts => { | |||
| if (posts.id) { | |||
| this.commentsVisibility.set(posts.id, false); | |||
| }; | |||
| constructor( | |||
| private accountService: AccountService, | |||
| private saleService: SaleService, | |||
| private route: ActivatedRoute, | |||
| private postService: PostService, | |||
| private modalService: NgbModal, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| this.user = this.accountService.userValue; | |||
| this.saleId = ""; | |||
| this.saleSub = new Subscription(); | |||
| this.postsSub = new Subscription(); | |||
| this.posts = []; | |||
| this.dataSource = new MatTableDataSource<PostJsonld>(this.posts); | |||
| this.commentsVisibility = new Map<string, boolean>(); | |||
| } | |||
| ngOnInit() { | |||
| this.route.params.subscribe(params => { | |||
| this.saleId = params['id']; | |||
| }); | |||
| } | |||
| ngAfterViewInit() { | |||
| this.getSaleData(); | |||
| } | |||
| getSaleData = () => { | |||
| this.saleSub = this.saleService.salesIdGet( | |||
| this.saleId | |||
| ).subscribe( | |||
| data => { | |||
| this.sale = data; | |||
| this.pagingComponent.initData(); | |||
| } | |||
| ); | |||
| } | |||
| getPostsData = () => { | |||
| this.postsSub = this.postService.postsGetCollection( | |||
| this.pagingComponent.getPageIndex(), | |||
| this.pagingComponent.getPageSize(), | |||
| this.sale.partner + '', | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| this.saleId, | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| true | |||
| ).subscribe( | |||
| data => { | |||
| this.posts = data["hydra:member"]; | |||
| this.pagingComponent.dataLength = Number(data["hydra:totalItems"]); | |||
| this.posts.forEach(posts => { | |||
| if (posts.id) { | |||
| this.commentsVisibility.set(posts.id, false); | |||
| } | |||
| }); | |||
| } | |||
| }); | |||
| ); | |||
| } | |||
| openModalNewPosting() { | |||
| const modalRefPosting = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| let posting: PostJsonld = {} as PostJsonld; | |||
| posting.sale = this.sale.id ?? null; | |||
| posting.partner = this.sale.partner ?? null; | |||
| posting.product = this.sale.product ?? 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.appHelperService.getModalOptions()); | |||
| 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(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditPosting(post: PostJsonld) { | |||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| 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.appHelperService.getModalOptions()); | |||
| modalRefComment.componentInstance.comment = comment; | |||
| modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefComment.dismiss(); | |||
| this.getPostsData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditSale() { | |||
| const modalRefSale = this.modalService.open(NewSaleComponent, this.appHelperService.getModalOptions()); | |||
| modalRefSale.componentInstance.sale = this.sale; | |||
| modalRefSale.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefSale.dismiss(); | |||
| this.getSaleData(); | |||
| } | |||
| }); | |||
| } | |||
| showComments(post: PostJsonld) { | |||
| if (post.id) { | |||
| const currentVisibility = this.commentsVisibility.get(post.id); | |||
| this.commentsVisibility.set(post.id, !currentVisibility); | |||
| } | |||
| ); | |||
| } | |||
| postsHandlePageEvent(e: PageEvent) { | |||
| this.postsPageEvent = e; | |||
| this.postsLength = e.length; | |||
| this.postsPageIndex = e.pageIndex.valueOf(); | |||
| this.postsPageSize = e.pageSize.valueOf(); | |||
| this.getPostsData(); | |||
| } | |||
| openModalNewPosting() { | |||
| const modalRefPosting = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| let posting: PostJsonld = {} as PostJsonld; | |||
| posting.sale = this.sale.id ?? null; | |||
| posting.partner = this.sale.partner ?? null; | |||
| posting.product = this.sale.product ?? 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.appHelperService.getModalOptions()); | |||
| 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(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditPosting(post: PostJsonld) { | |||
| const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.appHelperService.getModalOptions()); | |||
| 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.appHelperService.getModalOptions()); | |||
| modalRefComment.componentInstance.comment = comment; | |||
| modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefComment.dismiss(); | |||
| this.getPostsData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditSale() { | |||
| const modalRefSale = this.modalService.open(NewSaleComponent, this.appHelperService.getModalOptions()); | |||
| modalRefSale.componentInstance.sale = this.sale; | |||
| modalRefSale.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefSale.dismiss(); | |||
| this.getSaleData(); | |||
| } | |||
| }); | |||
| } | |||
| showComments(post: PostJsonld) { | |||
| if (post.id) { | |||
| const currentVisibility = this.commentsVisibility.get(post.id); | |||
| this.commentsVisibility.set(post.id, !currentVisibility); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,6 +1,6 @@ | |||
| <div class="spt-container"> | |||
| <div class="spt-accordion position-relative"> | |||
| <button class="btn btn-primary toggle-btn" (click)="openModalNewTask()">{{ 'basic.new-task' | translate }}</button> | |||
| <button *ngIf="partner" class="btn btn-primary toggle-btn" (click)="openModalNewTask()">{{ 'basic.new-task' | translate }}</button> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getData" | |||
| [dataSource]="dataSource" | |||
| @@ -4,10 +4,8 @@ import {Subscription} from "rxjs"; | |||
| import {PartnerJsonld, TaskJsonld, TaskNoteJsonld, TaskService} from "@app/core/api/v1"; | |||
| import {MatTableDataSource} from "@angular/material/table"; | |||
| import {NewTaskComponent} from "@app/_views/tasks/new-task/new-task.component"; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; | |||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {NgbModal} from "@ng-bootstrap/ng-bootstrap"; | |||
| import {AccountService} from "@app/_services"; | |||
| import {User} from "@app/_models"; | |||
| @@ -16,10 +14,10 @@ import {User} from "@app/_models"; | |||
| templateUrl: './task-list.component.html', | |||
| styleUrl: './task-list.component.scss' | |||
| }) | |||
| export class TaskListComponent { | |||
| export class TaskListComponent implements OnInit, AfterViewInit { | |||
| @Input() public partner!: PartnerJsonld; | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent: PagingComponent = new PagingComponent(); | |||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | |||
| protected user: User | null; | |||
| protected tasksSub: Subscription; | |||
| @@ -31,7 +29,6 @@ export class TaskListComponent { | |||
| constructor( | |||
| private taskService: TaskService, | |||
| private accountService: AccountService, | |||
| private modalService: NgbModal, | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| this.tasksSub = new Subscription(); | |||
| @@ -41,13 +38,20 @@ export class TaskListComponent { | |||
| this.user = this.accountService.userValue; | |||
| } | |||
| ngOnInit(): void { | |||
| } | |||
| ngAfterViewInit(): void { | |||
| this.pagingComponent.initData(); | |||
| } | |||
| getData = () => { | |||
| this.tasksSub = this.taskService.tasksGetCollection( | |||
| this.pagingComponent.getPageIndex(), | |||
| this.pagingComponent.getPageSize(), | |||
| undefined, | |||
| undefined, | |||
| this.partner.id | |||
| this.partner ? this.partner.id : undefined | |||
| ).subscribe( | |||
| data => { | |||
| this.tasks = data["hydra:member"]; | |||
| @@ -69,52 +73,23 @@ export class TaskListComponent { | |||
| } | |||
| openModalNewTask() { | |||
| const modalRefTask = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions()); | |||
| let task: TaskJsonld = {} as TaskJsonld; | |||
| task.partner = this.partner.id ?? null; | |||
| task.completed = false; | |||
| modalRefTask.componentInstance.task = task; | |||
| modalRefTask.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTask.dismiss(); | |||
| this.getData(); | |||
| } | |||
| }); | |||
| this.appHelperService.openModal(NewTaskComponent, { 'task': task }, this.getData); | |||
| } | |||
| openModalEditTask(task: TaskJsonld) { | |||
| this.appHelperService.openModal(NewTaskComponent, { 'task': task }, this.getData); | |||
| } | |||
| openModalNewTaskNote(task: TaskJsonld) { | |||
| const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions()); | |||
| let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld; | |||
| taskNote.task = task.id ?? null; | |||
| modalRefTaskNote.componentInstance.taskNote = taskNote; | |||
| modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskNote.dismiss(); | |||
| this.getData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditTask(task: TaskJsonld) { | |||
| const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions()); | |||
| modalRefTaskEdit.componentInstance.task = task; | |||
| modalRefTaskEdit.componentInstance.dueAtValue = this.appHelperService.convertDate(task.dueAt); | |||
| modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskEdit.dismiss(); | |||
| this.getData(); | |||
| } | |||
| }); | |||
| this.appHelperService.openModal(NewTaskNoteComponent, { 'taskNote': taskNote }, this.getData); | |||
| } | |||
| openModalEditTaskNote(taskNote: TaskNoteJsonld) { | |||
| const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions()); | |||
| modalRefTaskNote.componentInstance.taskNote = taskNote; | |||
| modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskNote.dismiss(); | |||
| this.getData(); | |||
| } | |||
| }); | |||
| this.appHelperService.openModal(NewTaskNoteComponent, { 'taskNote': taskNote }, this.getData); | |||
| } | |||
| } | |||
| @@ -2,57 +2,7 @@ | |||
| <div class="spt-accordion"> | |||
| <div class="d-flex justify-content-between align-items-start"> | |||
| <h2>{{'basic.tasks' | translate}}</h2> | |||
| <button class="btn btn-primary" (click)="openModalNewTask()">{{'basic.new-task' | translate}}</button> | |||
| </div> | |||
| <div class="tasks mb-3" *ngFor="let task of tasks"> | |||
| <div class="card p-3"> | |||
| <div class="position-relative"> | |||
| <h3 class="m-0" *ngIf="task.partner"><a href="/{{task.partnerType}}/{{this.appHelperService.extractId(task.partner)}}">{{task.partnerName}}</a></h3> | |||
| <span class="info d-flex position-absolute"> | |||
| <span class="due-date">{{ task.dueAt | date:'dd.MM.YYYY':'GMT+0000' }}</span> | |||
| <span class="importance" [attr.data-importance]="task.prio"></span> | |||
| </span> | |||
| <h2 class="m-0">{{task.headline}}</h2> | |||
| <div class="pt-3 pe-5 position-relative"> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(task.description)"></p> | |||
| <p>Zugewiesen an: {{task.assignedToName}}</p> | |||
| <span *ngIf="task.createdBy === user?.id" class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" (click)="openModalEditTask(task)"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div *ngIf="task.id && taskNotesVisibility.get(task.id)"> | |||
| <div class="card ms-5" *ngFor="let taskNote of task.taskNotes"> | |||
| <div class="card-body"> | |||
| <div class="d-flex justify-content-between align-items-center"> | |||
| <p>{{ taskNote.createdAt | date:'dd.MM.YYYY HH:mm' }}</p> | |||
| <p>{{ taskNote.ownerName }}</p> | |||
| </div> | |||
| <div> | |||
| <p class="m-0" [innerHTML]="appHelperService.getSafeLongtext(taskNote.message)"></p> | |||
| </div> | |||
| <span *ngIf="taskNote.owner === user?.id" class="position-absolute bi bi-pencil p-2" | |||
| data-type="user-tool" data-action="edit" (click)="openModalEditTaskNote(taskNote)"></span> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="d-flex justify-content-end mt-1"> | |||
| <span *ngIf="task.taskNotes?.length !== 0" role="button" class="badge bg-secondary p-2 me-2" | |||
| (click)="showTaskNotes(task)"> | |||
| <ng-container *ngIf="task.id && taskNotesVisibility.get(task.id)">{{ 'basic.hide-comments' | translate }}</ng-container> | |||
| <ng-container *ngIf="task.id && !taskNotesVisibility.get(task.id)">{{ 'basic.show-comments' | translate }}</ng-container> | |||
| </span> | |||
| <span role="button" class="badge bg-secondary p-2" (click)="openModalNewTaskNote(task)">{{'basic.comment-it' | translate}}</span> | |||
| </div> | |||
| </div> | |||
| <mat-paginator *ngIf="tasks.length > 0" class="rounded-1" | |||
| [pageSizeOptions]="[10,20,30]" | |||
| [length]="tasksLength" | |||
| (page)="tasksHandlePageEvent($event)" | |||
| [pageSize]="tasksPageSize" | |||
| [pageIndex]="tasksPageIndex" | |||
| showFirstLastButtons> | |||
| </mat-paginator> | |||
| <app-task-list #taskListComponent></app-task-list> | |||
| </div> | |||
| </div> | |||
| @@ -10,6 +10,7 @@ import {User} from "@app/_models"; | |||
| import {AccountService} from "@app/_services"; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; | |||
| import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component"; | |||
| @Component({ | |||
| selector: 'app-tasks', | |||
| @@ -17,130 +18,23 @@ import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-not | |||
| styleUrl: './tasks.component.scss' | |||
| }) | |||
| export class TasksComponent implements OnInit, AfterViewInit { | |||
| @ViewChild(MatPaginator) tasksPaginator: MatPaginator; | |||
| @ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent; | |||
| protected user: User | null; | |||
| protected tasksSub: Subscription; | |||
| protected tasks: Array<TaskJsonld>; | |||
| protected tasksDataSource; | |||
| protected tasksLength: number; | |||
| protected tasksPageEvent: PageEvent; | |||
| protected tasksPageSize: number; | |||
| protected tasksPageIndex: number; | |||
| protected taskNotesVisibility: Map<string, boolean>; | |||
| protected modalOptions: NgbModalOptions = { | |||
| centered: true | |||
| }; | |||
| constructor( | |||
| private modalService: NgbModal, | |||
| private accountService: AccountService, | |||
| private taskService: TaskService, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| this.user = this.accountService.userValue; | |||
| this.tasksSub = new Subscription(); | |||
| this.tasks = []; | |||
| this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); | |||
| this.tasksDataSource = new MatTableDataSource<TaskJsonld>(this.tasks); | |||
| this.tasksLength = 0; | |||
| this.tasksPageEvent = new PageEvent(); | |||
| this.tasksPageSize = 10; | |||
| this.tasksPageIndex = 0; | |||
| this.taskNotesVisibility = new Map<string, boolean>(); | |||
| } | |||
| ngOnInit() { | |||
| this.getTasksData(); | |||
| // this.getTasksData(); | |||
| } | |||
| ngAfterViewInit() { | |||
| this.tasksDataSource.paginator = this.tasksPaginator; | |||
| } | |||
| getTasksData() { | |||
| this.tasksSub = this.taskService.tasksGetCollection( | |||
| this.tasksPageIndex + 1, | |||
| this.tasksPageSize | |||
| ).subscribe( | |||
| data => { | |||
| this.tasks = data["hydra:member"]; | |||
| this.tasksLength = Number(data["hydra:totalItems"]); | |||
| this.tasks.forEach(task => { | |||
| if (task.id) { | |||
| this.taskNotesVisibility.set(task.id, false); | |||
| } | |||
| }); | |||
| } | |||
| ); | |||
| } | |||
| tasksHandlePageEvent(e: PageEvent) { | |||
| this.tasksPageEvent = e; | |||
| this.tasksLength = e.length; | |||
| this.tasksPageIndex = e.pageIndex.valueOf(); | |||
| this.tasksPageSize = e.pageSize.valueOf(); | |||
| this.getTasksData(); | |||
| } | |||
| openModalNewTask() { | |||
| const modalRefTask = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions()); | |||
| let task: TaskJsonld = {} as TaskJsonld; | |||
| task.partner = null; | |||
| task.completed = false; | |||
| modalRefTask.componentInstance.task = task; | |||
| modalRefTask.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTask.dismiss(); | |||
| this.getTasksData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalNewTaskNote(task: TaskJsonld) { | |||
| const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions()); | |||
| let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld; | |||
| taskNote.task = task.id ?? null; | |||
| modalRefTaskNote.componentInstance.taskNote = taskNote; | |||
| modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskNote.dismiss(); | |||
| this.getTasksData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditTask(task: TaskJsonld) { | |||
| const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions()); | |||
| modalRefTaskEdit.componentInstance.task = task; | |||
| modalRefTaskEdit.componentInstance.dueAtValue = this.appHelperService.convertDate(task.dueAt); | |||
| modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskEdit.dismiss(); | |||
| this.getTasksData(); | |||
| } | |||
| }); | |||
| } | |||
| openModalEditTaskNote(taskNote: TaskNoteJsonld) { | |||
| const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions()); | |||
| modalRefTaskNote.componentInstance.taskNote = taskNote; | |||
| modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { | |||
| if (modalStatus === ModalStatus.Submitted) { | |||
| modalRefTaskNote.dismiss(); | |||
| this.getTasksData(); | |||
| } | |||
| }); | |||
| } | |||
| showTaskNotes(task: TaskJsonld) { | |||
| if (task.id) { | |||
| const currentVisibility = this.taskNotesVisibility.get(task.id); | |||
| this.taskNotesVisibility.set(task.id, !currentVisibility); | |||
| } | |||
| } | |||
| } | |||
| @@ -54,6 +54,7 @@ import {ApiModule, Configuration, ConfigurationParameters} from "@app/core/api/v | |||
| import { TaskListComponent } from './_views/tasks/task-list/task-list.component'; | |||
| import { SearchInputComponent } from './_components/search-input/search-input.component'; | |||
| import { PagingComponent } from '@app/_components/paging/paging.component'; | |||
| import { PartnerListComponent } from './_views/partners/partner-list/partner-list.component'; | |||
| export function apiConfigFactory(): Configuration { | |||
| const params: ConfigurationParameters = { | |||
| @@ -129,6 +130,7 @@ export function HttpLoaderFactory(http: HttpClient) { | |||
| TaskListComponent, | |||
| SearchInputComponent, | |||
| PagingComponent, | |||
| PartnerListComponent, | |||
| ], | |||
| providers: [ | |||
| {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | |||