diff --git a/matsen-tool/src/app/_forms/apiForms.ts b/matsen-tool/src/app/_forms/apiForms.ts index 6683503..db33106 100644 --- a/matsen-tool/src/app/_forms/apiForms.ts +++ b/matsen-tool/src/app/_forms/apiForms.ts @@ -140,6 +140,7 @@ export const mediaObjectJsonldMediaObjectReadForm = new FormGroup({ export const partnerForm = new FormGroup({ name: new FormControl(null, [Validators.required]), partnerType: new FormControl(null, [Validators.required]), + description: new FormControl(null, []), street: new FormControl(null, []), streetNo: new FormControl(null, []), zip: new FormControl(null, []), @@ -157,6 +158,7 @@ export const partnerJsonhalForm = new FormGroup({ _links: new FormControl(null, []), name: new FormControl(null, [Validators.required]), partnerType: new FormControl(null, [Validators.required]), + description: new FormControl(null, []), street: new FormControl(null, []), streetNo: new FormControl(null, []), zip: new FormControl(null, []), @@ -173,6 +175,7 @@ export const partnerJsonhalForm = new FormGroup({ export const partnerJsonldForm = new FormGroup({ name: new FormControl(null, [Validators.required]), partnerType: new FormControl(null, [Validators.required]), + description: new FormControl(null, []), street: new FormControl(null, []), streetNo: new FormControl(null, []), zip: new FormControl(null, []), @@ -307,6 +310,7 @@ export const saleForm = new FormGroup({ owner: new FormControl(null, []), ownerName: new FormControl(null, []), partner: new FormControl(null, []), + partnerType: new FormControl(null, []), partnerName: new FormControl(null, []), product: new FormControl(null, []), productName: new FormControl(null, []), @@ -322,6 +326,7 @@ export const saleJsonhalForm = new FormGroup({ owner: new FormControl(null, []), ownerName: new FormControl(null, []), partner: new FormControl(null, []), + partnerType: new FormControl(null, []), partnerName: new FormControl(null, []), product: new FormControl(null, []), productName: new FormControl(null, []), @@ -336,6 +341,7 @@ export const saleJsonldForm = new FormGroup({ owner: new FormControl(null, []), ownerName: new FormControl(null, []), partner: new FormControl(null, []), + partnerType: new FormControl(null, []), partnerName: new FormControl(null, []), product: new FormControl(null, []), productName: new FormControl(null, []), diff --git a/matsen-tool/src/app/_helpers/api.converter.ts b/matsen-tool/src/app/_helpers/api.converter.ts index 17b89e7..d123b42 100644 --- a/matsen-tool/src/app/_helpers/api.converter.ts +++ b/matsen-tool/src/app/_helpers/api.converter.ts @@ -11,10 +11,12 @@ export class ApiConverter { return ""; } - public static convertDate(dateString: string | null) { + public static convertDate(dateString: string | null, withTime = false) { + // number 10 for input date (2024-03-15) + // number 16 for input datetime-local (2024-04-28T03:22) if (dateString !== null) { const date = new Date(dateString); - return date.toISOString().slice(0, 16); + return date.toISOString().slice(0, withTime ? 16 : 10); } return ""; } diff --git a/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.html b/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.html index b4a4afb..8d7c122 100644 --- a/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.html +++ b/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.html @@ -34,7 +34,7 @@
-

{{ post.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ post.createdAt | date:'dd.MM.YYYY' }}

{{ post.ownerName }}

@@ -49,7 +49,7 @@
-

{{ comment.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ comment.createdAt | date:'dd.MM.YYYY' }}

{{ comment.ownerName }}

diff --git a/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.ts b/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.ts index f5b295b..6cd58fd 100644 --- a/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.ts +++ b/matsen-tool/src/app/contacts/contacts-detail/contacts-detail.component.ts @@ -1,6 +1,5 @@ import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; -import {environment} from "@environments/environment"; -import {CommentJsonld, ContactJsonld, ContactService, PartnerJsonld, PostJsonld, PostService} from "@app/core/api/v1"; +import {CommentJsonld, ContactJsonld, ContactService, PostJsonld, PostService} from "@app/core/api/v1"; import {Subscription} from "rxjs"; import {ActivatedRoute} from "@angular/router"; import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; @@ -12,6 +11,7 @@ import {ModalStatus} from "@app/_helpers/modal.states"; import {User} from "@app/_models"; import {AccountService} from "@app/_services"; import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; +import {ApiConverter} from "@app/_helpers/api.converter"; @Component({ selector: 'app-contacts-detail', @@ -23,9 +23,8 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { protected user: User | null; - protected readonly environment = environment; - protected contact: ContactJsonld; protected id: string; + protected contact: ContactJsonld; protected contactSub: Subscription; protected postsSub: Subscription; @@ -52,7 +51,6 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { this.id = ""; this.contact = {} as ContactJsonld; - this.contactSub = new Subscription(); this.postsSub = new Subscription(); @@ -95,7 +93,12 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { this.postsPageSize, this.contact.partner + '', [], - this.id + this.id, + undefined, + undefined, + undefined, + undefined, + false ).subscribe( data => { this.posts = data["hydra:member"]; @@ -167,11 +170,14 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { } openModalEditContact() { - const modalRef = this.modalService.open(NewContactComponent, this.modalOptions); - modalRef.componentInstance.contact = this.contact; - modalRef.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + const modalRefContact = this.modalService.open(NewContactComponent, this.modalOptions); + modalRefContact.componentInstance.contact = this.contact; + if (this.contact.birthday !== undefined) { + modalRefContact.componentInstance.birthdayValue = ApiConverter.convertDate(this.contact.birthday); + } + modalRefContact.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { if (modalStatus === ModalStatus.Submitted) { - modalRef.dismiss(); + modalRefContact.dismiss(); this.getContactData(); } }); diff --git a/matsen-tool/src/app/contacts/new-contact/new-contact.component.html b/matsen-tool/src/app/contacts/new-contact/new-contact.component.html index 024649c..a0b0ede 100644 --- a/matsen-tool/src/app/contacts/new-contact/new-contact.component.html +++ b/matsen-tool/src/app/contacts/new-contact/new-contact.component.html @@ -20,7 +20,8 @@
- +
diff --git a/matsen-tool/src/app/contacts/new-contact/new-contact.component.ts b/matsen-tool/src/app/contacts/new-contact/new-contact.component.ts index 1c78218..368b3cb 100644 --- a/matsen-tool/src/app/contacts/new-contact/new-contact.component.ts +++ b/matsen-tool/src/app/contacts/new-contact/new-contact.component.ts @@ -15,7 +15,6 @@ import {ApiConverter} from "@app/_helpers/api.converter"; styleUrl: './new-contact.component.scss' }) export class NewContactComponent implements OnInit { - @Input() public contact!: ContactJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @@ -24,6 +23,8 @@ export class NewContactComponent implements OnInit { protected contactSub: Subscription; protected mediaSub: Subscription; + protected birthdayValue: string; + constructor( private contactService: ContactService, private mediaObjectService: MediaObjectService, @@ -34,12 +35,23 @@ export class NewContactComponent implements OnInit { this.contactSub = new Subscription(); this.mediaSub = new Subscription(); + + this.birthdayValue = ""; } ngOnInit(): void { this.contactForm = FormGroupInitializer.initFormGroup(this.contactForm, this.contact); } + protected onBirthdayChange(selectedItem: any) { + // Set T12:00 for correct string + let selectedItemValue = null; + if (selectedItem.target.value !== "") { + selectedItemValue = selectedItem.target.value + "T12:00"; + } + this.contactForm.get('birthday')?.setValue(selectedItemValue); + } + // On submit form: Check if image is set onSubmit() { if (this.selectedImage !== null) { diff --git a/matsen-tool/src/app/home/home.component.html b/matsen-tool/src/app/home/home.component.html index abb1f0d..368c90f 100644 --- a/matsen-tool/src/app/home/home.component.html +++ b/matsen-tool/src/app/home/home.component.html @@ -73,7 +73,7 @@ aria-controls="collapseExample">

{{task.partnerName}}

- {{ task.dueAt | date:'dd.MM.YYYY HH:mm':'GMT+0000' }} + {{ task.dueAt | date:'dd.MM.YYYY':'GMT+0000' }}

{{task.headline}}

@@ -91,7 +91,7 @@
-

{{ taskNote.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ taskNote.createdAt | date:'dd.MM.YYYY' }}

{{ taskNote.ownerName }}

diff --git a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html index 05f737f..29e15b9 100644 --- a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html +++ b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html @@ -121,7 +121,7 @@ aria-controls="collapseExample">

{{ task.partnerName }}

- {{ task.dueAt | date:'dd.MM.YYYY HH:mm':'GMT+0000' }} + {{ task.dueAt | date:'dd.MM.YYYY':'GMT+0000' }}

{{ task.headline }}

@@ -139,7 +139,7 @@
-

{{ taskNote.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ taskNote.createdAt | date:'dd.MM.YYYY' }}

{{ taskNote.ownerName }}

@@ -181,7 +181,7 @@
-

{{ post.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ post.createdAt | date:'dd.MM.YYYY' }}

{{ post.ownerName }}

@@ -197,7 +197,7 @@
-

{{ comment.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ comment.createdAt | date:'dd.MM.YYYY' }}

{{ comment.ownerName }}

diff --git a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts index b4b9896..f9752fa 100644 --- a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts +++ b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts @@ -180,6 +180,8 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { undefined, undefined, undefined, + undefined, + undefined, false ).subscribe( data => { diff --git a/matsen-tool/src/app/sales/new-sale/new-sale.component.html b/matsen-tool/src/app/sales/new-sale/new-sale.component.html index 0c3b316..ad100d2 100644 --- a/matsen-tool/src/app/sales/new-sale/new-sale.component.html +++ b/matsen-tool/src/app/sales/new-sale/new-sale.component.html @@ -31,6 +31,11 @@
+
+ + +
+ diff --git a/matsen-tool/src/app/sales/sales-detail/sales-detail.component.html b/matsen-tool/src/app/sales/sales-detail/sales-detail.component.html index 30220e8..aa0415a 100644 --- a/matsen-tool/src/app/sales/sales-detail/sales-detail.component.html +++ b/matsen-tool/src/app/sales/sales-detail/sales-detail.component.html @@ -1 +1,81 @@ -

sales-detail works!

+
+
+
+
+

{{'overview.sale-user' | translate }}: {{ sale.ownerName }}

+
+
{{'overview.partner' | translate}}:
+
{{ sale.partnerName }}
+
{{'overview.product' | translate}}:
+
{{ sale.productName }}
+
{{'overview.turnover' | translate}}:
+
{{ sale.turnover }}
+
{{'overview.profit' | translate}}:
+
{{ sale.profit }}
+
{{'overview.comment' | translate}}:
+
{{ sale.comment }}
+
+
+
+ +
+
+
+ +
+
+
+

{{'basic.posts' | translate}}

+ +
+
+
+
+
+

{{ post.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ post.ownerName }}

+
+
+

{{ post.headline }}

+

{{ post.message }}

+
+ +
+
+
+
+
+
+

{{ comment.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ comment.ownerName }}

+
+
+

{{ comment.message }}

+
+ +
+
+
+ +
+ + {{ 'basic.hide-comments' | translate }} + {{ 'basic.show-comments' | translate }} + + {{'basic.comment-it' | translate}} +
+
+ + +
+
\ No newline at end of file diff --git a/matsen-tool/src/app/sales/sales-detail/sales-detail.component.ts b/matsen-tool/src/app/sales/sales-detail/sales-detail.component.ts index 3e91f64..97fd280 100644 --- a/matsen-tool/src/app/sales/sales-detail/sales-detail.component.ts +++ b/matsen-tool/src/app/sales/sales-detail/sales-detail.component.ts @@ -1,10 +1,188 @@ -import { Component } 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 {MatTableDataSource} from "@angular/material/table"; +import {CommentJsonld, ContactJsonld, 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 {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; +import {ModalStatus} from "@app/_helpers/modal.states"; +import {NewCommentComponent} from "@app/postings/new-comment/new-comment.component"; +import {NewContactComponent} from "@app/contacts/new-contact/new-contact.component"; +import {NewSaleComponent} from "@app/sales/new-sale/new-sale.component"; +import {ActivatedRoute} from "@angular/router"; @Component({ selector: 'app-sales-detail', templateUrl: './sales-detail.component.html', styleUrl: './sales-detail.component.scss' }) -export class SalesDetailComponent { +export class SalesDetailComponent implements OnInit, AfterViewInit { + @ViewChild(MatPaginator) postsPaginator: MatPaginator; + + protected user: User | null; + + protected id: string; + protected sale: SaleJsonld; + protected saleSub: Subscription; + + protected postsSub: Subscription; + protected posts: Array; + protected postsDataSource; + protected postsLength: number; + protected postsPageEvent: PageEvent; + protected postsPageSize: number; + protected postsPageIndex: number; + protected commentsVisibility: Map; + + protected modalOptions: NgbModalOptions = { + centered: true + }; + + constructor( + private accountService: AccountService, + private saleService: SaleService, + private route: ActivatedRoute, + private postService: PostService, + private modalService: NgbModal + ) { + 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(this.posts); + this.postsLength = 0; + this.postsPageEvent = new PageEvent(); + this.postsPageSize = 10; + this.postsPageIndex = 0; + this.commentsVisibility = new Map(); + } + + 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; + } + ); + } + + getPostsData() { + this.postsSub = this.postService.postsGetCollection( + this.postsPageIndex + 1, + this.postsPageSize, + this.sale.partner + '', + undefined, + undefined, + undefined, + this.id, + undefined, + false + ).subscribe( + data => { + this.posts = data["hydra:member"]; + this.postsLength = Number(data["hydra:totalItems"]); + this.posts.forEach(posts => { + if (posts.id) { + this.commentsVisibility.set(posts.id, false); + } + }); + } + ); + } + + 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(NewPostingComponent, this.modalOptions); + let posting: PostJsonld = {} as PostJsonld; + posting.sale = this.sale.id ?? null; + posting.partner = this.sale.partner ?? null; + modalRefPosting.componentInstance.posting = posting; + modalRefPosting.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefPosting.dismiss(); + this.getPostsData(); + } + }); + } + + openModalNewComment(post: PostJsonld) { + const modalRefComment = this.modalService.open(NewCommentComponent, this.modalOptions); + let comment: CommentJsonld = {} as CommentJsonld; + comment.post = post.id ?? null; + modalRefComment.componentInstance.comment = comment; + modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefComment.dismiss(); + this.getPostsData(); + } + }); + } + + openModalEditPosting(post: PostJsonld) { + const modalRefPostingEdit = this.modalService.open(NewPostingComponent, this.modalOptions); + modalRefPostingEdit.componentInstance.posting = post; + modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefPostingEdit.dismiss(); + this.getPostsData(); + } + }); + } + + openModalEditComment(comment: CommentJsonld) { + const modalRefComment = this.modalService.open(NewCommentComponent, this.modalOptions); + modalRefComment.componentInstance.comment = comment; + modalRefComment.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefComment.dismiss(); + this.getPostsData(); + } + }); + } + + openModalEditSale() { + const modalRefSale = this.modalService.open(NewSaleComponent, this.modalOptions); + 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); + } + } } diff --git a/matsen-tool/src/app/sales/sales.component.ts b/matsen-tool/src/app/sales/sales.component.ts index fde7b0f..3ee9a9a 100644 --- a/matsen-tool/src/app/sales/sales.component.ts +++ b/matsen-tool/src/app/sales/sales.component.ts @@ -160,9 +160,8 @@ export class SalesComponent implements OnInit { } navigateToSaleDetails(element: any) { - console.log(element); - // const sale: SaleJsonld = element as SaleJsonld; - // this.router.navigate(['/sales', ApiConverter.extractId(sale.id)]); + const sale: SaleJsonld = element as SaleJsonld; + this.router.navigate(['/sales', ApiConverter.extractId(sale.id)]); } openModalNewSale() { diff --git a/matsen-tool/src/app/tasks/new-task/new-task.component.html b/matsen-tool/src/app/tasks/new-task/new-task.component.html index abbb485..f54c938 100644 --- a/matsen-tool/src/app/tasks/new-task/new-task.component.html +++ b/matsen-tool/src/app/tasks/new-task/new-task.component.html @@ -37,7 +37,7 @@
-
{{ 'form.due-date' | translate }} {{ 'form.mandatory' | translate }}. diff --git a/matsen-tool/src/app/tasks/new-task/new-task.component.ts b/matsen-tool/src/app/tasks/new-task/new-task.component.ts index 28d6880..2dab5f7 100644 --- a/matsen-tool/src/app/tasks/new-task/new-task.component.ts +++ b/matsen-tool/src/app/tasks/new-task/new-task.component.ts @@ -76,7 +76,9 @@ export class NewTaskComponent implements OnInit { } protected onDueAtChange(selectedItem: any) { - this.taskForm.get('dueAt')?.setValue(selectedItem.target.value); + // Set T12:00 for correct string + let selectedItemValue = selectedItem.target.value + "T12:00"; + this.taskForm.get('dueAt')?.setValue(selectedItemValue); } protected onSubmit() { diff --git a/matsen-tool/src/app/tasks/tasks.component.html b/matsen-tool/src/app/tasks/tasks.component.html index 9ca1cea..db85167 100644 --- a/matsen-tool/src/app/tasks/tasks.component.html +++ b/matsen-tool/src/app/tasks/tasks.component.html @@ -11,7 +11,7 @@ aria-controls="collapseExample">

{{task.partnerName}}

- {{ task.dueAt | date:'dd.MM.YYYY HH:mm':'GMT+0000' }} + {{ task.dueAt | date:'dd.MM.YYYY':'GMT+0000' }}

{{task.headline}}

diff --git a/matsen-tool/src/assets/i18n/de.json b/matsen-tool/src/assets/i18n/de.json index 534e0ba..9ec75d3 100644 --- a/matsen-tool/src/assets/i18n/de.json +++ b/matsen-tool/src/assets/i18n/de.json @@ -78,6 +78,7 @@ "details": "Details", "turnover": "Umsatz", "profit": "Gewinn", + "comment": "Kommentar", "createdAt": "erstellt am" }, "form": diff --git a/matsen-tool/src/assets/scss/_button.scss b/matsen-tool/src/assets/scss/_button.scss index 95c8210..b0874cd 100644 --- a/matsen-tool/src/assets/scss/_button.scss +++ b/matsen-tool/src/assets/scss/_button.scss @@ -13,8 +13,13 @@ font-size: 20px; @include transition(); - &:hover { - background: $color-matsen; + &:not(.btn):hover { + color: $color-matsen; + } + &.btn { + &:hover { + background: $color-matsen; + } } }