From bf6ccedc251c7a3ae69e993fdf9ac756b6e3194a Mon Sep 17 00:00:00 2001 From: Florian Eisenmenger Date: Fri, 21 Jun 2024 17:18:53 +0200 Subject: [PATCH] fixes, sales edit --- .../app/_components/list/list.component.ts | 74 +++++++++++---- .../src/app/_helpers/app-helper.service.ts | 9 +- .../sales/sale-list/sale-list.component.ts | 14 ++- .../sales-detail/sales-detail.component.html | 2 +- .../sales-detail/sales-detail.component.ts | 93 ++++--------------- matsen-tool/src/assets/scss/_tasks-posts.scss | 1 + 6 files changed, 91 insertions(+), 102 deletions(-) diff --git a/matsen-tool/src/app/_components/list/list.component.ts b/matsen-tool/src/app/_components/list/list.component.ts index 8ff44a6..8cbac6e 100644 --- a/matsen-tool/src/app/_components/list/list.component.ts +++ b/matsen-tool/src/app/_components/list/list.component.ts @@ -7,9 +7,9 @@ import {AppHelperService} from "@app/_helpers/app-helper.service"; import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; @Component({ - selector: 'app-list', - templateUrl: './list.component.html', - styleUrl: './list.component.scss' + selector: 'app-list', + templateUrl: './list.component.html', + styleUrl: './list.component.scss' }) export class ListComponent implements OnInit, AfterViewInit { @@ -26,7 +26,7 @@ export class ListComponent implements OnInit, AfterViewInit { @Input() public listColDefinitions!: ListColDefinition[]; @Input() public hidePageSize: boolean; @ViewChild(MatSort) sort; - @ViewChild("pagingComponent", { static: false }) protected pagingComponent!: PagingComponent; + @ViewChild("pagingComponent", {static: false}) protected pagingComponent!: PagingComponent; public static COLUMN_TYPE_ADDRESS: string = 'address'; public static COLUMN_TYPE_BTN_DOWNLOAD: string = 'btn_download'; @@ -42,19 +42,57 @@ export class ListComponent implements OnInit, AfterViewInit { public static COLUMN_TYPE_TEXT_LINKED: string = 'text_linked'; public static COLUMN_TYPE_WEBSITE: string = 'website'; - get COLUMN_TYPE_ADDRESS(): string { return ListComponent.COLUMN_TYPE_ADDRESS; } - get COLUMN_TYPE_BTN_DOWNLOAD(): string { return ListComponent.COLUMN_TYPE_BTN_DOWNLOAD; } - get COLUMN_TYPE_BTN_EDIT(): string { return ListComponent.COLUMN_TYPE_BTN_EDIT; } - get COLUMN_TYPE_BTN_REMOVE(): string { return ListComponent.COLUMN_TYPE_BTN_REMOVE; } - get COLUMN_TYPE_CURRENCY(): string { return ListComponent.COLUMN_TYPE_CURRENCY; } - get COLUMN_TYPE_DATE(): string { return ListComponent.COLUMN_TYPE_DATE; } - get COLUMN_TYPE_DETAIL(): string { return ListComponent.COLUMN_TYPE_DETAIL; } - get COLUMN_TYPE_EMAIL(): string { return ListComponent.COLUMN_TYPE_EMAIL; } - get COLUMN_TYPE_POSITION(): string { return ListComponent.COLUMN_TYPE_POSITION; } - get COLUMN_TYPE_IMAGE(): string { return ListComponent.COLUMN_TYPE_IMAGE; } - get COLUMN_TYPE_TEXT(): string { return ListComponent.COLUMN_TYPE_TEXT; } - get COLUMN_TYPE_TEXT_LINKED(): string { return ListComponent.COLUMN_TYPE_TEXT_LINKED; } - get COLUMN_TYPE_WEBSITE(): string { return ListComponent.COLUMN_TYPE_WEBSITE; } + get COLUMN_TYPE_ADDRESS(): string { + return ListComponent.COLUMN_TYPE_ADDRESS; + } + + get COLUMN_TYPE_BTN_DOWNLOAD(): string { + return ListComponent.COLUMN_TYPE_BTN_DOWNLOAD; + } + + get COLUMN_TYPE_BTN_EDIT(): string { + return ListComponent.COLUMN_TYPE_BTN_EDIT; + } + + get COLUMN_TYPE_BTN_REMOVE(): string { + return ListComponent.COLUMN_TYPE_BTN_REMOVE; + } + + get COLUMN_TYPE_CURRENCY(): string { + return ListComponent.COLUMN_TYPE_CURRENCY; + } + + get COLUMN_TYPE_DATE(): string { + return ListComponent.COLUMN_TYPE_DATE; + } + + get COLUMN_TYPE_DETAIL(): string { + return ListComponent.COLUMN_TYPE_DETAIL; + } + + get COLUMN_TYPE_EMAIL(): string { + return ListComponent.COLUMN_TYPE_EMAIL; + } + + get COLUMN_TYPE_POSITION(): string { + return ListComponent.COLUMN_TYPE_POSITION; + } + + get COLUMN_TYPE_IMAGE(): string { + return ListComponent.COLUMN_TYPE_IMAGE; + } + + get COLUMN_TYPE_TEXT(): string { + return ListComponent.COLUMN_TYPE_TEXT; + } + + get COLUMN_TYPE_TEXT_LINKED(): string { + return ListComponent.COLUMN_TYPE_TEXT_LINKED; + } + + get COLUMN_TYPE_WEBSITE(): string { + return ListComponent.COLUMN_TYPE_WEBSITE; + } protected displayedColumns!: string[]; protected selectedRowIndex: number | null = null; @@ -114,7 +152,7 @@ export class ListComponent implements OnInit, AfterViewInit { } getElementValue(element: any, column: ListColDefinition): string | null { - element = column.subResource !== undefined ? element[column.subResource]: element; + element = column.subResource !== undefined ? element[column.subResource] : element; if (element === undefined) { return null; } diff --git a/matsen-tool/src/app/_helpers/app-helper.service.ts b/matsen-tool/src/app/_helpers/app-helper.service.ts index 7818648..73e9dbb 100644 --- a/matsen-tool/src/app/_helpers/app-helper.service.ts +++ b/matsen-tool/src/app/_helpers/app-helper.service.ts @@ -5,13 +5,14 @@ import {ModalStatus} from "@app/_helpers/modal.states"; import {PartnerJsonld} from "@app/core/api/v1"; import {ROUTE_CUSTOMER, ROUTE_SERVICE, ROUTE_SUPPLIER} from "@app/app-routing.module"; -@Injectable({ providedIn: 'root' }) +@Injectable({providedIn: 'root'}) export class AppHelperService { constructor( private sanitizer: DomSanitizer, private modalService: NgbModal, - ) {} + ) { + } public extractId(iri: string | undefined | null): string { if (iri !== undefined && iri !== null) { @@ -42,7 +43,7 @@ export class AppHelperService { } public getModalOptions(): NgbModalOptions { - return { centered: true } as NgbModalOptions; + return {centered: true} as NgbModalOptions; } public openModal(component: any, data: any, callback?: (callbackParam?: any) => void, callbackParam?: any): Promise { @@ -69,7 +70,7 @@ export class AppHelperService { public getResourceLink(element: any, subResource?: any): string | null { let resourceLink: string = '/'; - element = subResource !== undefined ? element[subResource]: element; + element = subResource !== undefined ? element[subResource] : element; if (element === undefined) { return null; } diff --git a/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts b/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts index 0ec8df7..0b213d5 100644 --- a/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts +++ b/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts @@ -153,11 +153,15 @@ export class SaleListComponent implements OnInit, AfterViewInit { openModalNewSale() { let sale: SaleJsonld = {} as SaleJsonld; - this.appHelperService.openModal(NewSaleComponent, { - 'sale': sale, - 'partner': this.partner, - 'product': this.product - }, this.listComponent.getData); + this.appHelperService.openModal( + NewSaleComponent, + { + 'sale': sale, + 'partner': this.partner, + 'product': this.product + }, + this.listComponent.getData + ); } } \ No newline at end of file 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 7c34370..98c6541 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 @@ -17,7 +17,7 @@
-
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 8fc6c81..9f6bfcf 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 @@ -1,31 +1,26 @@ import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; -import {Subscription} from "rxjs"; import {MatTableDataSource} from "@angular/material/table"; -import {CommentJsonld, PostJsonld, PostService, SaleJsonld, SaleService} from "@app/core/api/v1"; +import {PostJsonld, PostService, SaleJsonld, SaleService} from "@app/core/api/v1"; import {User} from "@app/_models"; import {AccountService} from "@app/_services"; -import {NewPostComponent} from "@app/_views/posts/new-post/new-post.component"; -import {NewCommentComponent} from "@app/_views/posts/new-comment/new-comment.component"; import {NewSaleComponent} from "@app/_views/sales/new-sale/new-sale.component"; import {ActivatedRoute} from "@angular/router"; import {AppHelperService} from "@app/_helpers/app-helper.service"; import {PagingComponent} from "@app/_components/paging/paging.component"; @Component({ - selector: 'app-sales-detail', - templateUrl: './sales-detail.component.html', - styleUrl: './sales-detail.component.scss' + selector: 'app-sales-detail', + templateUrl: './sales-detail.component.html', + styleUrl: './sales-detail.component.scss' }) export class SalesDetailComponent implements OnInit, AfterViewInit { - @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; + @ViewChild("pagingComponent", {static: false}) pagingComponent!: PagingComponent; protected user: User | null; protected saleId: string; protected sale!: SaleJsonld; - protected saleSub: Subscription; - protected postsSub: Subscription; protected posts: Array; protected dataSource; protected commentsVisibility: Map; @@ -40,9 +35,7 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { this.user = this.accountService.userValue; this.saleId = ""; - this.saleSub = new Subscription(); - this.postsSub = new Subscription(); this.posts = []; this.dataSource = new MatTableDataSource(this.posts); this.commentsVisibility = new Map(); @@ -50,9 +43,8 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { ngOnInit() { this.route.params.subscribe(params => { - this.saleId = params['id']; + this.saleId = params['id']; }); - } ngAfterViewInit() { @@ -60,73 +52,26 @@ export class SalesDetailComponent implements OnInit, AfterViewInit { } getSaleData = () => { - this.saleSub = this.saleService.salesIdGet( + this.saleService.salesIdGet( this.saleId ).subscribe( data => { - this.sale = data; - // this.pagingComponent.getData(); + this.sale = data; + // this.pagingComponent.getData(); } ); } - 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.setDataLength(Number(data["hydra:totalItems"])); - this.posts.forEach(posts => { - if (posts.id) { - this.commentsVisibility.set(posts.id, false); - } - }); - } - ); - } - - openModalNewPosting() { - let posting: PostJsonld = {} as PostJsonld; - posting.saleIri = this.sale.id ?? null; - posting.partnerIri = this.sale.partner?.id ?? null; - posting.productIri = this.sale.product?.id ?? null; - this.appHelperService.openModal(NewPostComponent, { 'posting': posting }, this.getPostsData); - } - - openModalEditPosting(post: PostJsonld) { - this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getPostsData); - } - - openModalNewComment(post: PostJsonld) { - let comment: CommentJsonld = {} as CommentJsonld; - comment.postIri = post.id ?? null; - this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getPostsData); - } - - openModalEditComment(comment: CommentJsonld) { - this.appHelperService.openModal(NewCommentComponent, { 'comment': comment }, this.getPostsData); - } - openModalEditSale() { - this.appHelperService.openModal(NewSaleComponent, { 'sale': this.sale }, this.getPostsData); - } - - showComments(post: PostJsonld) { - if (post.id) { - const currentVisibility = this.commentsVisibility.get(post.id); - this.commentsVisibility.set(post.id, !currentVisibility); - } + console.log(this.sale); + this.appHelperService.openModal( + NewSaleComponent, + { + 'sale': this.sale, + 'partner': this.sale.partner, + 'product': this.sale.product + }, + this.getSaleData + ); } } \ No newline at end of file diff --git a/matsen-tool/src/assets/scss/_tasks-posts.scss b/matsen-tool/src/assets/scss/_tasks-posts.scss index 9117020..da89642 100644 --- a/matsen-tool/src/assets/scss/_tasks-posts.scss +++ b/matsen-tool/src/assets/scss/_tasks-posts.scss @@ -81,6 +81,7 @@ .spt-compact { position: relative; padding-top: 4px; + padding-bottom: 12px; &:before { content: ""; position: absolute;