# Conflicts: # matsen-tool/src/app/contacts/new-contact/new-contact.component.ts # matsen-tool/src/app/partners/partners-detail/partners-detail.component.tsmaster
| @@ -3,7 +3,7 @@ | |||||
| <button type="button" class="btn-close" aria-label="Close" (click)="activeModal.dismiss('Cross click')"></button> | <button type="button" class="btn-close" aria-label="Close" (click)="activeModal.dismiss('Cross click')"></button> | ||||
| </div> | </div> | ||||
| <div class="modal-body"> | <div class="modal-body"> | ||||
| <ng-container *ngComponentOutlet="dynamicComponent"></ng-container> | |||||
| <ng-container *ngComponentOutlet="dynamicComponent; inputs: inputData"></ng-container> | |||||
| </div> | </div> | ||||
| <div class="modal-footer"> | <div class="modal-footer"> | ||||
| <button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button> | <button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button> | ||||
| @@ -1,14 +1,26 @@ | |||||
| import {Component, Input} from '@angular/core'; | |||||
| import {Component, Input, OnInit} from '@angular/core'; | |||||
| import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; | import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; | ||||
| import {ModalContent} from "@app/_interfaces/modalContent"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-modal', | |||||
| templateUrl: './modal.component.html', | |||||
| styleUrl: './modal.component.scss' | |||||
| selector: 'app-modal', | |||||
| templateUrl: './modal.component.html', | |||||
| styleUrl: './modal.component.scss', | |||||
| }) | }) | ||||
| export class ModalComponent { | |||||
| @Input() dynamicComponent: any; | |||||
| export class ModalComponent implements OnInit { | |||||
| @Input() dynamicComponent: any; | |||||
| @Input() inputData: any; | |||||
| constructor(public activeModal: NgbActiveModal) { } | |||||
| constructor(public activeModal: NgbActiveModal) { | |||||
| } | |||||
| ngOnInit(): void { | |||||
| } | |||||
| public static createInputData(inputData: any) { | |||||
| return { 'inputData': inputData } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,3 @@ | |||||
| export interface ModalContent { | |||||
| inputData: any; | |||||
| } | |||||
| @@ -48,3 +48,4 @@ | |||||
| <button type="submit" class="btn btn-primary" [disabled]="contactForm.invalid">Abschicken</button> | <button type="submit" class="btn btn-primary" [disabled]="contactForm.invalid">Abschicken</button> | ||||
| </form> | </form> | ||||
| </div> | </div> | ||||
| @@ -3,21 +3,24 @@ import {FormGroup} from "@angular/forms"; | |||||
| import {contactForm} from "@app/_forms/apiForms"; | import {contactForm} from "@app/_forms/apiForms"; | ||||
| import {ContactJsonld, ContactService} from "@app/core/api/v1"; | import {ContactJsonld, ContactService} from "@app/core/api/v1"; | ||||
| import {Subscription} from "rxjs"; | import {Subscription} from "rxjs"; | ||||
| import {ModalContent} from "@app/_interfaces/modalContent"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-new-contact', | selector: 'app-new-contact', | ||||
| templateUrl: './new-contact.component.html', | templateUrl: './new-contact.component.html', | ||||
| styleUrl: './new-contact.component.scss' | styleUrl: './new-contact.component.scss' | ||||
| }) | }) | ||||
| export class NewContactComponent implements OnInit { | |||||
| @Input() contactId: number | undefined; | |||||
| export class NewContactComponent implements ModalContent, OnInit { | |||||
| @Input() public inputData: any; | |||||
| protected contactForm: FormGroup; | protected contactForm: FormGroup; | ||||
| protected selectedImage: File | null; | protected selectedImage: File | null; | ||||
| protected contactSub: Subscription; | protected contactSub: Subscription; | ||||
| constructor( | constructor( | ||||
| private contactService: ContactService | |||||
| private contactService: ContactService, | |||||
| ) { | ) { | ||||
| this.contactForm = contactForm; | this.contactForm = contactForm; | ||||
| this.selectedImage = null; | this.selectedImage = null; | ||||
| @@ -25,20 +28,20 @@ export class NewContactComponent implements OnInit { | |||||
| this.contactSub = new Subscription(); | this.contactSub = new Subscription(); | ||||
| } | } | ||||
| ngOnInit() { | |||||
| console.log(this.contactId); | |||||
| } | |||||
| getData(meineId: any) { | |||||
| console.log(meineId); | |||||
| ngOnInit(): void { | |||||
| console.log(this.inputData); | |||||
| } | } | ||||
| onSubmit() { | onSubmit() { | ||||
| //console.log(this.partnerId); | |||||
| if (this.contactForm.valid) { | if (this.contactForm.valid) { | ||||
| // Hier können Sie die Daten senden oder weitere Aktionen durchführen | // Hier können Sie die Daten senden oder weitere Aktionen durchführen | ||||
| console.log(this.selectedImage); | console.log(this.selectedImage); | ||||
| console.log('Formular wurde gesendet:', this.contactForm.value); | console.log('Formular wurde gesendet:', this.contactForm.value); | ||||
| let newContact: ContactJsonld = this.contactForm.value as ContactJsonld; | |||||
| newContact.postings = []; | |||||
| this.contactSub = this.contactService.contactsPost( | this.contactSub = this.contactService.contactsPost( | ||||
| this.contactForm.value as ContactJsonld | this.contactForm.value as ContactJsonld | ||||
| ).subscribe( | ).subscribe( | ||||
| @@ -11,6 +11,7 @@ import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/pagin | |||||
| import {MatTableDataSource} from "@angular/material/table"; | import {MatTableDataSource} from "@angular/material/table"; | ||||
| import {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; | import {NewPostingComponent} from "@app/postings/new-posting/new-posting.component"; | ||||
| import {NewTaskComponent} from "@app/tasks/new-task/new-task.component"; | import {NewTaskComponent} from "@app/tasks/new-task/new-task.component"; | ||||
| import {NewPartnerComponent} from "@app/partners/new-partner/new-partner.component"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-partners-detail', | selector: 'app-partners-detail', | ||||
| @@ -95,16 +96,14 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { | |||||
| openModalNewContact() { | openModalNewContact() { | ||||
| const modalRef = this.modalService.open(ModalComponent); | const modalRef = this.modalService.open(ModalComponent); | ||||
| const newContactComponentInstance = new NewContactComponent(this.contactService); | |||||
| newContactComponentInstance.contactId = 3; | |||||
| // const newContactComponentInstance = modalRef.componentInstance.dynamicComponent = new NewContactComponent(this.contactService); | |||||
| //newContactComponentVar.getData(3); | |||||
| modalRef.componentInstance.dynamicComponent = newContactComponentInstance; | |||||
| modalRef.componentInstance.dynamicComponent = NewContactComponent; | |||||
| modalRef.componentInstance.inputData = ModalComponent.createInputData(this.partner.id); | |||||
| } | } | ||||
| openModalNewPosting() { | openModalNewPosting() { | ||||
| const modalRef = this.modalService.open(ModalComponent); | const modalRef = this.modalService.open(ModalComponent); | ||||
| modalRef.componentInstance.dynamicComponent = NewPostingComponent; | modalRef.componentInstance.dynamicComponent = NewPostingComponent; | ||||
| } | } | ||||
| openModalNewTask() { | openModalNewTask() { | ||||