diff --git a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts index 390615d..ad47ba9 100644 --- a/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts +++ b/matsen-tool/src/app/_views/contacts/contact-list/contact-list.component.ts @@ -49,9 +49,12 @@ export class ContactListComponent implements OnInit, AfterViewInit { } openModalNewContact() { + let postInputs: any = {}; let contact: ContactJsonld = {} as ContactJsonld; contact.partnerIri = this.partner.id ?? null; - this.appHelperService.openModal(NewContactComponent, {'contact': contact}, this.getData); + postInputs['contact'] = contact; + postInputs['partner'] = this.partner; + this.appHelperService.openModal(NewContactComponent, postInputs, this.getData); } navigateToContactDetails(element: any) { diff --git a/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.html b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.html index 114a5b6..a860a8b 100644 --- a/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.html +++ b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.html @@ -25,6 +25,11 @@ (change)="onBirthdayChange($event)"/> +
+ + +
+
diff --git a/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts index 5ec0caf..351ee63 100644 --- a/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts +++ b/matsen-tool/src/app/_views/contacts/new-contact/new-contact.component.ts @@ -1,7 +1,7 @@ import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {FormGroup} from "@angular/forms"; import {contactForm} from "@app/_forms/apiForms"; -import {ContactJsonld, ContactService, MediaObjectService} from "@app/core/api/v1"; +import {ContactJsonld, ContactService, MediaObjectService, PartnerJsonld} from "@app/core/api/v1"; import {ModalStatus} from "@app/_helpers/modal.states"; import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; import {TranslateService} from "@ngx-translate/core"; @@ -15,6 +15,7 @@ import {AppHelperService} from "@app/_helpers/app-helper.service"; }) export class NewContactComponent implements OnInit, AfterViewInit { @Input() public contact!: ContactJsonld; + @Input() public partner!: PartnerJsonld; @Output() public submit: EventEmitter = new EventEmitter(); protected contactForm: FormGroup; 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 773074f..d613004 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 @@ -110,8 +110,18 @@ export class DocumentListComponent implements OnInit, AfterViewInit { } openModalNewDocument() { + let postInputs: any = {}; let document: DocumentJsonld = {} as DocumentJsonld; - this.appHelperService.openModal(NewDocumentComponent, {'document': document}, this.listComponent.getData); + if (this.partner !== undefined) { + document.partnerIri = this.partner?.id; + postInputs['partner'] = this.partner; + } + if (this.product !== undefined) { + document.productIri = this.product?.id; + postInputs['product'] = this.product; + } + postInputs['document'] = document; + this.appHelperService.openModal(NewDocumentComponent, postInputs, this.listComponent.getData); } openModalEditDocument = (element: DocumentJsonld) => { 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 7ec5a5f..d56d768 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 @@ -14,32 +14,48 @@
- - - + + + + + + +
- - - + + + + + + +
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 e3e81ba..00cfab1 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,7 +1,7 @@ import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import { DocumentJsonld, DocumentObjectService, - DocumentService, PartnerService, ProductService + DocumentService, PartnerJsonld, PartnerService, ProductJsonld, ProductService } from "@app/core/api/v1"; import {ModalStatus} from "@app/_helpers/modal.states"; import {FormGroup} from "@angular/forms"; @@ -20,6 +20,8 @@ import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-funct }) export class NewDocumentComponent implements OnInit, AfterViewInit { @Input() public document!: DocumentJsonld; + @Input() public partner!: PartnerJsonld; + @Input() public product!: ProductJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @ViewChild('partnerSearchSelect', {static: false}) partnerSearchSelect!: SearchSelectComponent; @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent; @@ -42,6 +44,7 @@ export class NewDocumentComponent implements OnInit, AfterViewInit { ngOnInit(): void { this.documentForm = FormGroupInitializer.initFormGroup(this.documentForm, this.document); + console.log(this.document); } ngAfterViewInit(): void { 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 040be83..33a51dd 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 @@ -10,10 +10,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 f0c2aa3..edee4d8 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 @@ -3,6 +3,8 @@ import {ModalStatus} from "@app/_helpers/modal.states"; import {FormGroup} from "@angular/forms"; import {postForm} from "@app/_forms/apiForms"; import { + PartnerJsonld, + PartnerService, PostJsonld, PostService, ProductJsonld, @@ -21,6 +23,7 @@ import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-funct export class NewPostComponent implements OnInit { @Input() public posting!: PostJsonld; @Input() public product!: ProductJsonld; + @Input() public partner!: PartnerJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent; protected readonly SearchSelectComponent = SearchSelectComponent; @@ -30,6 +33,7 @@ export class NewPostComponent implements OnInit { constructor( private postService: PostService, protected productService: ProductService, + protected partnerService: PartnerService, protected appHelperService: AppHelperService, ) { this.postForm = postForm; @@ -37,6 +41,11 @@ export class NewPostComponent implements OnInit { ngOnInit(): void { this.postForm = FormGroupInitializer.initFormGroup(this.postForm, this.posting); + this.partnerService.partnersIdGet(this.appHelperService.extractId(this.posting.partnerIri)).subscribe( + data => { + this.partner = data; + } + ); } getProducts: ListGetDataFunctionType = (index: number, pageSize: number, term?: string) => { diff --git a/matsen-tool/src/app/_views/posts/post-list/post-list.component.ts b/matsen-tool/src/app/_views/posts/post-list/post-list.component.ts index 295c868..93526bc 100644 --- a/matsen-tool/src/app/_views/posts/post-list/post-list.component.ts +++ b/matsen-tool/src/app/_views/posts/post-list/post-list.component.ts @@ -139,6 +139,7 @@ export class PostListComponent implements OnInit, AfterViewInit { if (this.partner !== undefined) { post.partnerIri = this.partner?.id; + postInputs['partner'] = this.partner; } if (this.contact !== undefined) { post.contactIri = this.contact.id; 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 5250e71..bc3319b 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 @@ -5,30 +5,46 @@
- - - + + + + + + +
- - - + + + + + + +
diff --git a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts index c115a35..c385059 100644 --- a/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts +++ b/matsen-tool/src/app/_views/sales/new-sale/new-sale.component.ts @@ -1,7 +1,7 @@ import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import { PartnerJsonld, - PartnerService, + PartnerService, ProductJsonld, ProductService, SaleJsonld, SaleService @@ -23,6 +23,7 @@ import {SearchSelectComponent} from "@app/_components/search-select/search-selec export class NewSaleComponent implements OnInit, AfterViewInit { @Input() public sale!: SaleJsonld; @Input() public partner!: PartnerJsonld; + @Input() public product!: ProductJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @ViewChild('partnerSearchSelect', {static: false}) partnerSearchSelect!: SearchSelectComponent; @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent; @@ -42,6 +43,12 @@ export class NewSaleComponent implements OnInit, AfterViewInit { ngOnInit(): void { this.saleForm = FormGroupInitializer.initFormGroup(this.saleForm, this.sale); + if (this.partner && this.saleForm.get('partnerIri')?.value === null) { + this.saleForm.get('partnerIri')?.setValue(this.partner.id); + } + if (this.product && this.saleForm.get('productIri')?.value === null) { + this.saleForm.get('productIri')?.setValue(this.product.id); + } } ngAfterViewInit(): void { diff --git a/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts b/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts index f83f948..a614ecd 100644 --- a/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts +++ b/matsen-tool/src/app/_views/sales/sale-list/sale-list.component.ts @@ -118,7 +118,8 @@ export class SaleListComponent implements OnInit, AfterViewInit { let sale: SaleJsonld = {} as SaleJsonld; this.appHelperService.openModal(NewSaleComponent, { 'sale': sale, - 'partner': this.partner + 'partner': this.partner, + 'product': this.product }, this.listComponent.getData); } diff --git a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html index 2011337..522c676 100644 --- a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html +++ b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.html @@ -18,6 +18,11 @@
+
+ + +
+
- +
@@ -45,11 +50,8 @@ [dataSet]="task.assignedTo" [listColDefinitions]="SearchSelectComponent.getDefaultColDefUsers()" > - -
- {{ 'form.assign-to' | translate }} {{ 'form.mandatory' | translate }}. -
+
diff --git a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts index ec5b98e..9980444 100644 --- a/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts +++ b/matsen-tool/src/app/_views/tasks/new-task/new-task.component.ts @@ -1,5 +1,7 @@ import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import { + PartnerJsonld, + ProductJsonld, ProductService, TaskJsonld, TaskService, @@ -20,6 +22,7 @@ import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-funct }) export class NewTaskComponent implements OnInit, AfterViewInit { @Input() public task!: TaskJsonld; + @Input() public partner!: PartnerJsonld; @Output() public submit: EventEmitter = new EventEmitter(); @ViewChild('userSearchSelect', {static: false}) userSearchSelect!: SearchSelectComponent; @ViewChild('productSearchSelect', {static: false}) productSearchSelect!: SearchSelectComponent; diff --git a/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts index c208e69..e643684 100644 --- a/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts +++ b/matsen-tool/src/app/_views/tasks/task-list/task-list.component.ts @@ -1,6 +1,5 @@ import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core'; import {PagingComponent} from "@app/_components/paging/paging.component"; -import {Subscription} from "rxjs"; import { PartnerJsonld, TaskJsonld, @@ -33,7 +32,6 @@ export class TaskListComponent implements OnInit, AfterViewInit { protected taskCompactMode: boolean; protected showCompletedTasks: boolean; protected taskNotes: Map; - protected taskSub: Subscription; protected taskNotesVisibility: Map; @@ -47,7 +45,6 @@ export class TaskListComponent implements OnInit, AfterViewInit { this.taskNotes = new Map(); this.dataSource = new MatTableDataSource(this.tasks); this.taskNotesVisibility = new Map(); - this.taskSub = new Subscription(); this.currentUser = this.accountService.userValue; if (localStorage.getItem('taskCompactMode') !== null) { this.taskCompactMode = localStorage.getItem('taskCompactMode') === 'true'; @@ -93,7 +90,7 @@ export class TaskListComponent implements OnInit, AfterViewInit { } getTaskData = (taskIri: string) => { - this.taskSub = this.taskService.tasksIdGet(this.appHelperService.extractId(taskIri)).subscribe( + this.taskService.tasksIdGet(this.appHelperService.extractId(taskIri)).subscribe( data => { for (let index = 0; index < this.tasks.length; index++) { const item = this.tasks[index]; @@ -135,10 +132,15 @@ export class TaskListComponent implements OnInit, AfterViewInit { } openModalNewTask() { + let postInputs: any = {}; let task: TaskJsonld = {} as TaskJsonld; task.partnerIri = this.partner.id; task.completed = false; - this.appHelperService.openModal(NewTaskComponent, {'task': task}, this.getTasksData); + if (this.partner !== undefined) { + postInputs['partner'] = this.partner; + } + postInputs['task'] = task; + this.appHelperService.openModal(NewTaskComponent, postInputs, this.getTasksData); } openModalEditTask(task: TaskJsonld) {