Quellcode durchsuchen

refactoring

master
Daniel vor 1 Jahr
Ursprung
Commit
a6b120fc1c
20 geänderte Dateien mit 359 neuen und 484 gelöschten Zeilen
  1. +5
    -0
      matsen-tool/src/app/_components/paging/paging.component.ts
  2. +10
    -3
      matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts
  3. +9
    -1
      matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html
  4. +24
    -17
      matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts
  5. +1
    -1
      matsen-tool/src/app/_views/documents/documents.component.ts
  6. +1
    -0
      matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html
  7. +0
    -0
      matsen-tool/src/app/_views/partners/partner-list/partner-list.component.scss
  8. +23
    -0
      matsen-tool/src/app/_views/partners/partner-list/partner-list.component.spec.ts
  9. +26
    -0
      matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts
  10. +12
    -0
      matsen-tool/src/app/_views/posts/new-post/new-post.component.html
  11. +23
    -3
      matsen-tool/src/app/_views/posts/new-post/new-post.component.ts
  12. +1
    -1
      matsen-tool/src/app/_views/posts/post-list/post-list.component.html
  13. +17
    -48
      matsen-tool/src/app/_views/posts/post-list/post-list.component.ts
  14. +37
    -40
      matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html
  15. +146
    -167
      matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts
  16. +1
    -1
      matsen-tool/src/app/_views/tasks/task-list/task-list.component.html
  17. +17
    -42
      matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts
  18. +1
    -51
      matsen-tool/src/app/_views/tasks/tasks.component.html
  19. +3
    -109
      matsen-tool/src/app/_views/tasks/tasks.component.ts
  20. +2
    -0
      matsen-tool/src/app/app.module.ts

+ 5
- 0
matsen-tool/src/app/_components/paging/paging.component.ts Datei anzeigen

