|
|
@@ -1,5 +1,5 @@ |
|
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; |
|
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; |
|
|
import {TaskJsonld, TaskService, UserJsonld, UserService} from "@app/core/api/v1"; |
|
|
|
|
|
|
|
|
import {PartnerService, TaskJsonld, TaskService, UserJsonld, UserService} from "@app/core/api/v1"; |
|
|
import {ModalStatus} from "@app/_helpers/modal.states"; |
|
|
import {ModalStatus} from "@app/_helpers/modal.states"; |
|
|
import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; |
|
|
import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; |
|
|
import {FormGroup} from "@angular/forms"; |
|
|
import {FormGroup} from "@angular/forms"; |
|
|
@@ -23,7 +23,7 @@ export class NewTaskComponent implements OnInit { |
|
|
|
|
|
|
|
|
protected formatter = (apiData: any) => apiData.name; |
|
|
protected formatter = (apiData: any) => apiData.name; |
|
|
|
|
|
|
|
|
protected search: OperatorFunction<string, readonly { id: any; name: any }[]> = (text$: Observable<string>) => |
|
|
|
|
|
|
|
|
protected searchUsers: OperatorFunction<string, readonly { id: any; name: any }[]> = (text$: Observable<string>) => |
|
|
text$.pipe( |
|
|
text$.pipe( |
|
|
debounceTime(200), |
|
|
debounceTime(200), |
|
|
distinctUntilChanged(), |
|
|
distinctUntilChanged(), |
|
|
@@ -32,9 +32,19 @@ export class NewTaskComponent implements OnInit { |
|
|
map((users) => users.slice(0, 10)), |
|
|
map((users) => users.slice(0, 10)), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
protected searchPartners: OperatorFunction<string, readonly { id: any; name: any }[]> = (text$: Observable<string>) => |
|
|
|
|
|
text$.pipe( |
|
|
|
|
|
debounceTime(200), |
|
|
|
|
|
distinctUntilChanged(), |
|
|
|
|
|
filter((term) => term.length >= 2), |
|
|
|
|
|
switchMap((term) => this.fetchPartners(term)), |
|
|
|
|
|
map((partners) => partners.slice(0, 10)), |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private taskService: TaskService, |
|
|
private taskService: TaskService, |
|
|
private userService: UserService |
|
|
|
|
|
|
|
|
private userService: UserService, |
|
|
|
|
|
private partnerService: PartnerService |
|
|
) { |
|
|
) { |
|
|
this.taskForm = taskForm; |
|
|
this.taskForm = taskForm; |
|
|
this.taskSub = new Subscription(); |
|
|
this.taskSub = new Subscription(); |
|
|
@@ -42,7 +52,6 @@ export class NewTaskComponent implements OnInit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
console.log(this.dueAtValue); |
|
|
|
|
|
this.taskForm = FormGroupInitializer.initFormGroup(this.taskForm, this.task); |
|
|
this.taskForm = FormGroupInitializer.initFormGroup(this.taskForm, this.task); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -52,6 +61,15 @@ export class NewTaskComponent implements OnInit { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected fetchPartners(term: string): Observable<{ id: any; name: any }[]> { |
|
|
|
|
|
return this.partnerService.partnersGetCollection(1, 50, undefined, undefined, term).pipe( |
|
|
|
|
|
map((response) => response['hydra:member'].map(partner => ({ id: partner.id, name: partner.name }))), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected onPartnerSelect(selectedItem: any): void { |
|
|
|
|
|
this.taskForm.get('partner')?.setValue(selectedItem.item.id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected onAssignedToSelect(selectedItem: any): void { |
|
|
protected onAssignedToSelect(selectedItem: any): void { |
|
|
this.taskForm.get('assignedTo')?.setValue(selectedItem.item.id); |
|
|
this.taskForm.get('assignedTo')?.setValue(selectedItem.item.id); |
|
|
|