diff --git a/matsen-tool/src/app/app.module.ts b/matsen-tool/src/app/app.module.ts index ff2fc2f..0f26c99 100644 --- a/matsen-tool/src/app/app.module.ts +++ b/matsen-tool/src/app/app.module.ts @@ -42,6 +42,7 @@ import {MatOptionModule} from "@angular/material/core"; import {MatAutocompleteModule} from "@angular/material/autocomplete"; import {MatFormFieldModule} from "@angular/material/form-field"; import {MatInputModule} from "@angular/material/input"; +import { NewTaskNoteComponent } from './tasks/new-task-note/new-task-note.component'; export function apiConfigFactory(): Configuration { const params: ConfigurationParameters = { @@ -104,7 +105,8 @@ export function HttpLoaderFactory(http: HttpClient) { NewPartnerComponent, NewDocumentComponent, NewProductComponent, - NewCommentComponent + NewCommentComponent, + NewTaskNoteComponent ], providers: [ {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, diff --git a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html index 2d7afa2..aa6b510 100644 --- a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html +++ b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html @@ -104,8 +104,8 @@

{{'basic.tasks' | translate}}

-
-
+
+
+
+
+
+

{{ taskNote.createdAt | date:'dd.MM.YYYY HH:mm' }}

+

{{ taskNote.ownerName }}

+
+
+

{{ taskNote.message }}

+
+ +
+
+ +
+ {{'basic.comment-it' | translate}} +
{ + if (modalStatus === ModalStatus.Submitted) { + modalRefTaskNote.dismiss(); + this.getTasksData(); + } + }); + } + openModalNewPosting() { const modalRefPosting = this.modalService.open(NewPostingComponent, this.modalOptions); let posting: PostJsonld = {} as PostJsonld; @@ -282,6 +296,17 @@ export class PartnersDetailComponent implements OnInit, AfterViewInit { }); } + openModalEditTaskNote(taskNote: TaskNoteJsonld) { + const modalRefTaskNote = this.modalService.open(NewTaskNoteComponent, this.modalOptions); + modalRefTaskNote.componentInstance.taskNote = taskNote; + modalRefTaskNote.componentInstance.submit.subscribe((modalStatus: ModalStatus) => { + if (modalStatus === ModalStatus.Submitted) { + modalRefTaskNote.dismiss(); + this.getTasksData(); + } + }); + } + openModalEditPosting(post: PostJsonld) { const modalRefPostingEdit = this.modalService.open(NewPostingComponent, this.modalOptions); modalRefPostingEdit.componentInstance.posting = post; diff --git a/matsen-tool/src/app/postings/new-comment/new-comment.component.ts b/matsen-tool/src/app/postings/new-comment/new-comment.component.ts index 4123435..635f378 100644 --- a/matsen-tool/src/app/postings/new-comment/new-comment.component.ts +++ b/matsen-tool/src/app/postings/new-comment/new-comment.component.ts @@ -33,9 +33,9 @@ export class NewCommentComponent implements OnInit { onSubmit() { if (this.commentForm.valid) { if (this.comment.id === null || this.comment.id === undefined) { - // Create new post + // Create new comment this.commentSub = this.commentService.commentsPost( - this.commentForm.value as PostJsonld + this.commentForm.value as CommentJsonld ).subscribe( data => { this.commentForm.reset(); @@ -43,10 +43,10 @@ export class NewCommentComponent implements OnInit { } ); } else { - // Edit post + // Edit comment this.commentSub = this.commentService.commentsIdPatch( ApiConverter.extractId(this.comment.id), - this.commentForm.value as PostJsonld + this.commentForm.value as CommentJsonld ).subscribe( data => { this.commentForm.reset(); diff --git a/matsen-tool/src/app/products/new-product/new-product.component.ts b/matsen-tool/src/app/products/new-product/new-product.component.ts index 4e9dd33..f3d9925 100644 --- a/matsen-tool/src/app/products/new-product/new-product.component.ts +++ b/matsen-tool/src/app/products/new-product/new-product.component.ts @@ -57,7 +57,7 @@ export class NewProductComponent implements OnInit { submitForm() { if (this.productForm.valid) { if (this.product.id === null || this.product.id === undefined) { - // Create new post + // Create new product this.productSub = this.productService.productsPost( this.productForm.value as ProductJsonld ).subscribe( @@ -67,7 +67,7 @@ export class NewProductComponent implements OnInit { } ); } else { - // Edit post + // Edit product this.productSub = this.productService.productsIdPatch( ApiConverter.extractId(this.product.id), this.productForm.value as ProductJsonld diff --git a/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.html b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.html new file mode 100644 index 0000000..c1a35b2 --- /dev/null +++ b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.html @@ -0,0 +1,16 @@ +

{{'basic.new-comment' | translate}}

+

{{'basic.edit-comment' | translate}}

+
+
+
+ + +
+ {{'form.comment' | translate}} {{'form.mandatory' | translate}}. +
+
+ + +
+
+ diff --git a/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.scss b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.spec.ts b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.spec.ts new file mode 100644 index 0000000..be4258c --- /dev/null +++ b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NewTaskNoteComponent } from './new-task-note.component'; + +describe('NewTaskNoteComponent', () => { + let component: NewTaskNoteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [NewTaskNoteComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(NewTaskNoteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.ts b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.ts new file mode 100644 index 0000000..c3cff06 --- /dev/null +++ b/matsen-tool/src/app/tasks/new-task-note/new-task-note.component.ts @@ -0,0 +1,59 @@ +import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {TaskJsonld, TaskNoteJsonld, TaskNoteService} from "@app/core/api/v1"; +import {ModalStatus} from "@app/_helpers/modal.states"; +import {FormGroup} from "@angular/forms"; +import {Subscription} from "rxjs"; +import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; +import {ApiConverter} from "@app/_helpers/api.converter"; +import {taskNoteForm} from "@app/_forms/apiForms"; + +@Component({ + selector: 'app-new-task-note', + templateUrl: './new-task-note.component.html', + styleUrl: './new-task-note.component.scss' +}) +export class NewTaskNoteComponent { + @Input() public taskNote!: TaskNoteJsonld; + @Output() public submit: EventEmitter = new EventEmitter(); + + protected taskNoteForm: FormGroup; + protected taskNoteSub: Subscription; + + constructor( + private taskNoteService: TaskNoteService + ) { + this.taskNoteForm = taskNoteForm; + this.taskNoteSub = new Subscription(); + } + + ngOnInit(): void { + this.taskNoteForm = FormGroupInitializer.initFormGroup(this.taskNoteForm, this.taskNote); + } + + onSubmit() { + if (this.taskNoteForm.valid) { + if (this.taskNote.id === null || this.taskNote.id === undefined) { + // Create new taskNote + this.taskNoteSub = this.taskNoteService.taskNotesPost( + this.taskNoteForm.value as TaskNoteJsonld + ).subscribe( + data => { + this.taskNoteForm.reset(); + this.submit.emit(ModalStatus.Submitted); + } + ); + } else { + // Edit taskNote + this.taskNoteSub = this.taskNoteService.taskNotesIdPatch( + ApiConverter.extractId(this.taskNote.id), + this.taskNoteForm.value as TaskNoteJsonld + ).subscribe( + data => { + this.taskNoteForm.reset(); + this.submit.emit(ModalStatus.Submitted); + } + ); + } + } + } +} diff --git a/matsen-tool/src/app/tasks/new-task/new-task.component.ts b/matsen-tool/src/app/tasks/new-task/new-task.component.ts index e0fa9cb..2eaf884 100644 --- a/matsen-tool/src/app/tasks/new-task/new-task.component.ts +++ b/matsen-tool/src/app/tasks/new-task/new-task.component.ts @@ -76,7 +76,7 @@ export class NewTaskComponent implements OnInit { onSubmit() { if (this.taskForm.valid) { if (this.task.id === null || this.task.id === undefined) { - // Create new post + // Create new task this.taskSub = this.taskService.tasksPost( this.taskForm.value as TaskJsonld ).subscribe( @@ -86,7 +86,7 @@ export class NewTaskComponent implements OnInit { } ); } else { - // Edit post + // Edit task this.taskSub = this.taskService.tasksIdPatch( ApiConverter.extractId(this.task.id), this.taskForm.value as TaskJsonld