diff --git a/matsen-tool/src/app/_views/documents/document-list/document-list.component.ts b/matsen-tool/src/app/_views/documents/document-list/document-list.component.ts
index 256a82c..9f8b002 100644
--- a/matsen-tool/src/app/_views/documents/document-list/document-list.component.ts
+++ b/matsen-tool/src/app/_views/documents/document-list/document-list.component.ts
@@ -1,5 +1,5 @@
-import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
-import {DocumentJsonld, DocumentService} from "@app/core/api/v1";
+import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
+import {DocumentJsonld, DocumentService, PartnerJsonld, ProductJsonld} from "@app/core/api/v1";
import {AppHelperService} from "@app/_helpers/app-helper.service";
import {MatSort, Sort} from "@angular/material/sort";
import {Subscription} from "rxjs";
@@ -15,6 +15,8 @@ import {NewDocumentComponent} from "@app/_views/documents/new-document/new-docum
})
export class DocumentListComponent implements OnInit, AfterViewInit {
+ @Input() public product!: ProductJsonld;
+ @Input() public partner!: PartnerJsonld;
@ViewChild(MatSort) sort;
@ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent;
@@ -49,7 +51,13 @@ export class DocumentListComponent implements OnInit, AfterViewInit {
getData = () => {
this.documentsSub = this.documentService.documentsGetCollection(
this.pagingComponent.getPageIndex(),
- this.pagingComponent.getPageSize()
+ this.pagingComponent.getPageSize(),
+ undefined,
+ undefined,
+ this.partner !== undefined ? this.partner.id : undefined,
+ undefined,
+ this.product !== undefined ? this.product.id : undefined
+
).subscribe(
data => {
this.documents = data["hydra:member"];
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 15ce707..de2d814 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,26 +13,28 @@
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 8b36bab..7c5109e 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,65 +1,108 @@
-import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
+import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {
DocumentJsonld, DocumentObjectService,
- DocumentService, MediaObjectService, PartnerJsonld, PartnerService, ProductService
+ DocumentService, PartnerJsonld, PartnerService, ProductJsonld, ProductService, UserJsonld, UserService
} from "@app/core/api/v1";
import {ModalStatus} from "@app/_helpers/modal.states";
import {FormGroup} from "@angular/forms";
-import {debounceTime, distinctUntilChanged, Observable, OperatorFunction, Subscription, switchMap} from "rxjs";
+import {Observable, Subscription} from "rxjs";
import {TranslateService} from "@ngx-translate/core";
import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer";
import {documentForm} from "@app/_forms/apiForms";
import {AppHelperService} from "@app/_helpers/app-helper.service";
-import {filter, map} from "rxjs/operators";
-import {SearchInputComponent} from "@app/_components/search-input/search-input.component";
+import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
+import {MatTableDataSource} from "@angular/material/table";
+import {SearchInputColDef} from "@app/_components/search-input/search-input-col-def";
@Component({
selector: 'app-new-document',
templateUrl: './new-document.component.html',
styleUrl: './new-document.component.scss'
})
-export class NewDocumentComponent implements OnInit {
+export class NewDocumentComponent implements OnInit, AfterViewInit {
@Input() public document!: DocumentJsonld;
@Output() public submit: EventEmitter = new EventEmitter();
- @ViewChild('partnerSearchInput', { static: false }) $partnerSearchInput!: SearchInputComponent;
- @ViewChild('productSearchInput', { static: false }) $productSearchInput!: SearchInputComponent;
+ @ViewChild('partnerSearchSelect', { static: false }) partnerSearchSelect!: SearchSelectComponent;
+ @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent;
protected documentForm: FormGroup;
protected documentSub: Subscription;
-
protected selectedFile: File | null;
protected documentObjectSub: Subscription;
-
- protected formatter = (apiData: any) => apiData.name;
+ protected partners: Array;
+ protected dataSourcePartners;
+ protected products: Array;
+ protected dataSourceProducts;
+ protected colDefPartners: SearchInputColDef[];
+ protected colDefProducts: SearchInputColDef[];
constructor(
- private documentService: DocumentService,
- private documentObjectService: DocumentObjectService,
- private translateService: TranslateService,
- private partnerService: PartnerService,
- private productService: ProductService,
+ protected documentService: DocumentService,
+ protected documentObjectService: DocumentObjectService,
+ protected translateService: TranslateService,
+ protected partnerService: PartnerService,
+ protected productService: ProductService,
protected appHelperService: AppHelperService,
) {
+ this.partners = [];
+ this.dataSourcePartners = new MatTableDataSource(this.partners);
+ this.products = [];
+ this.dataSourceProducts = new MatTableDataSource(this.products);
this.documentForm = documentForm;
this.documentSub = new Subscription();
this.selectedFile = null;
this.documentObjectSub = new Subscription();
+
+ this.colDefPartners = [
+ SearchSelectComponent.createColDef('pos', 'overview.number', SearchSelectComponent.COLUMN_TYPE_POSITION),
+ SearchSelectComponent.createColDef('img', 'overview.image', SearchSelectComponent.COLUMN_TYPE_IMAGE, 'logoUrl'),
+ SearchSelectComponent.createColDef('name', 'form.name', SearchSelectComponent.COLUMN_TYPE_TEXT, 'name'),
+ ];
+ this.colDefProducts = [
+ SearchSelectComponent.createColDef('pos', 'overview.number', SearchSelectComponent.COLUMN_TYPE_POSITION),
+ SearchSelectComponent.createColDef('img', 'overview.image', SearchSelectComponent.COLUMN_TYPE_IMAGE, 'imageUrl'),
+ SearchSelectComponent.createColDef('name', 'form.product', SearchSelectComponent.COLUMN_TYPE_TEXT, 'name'),
+ ];
}
ngOnInit(): void {
this.documentForm = FormGroupInitializer.initFormGroup(this.documentForm, this.document);
}
- 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}))),
- );
+ ngAfterViewInit(): void {
+ this.partnerSearchSelect.getData();
+ this.productSearchSelect.getData();
}
- 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}))),
+ getPartners = (term: string): void => {
+ this.partnerService.partnersGetCollection(
+ this.partnerSearchSelect.pagingComponent.getPageIndex(),
+ this.partnerSearchSelect.pagingComponent.getPageSize(),
+ undefined,
+ undefined,
+ term
+ ).subscribe(
+ data => {
+ this.partners = data['hydra:member'];
+ this.dataSourcePartners = new MatTableDataSource(this.partners);
+ this.partnerSearchSelect.setData(this.dataSourcePartners, this.partners, Number(data["hydra:totalItems"]));
+ }
+ )
+ }
+
+ getProducts = (term?: string): void => {
+ // NOTE: all products that are not assigned to partner yet
+ this.productService.productsGetCollection(
+ this.productSearchSelect.pagingComponent.getPageIndex(),
+ this.productSearchSelect.pagingComponent.getPageSize(),
+ term
+ ).subscribe(
+ data => {
+ this.products = data['hydra:member'];
+ this.dataSourceProducts = new MatTableDataSource(this.products);
+ this.productSearchSelect.setData(this.dataSourceProducts, this.products, Number(data["hydra:totalItems"]));
+ }
);
}
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 b84adc8..73e4eea 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
@@ -132,8 +132,6 @@ export class PartnerListComponent implements OnInit, AfterViewInit {
}
getPartnerProducts = (searchValue = undefined) => {
- console.log(this.partnerType);
- console.log(searchValue);
this.partnersSub = this.partnerProductService.partnerProductsGetCollection(
this.pagingComponent.getPageIndex(),
this.pagingComponent.getPageSize(),
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 d219f58..8b86183 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
@@ -84,3 +84,9 @@
>
+
+
+
+
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 2cbd7f2..051be7c 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
@@ -16,6 +16,7 @@ import {ContactListComponent} from "@app/_views/contacts/contact-list/contact-li
import {TaskListComponent} from "@app/_views/tasks/task-list/task-list.component";
import {ProductListComponent} from "@app/_views/products/product-list/product-list.component";
import {SaleListComponent} from "@app/_views/sales/sale-list/sale-list.component";
+import {DocumentListComponent} from "@app/_views/documents/document-list/document-list.component";
@Component({
selector: 'app-partners-detail',
@@ -34,6 +35,8 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit {
@ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent;
@ViewChild("toggleSales", { static: true }) toggleSales!: ToggleComponent;
@ViewChild("salesListComponent", { static: false }) salesListComponent!: SaleListComponent;
+ @ViewChild("toggleDocuments", { static: true }) toggleDocuments!: ToggleComponent;
+ @ViewChild("documentsListComponent", { static: false }) documentsListComponent!: DocumentListComponent;
protected user: User | null;
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 5e6c5c5..0241344 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
@@ -11,14 +11,15 @@
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 a1cb3cb..1f33d7f 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
@@ -2,12 +2,18 @@ import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angula
import {ModalStatus} from "@app/_helpers/modal.states";
import {FormGroup} from "@angular/forms";
import {postForm} from "@app/_forms/apiForms";
-import {PartnerJsonld, PartnerProductService, PostJsonld, PostService, ProductService} from "@app/core/api/v1";
+import {
+ PostJsonld,
+ PostService,
+ ProductJsonld,
+ ProductService
+} from "@app/core/api/v1";
import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer";
import {AppHelperService} from "@app/_helpers/app-helper.service";
-import {Observable, Subscription} from "rxjs";
-import {SearchInputComponent} from "@app/_components/search-input/search-input.component";
-import {map} from "rxjs/operators";
+import {Subscription} from "rxjs";
+import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
+import {MatTableDataSource} from "@angular/material/table";
+import {SearchInputColDef} from "@app/_components/search-input/search-input-col-def";
@Component({
selector: 'app-new-post',
@@ -17,10 +23,13 @@ import {map} from "rxjs/operators";
export class NewPostComponent implements OnInit {
@Input() public posting!: PostJsonld;
@Output() public submit: EventEmitter = new EventEmitter();
- @ViewChild('productSearchInput', { static: false }) $productSearchInput!: SearchInputComponent;
+ @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent;
protected postForm: FormGroup;
protected postSub: Subscription;
+ protected products: Array;
+ protected dataSourceProducts;
+ protected colDefProducts: SearchInputColDef[];
constructor(
private postService: PostService,
@@ -29,15 +38,31 @@ export class NewPostComponent implements OnInit {
) {
this.postForm = postForm;
this.postSub = new Subscription();
+ this.products = [];
+ this.dataSourceProducts = new MatTableDataSource(this.products);
+ this.colDefProducts = [
+ SearchSelectComponent.createColDef('pos', 'overview.number', SearchSelectComponent.COLUMN_TYPE_POSITION),
+ SearchSelectComponent.createColDef('img', 'overview.image', SearchSelectComponent.COLUMN_TYPE_IMAGE, 'imageUrl'),
+ SearchSelectComponent.createColDef('name', 'form.product', SearchSelectComponent.COLUMN_TYPE_TEXT, 'name'),
+ ];
}
ngOnInit(): void {
this.postForm = FormGroupInitializer.initFormGroup(this.postForm, this.posting);
}
- 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}))),
+ getProducts = (term?: string): void => {
+ // NOTE: all products that are not assigned to partner yet
+ this.productService.productsGetCollection(
+ this.productSearchSelect.pagingComponent.getPageIndex(),
+ this.productSearchSelect.pagingComponent.getPageSize(),
+ term
+ ).subscribe(
+ data => {
+ this.products = data['hydra:member'];
+ this.dataSourceProducts = new MatTableDataSource(this.products);
+ this.productSearchSelect.setData(this.dataSourceProducts, this.products, Number(data["hydra:totalItems"]));
+ }
);
}
diff --git a/matsen-tool/src/app/_views/products/products-detail/products-detail.component.html b/matsen-tool/src/app/_views/products/products-detail/products-detail.component.html
index 38edf4f..a385eb3 100644
--- a/matsen-tool/src/app/_views/products/products-detail/products-detail.component.html
+++ b/matsen-tool/src/app/_views/products/products-detail/products-detail.component.html
@@ -19,10 +19,10 @@

+ src="{{product.imageUrl}}" width="247" height="94"
+ alt="{{product.name}}" title="{{product.name}}"/>

+ src="/assets/images/icons/dummy-product.png" width="247" height="94" alt=""/>
+
+
+
+
\ No newline at end of file
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 a4c9418..a72274b 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
@@ -2,28 +2,31 @@
{{ 'basic.edit-sale' | translate }}