| @@ -365,6 +365,18 @@ paths: | |||
| style: form | |||
| explode: true | |||
| allowReserved: false | |||
| - | |||
| name: partnerProduct.product.name | |||
| in: query | |||
| description: '' | |||
| required: false | |||
| deprecated: false | |||
| allowEmptyValue: true | |||
| schema: | |||
| type: string | |||
| style: form | |||
| explode: false | |||
| allowReserved: false | |||
| deprecated: false | |||
| post: | |||
| operationId: api_contact_partner_products_post | |||
| @@ -4514,6 +4526,10 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| partnerProduct: | |||
| readOnly: true | |||
| description: '?PartnerProduct' | |||
| $ref: '#/components/schemas/PartnerProduct' | |||
| product: | |||
| readOnly: true | |||
| description: '?ProductApi' | |||
| @@ -4553,6 +4569,10 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| partnerProduct: | |||
| readOnly: true | |||
| description: '?PartnerProduct' | |||
| $ref: '#/components/schemas/PartnerProduct.jsonhal' | |||
| product: | |||
| readOnly: true | |||
| description: '?ProductApi' | |||
| @@ -4606,6 +4626,10 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| partnerProduct: | |||
| readOnly: true | |||
| description: '?PartnerProduct' | |||
| $ref: '#/components/schemas/PartnerProduct.jsonld' | |||
| product: | |||
| readOnly: true | |||
| description: '?ProductApi' | |||
| @@ -77,6 +77,7 @@ export const contactJsonldForm = new FormGroup({ | |||
| export const contactPartnerProductForm = new FormGroup({ | |||
| contactIri: new FormControl(null, [Validators.required]), | |||
| partnerProductIri: new FormControl(null, [Validators.required]), | |||
| partnerProduct: new FormControl(null, []), | |||
| product: new FormControl(null, []), | |||
| createdAt: new FormControl(null, []) | |||
| }); | |||
| @@ -85,6 +86,7 @@ export const contactPartnerProductJsonhalForm = new FormGroup({ | |||
| _links: new FormControl(null, []), | |||
| contactIri: new FormControl(null, [Validators.required]), | |||
| partnerProductIri: new FormControl(null, [Validators.required]), | |||
| partnerProduct: new FormControl(null, []), | |||
| product: new FormControl(null, []), | |||
| createdAt: new FormControl(null, []) | |||
| }); | |||
| @@ -92,6 +94,7 @@ export const contactPartnerProductJsonhalForm = new FormGroup({ | |||
| export const contactPartnerProductJsonldForm = new FormGroup({ | |||
| contactIri: new FormControl(null, [Validators.required]), | |||
| partnerProductIri: new FormControl(null, [Validators.required]), | |||
| partnerProduct: new FormControl(null, []), | |||
| product: new FormControl(null, []), | |||
| createdAt: new FormControl(null, []) | |||
| }); | |||
| @@ -1,5 +1,5 @@ | |||
| <div class="spt-container"> | |||
| <div class="top-btn"> | |||
| <div *ngIf="!this.user" class="top-btn"> | |||
| <button class="btn btn-primary" (click)="openModalNewPartner()">+ {{ 'basic.new' | translate }} {{ partnerColumnHeadline }}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| @@ -1,6 +1,6 @@ | |||
| <div class="spt-container"> | |||
| <div class="posts"> | |||
| <div class="top-btn"> | |||
| <div *ngIf="!this.user" class="top-btn"> | |||
| <button class="btn btn-primary" (click)="openModalNewPost()">+ {{ 'basic.new-post' | translate }}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| @@ -5,16 +5,25 @@ | |||
| <div class="mb-3" *ngIf="this.partnerProduct"> | |||
| <app-search-input #productSearchInput | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'productName'" | |||
| [documentForm]="form" | |||
| [documentFormField]="'productName'" | |||
| [fetchFunction]="fetchProducts"> | |||
| [fetchFunction]="fetchPartnerProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="partnerIri" value="{{partnerProduct.partnerIri}}"/> | |||
| </div> | |||
| <div class="mb-3" *ngIf="this.contactPartnerProduct"> | |||
| <app-search-input #productSearchInput | |||
| [formId]="'partnerProductIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [dataField]="'productName'" | |||
| [documentForm]="form" | |||
| [documentFormField]="'productName'" | |||
| [fetchFunction]="fetchContactPartnerProducts"> | |||
| </app-search-input> | |||
| <input type="hidden" formControlName="partnerProductIri" value="{{contactPartnerProduct.partnerProductIri}}"/> | |||
| </div> | |||
| <button type="submit" class="btn btn-primary" [disabled]="form.invalid">{{'form.send' | translate}}</button> | |||
| </form> | |||
| </div> | |||
| @@ -1,15 +1,14 @@ | |||
| import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; | |||
| import { | |||
| ContactJsonld, | |||
| ContactPartnerProductJsonld, ContactPartnerProductService, PartnerJsonld, | |||
| PartnerProductJsonld, PartnerProductService, | |||
| ProductService, | |||
| UserJsonld | |||
| } from "@app/core/api/v1"; | |||
| import {ModalStatus} from "@app/_helpers/modal.states"; | |||
| import {SearchInputComponent} from "@app/_components/search-input/search-input.component"; | |||
| import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; | |||
| import {FormGroup} from "@angular/forms"; | |||
| import {partnerProductForm} from "@app/_forms/apiForms"; | |||
| import {contactPartnerProductForm, partnerProductForm} from "@app/_forms/apiForms"; | |||
| import {forkJoin, Observable} from "rxjs"; | |||
| import {map} from "rxjs/operators"; | |||
| @@ -19,9 +18,9 @@ import {map} from "rxjs/operators"; | |||
| styleUrl: './assign-product.component.scss' | |||
| }) | |||
| export class AssignProductComponent implements OnInit { | |||
| @Input() public user!: UserJsonld; | |||
| @Input() public partnerIri!: string; | |||
| @Input() public partnerProduct!: PartnerProductJsonld; | |||
| @Input() public contact!: ContactJsonld; | |||
| @Input() public contactPartnerProduct!: ContactPartnerProductJsonld; | |||
| @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | |||
| @ViewChild('productSearchInput', { static: false }) $productSearchInput!: SearchInputComponent; | |||
| @@ -29,7 +28,8 @@ export class AssignProductComponent implements OnInit { | |||
| constructor( | |||
| protected productService: ProductService, | |||
| protected partnerProductService: PartnerProductService | |||
| protected partnerProductService: PartnerProductService, | |||
| protected contactPartnerProductService: ContactPartnerProductService | |||
| ) { | |||
| } | |||
| @@ -38,10 +38,13 @@ export class AssignProductComponent implements OnInit { | |||
| if (this.partnerProduct !== undefined) { | |||
| this.form = FormGroupInitializer.initFormGroup(partnerProductForm, this.partnerProduct); | |||
| } | |||
| console.log(this.contactPartnerProduct); | |||
| if (this.contactPartnerProduct !== undefined) { | |||
| this.form = FormGroupInitializer.initFormGroup(contactPartnerProductForm, this.contactPartnerProduct); | |||
| } | |||
| } | |||
| fetchProducts = (term: string): Observable<{ id: any; name: any }[]> => { | |||
| // Beide API-Calls werden hier definiert | |||
| fetchPartnerProducts = (term: string): Observable<{ id: any; name: any }[]> => { | |||
| let products$ = this.productService.productsGetCollection(1, 50, term); | |||
| let partnerProducts$ = this.partnerProductService.partnerProductsGetCollection( | |||
| 1, | |||
| @@ -65,16 +68,65 @@ export class AssignProductComponent implements OnInit { | |||
| ); | |||
| } | |||
| fetchContactPartnerProducts = (term: string): Observable<{ id: any; name: any }[]> => { | |||
| let partnerProducts$ = this.partnerProductService.partnerProductsGetCollection( | |||
| 1, | |||
| 50, | |||
| this.partnerIri, | |||
| undefined, | |||
| undefined, | |||
| undefined, | |||
| term | |||
| ); | |||
| let contactPartnerProducts$ = this.contactPartnerProductService.contactPartnerProductsGetCollection( | |||
| 1, | |||
| 50, | |||
| this.contactPartnerProduct.contactIri!, | |||
| undefined, | |||
| term | |||
| ); | |||
| // Combine api calls | |||
| return forkJoin([partnerProducts$, contactPartnerProducts$]) | |||
| .pipe( | |||
| map(([partnerProductsResponse, contactPartnerProductsResponse]) => { | |||
| let partnerProducts = partnerProductsResponse['hydra:member'].map(partnerProduct => | |||
| ({ id: partnerProduct.id, name: partnerProduct.product!.name }) | |||
| ); | |||
| let contactPartnerProductIds = contactPartnerProductsResponse['hydra:member'].map(contactPartnerProduct => | |||
| contactPartnerProduct.partnerProduct?.id | |||
| ); | |||
| // Filter all products where a partner product already exists | |||
| return partnerProducts.filter(partnerProduct => !contactPartnerProductIds.includes(partnerProduct.id)); | |||
| }) | |||
| ); | |||
| } | |||
| onSubmit() { | |||
| if (this.form.valid) { | |||
| this.partnerProductService.partnerProductsPost( | |||
| this.form.value as PartnerProductJsonld | |||
| ).subscribe( | |||
| data => { | |||
| this.form.reset(); | |||
| this.submit.emit(ModalStatus.Submitted); | |||
| } | |||
| ) | |||
| if (this.partnerProduct !== undefined) { | |||
| // Partner product | |||
| this.partnerProductService.partnerProductsPost( | |||
| this.form.value as PartnerProductJsonld | |||
| ).subscribe( | |||
| data => { | |||
| this.form.reset(); | |||
| this.submit.emit(ModalStatus.Submitted); | |||
| } | |||
| ) | |||
| } | |||
| if (this.contactPartnerProduct !== undefined) { | |||
| this.contactPartnerProductService.contactPartnerProductsPost( | |||
| this.form.value as ContactPartnerProductJsonld | |||
| ).subscribe( | |||
| data => { | |||
| this.form.reset(); | |||
| this.submit.emit(ModalStatus.Submitted); | |||
| } | |||
| ) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,5 +1,5 @@ | |||
| <div class="spt-container"> | |||
| <div class="top-btn"> | |||
| <div *ngIf="!this.user" class="top-btn"> | |||
| <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> | |||
| @@ -3,7 +3,7 @@ import {MatSort, Sort} from "@angular/material/sort"; | |||
| import {PagingComponent} from "@app/_components/paging/paging.component"; | |||
| import {Subscription} from "rxjs"; | |||
| import { | |||
| ContactJsonld, ContactPartnerProductService, | |||
| ContactJsonld, ContactPartnerProductJsonld, ContactPartnerProductService, | |||
| PartnerJsonld, PartnerProductJsonld, | |||
| PartnerProductService, PostJsonld, | |||
| ProductJsonld, | |||
| @@ -187,18 +187,18 @@ export class ProductListComponent implements OnInit, AfterViewInit { | |||
| ); | |||
| } else if (this.partner !== undefined) { | |||
| let partnerProduct: PartnerProductJsonld = {} as PartnerProductJsonld; | |||
| if (this.partner.id) { | |||
| partnerProduct.partnerIri = this.partner.id; | |||
| } | |||
| partnerProduct.partnerIri = this.partner.id!; | |||
| this.appHelperService.openModal( | |||
| AssignProductComponent, | |||
| { 'partnerProduct' : partnerProduct }, | |||
| this.getPartnerProducts | |||
| ); | |||
| } else if (this.contact !== undefined) { | |||
| let contactPartnerProduct: ContactPartnerProductJsonld = {} as ContactPartnerProductJsonld; | |||
| contactPartnerProduct.contactIri = this.contact.id!; | |||
| this.appHelperService.openModal( | |||
| AssignProductComponent, | |||
| { 'contact' : this.contact }, | |||
| { 'contactPartnerProduct' : contactPartnerProduct, 'partnerIri' : this.contact.partnerIri }, | |||
| this.getContactPartnerProduct | |||
| ); | |||
| } else { | |||
| @@ -98,7 +98,7 @@ export class ProductsDetailComponent implements OnInit, AfterViewInit { | |||
| this.userProductSub = this.userProductService.userProductsPost( | |||
| { | |||
| user: this.user?.id, | |||
| product: this.product, | |||
| productIri: this.product.id, | |||
| } as UserProductJsonld | |||
| ).subscribe( | |||
| data => { | |||
| @@ -1,6 +1,6 @@ | |||
| <div class="spt-container"> | |||
| <div class="top-btn"> | |||
| <button class="btn btn-primary" (click)="openModalNewSale()">+ {{ 'basic.new-sale' | translate }}</button> | |||
| <button *ngIf="!this.user" class="btn btn-primary" (click)="openModalNewSale()">+ {{ 'basic.new-sale' | translate }}</button> | |||
| </div> | |||
| <app-paging #pagingComponent | |||
| [getDataFunction]="getData" | |||
| @@ -106,13 +106,14 @@ export class ContactPartnerProductService { | |||
| * @param itemsPerPage The number of items per page | |||
| * @param contact | |||
| * @param contact2 | |||
| * @param partnerProductProductName | |||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||
| * @param reportProgress flag to report request and response progress. | |||
| */ | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<ApiContactPartnerProductsGetCollection200Response>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<ApiContactPartnerProductsGetCollection200Response>>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<ApiContactPartnerProductsGetCollection200Response>>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<any> { | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, partnerProductProductName?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<ApiContactPartnerProductsGetCollection200Response>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, partnerProductProductName?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<ApiContactPartnerProductsGetCollection200Response>>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, partnerProductProductName?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<ApiContactPartnerProductsGetCollection200Response>>; | |||
| public contactPartnerProductsGetCollection(page?: number, itemsPerPage?: number, contact?: string, contact2?: Array<string>, partnerProductProductName?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext, transferCache?: boolean}): Observable<any> { | |||
| let localVarQueryParameters = new HttpParams({encoder: this.encoder}); | |||
| if (page !== undefined && page !== null) { | |||
| @@ -133,6 +134,10 @@ export class ContactPartnerProductService { | |||
| <any>element, 'contact[]'); | |||
| }) | |||
| } | |||
| if (partnerProductProductName !== undefined && partnerProductProductName !== null) { | |||
| localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, | |||
| <any>partnerProductProductName, 'partnerProduct.product.name'); | |||
| } | |||
| let localVarHeaders = this.defaultHeaders; | |||
| @@ -10,6 +10,7 @@ | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { Product } from './product'; | |||
| import { PartnerProduct } from './partnerProduct'; | |||
| /** | |||
| @@ -18,6 +19,10 @@ import { Product } from './product'; | |||
| export interface ContactPartnerProduct { | |||
| contactIri: string | null; | |||
| partnerProductIri: string | null; | |||
| /** | |||
| * ?PartnerProduct | |||
| */ | |||
| readonly partnerProduct?: PartnerProduct; | |||
| /** | |||
| * ?ProductApi | |||
| */ | |||
| @@ -10,6 +10,7 @@ | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { CommentJsonhalLinks } from './commentJsonhalLinks'; | |||
| import { PartnerProductJsonhal } from './partnerProductJsonhal'; | |||
| import { ProductJsonhal } from './productJsonhal'; | |||
| @@ -20,6 +21,10 @@ export interface ContactPartnerProductJsonhal { | |||
| _links?: CommentJsonhalLinks; | |||
| contactIri: string | null; | |||
| partnerProductIri: string | null; | |||
| /** | |||
| * ?PartnerProduct | |||
| */ | |||
| readonly partnerProduct?: PartnerProductJsonhal; | |||
| /** | |||
| * ?ProductApi | |||
| */ | |||
| @@ -9,6 +9,7 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { PartnerProductJsonld } from './partnerProductJsonld'; | |||
| import { CommentJsonldContext } from './commentJsonldContext'; | |||
| import { ProductJsonld } from './productJsonld'; | |||
| @@ -22,6 +23,10 @@ export interface ContactPartnerProductJsonld { | |||
| readonly type?: string; | |||
| contactIri: string | null; | |||
| partnerProductIri: string | null; | |||
| /** | |||
| * ?PartnerProduct | |||
| */ | |||
| readonly partnerProduct?: PartnerProductJsonld; | |||
| /** | |||
| * ?ProductApi | |||
| */ | |||