diff --git a/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.html b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.html
new file mode 100644
index 0000000..310ef34
--- /dev/null
+++ b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.html
@@ -0,0 +1,19 @@
+
{{ 'basic.assign-partner-01' | translate }} {{ partnerText }} {{ 'basic.assign-partner-02' | translate }}
+
diff --git a/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.scss b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.spec.ts b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.spec.ts
new file mode 100644
index 0000000..6cca850
--- /dev/null
+++ b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AssignPartnerComponent } from './assign-partner.component';
+
+describe('AssignPartnerComponent', () => {
+ let component: AssignPartnerComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [AssignPartnerComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(AssignPartnerComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.ts b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.ts
new file mode 100644
index 0000000..37ac5dc
--- /dev/null
+++ b/matsen-tool/src/app/_views/partners/assign-partner/assign-partner.component.ts
@@ -0,0 +1,78 @@
+import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
+import {
+ ContactPartnerProductJsonld,
+ ContactPartnerProductService, PartnerJsonld,
+ PartnerProductJsonld,
+ PartnerProductService, PartnerService,
+ ProductService
+} from "@app/core/api/v1";
+import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer";
+import {FormGroup} from "@angular/forms";
+import {partnerProductForm} from "@app/_forms/apiForms";
+import {AppHelperService} from "@app/_helpers/app-helper.service";
+import {ModalStatus} from "@app/_helpers/modal.states";
+import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
+import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type";
+import {TranslateService} from "@ngx-translate/core";
+
+@Component({
+ selector: 'app-assign-partner',
+ templateUrl: './assign-partner.component.html',
+ styleUrl: './assign-partner.component.scss'
+})
+export class AssignPartnerComponent implements OnInit {
+ @Input() public partner!: PartnerJsonld;
+ @Input() public productIri!: string;
+ @Input() public partnerProduct!: PartnerProductJsonld;
+ @Output() public submit: EventEmitter = new EventEmitter();
+ @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent;
+ protected readonly SearchSelectComponent = SearchSelectComponent;
+
+ protected partnerText: string;
+ protected form!: FormGroup;
+
+ constructor(
+ protected partnerService: PartnerService,
+ protected partnerProductService: PartnerProductService,
+ protected appHelperService: AppHelperService,
+ protected translateService: TranslateService,
+ ) {
+ this.partnerText = "";
+ }
+
+ ngOnInit(): void {
+ this.translateService.get('basic.' + this.partner.partnerType).subscribe((translation: string) => {
+ this.partnerText = translation;
+ });
+ if (this.partnerProduct !== undefined) {
+ this.form = FormGroupInitializer.initFormGroup(partnerProductForm, this.partnerProduct);
+ }
+ }
+
+ // TODO: Wie kriegen wir die Partner raus, die dieses Produkt bereits haben?
+ getUnassignedPartners: ListGetDataFunctionType = (index: number, pageSize: number, term?: string) => {
+ return this.partnerService.partnersGetCollection(
+ index,
+ pageSize,
+ undefined,
+ undefined,
+ term,
+ //this.appHelperService.extractId(this.partnerProduct.partnerIri)
+ );
+ }
+
+ onSubmit() {
+ if (this.form.valid) {
+ if (this.partnerProduct !== undefined) {
+ this.partnerProductService.partnerProductsPost(
+ this.form.value as PartnerProductJsonld
+ ).subscribe(
+ data => {
+ this.form.reset();
+ this.submit.emit(ModalStatus.Submitted);
+ }
+ )
+ }
+ }
+ }
+}
diff --git a/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html b/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html
index afc3397..071dd59 100644
--- a/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html
+++ b/matsen-tool/src/app/_views/partners/partner-list/partner-list.component.html
@@ -1,8 +1,11 @@
-
{
this.partnerColumnHeadline = translation;
});
+ this.translateService.get('basic.' + this.partnerType).subscribe((translation: string) => {
+ this.partnerText = translation;
+ });
let withSubResource: boolean = (this.user !== undefined || this.product !== undefined);
this.listColDefinitions = [
@@ -109,6 +119,9 @@ export class PartnerListComponent implements OnInit, AfterViewInit {
)
}
this.getDataFunction = this.getGetDataFunction();
+
+ this.bShowNewPartnerButton =
+ this.user === undefined && this.product === undefined;
}
ngAfterViewInit() {
@@ -206,6 +219,31 @@ export class PartnerListComponent implements OnInit, AfterViewInit {
this.appHelperService.openModal(NewPartnerComponent, { 'partner': partner }, this.getGetDataFunction);
}
+ openModalAssignPartner() {
+ let partner: PartnerJsonld = {} as PartnerJsonld;
+ partner.partnerType = this.partnerType as TypeEnum;
+ if (this.user !== undefined) {
+ this.appHelperService.openModal(
+ AssignPartnerComponent,
+ {'user': this.user},
+ this.listComponent.getData
+ );
+ } else if (this.product !== undefined) {
+ let partnerProduct: PartnerProductJsonld = {} as PartnerProductJsonld;
+ partnerProduct.productIri = this.product.id!;
+ this.appHelperService.openModal(
+ AssignPartnerComponent,
+ {
+ 'partnerProduct': partnerProduct,
+ 'partner': partner
+ },
+ this.listComponent.getData
+ );
+ } else {
+ throw new Error('data not found')
+ }
+ }
+
unassignPartner = (element: any)=> {
let confirmMessage = "";
this.translateService.get('system.confirm-unassign').subscribe((translation: string) => {
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 d229e0a..37dcb4b 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
@@ -19,12 +19,12 @@ import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-funct
templateUrl: './assign-product.component.html',
styleUrl: './assign-product.component.scss'
})
-export class AssignProductComponent implements OnInit, AfterViewInit {
+export class AssignProductComponent implements OnInit {
@Input() public partnerIri!: string;
@Input() public partnerProduct!: PartnerProductJsonld;
@Input() public contactPartnerProduct!: ContactPartnerProductJsonld;
@Output() public submit: EventEmitter = new EventEmitter();
- @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent
+ @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent;
protected readonly SearchSelectComponent = SearchSelectComponent;
protected form!: FormGroup;
@@ -46,9 +46,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit {
}
}
- ngAfterViewInit(): void {
- }
-
getUnassignedProducts: ListGetDataFunctionType = (index: number, pageSize: number, term?: string) => {
return this.productService.productsGetCollection(
index,
diff --git a/matsen-tool/src/app/app.module.ts b/matsen-tool/src/app/app.module.ts
index 1bc8812..2d46889 100644
--- a/matsen-tool/src/app/app.module.ts
+++ b/matsen-tool/src/app/app.module.ts
@@ -67,6 +67,7 @@ import {LoadingInterceptor} from "@app/_helpers/loading-interceptor.service";
import {SearchSelectComponent} from './_components/search-select/search-select.component';
import {ListComponent} from './_components/list/list.component';
import {MatTabsModule} from "@angular/material/tabs";
+import { AssignPartnerComponent } from './_views/partners/assign-partner/assign-partner.component';
export function apiConfigFactory(): Configuration {
@@ -157,6 +158,7 @@ export function HttpLoaderFactory(http: HttpClient) {
LinkedLabelComponent,
SearchSelectComponent,
ListComponent,
+ AssignPartnerComponent,
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},
diff --git a/matsen-tool/src/assets/i18n/de.json b/matsen-tool/src/assets/i18n/de.json
index 5bd6001..078a145 100644
--- a/matsen-tool/src/assets/i18n/de.json
+++ b/matsen-tool/src/assets/i18n/de.json
@@ -28,6 +28,8 @@
"comments": "Kommentare",
"users": "Benutzer",
"new": "Neuer",
+ "assign-partner-01": "Produkt diesem",
+ "assign-partner-02": "zuordnen",
"new-product": "Neues Produkt",
"assign-product": "Produkt zuordnen",
"new-document": "Neues Dokument",