| @@ -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; | |||
| } | |||
| @@ -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<ModalStatus> { | |||
| @@ -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; | |||
| } | |||
| @@ -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 | |||
| ); | |||
| } | |||
| } | |||
| @@ -17,7 +17,7 @@ | |||
| </dl> | |||
| </div> | |||
| <div class="col-12 col-sm-6 col-lg-4"> | |||
| <span *ngIf="sale.owner === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| <span *ngIf="sale.owner?.id === user?.id" class="position-absolute bi bi-pencil p-2" data-type="user-tool" | |||
| data-action="edit" | |||
| (click)="openModalEditSale()"></span> | |||
| </div> | |||
| @@ -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<PostJsonld>; | |||
| protected dataSource; | |||
| protected commentsVisibility: Map<string, boolean>; | |||
| @@ -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<PostJsonld>(this.posts); | |||
| this.commentsVisibility = new Map<string, boolean>(); | |||
| @@ -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 | |||
| ); | |||
| } | |||
| } | |||
| @@ -81,6 +81,7 @@ | |||
| .spt-compact { | |||
| position: relative; | |||
| padding-top: 4px; | |||
| padding-bottom: 12px; | |||
| &:before { | |||
| content: ""; | |||
| position: absolute; | |||