diff --git a/matsen-tool/src/app/_components/list/list.component.ts b/matsen-tool/src/app/_components/list/list.component.ts index 38a4742..5d3ba7f 100644 --- a/matsen-tool/src/app/_components/list/list.component.ts +++ b/matsen-tool/src/app/_components/list/list.component.ts @@ -1,5 +1,6 @@ import {PageEvent} from "@angular/material/paginator"; import {throwError} from "rxjs"; +import {NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; export class ListComponent{ @@ -8,6 +9,9 @@ export class ListComponent{ protected pageSize: number; protected pageIndex: number; protected pageSizeOptions: number[]; + protected modalOptions: NgbModalOptions = { + centered: true + }; constructor() { diff --git a/matsen-tool/src/app/_components/search-input/search-input.component.html b/matsen-tool/src/app/_components/search-input/search-input.component.html new file mode 100644 index 0000000..eca4a3b --- /dev/null +++ b/matsen-tool/src/app/_components/search-input/search-input.component.html @@ -0,0 +1,4 @@ + + diff --git a/matsen-tool/src/app/_components/search-input/search-input.component.scss b/matsen-tool/src/app/_components/search-input/search-input.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/matsen-tool/src/app/_components/search-input/search-input.component.spec.ts b/matsen-tool/src/app/_components/search-input/search-input.component.spec.ts new file mode 100644 index 0000000..0e2124c --- /dev/null +++ b/matsen-tool/src/app/_components/search-input/search-input.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchInputComponent } from './search-input.component'; + +describe('SearchInputComponent', () => { + let component: SearchInputComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [SearchInputComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SearchInputComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/matsen-tool/src/app/_components/search-input/search-input.component.ts b/matsen-tool/src/app/_components/search-input/search-input.component.ts new file mode 100644 index 0000000..25e30f6 --- /dev/null +++ b/matsen-tool/src/app/_components/search-input/search-input.component.ts @@ -0,0 +1,38 @@ +import {Component, Input} from '@angular/core'; +import {FormGroup} from "@angular/forms"; +import {debounceTime, distinctUntilChanged, Observable, OperatorFunction, switchMap} from "rxjs"; +import {filter, map} from "rxjs/operators"; + +@Component({ + selector: 'app-search-input', + templateUrl: './search-input.component.html', + styleUrl: './search-input.component.scss' +}) +export class SearchInputComponent { + + @Input() public formId!: string; + @Input() public formLabelLangKey!: string; + @Input() public dataField!: string; + @Input() public documentForm!: FormGroup; + @Input() public documentFormField!: string; + @Input() public fetchFunction!: (term: string) => Observable<{ id: any; name: any }[]>; + + + protected formatter = (apiData: any) => apiData.name; + + protected searchItem: OperatorFunction = (text$: Observable) => + text$.pipe( + debounceTime(200), + distinctUntilChanged(), + filter((term) => term.length >= 2), + switchMap((term) => this.fetchFunction(term)), + map((items: {id: any, name: any}[]) => items.slice(0, 10)), + ); + + protected onItemSelect(selectedItem: any): void { + this.documentForm.get(this.formId)?.setValue(selectedItem.item.id); + } +} diff --git a/matsen-tool/src/app/_helpers/api.converter.ts b/matsen-tool/src/app/_helpers/api-helper.service.ts similarity index 97% rename from matsen-tool/src/app/_helpers/api.converter.ts rename to matsen-tool/src/app/_helpers/api-helper.service.ts index decfb21..f634be0 100644 --- a/matsen-tool/src/app/_helpers/api.converter.ts +++ b/matsen-tool/src/app/_helpers/api-helper.service.ts @@ -2,7 +2,7 @@ import {DomSanitizer, SafeHtml} from "@angular/platform-browser"; import {Injectable} from "@angular/core"; @Injectable({ providedIn: 'root' }) -export class ApiConverter { +export class ApiHelperService { constructor(private sanitizer: DomSanitizer) {} diff --git a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.html b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.html index a9b22c9..cc75398 100644 --- a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.html +++ b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.html @@ -26,12 +26,12 @@ - diff --git a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts index 5c67f76..c7fbc7e 100644 --- a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts +++ b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts @@ -7,14 +7,15 @@ import {NewContactComponent} from "@app/_views/contacts/new-contact/new-contact. import {ModalStatus} from "@app/_helpers/modal.states"; import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; import {Router} from "@angular/router"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; +import {ListComponent} from "@app/_components/list/list.component"; @Component({ selector: 'app-contact-list', templateUrl: './contact-list.component.html', styleUrl: './contact-list.component.scss' }) -export class ContactListComponent implements OnInit { +export class ContactListComponent extends ListComponent implements OnInit { @Input() public partner!: PartnerJsonld; @@ -23,48 +24,36 @@ export class ContactListComponent implements OnInit { protected contactsSub: Subscription; protected contacts: Array; protected contactsDataSource; - protected contactsLength: number; - protected contactsPageEvent: PageEvent; - protected contactsPageSize: number; - protected contactsPageIndex: number; - - protected modalOptions: NgbModalOptions = { - centered: true - }; constructor( private router: Router, private modalService: NgbModal, private contactService: ContactService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { + super(); this.contactsSub = new Subscription(); this.contacts = []; this.contactsPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); this.contactsDataSource = new MatTableDataSource(this.contacts); - this.contactsLength = 0; - this.contactsPageEvent = new PageEvent(); - this.contactsPageSize = 6; - this.contactsPageIndex = 0; } ngOnInit() { - this.getContactsData(); + this.getData(); } - getContactsData() { + override getData() { this.contactsSub = this.contactService.contactsGetCollection( - this.contactsPageIndex + 1, - this.contactsPageSize, + this.pageIndex + 1, + this.pageSize, this.partner.id ).subscribe( data => { this.contacts = data["hydra:member"]; - this.contactsLength = Number(data["hydra:totalItems"]); + this.dataLength = Number(data["hydra:totalItems"]); if (this.contactsPaginator !== undefined) { - this.contactsPaginator.length = this.contactsLength; + this.contactsPaginator.length = this.dataLength; } - console.log('getPartnerProducts done'); } ); } @@ -77,21 +66,13 @@ export class ContactListComponent implements OnInit { modalRefContact.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { if (modalStatus === ModalStatus.Submitted) { modalRefContact.dismiss(); - this.getContactsData(); + this.getData(); } }); } navigateToContactDetails(element: any) { const contact: ContactJsonld = element as ContactJsonld; - this.router.navigate(['/contacts', this.apiConverter.extractId(contact.id)]); - } - - contactsHandlePageEvent(e: PageEvent) { - this.contactsPageEvent = e; - this.contactsLength = e.length; - this.contactsPageIndex = e.pageIndex.valueOf(); - this.contactsPageSize = e.pageSize.valueOf(); - this.getContactsData(); + this.router.navigate(['/contacts', this.apiHelperService.extractId(contact.id)]); } } diff --git a/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html b/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html index b788d81..32ed1d4 100644 --- a/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html +++ b/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.html @@ -1,5 +1,5 @@
-
+

{{ contact.firstName }} {{ contact.lastName }}

@@ -25,57 +25,8 @@
-
-
- -
-
-
-
-

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

-

{{ post.ownerName }}

-
-
-

{{ post.headline }}

-

-
- -
-
-
-
-
-
-

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

-

{{ comment.ownerName }}

-
-
-

-
- -
-
-
- -
- - {{ 'basic.hide-comments' | translate }} - {{ 'basic.show-comments' | translate }} - - {{'basic.comment-it' | translate}} -
-
- - -
-
+
diff --git a/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts b/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts index 2c44dd8..4d2f09a 100644 --- a/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts +++ b/matsen-tool/src/app/_views/contacts/contacts-detail/contacts-detail.component.ts @@ -1,5 +1,13 @@ import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; -import {CommentJsonld, ContactJsonld, ContactService, PostJsonld, PostService} from "@app/core/api/v1"; +import { + CommentJsonld, + ContactJsonld, + 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"; @@ -11,8 +19,10 @@ 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 {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-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"; @Component({ selector: 'app-contacts-detail', @@ -20,166 +30,73 @@ import {constructorParametersDownlevelTransform} from "@angular/compiler-cli"; styleUrl: './contacts-detail.component.scss' }) export class ContactsDetailComponent implements OnInit, AfterViewInit { - @ViewChild(MatPaginator) postsPaginator: MatPaginator; + @ViewChild("togglePosts", { static: true }) togglePosts: ToggleComponent = new ToggleComponent(); + @ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent; protected user: User | null; - protected id: string; - protected contact: ContactJsonld; + protected contactId!: string; + protected contact!: ContactJsonld; protected contactSub: Subscription; - - protected postsSub: Subscription; - protected posts: Array; - protected postsDataSource; - protected postsLength: number; - protected postsPageEvent: PageEvent; - protected postsPageSize: number; - protected postsPageIndex: number; + protected partner!: PartnerJsonld; + protected partnerSub: Subscription; protected commentsVisibility: Map; - protected modalOptions: NgbModalOptions = { centered: true }; constructor( private contactService: ContactService, + private partnerService: PartnerService, private accountService: AccountService, private route: ActivatedRoute, - private postService: PostService, private modalService: NgbModal, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.user = this.accountService.userValue; - - this.id = ""; - this.contact = {} as ContactJsonld; this.contactSub = 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(); + this.partnerSub = new Subscription(); } ngOnInit() { + // Get contact id from route url parameter this.route.params.subscribe(params => { - this.id = params['id']; + this.contactId = params['id']; }); this.getContactData(); - this.getPostsData(); } ngAfterViewInit() { - this.postsDataSource.paginator = this.postsPaginator; } getContactData() { // switch over this.dataType (customers, etc.) this.contactSub = this.contactService.contactsIdGet( - this.id + this.contactId ).subscribe( data => { this.contact = data; + this.getPartnerData() } ); } - getPostsData() { - this.postsSub = this.postService.postsGetCollection( - this.postsPageIndex + 1, - this.postsPageSize, - this.contact.partner + '', - [], - this.id, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - false + getPartnerData() { + this.partnerSub = this.partnerService.partnersIdGet( + this.apiHelperService.extractId(this.contact.partner) ).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(NewPostComponent, this.modalOptions); - let posting: PostJsonld = {} as PostJsonld; - posting.contact = this.contact.id ?? null; - posting.partner = this.contact.partner ?? null; - // TODO: REAL PRODUCT - posting.product = "/api/products/101"; - 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(NewPostComponent, this.modalOptions); - modalRefPostingEdit.componentInstance.posting = post; - modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { - if (modalStatus === ModalStatus.Submitted) { - modalRefPostingEdit.dismiss(); - this.getPostsData(); + this.partner = data; } - }); - } - - 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(); - } - }); + ) } openModalEditContact() { const modalRefContact = this.modalService.open(NewContactComponent, this.modalOptions); modalRefContact.componentInstance.contact = this.contact; if (this.contact.birthday !== undefined) { - modalRefContact.componentInstance.birthdayValue = this.apiConverter.convertDate(this.contact.birthday); + modalRefContact.componentInstance.birthdayValue = this.apiHelperService.convertDate(this.contact.birthday); } modalRefContact.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { if (modalStatus === ModalStatus.Submitted) { @@ -188,11 +105,4 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { } }); } - - 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/_views/contacts/new-contact/new-contact.component.ts b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts index bb848fc..eeb236d 100644 --- a/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts +++ b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts @@ -6,7 +6,7 @@ import {Subscription} from "rxjs"; import {ModalStatus} from "@app/_helpers/modal.states"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {TranslateService} from "@ngx-translate/core"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ @@ -29,7 +29,7 @@ export class NewContactComponent implements OnInit { private contactService: ContactService, private mediaObjectService: MediaObjectService, private translateService: TranslateService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.contactForm = contactForm; this.selectedImage = null; @@ -85,7 +85,7 @@ export class NewContactComponent implements OnInit { } else { // Edit contact this.contactSub = this.contactService.contactsIdPatch( - this.apiConverter.extractId(this.contact.id), + this.apiHelperService.extractId(this.contact.id), this.contactForm.value as ContactJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/documents/documents.component.ts b/matsen-tool/src/app/_views/documents/documents.component.ts index 60cd9bc..7c4bcc7 100644 --- a/matsen-tool/src/app/_views/documents/documents.component.ts +++ b/matsen-tool/src/app/_views/documents/documents.component.ts @@ -12,7 +12,7 @@ import {NewDocumentComponent} from "@app/_views/documents/new-document/new-docum import {TranslateModule} from "@ngx-translate/core"; import {ModalStatus} from "@app/_helpers/modal.states"; import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-documents', @@ -43,7 +43,7 @@ export class DocumentsComponent { private router: Router, private modalService: NgbModal, private documentService: DocumentService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.sort = new MatSort(); this.displayedColumns = ['pos', 'name', 'description', 'partnerName', 'productName', 'createdAt', 'createdByName', 'download', 'edit']; diff --git a/matsen-tool/src/app/_views/documents/new-document/new-document.component.html b/matsen-tool/src/app/_views/documents/new-document/new-document.component.html index 1e3433a..2061b1c 100644 --- a/matsen-tool/src/app/_views/documents/new-document/new-document.component.html +++ b/matsen-tool/src/app/_views/documents/new-document/new-document.component.html @@ -13,24 +13,32 @@
- - +
- - +
- - + +
diff --git a/matsen-tool/src/app/_views/documents/new-document/new-document.component.ts b/matsen-tool/src/app/_views/documents/new-document/new-document.component.ts index 95b017f..0d92036 100644 --- a/matsen-tool/src/app/_views/documents/new-document/new-document.component.ts +++ b/matsen-tool/src/app/_views/documents/new-document/new-document.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import { DocumentJsonld, DocumentObjectService, DocumentService, MediaObjectService, PartnerJsonld, PartnerService, ProductService @@ -9,8 +9,9 @@ import {debounceTime, distinctUntilChanged, Observable, OperatorFunction, Subscr import {TranslateService} from "@ngx-translate/core"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {documentForm} from "@app/_forms/apiForms"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {filter, map} from "rxjs/operators"; +import {SearchInputComponent} from "@app/_components/search-input/search-input.component"; @Component({ selector: 'app-new-document', @@ -21,6 +22,9 @@ export class NewDocumentComponent implements OnInit { @Input() public document!: DocumentJsonld; @Output() public submit: EventEmitter = new EventEmitter(); + @ViewChild('partnerSearchInput', { static: false }) $partnerSearchInput!: SearchInputComponent; + @ViewChild('productSearchInput', { static: false }) $productSearchInput!: SearchInputComponent; + protected documentForm: FormGroup; protected documentSub: Subscription; @@ -35,7 +39,7 @@ export class NewDocumentComponent implements OnInit { private translateService: TranslateService, private partnerService: PartnerService, private productService: ProductService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.documentForm = documentForm; this.documentSub = new Subscription(); @@ -47,51 +51,20 @@ export class NewDocumentComponent implements OnInit { this.documentForm = FormGroupInitializer.initFormGroup(this.documentForm, this.document); } - protected searchPartners: OperatorFunction = (text$: Observable) => - text$.pipe( - debounceTime(200), - distinctUntilChanged(), - filter((term) => term.length >= 2), - switchMap((term) => this.fetchPartners(term)), - map((partners) => partners.slice(0, 10)), - ); - - protected searchProducts: OperatorFunction = (text$: Observable) => - text$.pipe( - debounceTime(200), - distinctUntilChanged(), - filter((term) => term.length >= 2), - switchMap((term) => this.fetchProducts(term)), - map((products) => products.slice(0, 10)), - ); - - protected fetchPartners(term: string): Observable<{ id: any; name: any }[]> { + fetchPartners = (term: string): Observable<{ id: any; name: any }[]> => { return this.partnerService.partnersGetCollection(1, 50, undefined, undefined, term).pipe( map((response) => response['hydra:member'].map(partner => ({id: partner.id, name: partner.name}))), ); } - protected fetchProducts(term: string): Observable<{ id: any; name: any }[]> { + fetchProducts = (term: string): Observable<{ id: any; name: any }[]> => { return this.productService.productsGetCollection(1, 50, term).pipe( map((response) => response['hydra:member'].map(product => ({id: product.id, name: product.name}))), ); } - protected onPartnerSelect(selectedItem: any): void { - this.documentForm.get('partner')?.setValue(selectedItem.item.id); - } - - protected onProductSelect(selectedItem: any): void { - this.documentForm.get('product')?.setValue(selectedItem.item.id); - } - onSubmit() { + console.log(this.documentForm); if (this.selectedFile !== null) { this.documentObjectSub = this.documentObjectService.documentObjectsPost( this.selectedFile @@ -121,7 +94,7 @@ export class NewDocumentComponent implements OnInit { } else { // Edit contact this.documentSub = this.documentService.documentsIdPatch( - this.apiConverter.extractId(this.document.id), + this.apiHelperService.extractId(this.document.id), this.documentForm.value as DocumentJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/home/home.component.html b/matsen-tool/src/app/_views/home/home.component.html index 72099c6..99d9382 100644 --- a/matsen-tool/src/app/_views/home/home.component.html +++ b/matsen-tool/src/app/_views/home/home.component.html @@ -69,14 +69,14 @@
-

{{task.partnerName}}

+

{{task.partnerName}}

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

{{ task.headline }}

-

+

Zugewiesen an: {{ task.assignedToName }}

diff --git a/matsen-tool/src/app/_views/home/home.component.ts b/matsen-tool/src/app/_views/home/home.component.ts index 8fd3f4c..de9508c 100644 --- a/matsen-tool/src/app/_views/home/home.component.ts +++ b/matsen-tool/src/app/_views/home/home.component.ts @@ -18,7 +18,7 @@ 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 {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ templateUrl: 'home.component.html', @@ -36,8 +36,6 @@ export class HomeComponent implements OnInit, AfterViewInit { protected userIsAdmin: boolean; - protected readonly ApiConverter = ApiConverter; - protected tasksSub: Subscription; protected tasks: Array; protected tasksDataSource; @@ -58,7 +56,7 @@ export class HomeComponent implements OnInit, AfterViewInit { private postService: PostService, private userService: UserService, private taskService: TaskService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.user = this.accountService.userValue; // this.accountService.user.subscribe(x => this.user = x); @@ -159,7 +157,7 @@ export class HomeComponent implements OnInit, AfterViewInit { openModalEditTask(task: TaskJsonld) { const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.modalOptions); modalRefTaskEdit.componentInstance.task = task; - modalRefTaskEdit.componentInstance.dueAtValue = this.apiConverter.convertDate(task.dueAt); + modalRefTaskEdit.componentInstance.dueAtValue = this.apiHelperService.convertDate(task.dueAt); modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { if (modalStatus === ModalStatus.Submitted) { modalRefTaskEdit.dismiss(); diff --git a/matsen-tool/src/app/_views/partners/new-partner/new-partner.component.ts b/matsen-tool/src/app/_views/partners/new-partner/new-partner.component.ts index d778d1f..74fa557 100644 --- a/matsen-tool/src/app/_views/partners/new-partner/new-partner.component.ts +++ b/matsen-tool/src/app/_views/partners/new-partner/new-partner.component.ts @@ -6,7 +6,7 @@ import {FormGroup} from "@angular/forms"; import {Subscription} from "rxjs"; import {TranslateService} from "@ngx-translate/core"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-new-partner', @@ -29,7 +29,7 @@ export class NewPartnerComponent implements OnInit { private partnerService: PartnerService, private mediaObjectService: MediaObjectService, private translateService: TranslateService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.partnerForm = partnerForm; this.selectedImage = null; @@ -79,7 +79,7 @@ export class NewPartnerComponent implements OnInit { } else { // Edit contact this.partnerSub = this.partnerService.partnersIdPatch( - this.apiConverter.extractId(this.partner.id), + this.apiHelperService.extractId(this.partner.id), this.partnerForm.value as PartnerJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.html b/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.html index 007e4bb..2042ca8 100644 --- a/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.html +++ b/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.html @@ -42,82 +42,33 @@
-

+

- + + -
-
- -
-
-
-

{{task.partnerName}}

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

{{ task.headline }}

-
-

-

Zugewiesen an: {{ task.assignedToName }}

- -
-
-
-
-
-
-
-

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

-

{{ taskNote.ownerName }}

-
-
-

{{ taskNote.message }}

-
- -
-
-
- -
- - {{ 'basic.hide-comments' | translate }} - {{ 'basic.show-comments' | translate }} - - {{ 'basic.comment-it' | translate }} -
-
- - -
-
+ +
- + + diff --git a/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.ts b/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.ts index 4c46bd2..9fed827 100644 --- a/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.ts +++ b/matsen-tool/src/app/_views/partners/partners-detail/partners-detail.component.ts @@ -1,25 +1,22 @@ -import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; import {ActivatedRoute, Router} from "@angular/router"; import { PartnerFollowJsonld, PartnerFollowService, PartnerJsonld, PartnerProductJsonld, PartnerProductService, - PartnerService, TaskJsonld, TaskNoteJsonld, TaskService + PartnerService } from "@app/core/api/v1"; import {Subscription} from "rxjs"; import {environment} from "@environments/environment"; -import {ApiConverter} from "@app/_helpers/api.converter"; -import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; -import {MatTableDataSource} from "@angular/material/table"; -import {NewTaskComponent} from "@app/_views/tasks/new-task/new-task.component"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {ModalStatus} from "@app/_helpers/modal.states"; import {AccountService} from "@app/_services"; import {User} from "@app/_models"; import {NewPartnerComponent} from "@app/_views/partners/new-partner/new-partner.component"; -import {NewTaskNoteComponent} from "@app/_views/tasks/new-task-note/new-task-note.component"; import {ToggleComponent} from "@app/_components/toggle/toggle.component"; import {PostListComponent} from "@app/_views/posts/post-list/post-list.component"; import {ContactListComponent} from "@app/_views/contacts/contact-list/contact-list.component"; +import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component"; @Component({ selector: 'app-partners-detail', @@ -28,39 +25,23 @@ import {ContactListComponent} from "@app/_views/contacts/contact-list/contact-li }) export class PartnersDetailComponent implements OnInit, AfterViewInit { @ViewChild("toggleContacts", { static: true }) toggleContacts: ToggleComponent = new ToggleComponent(); - @ViewChild("contactsComponent", { static: false }) contactsComponent!: ContactListComponent; - + @ViewChild("contactListComponent", { static: false }) contactsComponent!: ContactListComponent; @ViewChild("toggleTasks", { static: true }) toggleTasks: ToggleComponent = new ToggleComponent(); - + @ViewChild("taskListComponent", { static: false }) taskListComponent!: TaskListComponent; @ViewChild("togglePosts", { static: true }) togglePosts: ToggleComponent = new ToggleComponent(); - @ViewChild("postsComponent", { static: false }) postsComponent!: PostListComponent; - - @ViewChild(MatPaginator) tasksPaginator: MatPaginator; + @ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent; protected user: User | null; protected readonly environment = environment; - protected id: string; + protected partnerId!: string; protected partnerDetailSub: Subscription; protected partner!: PartnerJsonld; - protected partnerProductSub: Subscription; protected partnerProducts: Array; - protected partnerFollowSub: Subscription; protected partnerFollow: PartnerFollowJsonld | null; - - protected tasksSub: Subscription; - protected tasks: Array; - protected tasksDataSource; - protected tasksLength: number; - protected tasksPageEvent: PageEvent; - protected tasksPageSize: number; - protected tasksPageIndex: number; - - protected taskNotesVisibility: Map; - protected modalOptions: NgbModalOptions = { centered: true }; @@ -73,12 +54,9 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { private partnerService: PartnerService, private partnerProductService: PartnerProductService, private partnerFollowService: PartnerFollowService, - private taskService: TaskService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { - this.id = ""; this.partnerDetailSub = new Subscription(); - //this.partner = {} as PartnerJsonld; this.partnerProductSub = new Subscription(); this.partnerProducts = []; @@ -87,42 +65,26 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { this.partnerFollow = null; this.user = this.accountService.userValue; - - this.tasksSub = new Subscription(); - this.tasks = []; - this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); - this.tasksDataSource = new MatTableDataSource(this.tasks); - this.tasksLength = 0; - this.tasksPageEvent = new PageEvent(); - this.tasksPageSize = 10; - this.tasksPageIndex = 0; - this.taskNotesVisibility = new Map(); } ngOnInit() { this.route.params.subscribe(params => { - this.id = params['id']; + this.partnerId = params['id']; }); this.getPartnerData(); this.getPartnerProducts(); - this.getTasksData(); this.getPartnerFollowedStatus(); - - console.log('ng init done'); } ngAfterViewInit() { - console.log('ng after view init'); - this.tasksDataSource.paginator = this.tasksPaginator; } getPartnerData() { this.partnerDetailSub = this.partnerService.partnersIdGet( - this.id + this.partnerId ).subscribe( data => { this.partner = data; - console.log('getPartnerData done'); } ); } @@ -131,96 +93,14 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { this.partnerProductSub = this.partnerProductService.partnerProductsGetCollection( 1, 50, - this.id + this.partnerId ).subscribe( data => { this.partnerProducts = data["hydra:member"]; - console.log('getPartnerProducts done'); - } - ); - } - - getTasksData() { - this.tasksSub = this.taskService.tasksGetCollection( - this.tasksPageIndex + 1, - this.tasksPageSize, - undefined, - undefined, - this.id - ).subscribe( - data => { - this.tasks = data["hydra:member"]; - console.log(this.tasks); - this.tasksLength = Number(data["hydra:totalItems"]); - this.tasks.forEach(task => { - if (task.id) { - this.taskNotesVisibility.set(task.id, false); - } - }); - console.log('getTasksData done'); } ); } - 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.modalOptions); - 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.getTasksData(); - } - }); - } - - openModalNewTaskNote(task: TaskJsonld) { - const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.modalOptions); - 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.modalOptions); - modalRefTaskEdit.componentInstance.task = task; - modalRefTaskEdit.componentInstance.dueAtValue = this.apiConverter.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.modalOptions); - modalRefTaskNote.componentInstance.taskNote = taskNote; - modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { - if (modalStatus === ModalStatus.Submitted) { - modalRefTaskNote.dismiss(); - this.getTasksData(); - } - }); - } - openModalEditPartner() { const modalRef = this.modalService.open(NewPartnerComponent, this.modalOptions); modalRef.componentInstance.partner = this.partner; @@ -232,18 +112,11 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { }); } - showTaskNotes(task: TaskJsonld) { - if (task.id) { - const currentVisibility = this.taskNotesVisibility.get(task.id); - this.taskNotesVisibility.set(task.id, !currentVisibility); - } - } - getPartnerFollowedStatus() { this.partnerFollowSub = this.partnerFollowService.partnerFollowsGetCollection( 1, 50, - this.id, + this.partnerId, undefined, this.user?.id ).subscribe( @@ -271,7 +144,7 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { ); } else { this.partnerFollowSub = this.partnerFollowService.partnerFollowsIdDelete( - this.apiConverter.extractId(this.partnerFollow.id) + this.apiHelperService.extractId(this.partnerFollow.id) ).subscribe( data => { this.partnerFollow = null; diff --git a/matsen-tool/src/app/_views/partners/partners.component.ts b/matsen-tool/src/app/_views/partners/partners.component.ts index 4a76b94..9ed7315 100644 --- a/matsen-tool/src/app/_views/partners/partners.component.ts +++ b/matsen-tool/src/app/_views/partners/partners.component.ts @@ -6,7 +6,7 @@ import {Subscription} from "rxjs"; import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; import {OrderFilter} from "@app/_models/orderFilter"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {NgIf} from "@angular/common"; import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; import {NewPartnerComponent} from "@app/_views/partners/new-partner/new-partner.component"; @@ -53,7 +53,7 @@ export class PartnersComponent implements OnInit, AfterViewInit { private router: Router, private modalService: NgbModal, private translateService: TranslateService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.partnersSort = new MatSort(); this.partnersPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); @@ -153,7 +153,7 @@ export class PartnersComponent implements OnInit, AfterViewInit { navigateToPartnerDetails(element: any) { const partner: PartnerJsonld = element as PartnerJsonld; - this.router.navigate(['/' + partner.partnerType, this.apiConverter.extractId(partner.id)]); + this.router.navigate(['/' + partner.partnerType, this.apiHelperService.extractId(partner.id)]); } openModalNewPartner() { diff --git a/matsen-tool/src/app/_views/posts/new-comment/new-comment.component.ts b/matsen-tool/src/app/_views/posts/new-comment/new-comment.component.ts index ff2dbb1..a256c24 100644 --- a/matsen-tool/src/app/_views/posts/new-comment/new-comment.component.ts +++ b/matsen-tool/src/app/_views/posts/new-comment/new-comment.component.ts @@ -5,7 +5,7 @@ import {Subscription} from "rxjs"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {FormGroup} from "@angular/forms"; import {commentForm} from "@app/_forms/apiForms"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-new-comment', @@ -21,7 +21,7 @@ export class NewCommentComponent implements OnInit { constructor( private commentService: CommentService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.commentForm = commentForm; this.commentSub = new Subscription(); @@ -46,7 +46,7 @@ export class NewCommentComponent implements OnInit { } else { // Edit comment this.commentSub = this.commentService.commentsIdPatch( - this.apiConverter.extractId(this.comment.id), + this.apiHelperService.extractId(this.comment.id), this.commentForm.value as CommentJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/posts/new-post/new-post.component.ts b/matsen-tool/src/app/_views/posts/new-post/new-post.component.ts index f383e5a..343817e 100644 --- a/matsen-tool/src/app/_views/posts/new-post/new-post.component.ts +++ b/matsen-tool/src/app/_views/posts/new-post/new-post.component.ts @@ -4,7 +4,7 @@ import {FormGroup} from "@angular/forms"; import {postForm} from "@app/_forms/apiForms"; import {PartnerJsonld, PostJsonld, PostService} from "@app/core/api/v1"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {Subscription} from "rxjs"; @Component({ @@ -21,7 +21,7 @@ export class NewPostComponent implements OnInit { constructor( private postService: PostService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.postForm = postForm; this.postSub = new Subscription(); @@ -47,7 +47,7 @@ export class NewPostComponent implements OnInit { } else { // Edit post this.postSub = this.postService.postsIdPatch( - this.apiConverter.extractId(this.posting.id), + this.apiHelperService.extractId(this.posting.id), this.postForm.value as PostJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/posts/post-list/post-list.component.html b/matsen-tool/src/app/_views/posts/post-list/post-list.component.html index e3b6af7..e98e93a 100644 --- a/matsen-tool/src/app/_views/posts/post-list/post-list.component.html +++ b/matsen-tool/src/app/_views/posts/post-list/post-list.component.html @@ -1,6 +1,6 @@
- +
@@ -10,11 +10,11 @@

{{ post.headline }}

-

+

+ data-action="edit" (click)="openModalEditPost(post)">
@@ -25,7 +25,7 @@

{{ comment.ownerName }}

-

+

@@ -45,7 +45,7 @@ (click)="openModalNewComment(post)">{{ 'basic.comment-it' | translate }}
- ; protected postsDataSource; - protected postsLength: number; - protected postsPageEvent: PageEvent; - protected postsPageSize: number; - protected postsPageIndex: number; protected commentsVisibility: Map; - protected modalOptions: NgbModalOptions = { - centered: true - }; - constructor( private postService: PostService, - private partnerProductService: PartnerProductService, private modalService: NgbModal, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { super(); this.postsSub = new Subscription(); @@ -62,10 +53,6 @@ export class PostListComponent extends ListComponent implements OnInit, AfterVie this.partnerProducts = []; 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(); } @@ -79,8 +66,8 @@ export class PostListComponent extends ListComponent implements OnInit, AfterVie override getData() { this.postsSub = this.postService.postsGetCollection( - this.postsPageIndex + 1, - this.postsPageSize, + this.pageIndex + 1, + this.pageSize, this.partner !== undefined ? this.partner.id : undefined, undefined, this.contact !== undefined ? this.contact.id : undefined, @@ -94,7 +81,7 @@ export class PostListComponent extends ListComponent implements OnInit, AfterVie ).subscribe( data => { this.posts = data["hydra:member"]; - this.postsLength = Number(data["hydra:totalItems"]); + this.dataLength = Number(data["hydra:totalItems"]); this.posts.forEach(posts => { if (posts.id) { this.commentsVisibility.set(posts.id, false); @@ -111,7 +98,7 @@ export class PostListComponent extends ListComponent implements OnInit, AfterVie } } - openModalNewPosting() { + openModalNewPost() { const modalRefPosting = this.modalService.open(NewPostComponent, this.modalOptions); let posting: PostJsonld = {} as PostJsonld; posting.partner = this.partner.id ?? null; @@ -124,7 +111,7 @@ export class PostListComponent extends ListComponent implements OnInit, AfterVie }); } - openModalEditPosting(post: PostJsonld) { + openModalEditPost(post: PostJsonld) { const modalRefPostingEdit = this.modalService.open(NewPostComponent, this.modalOptions); modalRefPostingEdit.componentInstance.posting = post; modalRefPostingEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { diff --git a/matsen-tool/src/app/_views/products/new-product/new-product.component.ts b/matsen-tool/src/app/_views/products/new-product/new-product.component.ts index 1b9aba1..a569c93 100644 --- a/matsen-tool/src/app/_views/products/new-product/new-product.component.ts +++ b/matsen-tool/src/app/_views/products/new-product/new-product.component.ts @@ -5,7 +5,7 @@ import {FormGroup} from "@angular/forms"; import {Subscription} from "rxjs"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {productForm} from "@app/_forms/apiForms"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {TranslateService} from "@ngx-translate/core"; @Component({ @@ -27,7 +27,7 @@ export class NewProductComponent implements OnInit { private productService: ProductService, private mediaObjectService: MediaObjectService, private translateService: TranslateService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.productForm = productForm; this.productSub = new Subscription(); @@ -70,7 +70,7 @@ export class NewProductComponent implements OnInit { } else { // Edit product this.productSub = this.productService.productsIdPatch( - this.apiConverter.extractId(this.product.id), + this.apiHelperService.extractId(this.product.id), this.productForm.value as ProductJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/products/products-detail/products-detail.component.ts b/matsen-tool/src/app/_views/products/products-detail/products-detail.component.ts index 4187586..10a038e 100644 --- a/matsen-tool/src/app/_views/products/products-detail/products-detail.component.ts +++ b/matsen-tool/src/app/_views/products/products-detail/products-detail.component.ts @@ -13,7 +13,7 @@ import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; import {NewProductComponent} from "@app/_views/products/new-product/new-product.component"; import {User} from "@app/_models"; import {AccountService} from "@app/_services"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-products-detail', @@ -40,7 +40,7 @@ export class ProductsDetailComponent implements OnInit, AfterViewInit { private productService: ProductService, private userProductService: UserProductService, private modalService: NgbModal, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.id = ""; this.user = this.accountService.userValue; @@ -105,7 +105,7 @@ export class ProductsDetailComponent implements OnInit, AfterViewInit { ); } else { this.userProductSub = this.userProductService.userProductsIdDelete( - this.apiConverter.extractId(this.userProduct.id) + this.apiHelperService.extractId(this.userProduct.id) ).subscribe( data => { this.userProduct = null; diff --git a/matsen-tool/src/app/_views/products/products.component.ts b/matsen-tool/src/app/_views/products/products.component.ts index 6f79179..64327ae 100644 --- a/matsen-tool/src/app/_views/products/products.component.ts +++ b/matsen-tool/src/app/_views/products/products.component.ts @@ -4,7 +4,7 @@ import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@an import {MatTableDataSource, MatTableModule} from "@angular/material/table"; import {ProductJsonld, ProductService} from "@app/core/api/v1"; import {OrderFilter} from "@app/_models/orderFilter"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {Router, RouterLink, RouterLinkActive} from "@angular/router"; import {NgIf} from "@angular/common"; import {Subscription} from "rxjs"; @@ -42,7 +42,7 @@ export class ProductsComponent implements OnInit, AfterViewInit { private router: Router, private modalService: NgbModal, private productService: ProductService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.sort = new MatSort(); this.displayedColumns = ['pos', 'image', 'name', 'storage', 'number']; @@ -119,7 +119,7 @@ export class ProductsComponent implements OnInit, AfterViewInit { navigateToProductDetails(element: any) { const product: ProductJsonld = element as ProductJsonld; - this.router.navigate(['/products', this.apiConverter.extractId(product.id)]); + this.router.navigate(['/products', this.apiHelperService.extractId(product.id)]); } openModalNewProduct() { diff --git a/matsen-tool/src/app/_views/profile/profile.component.ts b/matsen-tool/src/app/_views/profile/profile.component.ts index 34ebc02..d0924bf 100644 --- a/matsen-tool/src/app/_views/profile/profile.component.ts +++ b/matsen-tool/src/app/_views/profile/profile.component.ts @@ -4,7 +4,7 @@ import {Router} from "@angular/router"; import {AccountService} from "@app/_services"; import {Subscription} from "rxjs"; import {PartnerJsonld, UserJsonld, UserService} from "@app/core/api/v1"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-profile', @@ -20,7 +20,7 @@ export class ProfileComponent implements OnInit { private router: Router, private accountService: AccountService, private userService: UserService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.userSub = new Subscription(); this.user = {} as UserJsonld; @@ -34,7 +34,7 @@ export class ProfileComponent implements OnInit { const user = this.accountService.userValue; if (user?.id !== null && user?.id !== undefined) { this.userSub = this.userService.usersIdGet( - this.apiConverter.extractId(user.id) + this.apiHelperService.extractId(user.id) ).subscribe( data => { this.user = data; diff --git a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts index c6fa39e..e487fe5 100644 --- a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts +++ b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts @@ -13,7 +13,7 @@ import {debounceTime, distinctUntilChanged, Observable, OperatorFunction, Subscr import {TranslateService} from "@ngx-translate/core"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {saleForm} from "@app/_forms/apiForms"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {filter, map} from "rxjs/operators"; @Component({ @@ -35,7 +35,7 @@ export class NewSaleComponent implements OnInit { private partnerService: PartnerService, private productService: ProductService, private translateService: TranslateService, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.saleForm = saleForm; @@ -113,7 +113,7 @@ export class NewSaleComponent implements OnInit { } else { // Edit sale this.saleSub = this.saleService.salesIdPatch( - this.apiConverter.extractId(this.sale.id), + this.apiHelperService.extractId(this.sale.id), this.saleForm.value as SaleJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html b/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html index 644a463..574972d 100644 --- a/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html +++ b/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.html @@ -13,7 +13,7 @@
{{'overview.profit' | translate}}:
{{ sale.profit }}
{{'overview.comment' | translate}}:
-
+
@@ -36,7 +36,7 @@

{{ post.headline }}

-

+

@@ -50,7 +50,7 @@

{{ comment.ownerName }}

-

+

diff --git a/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts b/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts index b24e7bd..e6c5082 100644 --- a/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts +++ b/matsen-tool/src/app/_views/sales/sales-detail/sales-detail.component.ts @@ -12,7 +12,7 @@ import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.com 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 {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; @Component({ selector: 'app-sales-detail', @@ -47,7 +47,7 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { private route: ActivatedRoute, private postService: PostService, private modalService: NgbModal, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.user = this.accountService.userValue; diff --git a/matsen-tool/src/app/_views/sales/sales.component.html b/matsen-tool/src/app/_views/sales/sales.component.html index 0ec8ca5..97ac289 100644 --- a/matsen-tool/src/app/_views/sales/sales.component.html +++ b/matsen-tool/src/app/_views/sales/sales.component.html @@ -53,7 +53,7 @@ {{ 'overview.sale-partner' | translate }} - {{ element.partnerName }} + {{ element.partnerName }} @@ -63,7 +63,7 @@ {{ 'overview.productname' | translate }} - {{ element.productName }} + {{ element.productName }} diff --git a/matsen-tool/src/app/_views/sales/sales.component.ts b/matsen-tool/src/app/_views/sales/sales.component.ts index 0495ddc..ebda07b 100644 --- a/matsen-tool/src/app/_views/sales/sales.component.ts +++ b/matsen-tool/src/app/_views/sales/sales.component.ts @@ -16,7 +16,7 @@ import {ModalStatus} from "@app/_helpers/modal.states"; import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; import {MatTableDataSource} from "@angular/material/table"; import {OrderFilter} from "@app/_models/orderFilter"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {Router} from "@angular/router"; import {registerLocaleData} from "@angular/common"; import localeDe from '@angular/common/locales/de'; @@ -63,7 +63,7 @@ export class SalesComponent implements OnInit { private translateService: TranslateService, private modalService: NgbModal, private router: Router, - protected apiConverter: ApiConverter, + protected apiHelperService: ApiHelperService, ) { this.sort = new MatSort(); this.displayedColumns = ['pos', 'user', 'partner', 'product', 'turnover', 'profit', 'date', 'details']; @@ -162,7 +162,7 @@ export class SalesComponent implements OnInit { navigateToSaleDetails(element: any) { const sale: SaleJsonld = element as SaleJsonld; - this.router.navigate(['/sales', this.apiConverter.extractId(sale.id)]); + this.router.navigate(['/sales', this.apiHelperService.extractId(sale.id)]); } openModalNewSale() { diff --git a/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.ts b/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.ts index 5920df3..6315b22 100644 --- a/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.ts +++ b/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.ts @@ -4,7 +4,7 @@ import {ModalStatus} from "@app/_helpers/modal.states"; import {FormGroup} from "@angular/forms"; import {Subscription} from "rxjs"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {taskNoteForm} from "@app/_forms/apiForms"; @Component({ @@ -21,7 +21,7 @@ export class NewTaskNoteComponent { constructor( private taskNoteService: TaskNoteService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.taskNoteForm = taskNoteForm; this.taskNoteSub = new Subscription(); @@ -46,7 +46,7 @@ export class NewTaskNoteComponent { } else { // Edit taskNote this.taskNoteSub = this.taskNoteService.taskNotesIdPatch( - this.apiConverter.extractId(this.taskNote.id), + this.apiHelperService.extractId(this.taskNote.id), this.taskNoteForm.value as TaskNoteJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts index 48b2015..ba7e0b9 100644 --- a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts +++ b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts @@ -5,7 +5,7 @@ import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {FormGroup} from "@angular/forms"; import {debounceTime, distinctUntilChanged, Observable, OperatorFunction, Subscription, switchMap} from "rxjs"; import {taskForm} from "@app/_forms/apiForms"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {filter, map} from "rxjs/operators"; @Component({ @@ -27,7 +27,7 @@ export class NewTaskComponent implements OnInit { private taskService: TaskService, private userService: UserService, private partnerService: PartnerService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.taskForm = taskForm; this.taskSub = new Subscription(); @@ -97,7 +97,7 @@ export class NewTaskComponent implements OnInit { } else { // Edit task this.taskSub = this.taskService.tasksIdPatch( - this.apiConverter.extractId(this.task.id), + this.apiHelperService.extractId(this.task.id), this.taskForm.value as TaskJsonld ).subscribe( data => { diff --git a/matsen-tool/src/app/_views/tasks/task-list/task-list.component.html b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.html new file mode 100644 index 0000000..bd00f71 --- /dev/null +++ b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.html @@ -0,0 +1,58 @@ +
+
+ +
+
+
+

{{task.partnerName}}

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

{{ task.headline }}

+
+

+

Zugewiesen an: {{ task.assignedToName }}

+ +
+
+
+
+
+
+
+

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

+

{{ taskNote.ownerName }}

+
+
+

{{ taskNote.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/_views/tasks/task-list/task-list.component.scss b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/matsen-tool/src/app/_views/tasks/task-list/task-list.component.spec.ts b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.spec.ts new file mode 100644 index 0000000..54ae0bd --- /dev/null +++ b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TaskListComponent } from './task-list.component'; + +describe('TaskListComponent', () => { + let component: TaskListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [TaskListComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(TaskListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts new file mode 100644 index 0000000..1be83d3 --- /dev/null +++ b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts @@ -0,0 +1,134 @@ +import {AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core'; +import {ListComponent} from "@app/_components/list/list.component"; +import {Subscription} from "rxjs"; +import {PartnerJsonld, TaskJsonld, TaskNoteJsonld, TaskService} from "@app/core/api/v1"; +import {MatPaginator, MatPaginatorIntl} from "@angular/material/paginator"; +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 {ApiHelperService} from "@app/_helpers/api-helper.service"; +import {NgbModal} from "@ng-bootstrap/ng-bootstrap"; +import {AccountService} from "@app/_services"; +import {User} from "@app/_models"; + +@Component({ + selector: 'app-task-list', + templateUrl: './task-list.component.html', + styleUrl: './task-list.component.scss' +}) +export class TaskListComponent extends ListComponent implements OnInit, AfterViewInit { + + @Input() public partner!: PartnerJsonld; + + @ViewChild(MatPaginator) tasksPaginator: MatPaginator; + + protected user: User | null; + protected tasksSub: Subscription; + protected tasks: Array; + protected tasksDataSource; + + protected taskNotesVisibility: Map; + + constructor( + private taskService: TaskService, + private accountService: AccountService, + private modalService: NgbModal, + protected apiHelperService: ApiHelperService, + ) { + super(); + this.tasksSub = new Subscription(); + this.tasks = []; + this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); + this.tasksDataSource = new MatTableDataSource(this.tasks); + this.tasksPaginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); + this.taskNotesVisibility = new Map(); + this.user = this.accountService.userValue; + } + + ngOnInit() { + this.getData(); + } + + ngAfterViewInit() { + this.tasksDataSource.paginator = this.tasksPaginator; + } + + override getData() { + this.tasksSub = this.taskService.tasksGetCollection( + this.pageIndex + 1, + this.pageSize, + undefined, + undefined, + this.partner.id + ).subscribe( + data => { + this.tasks = data["hydra:member"]; + console.log(this.tasks); + this.dataLength = Number(data["hydra:totalItems"]); + this.tasks.forEach(task => { + if (task.id) { + this.taskNotesVisibility.set(task.id, false); + } + }); + } + ); + } + + showTaskNotes(task: TaskJsonld) { + if (task.id) { + const currentVisibility = this.taskNotesVisibility.get(task.id); + this.taskNotesVisibility.set(task.id, !currentVisibility); + } + } + + openModalNewTask() { + const modalRefTask = this.modalService.open(NewTaskComponent, this.modalOptions); + 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(); + } + }); + } + + openModalNewTaskNote(task: TaskJsonld) { + const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.modalOptions); + 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.modalOptions); + modalRefTaskEdit.componentInstance.task = task; + modalRefTaskEdit.componentInstance.dueAtValue = this.apiHelperService.convertDate(task.dueAt); + modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefTaskEdit.dismiss(); + this.getData(); + } + }); + } + + openModalEditTaskNote(taskNote: TaskNoteJsonld) { + const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.modalOptions); + modalRefTaskNote.componentInstance.taskNote = taskNote; + modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefTaskNote.dismiss(); + this.getData(); + } + }); + } +} diff --git a/matsen-tool/src/app/_views/tasks/tasks.component.html b/matsen-tool/src/app/_views/tasks/tasks.component.html index b6a14f6..9bd8c42 100644 --- a/matsen-tool/src/app/_views/tasks/tasks.component.html +++ b/matsen-tool/src/app/_views/tasks/tasks.component.html @@ -7,14 +7,14 @@
-

{{task.partnerName}}

+

{{task.partnerName}}

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

{{task.headline}}

-

+

Zugewiesen an: {{task.assignedToName}}

@@ -29,7 +29,7 @@

{{ taskNote.ownerName }}

-

+

diff --git a/matsen-tool/src/app/_views/tasks/tasks.component.ts b/matsen-tool/src/app/_views/tasks/tasks.component.ts index eb264dd..fbb599d 100644 --- a/matsen-tool/src/app/_views/tasks/tasks.component.ts +++ b/matsen-tool/src/app/_views/tasks/tasks.component.ts @@ -1,7 +1,7 @@ import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; import {NewTaskComponent} from "@app/_views/tasks/new-task/new-task.component"; import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap"; -import {ApiConverter} from "@app/_helpers/api.converter"; +import {ApiHelperService} from "@app/_helpers/api-helper.service"; import {Subscription} from "rxjs"; import {TaskJsonld, TaskNoteJsonld, TaskService} from "@app/core/api/v1"; import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; @@ -20,7 +20,6 @@ export class TasksComponent implements OnInit, AfterViewInit { @ViewChild(MatPaginator) tasksPaginator: MatPaginator; protected user: User | null; - protected readonly ApiConverter = ApiConverter; protected tasksSub: Subscription; protected tasks: Array; @@ -40,7 +39,7 @@ export class TasksComponent implements OnInit, AfterViewInit { private modalService: NgbModal, private accountService: AccountService, private taskService: TaskService, - protected apiConverter: ApiConverter + protected apiHelperService: ApiHelperService ) { this.user = this.accountService.userValue; @@ -118,7 +117,7 @@ export class TasksComponent implements OnInit, AfterViewInit { openModalEditTask(task: TaskJsonld) { const modalRefTaskEdit = this.modalService.open(NewTaskComponent, this.modalOptions); modalRefTaskEdit.componentInstance.task = task; - modalRefTaskEdit.componentInstance.dueAtValue = this.apiConverter.convertDate(task.dueAt); + modalRefTaskEdit.componentInstance.dueAtValue = this.apiHelperService.convertDate(task.dueAt); modalRefTaskEdit.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { if (modalStatus === ModalStatus.Submitted) { modalRefTaskEdit.dismiss(); diff --git a/matsen-tool/src/app/app.module.ts b/matsen-tool/src/app/app.module.ts index b11020c..d9cd429 100644 --- a/matsen-tool/src/app/app.module.ts +++ b/matsen-tool/src/app/app.module.ts @@ -51,6 +51,8 @@ import { ProfileComponent } from './_views/profile/profile.component'; import { PostListComponent } from './_views/posts/post-list/post-list.component'; import {ContactListComponent} from "@app/_views/contacts/contact-list/contact-list.component"; import {ApiModule, Configuration, ConfigurationParameters} from "@app/core/api/v1"; +import { TaskListComponent } from './_views/tasks/task-list/task-list.component'; +import { SearchInputComponent } from './_components/search-input/search-input.component'; export function apiConfigFactory(): Configuration { const params: ConfigurationParameters = { @@ -123,6 +125,8 @@ export function HttpLoaderFactory(http: HttpClient) { PostListComponent, ContactListComponent, ContactListComponent, + TaskListComponent, + SearchInputComponent, ], providers: [ {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, diff --git a/matsen-tool/src/assets/i18n/de.json b/matsen-tool/src/assets/i18n/de.json index af3b6e5..7b7712b 100644 --- a/matsen-tool/src/assets/i18n/de.json +++ b/matsen-tool/src/assets/i18n/de.json @@ -94,6 +94,7 @@ "country": "Land", "website": "Website", "upload-image": "Bild hochladen", + "upload-file": "Datei hochladen", "firstname": "Vorname", "lastname": "Nachname", "birthday": "Geburtstag", @@ -114,7 +115,7 @@ "product": "Produkt", "turnover": "Umsatz", "profit": "Gewinn", - "send": "Abschicken" + "send": "Speichern" }, "sales": {