@@ -42,6 +42,11 @@ export class PagingComponent implements OnInit {
ngAfterViewInit() { ngAfterViewInit() {


this.dataSource = this.paginator; this.dataSource = this.paginator;
console.log('paging after init');
//this.getDataFunction();
}

initData() {
this.getDataFunction(); this.getDataFunction();
} }




+ 10
- 3
matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts Datei anzeigen

@@ -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 {Subscription} from "rxjs";
import {ContactJsonld, ContactService, PartnerJsonld} from "@app/core/api/v1"; import {ContactJsonld, ContactService, PartnerJsonld} from "@app/core/api/v1";
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
@@ -12,10 +12,10 @@ import {PagingComponent} from "@app/_components/paging/paging.component";
templateUrl: './contact-list.component.html', templateUrl: './contact-list.component.html',
styleUrl: './contact-list.component.scss' styleUrl: './contact-list.component.scss'
}) })
export class ContactListComponent {
export class ContactListComponent implements OnInit, AfterViewInit {


@Input() public partner!: PartnerJsonld; @Input() public partner!: PartnerJsonld;
@ViewChild("pagingComponent", { static: false }) pagingComponent: PagingComponent = new PagingComponent();
@ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent;


protected contactsSub: Subscription; protected contactsSub: Subscription;
protected contacts: Array<ContactJsonld>; protected contacts: Array<ContactJsonld>;
@@ -31,6 +31,13 @@ export class ContactListComponent {
this.dataSource = new MatTableDataSource<ContactJsonld>(this.contacts); this.dataSource = new MatTableDataSource<ContactJsonld>(this.contacts);
} }


ngOnInit(): void {
}

ngAfterViewInit(): void {
this.pagingComponent.initData();
}

getData = () => { getData = () => {
this.contactsSub = this.contactService.contactsGetCollection( this.contactsSub = this.contactService.contactsGetCollection(
this.pagingComponent.getPageIndex(), this.pagingComponent.getPageIndex(),


+ 9
- 1
matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html Datei anzeigen

@@ -20,7 +20,15 @@
alt="{{contact.firstName}} {{contact.lastName}}" title="{{contact.firstName}} {{contact.lastName}}"/> alt="{{contact.firstName}} {{contact.lastName}}" title="{{contact.firstName}} {{contact.lastName}}"/>
</div> </div>
<span class="position-absolute bi bi-pencil p-2" data-type="user-tool" data-action="edit" <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> </div>
</div> </div>


+ 24
- 17
matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts Datei anzeigen

@@ -1,26 +1,16 @@
import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core';
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import { import {
CommentJsonld,
ContactJsonld,
ContactJsonld, ContactPartnerProduct, ContactPartnerProductService,
ContactService, ContactService,
PartnerJsonld, PartnerJsonld,
PartnerService, PartnerService,
PostJsonld,
PostService
} from "@app/core/api/v1"; } from "@app/core/api/v1";
import {Subscription} from "rxjs"; import {Subscription} from "rxjs";
import {ActivatedRoute} from "@angular/router"; 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 {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact.component";
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/_views/posts/new-comment/new-comment.component";
import {AppHelperService} from "@app/_helpers/app-helper.service"; 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 {PostListComponent} from "@app/_views/posts/post-list/post-list.component";
import {ToggleComponent} from "@app/_components/toggle/toggle.component"; import {ToggleComponent} from "@app/_components/toggle/toggle.component";


@@ -39,16 +29,17 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit {
protected contact!: ContactJsonld; protected contact!: ContactJsonld;
protected contactSub: Subscription; protected contactSub: Subscription;
protected partner!: PartnerJsonld; protected partner!: PartnerJsonld;
protected contactPartnerProducts: Array<ContactPartnerProduct>;

protected partnerSub: Subscription; protected partnerSub: Subscription;
protected contactProductSub: Subscription;
protected commentsVisibility: Map<string, boolean>; protected commentsVisibility: Map<string, boolean>;
protected modalOptions: NgbModalOptions = {
centered: true
};


constructor( constructor(
private contactService: ContactService, private contactService: ContactService,
private partnerService: PartnerService, private partnerService: PartnerService,
private accountService: AccountService, private accountService: AccountService,
private contactProductService: ContactPartnerProductService,
private route: ActivatedRoute, private route: ActivatedRoute,
protected appHelperService: AppHelperService protected appHelperService: AppHelperService
) { ) {
@@ -56,6 +47,8 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit {
this.contactSub = new Subscription(); this.contactSub = new Subscription();
this.commentsVisibility = new Map<string, boolean>(); this.commentsVisibility = new Map<string, boolean>();
this.partnerSub = new Subscription(); this.partnerSub = new Subscription();
this.contactProductSub = new Subscription();
this.contactPartnerProducts = [];
} }


ngOnInit() { ngOnInit() {
@@ -76,12 +69,14 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit {
).subscribe( ).subscribe(
data => { data => {
this.contact = data; this.contact = data;
this.getPartnerData()
this.getPartnerData();
this.getContactProducts();

} }
); );
} }


getPartnerData() {
getPartnerData = () => {
this.partnerSub = this.partnerService.partnersIdGet( this.partnerSub = this.partnerService.partnersIdGet(
this.appHelperService.extractId(this.contact.partner) this.appHelperService.extractId(this.contact.partner)
).subscribe( ).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() { openModalEditContact() {
let data: any = { 'contact': this.contact } let data: any = { 'contact': this.contact }
if (this.contact.birthday !== undefined) { if (this.contact.birthday !== undefined) {


+ 1
- 1
matsen-tool/src/app/_views/documents/documents.component.ts Datei anzeigen

@@ -2,7 +2,7 @@ import {ChangeDetectorRef, Component, ViewChild} from '@angular/core';
import {MatSort, MatSortModule, Sort} from "@angular/material/sort"; import {MatSort, MatSortModule, Sort} from "@angular/material/sort";
import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator";
import {Subscription} from "rxjs"; 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 {Router, RouterLink, RouterLinkActive} from "@angular/router";
import {MatTableDataSource, MatTableModule} from "@angular/material/table"; import {MatTableDataSource, MatTableModule} from "@angular/material/table";
import {OrderFilter} from "@app/_models/orderFilter"; import {OrderFilter} from "@app/_models/orderFilter";


+ 1
- 0
matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html Datei anzeigen

@@ -0,0 +1 @@
<p>partner-list works!</p>

+ 0
- 0
matsen-tool/src/app/_views/partners/partner-list/partner-list.component.scss Datei anzeigen


+ 23
- 0
matsen-tool/src/app/_views/partners/partner-list/partner-list.component.spec.ts Datei anzeigen

@@ -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();
});
});

+ 26
- 0
matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts Datei anzeigen

@@ -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();
}
}

+ 12
- 0
matsen-tool/src/app/_views/posts/new-post/new-post.component.html Datei anzeigen

@@ -10,6 +10,18 @@
</div> </div>
</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"> <div class="mb-3">
<label for="message" class="form-label">{{'form.message' | translate}}:</label> <label for="message" class="form-label">{{'form.message' | translate}}:</label>
<textarea class="form-control" id="message" formControlName="message" cols="50" rows="5"></textarea> <textarea class="form-control" id="message" formControlName="message" cols="50" rows="5"></textarea>


+ 23
- 3
matsen-tool/src/app/_views/posts/new-post/new-post.component.ts Datei anzeigen

@@ -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 {ModalStatus} from "@app/_helpers/modal.states";
import {FormGroup} from "@angular/forms"; import {FormGroup} from "@angular/forms";
import {postForm} from "@app/_forms/apiForms"; 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 {FormGroupInitializer} from "@app/_helpers/formgroup.initializer";
import {AppHelperService} from "@app/_helpers/app-helper.service"; 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({ @Component({
selector: 'app-new-post', selector: 'app-new-post',
@@ -15,12 +17,14 @@ import {Subscription} from "rxjs";
export class NewPostComponent 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>();
@ViewChild('partnerProductSearchInput', { static: false }) $partnerProductSearchInput!: SearchInputComponent;


protected postForm: FormGroup; protected postForm: FormGroup;
protected postSub: Subscription; protected postSub: Subscription;


constructor( constructor(
private postService: PostService, private postService: PostService,
private partnerProductService: PartnerProductService,
protected appHelperService: AppHelperService, protected appHelperService: AppHelperService,
) { ) {
this.postForm = postForm; this.postForm = postForm;
@@ -32,6 +36,22 @@ export class NewPostComponent implements OnInit {
console.log(this.posting); 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() { onSubmit() {
if (this.postForm.valid) { if (this.postForm.valid) {
if (this.posting.id === null || this.posting.id === undefined) { if (this.posting.id === null || this.posting.id === undefined) {


+ 1
- 1
matsen-tool/src/app/_views/posts/post-list/post-list.component.html Datei anzeigen

@@ -3,7 +3,7 @@
<button class="btn btn-primary toggle-btn" (click)="openModalNewPost()">{{ 'basic.new-post' | translate }}</button> <button class="btn btn-primary toggle-btn" (click)="openModalNewPost()">{{ 'basic.new-post' | translate }}</button>
<app-paging #pagingComponent <app-paging #pagingComponent
[getDataFunction]="getData" [getDataFunction]="getData"
[dataSource]="postsDataSource"
[dataSource]="dataSource"
> >
<div class="post mb-3" *ngFor="let post of posts"> <div class="post mb-3" *ngFor="let post of posts">
<div class="card"> <div class="card">


+ 17
- 48
matsen-tool/src/app/_views/posts/post-list/post-list.component.ts Datei anzeigen

@@ -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 {Subscription} from "rxjs";
import { import {
CommentJsonld, CommentJsonld,
@@ -9,14 +9,12 @@ import {
PostService, PostService,
SaleJsonld, UserJsonld SaleJsonld, UserJsonld
} from "@app/core/api/v1"; } from "@app/core/api/v1";
import {MatPaginator, MatPaginatorIntl} from "@angular/material/paginator";
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; 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 {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap";
import {AppHelperService} from "@app/_helpers/app-helper.service"; 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 {PagingComponent} from "@app/_components/paging/paging.component";
import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component";


@Component({ @Component({
selector: 'app-post-list', selector: 'app-post-list',
@@ -32,14 +30,13 @@ export class PostListComponent implements OnInit, AfterViewInit {
@Input() public existsContact!: boolean; @Input() public existsContact!: boolean;
@Input() public existsSale!: 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 postsSub: Subscription;
protected posts: Array<PostJsonld>; protected posts: Array<PostJsonld>;
protected partnerProductsSub: Subscription; protected partnerProductsSub: Subscription;
protected partnerProducts: Array<PartnerProductJsonld>; protected partnerProducts: Array<PartnerProductJsonld>;
protected postsDataSource;
protected dataSource;
protected commentsVisibility: Map<string, boolean>; protected commentsVisibility: Map<string, boolean>;
protected modalOptions: NgbModalOptions = { protected modalOptions: NgbModalOptions = {
centered: true centered: true
@@ -54,17 +51,15 @@ export class PostListComponent implements OnInit, AfterViewInit {
this.posts = []; this.posts = [];
this.partnerProductsSub = new Subscription(); this.partnerProductsSub = new Subscription();
this.partnerProducts = []; 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>(); this.commentsVisibility = new Map<string, boolean>();
} }


ngOnInit() { ngOnInit() {
this.getData();
} }


ngAfterViewInit() { ngAfterViewInit() {
this.postsDataSource.paginator = this.postsPaginator;
this.pagingComponent.initData();
} }


getData = () => { getData = () => {
@@ -102,50 +97,24 @@ export class PostListComponent implements OnInit, AfterViewInit {
} }


openModalNewPost() { 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) { 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) { openModalNewComment(post: PostJsonld) {
const modalRefComment = this.modalService.open(NewCommentComponent, this.appHelperService.getModalOptions());
let comment: CommentJsonld = {} as CommentJsonld; let comment: CommentJsonld = {} as CommentJsonld;
comment.post = post.id ?? null; 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);
}


} }

+ 37
- 40
matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html Datei anzeigen

@@ -1,6 +1,6 @@
<div class="spt-container"> <div class="spt-container">
<div class="card"> <div class="card">
<div class="card-body row pb-5">
<div *ngIf="sale" class="card-body row pb-5">
<div class="col-8"> <div class="col-8">
<h1>{{'overview.sale-user' | translate }}: {{ sale.ownerName }}</h1> <h1>{{'overview.sale-user' | translate }}: {{ sale.ownerName }}</h1>
<dl> <dl>
@@ -27,54 +27,51 @@
<div class="spt-container"> <div class="spt-container">
<div class="posts position-relative"> <div class="posts position-relative">
<button class="btn btn-primary toggle-btn" (click)="openModalNewPosting()">{{'basic.new-post' | translate}}</button> <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="card-body">
<div class="d-flex justify-content-between align-items-center"> <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>
<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> </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>
</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>
</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>
</div> </div>
</app-toggle> </app-toggle>

+ 146
- 167
matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts Datei anzeigen

@@ -1,18 +1,17 @@
import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core';
import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator";
import {Subscription} from "rxjs"; import {Subscription} from "rxjs";
import {MatTableDataSource} from "@angular/material/table"; 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 {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 {NewPostComponent} from "@app/_views/posts/new-post/new-post.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/_views/posts/new-comment/new-comment.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 {NewSaleComponent} from "@app/_views/sales/new-sale/new-sale.component";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {AppHelperService} from "@app/_helpers/app-helper.service"; import {AppHelperService} from "@app/_helpers/app-helper.service";
import {PagingComponent} from "@app/_components/paging/paging.component";


@Component({ @Component({
selector: 'app-sales-detail', selector: 'app-sales-detail',
@@ -20,177 +19,157 @@ import {AppHelperService} from "@app/_helpers/app-helper.service";
styleUrl: './sales-detail.component.scss' styleUrl: './sales-detail.component.scss'
}) })
export class SalesDetailComponent implements OnInit, AfterViewInit { 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 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
- 1
matsen-tool/src/app/_views/tasks/task-list/task-list.component.html Datei anzeigen

@@ -1,6 +1,6 @@
<div class="spt-container"> <div class="spt-container">
<div class="spt-accordion position-relative"> <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 <app-paging #pagingComponent
[getDataFunction]="getData" [getDataFunction]="getData"
[dataSource]="dataSource" [dataSource]="dataSource"


+ 17
- 42
matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts Datei anzeigen

@@ -4,10 +4,8 @@ import {Subscription} from "rxjs";
import {PartnerJsonld, TaskJsonld, TaskNoteJsonld, TaskService} from "@app/core/api/v1"; import {PartnerJsonld, TaskJsonld, TaskNoteJsonld, TaskService} from "@app/core/api/v1";
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {NewTaskComponent} from "@app/_views/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 {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component";
import {AppHelperService} from "@app/_helpers/app-helper.service"; import {AppHelperService} from "@app/_helpers/app-helper.service";
import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
import {AccountService} from "@app/_services"; import {AccountService} from "@app/_services";
import {User} from "@app/_models"; import {User} from "@app/_models";


@@ -16,10 +14,10 @@ import {User} from "@app/_models";
templateUrl: './task-list.component.html', templateUrl: './task-list.component.html',
styleUrl: './task-list.component.scss' styleUrl: './task-list.component.scss'
}) })
export class TaskListComponent {
export class TaskListComponent implements OnInit, AfterViewInit {


@Input() public partner!: PartnerJsonld; @Input() public partner!: PartnerJsonld;
@ViewChild("pagingComponent", { static: false }) pagingComponent: PagingComponent = new PagingComponent();
@ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent;


protected user: User | null; protected user: User | null;
protected tasksSub: Subscription; protected tasksSub: Subscription;
@@ -31,7 +29,6 @@ export class TaskListComponent {
constructor( constructor(
private taskService: TaskService, private taskService: TaskService,
private accountService: AccountService, private accountService: AccountService,
private modalService: NgbModal,
protected appHelperService: AppHelperService, protected appHelperService: AppHelperService,
) { ) {
this.tasksSub = new Subscription(); this.tasksSub = new Subscription();
@@ -41,13 +38,20 @@ export class TaskListComponent {
this.user = this.accountService.userValue; this.user = this.accountService.userValue;
} }


ngOnInit(): void {
}

ngAfterViewInit(): void {
this.pagingComponent.initData();
}

getData = () => { getData = () => {
this.tasksSub = this.taskService.tasksGetCollection( this.tasksSub = this.taskService.tasksGetCollection(
this.pagingComponent.getPageIndex(), this.pagingComponent.getPageIndex(),
this.pagingComponent.getPageSize(), this.pagingComponent.getPageSize(),
undefined, undefined,
undefined, undefined,
this.partner.id
this.partner ? this.partner.id : undefined
).subscribe( ).subscribe(
data => { data => {
this.tasks = data["hydra:member"]; this.tasks = data["hydra:member"];
@@ -69,52 +73,23 @@ export class TaskListComponent {
} }


openModalNewTask() { openModalNewTask() {
const modalRefTask = this.modalService.open(NewTaskComponent, this.appHelperService.getModalOptions());
let task: TaskJsonld = {} as TaskJsonld; let task: TaskJsonld = {} as TaskJsonld;
task.partner = this.partner.id ?? null; task.partner = this.partner.id ?? null;
task.completed = false; 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) { openModalNewTaskNote(task: TaskJsonld) {
const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.appHelperService.getModalOptions());
let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld; let taskNote: TaskNoteJsonld = {} as TaskNoteJsonld;
taskNote.task = task.id ?? null; 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) { 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);
} }
} }

+ 1
- 51
matsen-tool/src/app/_views/tasks/tasks.component.html Datei anzeigen

@@ -2,57 +2,7 @@
<div class="spt-accordion"> <div class="spt-accordion">
<div class="d-flex justify-content-between align-items-start"> <div class="d-flex justify-content-between align-items-start">
<h2>{{'basic.tasks' | translate}}</h2> <h2>{{'basic.tasks' | translate}}</h2>
<button class="btn btn-primary" (click)="openModalNewTask()">{{'basic.new-task' | translate}}</button>
</div> </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>
</div> </div>

+ 3
- 109
matsen-tool/src/app/_views/tasks/tasks.component.ts Datei anzeigen

@@ -10,6 +10,7 @@ import {User} from "@app/_models";
import {AccountService} from "@app/_services"; import {AccountService} from "@app/_services";
import {ModalStatus} from "@app/_helpers/modal.states"; import {ModalStatus} from "@app/_helpers/modal.states";
import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; 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({ @Component({
selector: 'app-tasks', selector: 'app-tasks',
@@ -17,130 +18,23 @@ import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-not
styleUrl: './tasks.component.scss' styleUrl: './tasks.component.scss'
}) })
export class TasksComponent implements OnInit, AfterViewInit { export class TasksComponent implements OnInit, AfterViewInit {
@ViewChild(MatPaginator) tasksPaginator: MatPaginator;
@ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent;


protected user: User | null; 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( constructor(
private modalService: NgbModal,
private accountService: AccountService, private accountService: AccountService,
private taskService: TaskService,
protected appHelperService: AppHelperService protected appHelperService: AppHelperService
) { ) {
this.user = this.accountService.userValue; 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() { ngOnInit() {
this.getTasksData();
// this.getTasksData();
} }


ngAfterViewInit() { 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);
}
}
} }

+ 2
- 0
matsen-tool/src/app/app.module.ts Datei anzeigen

@@ -54,6 +54,7 @@ import {ApiModule, Configuration, ConfigurationParameters} from "@app/core/api/v
import { TaskListComponent } from './_views/tasks/task-list/task-list.component'; import { TaskListComponent } from './_views/tasks/task-list/task-list.component';
import { SearchInputComponent } from './_components/search-input/search-input.component'; import { SearchInputComponent } from './_components/search-input/search-input.component';
import { PagingComponent } from '@app/_components/paging/paging.component'; import { PagingComponent } from '@app/_components/paging/paging.component';
import { PartnerListComponent } from './_views/partners/partner-list/partner-list.component';


export function apiConfigFactory(): Configuration { export function apiConfigFactory(): Configuration {
const params: ConfigurationParameters = { const params: ConfigurationParameters = {
@@ -129,6 +130,7 @@ export function HttpLoaderFactory(http: HttpClient) {
TaskListComponent, TaskListComponent,
SearchInputComponent, SearchInputComponent,
PagingComponent, PagingComponent,
PartnerListComponent,
], ],
providers: [ providers: [
{provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},


Laden…
Abbrechen
Speichern