| @@ -4447,6 +4447,7 @@ components: | |||||
| required: | required: | ||||
| - contact | - contact | ||||
| - partnerProduct | - partnerProduct | ||||
| - product | |||||
| properties: | properties: | ||||
| contact: | contact: | ||||
| type: | type: | ||||
| @@ -4460,6 +4461,9 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | example: 'https://example.com/' | ||||
| product: | |||||
| description: '?ProductApi' | |||||
| $ref: '#/components/schemas/Product' | |||||
| productName: | productName: | ||||
| readOnly: true | readOnly: true | ||||
| type: | type: | ||||
| @@ -4478,6 +4482,7 @@ components: | |||||
| required: | required: | ||||
| - contact | - contact | ||||
| - partnerProduct | - partnerProduct | ||||
| - product | |||||
| properties: | properties: | ||||
| _links: | _links: | ||||
| type: object | type: object | ||||
| @@ -4500,6 +4505,9 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | example: 'https://example.com/' | ||||
| product: | |||||
| description: '?ProductApi' | |||||
| $ref: '#/components/schemas/Product.jsonhal' | |||||
| productName: | productName: | ||||
| readOnly: true | readOnly: true | ||||
| type: | type: | ||||
| @@ -4518,6 +4526,7 @@ components: | |||||
| required: | required: | ||||
| - contact | - contact | ||||
| - partnerProduct | - partnerProduct | ||||
| - product | |||||
| properties: | properties: | ||||
| '@context': | '@context': | ||||
| readOnly: true | readOnly: true | ||||
| @@ -4554,6 +4563,9 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | example: 'https://example.com/' | ||||
| product: | |||||
| description: '?ProductApi' | |||||
| $ref: '#/components/schemas/Product.jsonld' | |||||
| productName: | productName: | ||||
| readOnly: true | readOnly: true | ||||
| type: | type: | ||||
| @@ -77,6 +77,7 @@ export const contactJsonldForm = new FormGroup({ | |||||
| export const contactPartnerProductForm = new FormGroup({ | export const contactPartnerProductForm = new FormGroup({ | ||||
| contact: new FormControl(null, [Validators.required]), | contact: new FormControl(null, [Validators.required]), | ||||
| partnerProduct: new FormControl(null, [Validators.required]), | partnerProduct: new FormControl(null, [Validators.required]), | ||||
| product: new FormControl(null, [Validators.required]), | |||||
| productName: new FormControl(null, []), | productName: new FormControl(null, []), | ||||
| createdAt: new FormControl(null, []) | createdAt: new FormControl(null, []) | ||||
| }); | }); | ||||
| @@ -85,6 +86,7 @@ export const contactPartnerProductJsonhalForm = new FormGroup({ | |||||
| _links: new FormControl(null, []), | _links: new FormControl(null, []), | ||||
| contact: new FormControl(null, [Validators.required]), | contact: new FormControl(null, [Validators.required]), | ||||
| partnerProduct: new FormControl(null, [Validators.required]), | partnerProduct: new FormControl(null, [Validators.required]), | ||||
| product: new FormControl(null, [Validators.required]), | |||||
| productName: new FormControl(null, []), | productName: new FormControl(null, []), | ||||
| createdAt: new FormControl(null, []) | createdAt: new FormControl(null, []) | ||||
| }); | }); | ||||
| @@ -92,6 +94,7 @@ export const contactPartnerProductJsonhalForm = new FormGroup({ | |||||
| export const contactPartnerProductJsonldForm = new FormGroup({ | export const contactPartnerProductJsonldForm = new FormGroup({ | ||||
| contact: new FormControl(null, [Validators.required]), | contact: new FormControl(null, [Validators.required]), | ||||
| partnerProduct: new FormControl(null, [Validators.required]), | partnerProduct: new FormControl(null, [Validators.required]), | ||||
| product: new FormControl(null, [Validators.required]), | |||||
| productName: new FormControl(null, []), | productName: new FormControl(null, []), | ||||
| createdAt: new FormControl(null, []) | createdAt: new FormControl(null, []) | ||||
| }); | }); | ||||
| @@ -40,3 +40,8 @@ | |||||
| [contact]="contact" | [contact]="contact" | ||||
| ></app-post-list> | ></app-post-list> | ||||
| </app-toggle> | </app-toggle> | ||||
| <app-toggle #toggleProducts [headline]="'basic.products' | translate"> | |||||
| <app-product-list *ngIf="toggleProducts.isOpened" #productListComponent | |||||
| [contact]="contact"> | |||||
| </app-product-list> | |||||
| </app-toggle> | |||||
| @@ -13,6 +13,7 @@ import {AccountService} from "@app/_services"; | |||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | import {AppHelperService} from "@app/_helpers/app-helper.service"; | ||||
| import {PostListComponent} from "@app/_views/posts/post-list/post-list.component"; | import {PostListComponent} from "@app/_views/posts/post-list/post-list.component"; | ||||
| import {ToggleComponent} from "@app/_components/toggle/toggle.component"; | import {ToggleComponent} from "@app/_components/toggle/toggle.component"; | ||||
| import {ProductListComponent} from "@app/_views/products/product-list/product-list.component"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-contacts-detail', | selector: 'app-contacts-detail', | ||||
| @@ -22,6 +23,8 @@ import {ToggleComponent} from "@app/_components/toggle/toggle.component"; | |||||
| export class ContactsDetailComponent implements OnInit, AfterViewInit { | export class ContactsDetailComponent implements OnInit, AfterViewInit { | ||||
| @ViewChild("togglePosts", { static: true }) togglePosts!: ToggleComponent; | @ViewChild("togglePosts", { static: true }) togglePosts!: ToggleComponent; | ||||
| @ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent; | @ViewChild("postListComponent", { static: false }) postsComponent!: PostListComponent; | ||||
| @ViewChild("toggleProducts", { static: true }) toggleProducts!: ToggleComponent; | |||||
| @ViewChild("productListComponent", { static: false }) productsComponent!: ProductListComponent; | |||||
| protected user: User | null; | protected user: User | null; | ||||
| @@ -0,0 +1,2 @@ | |||||
| <h2 >{{'basic.assign-product' | translate}}</h2> | |||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { AssignProductComponent } from './assign-product.component'; | |||||
| describe('AssignProductComponent', () => { | |||||
| let component: AssignProductComponent; | |||||
| let fixture: ComponentFixture<AssignProductComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [AssignProductComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(AssignProductComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,17 @@ | |||||
| import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; | |||||
| import {ContactJsonld, PartnerJsonld, ProductJsonld, UserJsonld} from "@app/core/api/v1"; | |||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||||
| import {SearchInputComponent} from "@app/_components/search-input/search-input.component"; | |||||
| @Component({ | |||||
| selector: 'app-assign-product', | |||||
| templateUrl: './assign-product.component.html', | |||||
| styleUrl: './assign-product.component.scss' | |||||
| }) | |||||
| export class AssignProductComponent { | |||||
| @Input() public user!: UserJsonld; | |||||
| @Input() public partner!: PartnerJsonld; | |||||
| @Input() public contact!: ContactJsonld; | |||||
| @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | |||||
| @ViewChild('productSearchInput', { static: false }) $productSearchInput!: SearchInputComponent; | |||||
| } | |||||
| @@ -1,6 +1,7 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="top-btn"> | <div class="top-btn"> | ||||
| <button class="btn btn-primary" (click)="openModalNewProduct()">+ {{ 'basic.new-product' | translate }}</button> | |||||
| <button *ngIf="bShowNewProductButton" class="btn btn-primary" (click)="openModalNewProduct()">+ {{ 'basic.new-product' | translate }}</button> | |||||
| <button *ngIf="!bShowNewProductButton" class="btn btn-primary" (click)="openModalAssignProduct()">+ {{ 'basic.assign-product' | translate }}</button> | |||||
| </div> | </div> | ||||
| <app-paging #pagingComponent | <app-paging #pagingComponent | ||||
| [getDataFunction]="getData" | [getDataFunction]="getData" | ||||
| @@ -3,6 +3,7 @@ import {MatSort, Sort} from "@angular/material/sort"; | |||||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | import {PagingComponent} from "@app/_components/paging/paging.component"; | ||||
| import {Subscription} from "rxjs"; | import {Subscription} from "rxjs"; | ||||
| import { | import { | ||||
| ContactJsonld, ContactPartnerProductService, | |||||
| PartnerJsonld, | PartnerJsonld, | ||||
| PartnerProductService, | PartnerProductService, | ||||
| ProductJsonld, | ProductJsonld, | ||||
| @@ -15,6 +16,7 @@ import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| import {MatTableDataSource} from "@angular/material/table"; | import {MatTableDataSource} from "@angular/material/table"; | ||||
| import {OrderFilter} from "@app/_models/orderFilter"; | import {OrderFilter} from "@app/_models/orderFilter"; | ||||
| import {NewProductComponent} from "@app/_views/products/new-product/new-product.component"; | import {NewProductComponent} from "@app/_views/products/new-product/new-product.component"; | ||||
| import {AssignProductComponent} from "@app/_views/products/assign-product/assign-product.component"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-product-list', | selector: 'app-product-list', | ||||
| @@ -25,6 +27,7 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| @Input() public user!: UserJsonld; | @Input() public user!: UserJsonld; | ||||
| @Input() public partner!: PartnerJsonld; | @Input() public partner!: PartnerJsonld; | ||||
| @Input() public contact!: ContactJsonld; | |||||
| @ViewChild(MatSort) sort; | @ViewChild(MatSort) sort; | ||||
| @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | @ViewChild("pagingComponent", { static: false }) pagingComponent!: PagingComponent; | ||||
| @@ -33,12 +36,14 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| protected productsSub: Subscription; | protected productsSub: Subscription; | ||||
| protected products: Array<ProductJsonld>; | protected products: Array<ProductJsonld>; | ||||
| protected dataSource; | protected dataSource; | ||||
| protected bShowNewProductButton: boolean; | |||||
| constructor( | constructor( | ||||
| private router: Router, | private router: Router, | ||||
| private productService: ProductService, | private productService: ProductService, | ||||
| private userProductService: UserProductService, | private userProductService: UserProductService, | ||||
| private partnerProductService: PartnerProductService, | private partnerProductService: PartnerProductService, | ||||
| private contactPartnerProductService: ContactPartnerProductService, | |||||
| protected appHelperService: AppHelperService, | protected appHelperService: AppHelperService, | ||||
| ) { | ) { | ||||
| this.sort = new MatSort(); | this.sort = new MatSort(); | ||||
| @@ -47,14 +52,18 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| this.productsSub = new Subscription(); | this.productsSub = new Subscription(); | ||||
| this.products = []; | this.products = []; | ||||
| this.dataSource = new MatTableDataSource<ProductJsonld>(this.products); | this.dataSource = new MatTableDataSource<ProductJsonld>(this.products); | ||||
| this.bShowNewProductButton = true; | |||||
| } | } | ||||
| ngOnInit(){ | ngOnInit(){ | ||||
| this.bShowNewProductButton = | |||||
| this.user === undefined && this.partner === undefined && this.contact === undefined; | |||||
| } | } | ||||
| ngAfterViewInit() { | ngAfterViewInit() { | ||||
| this.dataSource.sort = this.sort; | this.dataSource.sort = this.sort; | ||||
| this.dataSource.paginator = this.pagingComponent.paginator; | this.dataSource.paginator = this.pagingComponent.paginator; | ||||
| //this.bShowNewProductButton = this.user === undefined && this.partner === undefined; | |||||
| this.pagingComponent.getData(); | this.pagingComponent.getData(); | ||||
| } | } | ||||
| @@ -63,6 +72,8 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| this.getUserProducts(); | this.getUserProducts(); | ||||
| } else if (this.partner !== undefined) { | } else if (this.partner !== undefined) { | ||||
| this.getPartnerProducts(); | this.getPartnerProducts(); | ||||
| } else if (this.contact !== undefined) { | |||||
| this.getContactPartnerProduct(); | |||||
| } else { | } else { | ||||
| this.getProducts(); | this.getProducts(); | ||||
| } | } | ||||
| @@ -93,12 +104,29 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| this.partner.id, | this.partner.id, | ||||
| ).subscribe( | ).subscribe( | ||||
| data => { | data => { | ||||
| console.log(data); | |||||
| let partnerProducts = data["hydra:member"]; | let partnerProducts = data["hydra:member"]; | ||||
| this.products = []; | this.products = []; | ||||
| partnerProducts.forEach(item => { | partnerProducts.forEach(item => { | ||||
| this.products.push(item.product); | this.products.push(item.product); | ||||
| }) | }) | ||||
| this.pagingComponent.dataLength = Number(data["hydra:totalItems"]); | |||||
| this.dataSource = new MatTableDataSource<ProductJsonld>(this.products); | |||||
| } | |||||
| ); | |||||
| } | |||||
| getContactPartnerProduct = () => { | |||||
| this.productsSub = this.contactPartnerProductService.contactPartnerProductsGetCollection( | |||||
| this.pagingComponent.getPageIndex(), | |||||
| this.pagingComponent.getPageSize(), | |||||
| this.contact.id, | |||||
| ).subscribe( | |||||
| data => { | |||||
| let contactProduct = data["hydra:member"]; | |||||
| this.products = []; | |||||
| contactProduct.forEach(item => { | |||||
| this.products.push(item.product); | |||||
| }) | |||||
| console.log(this.products); | console.log(this.products); | ||||
| this.pagingComponent.dataLength = Number(data["hydra:totalItems"]); | this.pagingComponent.dataLength = Number(data["hydra:totalItems"]); | ||||
| this.dataSource = new MatTableDataSource<ProductJsonld>(this.products); | this.dataSource = new MatTableDataSource<ProductJsonld>(this.products); | ||||
| @@ -142,4 +170,18 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||||
| product.name = ""; | product.name = ""; | ||||
| this.appHelperService.openModal(NewProductComponent, { 'product': product }, this.getData); | this.appHelperService.openModal(NewProductComponent, { 'product': product }, this.getData); | ||||
| } | } | ||||
| openModalAssignProduct() { | |||||
| let data = {}; | |||||
| if (this.user !== undefined) { | |||||
| this.appHelperService.openModal(AssignProductComponent, { 'user' : this.user }, this.getUserProducts); | |||||
| } else if (this.partner !== undefined) { | |||||
| data = { 'partner' : this.partner }; | |||||
| this.appHelperService.openModal(AssignProductComponent, { 'partner' : this.partner }, this.getPartnerProducts); | |||||
| } else if (this.contact !== undefined) { | |||||
| this.appHelperService.openModal(AssignProductComponent, { 'contact' : this.contact }, this.getContactPartnerProduct); | |||||
| } else { | |||||
| throw new Error('data not found') | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -61,6 +61,7 @@ import { SaleSummaryComponent } from './_views/sales/sale-summary/sale-summary.c | |||||
| import { UsersComponent } from './_views/user/users.component'; | import { UsersComponent } from './_views/user/users.component'; | ||||
| import { UserDetailComponent } from './_views/user/user-detail/user-detail.component'; | import { UserDetailComponent } from './_views/user/user-detail/user-detail.component'; | ||||
| import { UserListComponent } from './_views/user/user-list/user-list.component'; | import { UserListComponent } from './_views/user/user-list/user-list.component'; | ||||
| import { AssignProductComponent } from './_views/products/assign-product/assign-product.component'; | |||||
| export function apiConfigFactory(): Configuration { | export function apiConfigFactory(): Configuration { | ||||
| @@ -145,6 +146,7 @@ export function HttpLoaderFactory(http: HttpClient) { | |||||
| UsersComponent, | UsersComponent, | ||||
| UserDetailComponent, | UserDetailComponent, | ||||
| UserListComponent, | UserListComponent, | ||||
| AssignProductComponent, | |||||
| ], | ], | ||||
| providers: [ | providers: [ | ||||
| {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | ||||
| @@ -9,6 +9,7 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { Product } from './product'; | |||||
| /** | /** | ||||
| @@ -17,6 +18,10 @@ | |||||
| export interface ContactPartnerProduct { | export interface ContactPartnerProduct { | ||||
| contact: string | null; | contact: string | null; | ||||
| partnerProduct: string | null; | partnerProduct: string | null; | ||||
| /** | |||||
| * ?ProductApi | |||||
| */ | |||||
| product: Product; | |||||
| readonly productName?: string | null; | readonly productName?: string | null; | ||||
| readonly createdAt?: string | null; | readonly createdAt?: string | null; | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ | |||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { CommentJsonhalLinks } from './commentJsonhalLinks'; | import { CommentJsonhalLinks } from './commentJsonhalLinks'; | ||||
| import { ProductJsonhal } from './productJsonhal'; | |||||
| /** | /** | ||||
| @@ -19,6 +20,10 @@ export interface ContactPartnerProductJsonhal { | |||||
| _links?: CommentJsonhalLinks; | _links?: CommentJsonhalLinks; | ||||
| contact: string | null; | contact: string | null; | ||||
| partnerProduct: string | null; | partnerProduct: string | null; | ||||
| /** | |||||
| * ?ProductApi | |||||
| */ | |||||
| product: ProductJsonhal; | |||||
| readonly productName?: string | null; | readonly productName?: string | null; | ||||
| readonly createdAt?: string | null; | readonly createdAt?: string | null; | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ | |||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { CommentJsonldContext } from './commentJsonldContext'; | import { CommentJsonldContext } from './commentJsonldContext'; | ||||
| import { ProductJsonld } from './productJsonld'; | |||||
| /** | /** | ||||
| @@ -21,6 +22,10 @@ export interface ContactPartnerProductJsonld { | |||||
| readonly type?: string; | readonly type?: string; | ||||
| contact: string | null; | contact: string | null; | ||||
| partnerProduct: string | null; | partnerProduct: string | null; | ||||
| /** | |||||
| * ?ProductApi | |||||
| */ | |||||
| product: ProductJsonld; | |||||
| readonly productName?: string | null; | readonly productName?: string | null; | ||||
| readonly createdAt?: string | null; | readonly createdAt?: string | null; | ||||
| } | } | ||||
| @@ -28,6 +28,7 @@ | |||||
| "users": "Benutzer", | "users": "Benutzer", | ||||
| "new": "Neuer", | "new": "Neuer", | ||||
| "new-product": "Neues Produkt", | "new-product": "Neues Produkt", | ||||
| "assign-product": "Produkt zuordnen", | |||||
| "new-document": "Neues Dokument", | "new-document": "Neues Dokument", | ||||
| "new-task": "Neue Aufgabe", | "new-task": "Neue Aufgabe", | ||||
| "new-contact": "Neuer Kontakt", | "new-contact": "Neuer Kontakt", | ||||