From e3573728f5898e99e154250925db52d9d96e57b0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 19 Jun 2024 09:34:16 +0200 Subject: [PATCH] fixes --- .../app/_components/list/list.component.ts | 20 ------------------- .../search-select.component.html | 1 - .../search-select/search-select.component.ts | 9 +++------ .../contacts-detail.component.html | 3 +-- .../contacts-detail.component.ts | 2 ++ .../partner-list/partner-list.component.ts | 12 +++-------- .../posts/new-post/new-post.component.html | 15 +++++++------- .../posts/new-post/new-post.component.ts | 13 ++---------- .../assign-product.component.html | 8 +++----- .../assign-product.component.ts | 10 ---------- .../sales/new-sale/new-sale.component.html | 8 ++++---- .../sales/new-sale/new-sale.component.ts | 15 +++----------- .../sales/sale-list/sale-list.component.ts | 2 +- .../new-task-note.component.html | 1 - .../new-task-note/new-task-note.component.ts | 10 ++-------- .../tasks/new-task/new-task.component.html | 2 -- .../tasks/new-task/new-task.component.ts | 16 ++------------- 17 files changed, 33 insertions(+), 114 deletions(-) diff --git a/matsen-tool/src/app/_components/list/list.component.ts b/matsen-tool/src/app/_components/list/list.component.ts index 5eed08d..29b8913 100644 --- a/matsen-tool/src/app/_components/list/list.component.ts +++ b/matsen-tool/src/app/_components/list/list.component.ts @@ -42,21 +42,6 @@ export class ListComponent implements OnInit, AfterViewInit { public static COLUMN_TYPE_TEXT_LINKED: string = 'text_linked'; public static COLUMN_TYPE_WEBSITE: string = 'website'; - public static validColumnTypes: string[] = [ - ListComponent.COLUMN_TYPE_ADDRESS, - ListComponent.COLUMN_TYPE_BTN_DOWNLOAD, - ListComponent.COLUMN_TYPE_BTN_EDIT, - ListComponent.COLUMN_TYPE_BTN_REMOVE, - ListComponent.COLUMN_TYPE_CURRENCY, - ListComponent.COLUMN_TYPE_DATE, - ListComponent.COLUMN_TYPE_DETAIL, - ListComponent.COLUMN_TYPE_EMAIL, - ListComponent.COLUMN_TYPE_IMAGE, - ListComponent.COLUMN_TYPE_POSITION, - ListComponent.COLUMN_TYPE_TEXT, - ListComponent.COLUMN_TYPE_TEXT_LINKED, - 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; } @@ -115,11 +100,6 @@ export class ListComponent implements OnInit, AfterViewInit { ) } - setData(dataSource: any, dataLength: number): void { - this.pagingComponent.dataSource = dataSource; - this.pagingComponent.setDataLength(dataLength); - } - onSortChange = (sortState: Sort) => { this.pagingComponent.resetPageIndex() this.onSortFunction(sortState); diff --git a/matsen-tool/src/app/_components/search-select/search-select.component.html b/matsen-tool/src/app/_components/search-select/search-select.component.html index 8a3b673..f5bef98 100644 --- a/matsen-tool/src/app/_components/search-select/search-select.component.html +++ b/matsen-tool/src/app/_components/search-select/search-select.component.html @@ -3,7 +3,6 @@

-
Observable; - @Input() public dataSource: any; @Input() public dataSet!: any; @Input() public displayedDataField!: string; @Input() public displayedDataSubResource!: string; @@ -52,10 +51,6 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { } } - setData(dataSource: any, data: any[], dataLength: number): void { - this.listComponent.setData(dataSource, dataLength); - } - onSortChange = (sortState: Sort) => { let order: OrderFilter; if (sortState.direction === "") { @@ -118,7 +113,7 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { ]; } - public static getDefaultColDefProducts(): ListColDefinition[] { + public static getDefaultColDefProducts(subResource?: string): ListColDefinition[] { return [ ListComponent.getDefaultColPosition(), { @@ -126,12 +121,14 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { text: 'overview.image', type: ListComponent.COLUMN_TYPE_IMAGE, field: 'imageUrl', + subResource: subResource, } as ListColDefinition, { name: 'name', text: 'form.product', type: ListComponent.COLUMN_TYPE_TEXT, field: 'name', + subResource: subResource, } ]; } 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 feef345..234ef93 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 @@ -18,8 +18,7 @@
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 65e8391..dce59b6 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 @@ -107,4 +107,6 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { } this.appHelperService.openModal(NewContactComponent, data, this.getContactData); } + + protected readonly AppHelperService = AppHelperService; } diff --git a/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts b/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts index 2f2f758..50a9055 100644 --- a/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts +++ b/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.ts @@ -107,20 +107,14 @@ export class PartnerListComponent implements OnInit, AfterViewInit { } as ListColDefinition ) } - if (this.user !== undefined) { - this.getDataFunction = this.getPartnerData; - } else if (this.product !== undefined) { - this.getDataFunction = this.getUserPartnerData - } else { - this.getDataFunction = this.getPartnerData; - } + this.getDataFunction = this.getGetDataFunction(); } ngAfterViewInit() { this.listComponent.getData(); } - getData = (): ListGetDataFunctionType => { + getGetDataFunction = (): ListGetDataFunctionType => { if (this.user !== undefined) { return this.getUserPartnerData; } else if (this.product !== undefined) { @@ -207,7 +201,7 @@ export class PartnerListComponent implements OnInit, AfterViewInit { openModalNewPartner() { let partner: PartnerJsonld = {} as PartnerJsonld; partner.partnerType = this.partnerType as TypeEnum; - this.appHelperService.openModal(NewPartnerComponent, { 'partner': partner }, this.getData); + this.appHelperService.openModal(NewPartnerComponent, { 'partner': partner }, this.getGetDataFunction); } unassignPartner = (element: any)=> { diff --git a/matsen-tool/src/app/_views/posts/new-post/new-post.component.html b/matsen-tool/src/app/_views/posts/new-post/new-post.component.html index ea52720..1793df7 100644 --- a/matsen-tool/src/app/_views/posts/new-post/new-post.component.html +++ b/matsen-tool/src/app/_views/posts/new-post/new-post.component.html @@ -14,14 +14,13 @@ ; - protected dataSourceProducts; constructor( private postService: PostService, @@ -39,9 +33,6 @@ export class NewPostComponent implements OnInit { protected appHelperService: AppHelperService, ) { this.postForm = postForm; - this.postSub = new Subscription(); - this.products = []; - this.dataSourceProducts = new MatTableDataSource(this.products); } ngOnInit(): void { @@ -60,7 +51,7 @@ export class NewPostComponent implements OnInit { if (this.postForm.valid) { if (this.posting.id === null || this.posting.id === undefined) { // Create new post - this.postSub = this.postService.postsPost( + this.postService.postsPost( this.postForm.value as PostJsonld ).subscribe( data => { @@ -70,7 +61,7 @@ export class NewPostComponent implements OnInit { ); } else { // Edit post - this.postSub = this.postService.postsIdPatch( + this.postService.postsIdPatch( this.appHelperService.extractId(this.posting.id), this.postForm.value as PostJsonld ).subscribe( diff --git a/matsen-tool/src/app/_views/products/assign-product/assign-product.component.html b/matsen-tool/src/app/_views/products/assign-product/assign-product.component.html index d465b3f..e4d79e0 100644 --- a/matsen-tool/src/app/_views/products/assign-product/assign-product.component.html +++ b/matsen-tool/src/app/_views/products/assign-product/assign-product.component.html @@ -9,24 +9,22 @@ [formLabelLangKey]="'form.product'" [documentForm]="form" [getDataFunction]="getUnassignedProducts" - [dataSource]="dataSourceProducts" [displayedDataField]="'name'" - [listColDefinitions]="SearchSelectComponent.getDefaultColDefPartners()" + [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" >
- diff --git a/matsen-tool/src/app/_views/products/assign-product/assign-product.component.ts b/matsen-tool/src/app/_views/products/assign-product/assign-product.component.ts index d26a24e..7759a48 100644 --- a/matsen-tool/src/app/_views/products/assign-product/assign-product.component.ts +++ b/matsen-tool/src/app/_views/products/assign-product/assign-product.component.ts @@ -27,10 +27,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent protected readonly SearchSelectComponent = SearchSelectComponent; - protected products: Array; - protected dataSourceProducts; - protected partnerProducts: Array; - protected dataSourcePartnerProducts; protected form!: FormGroup; constructor( @@ -39,11 +35,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { protected contactPartnerProductService: ContactPartnerProductService, protected appHelperService: AppHelperService, ) { - this.products = []; - this.dataSourceProducts = new MatTableDataSource(this.products); - - this.partnerProducts = []; - this.dataSourcePartnerProducts = new MatTableDataSource(this.partnerProducts); } ngOnInit(): void { @@ -87,7 +78,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { onSubmit() { if (this.form.valid) { if (this.partnerProduct !== undefined) { - // Partner product this.partnerProductService.partnerProductsPost( this.form.value as PartnerProductJsonld ).subscribe( diff --git a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.html b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.html index 29eedb4..27fafc0 100644 --- a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.html +++ b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.html @@ -4,12 +4,12 @@
- {{ 'form.partner' | translate }}: + @@ -18,12 +18,12 @@
- {{ 'form.product' | translate }}: + 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 64766fd..b698dd6 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 @@ -26,17 +26,13 @@ import {ListColDefinition} from "@app/_components/list/list-col-definition"; }) export class NewSaleComponent implements OnInit, AfterViewInit { @Input() public sale!: SaleJsonld; + @Input() public partner!: PartnerJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @ViewChild('partnerSearchSelect', { static: false }) partnerSearchSelect!: SearchSelectComponent; @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent; protected readonly SearchSelectComponent = SearchSelectComponent; protected saleForm: FormGroup; - protected saleSub: Subscription; - protected partners: Array; - protected dataSourcePartners; - protected products: Array; - protected dataSourceProducts; constructor( private saleService: SaleService, @@ -46,11 +42,6 @@ export class NewSaleComponent implements OnInit, AfterViewInit { protected appHelperService: AppHelperService, ) { this.saleForm = saleForm; - this.saleSub = new Subscription(); - this.partners = []; - this.dataSourcePartners = new MatTableDataSource(this.partners); - this.products = []; - this.dataSourceProducts = new MatTableDataSource(this.products); } ngOnInit(): void { @@ -90,7 +81,7 @@ export class NewSaleComponent implements OnInit, AfterViewInit { } if (this.sale.id === null || this.sale.id === undefined) { // Create new sale - this.saleSub = this.saleService.salesPost( + this.saleService.salesPost( this.saleForm.value as SaleJsonld ).subscribe( data => { @@ -100,7 +91,7 @@ export class NewSaleComponent implements OnInit, AfterViewInit { ); } else { // Edit sale - this.saleSub = this.saleService.salesIdPatch( + this.saleService.salesIdPatch( this.appHelperService.extractId(this.sale.id), this.saleForm.value as SaleJsonld ).subscribe( 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 bfc3b00..f0edd41 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 @@ -120,7 +120,7 @@ export class SaleListComponent implements OnInit, AfterViewInit { openModalNewSale() { let sale: SaleJsonld = {} as SaleJsonld; - this.appHelperService.openModal(NewSaleComponent, { 'sale': sale }, this.listComponent.getData); + this.appHelperService.openModal(NewSaleComponent, { 'sale': sale, 'partner': this.partner }, this.listComponent.getData); } } diff --git a/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.html b/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.html index aa01d63..99b1b47 100644 --- a/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.html +++ b/matsen-tool/src/app/_views/tasks/new-task-note/new-task-note.component.html @@ -17,7 +17,6 @@ [formLabelLangKey]="'form.product'" [documentForm]="taskNoteForm" [getDataFunction]="getContacts" - [dataSource]="dataSourceContacts" [displayedDataField]="'fullName'" [dataSet]="taskNote.contact" [listColDefinitions]="SearchSelectComponent.getDefaultColDefContacts()" 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 f0995d4..f2efe27 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 @@ -30,10 +30,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { protected readonly SearchSelectComponent = SearchSelectComponent; protected taskNoteForm: FormGroup; - protected taskNoteSub: Subscription; protected contactTypes = Object.values(TaskNoteJsonld.ContactTypeEnum); - protected contacts: Array; - protected dataSourceContacts; constructor( protected taskNoteService: TaskNoteService, @@ -41,9 +38,6 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { protected contactService: ContactService ) { this.taskNoteForm = taskNoteForm; - this.taskNoteSub = new Subscription(); - this.contacts = []; - this.dataSourceContacts = new MatTableDataSource(this.contacts); } ngOnInit(): void { @@ -77,7 +71,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { if (this.taskNoteForm.valid) { if (this.taskNote.id === null || this.taskNote.id === undefined) { // Create new taskNote - this.taskNoteSub = this.taskNoteService.taskNotesPost( + this.taskNoteService.taskNotesPost( this.taskNoteForm.value as TaskNoteJsonld ).subscribe( data => { @@ -87,7 +81,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { ); } else { // Edit taskNote - this.taskNoteSub = this.taskNoteService.taskNotesIdPatch( + this.taskNoteService.taskNotesIdPatch( this.appHelperService.extractId(this.taskNote.id), this.taskNoteForm.value as TaskNoteJsonld ).subscribe( diff --git a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html index 48c50a2..2011337 100644 --- a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html +++ b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html @@ -25,7 +25,6 @@ [formLabelLangKey]="'form.product'" [documentForm]="taskForm" [getDataFunction]="getProducts" - [dataSource]="dataSourceProducts" [displayedDataField]="'name'" [dataSet]="task.product" [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" @@ -42,7 +41,6 @@ [formLabelLangKey]="'form.user'" [documentForm]="taskForm" [getDataFunction]="getUsers" - [dataSource]="dataSourceUsers" [displayedDataField]="'fullName'" [dataSet]="task.assignedTo" [listColDefinitions]="SearchSelectComponent.getDefaultColDefUsers()" 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 3ad756f..1536b02 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 @@ -33,27 +33,15 @@ export class NewTaskComponent implements OnInit, AfterViewInit { protected readonly SearchSelectComponent = SearchSelectComponent; protected taskForm: FormGroup; - protected taskSub: Subscription; protected dueAtValue: string; - protected users: Array; - protected dataSourceUsers; - - protected products: Array; - protected dataSourceProducts; - constructor( protected taskService: TaskService, protected userService: UserService, protected productService: ProductService, protected appHelperService: AppHelperService ) { - this.users = []; - this.dataSourceUsers = new MatTableDataSource(this.users); - this.products = []; - this.dataSourceProducts = new MatTableDataSource(this.products); this.taskForm = taskForm; - this.taskSub = new Subscription(); this.dueAtValue = ""; } @@ -101,7 +89,7 @@ export class NewTaskComponent implements OnInit, AfterViewInit { if (this.taskForm.valid) { if (this.task.id === null || this.task.id === undefined) { // Create new task - this.taskSub = this.taskService.tasksPost( + this.taskService.tasksPost( this.taskForm.value as TaskJsonld ).subscribe( data => { @@ -111,7 +99,7 @@ export class NewTaskComponent implements OnInit, AfterViewInit { ); } else { // Edit task - this.taskSub = this.taskService.tasksIdPatch( + this.taskService.tasksIdPatch( this.appHelperService.extractId(this.task.id), this.taskForm.value as TaskJsonld ).subscribe(