|
|
@@ -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} from "@app/core/api/v1"; |
|
|
|
|
|
|
|
|
import {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"; |
|
|
@@ -19,12 +19,13 @@ export class NewTaskComponent implements OnInit { |
|
|
|
|
|
|
|
|
protected taskForm: FormGroup; |
|
|
protected taskForm: FormGroup; |
|
|
protected taskSub: Subscription; |
|
|
protected taskSub: Subscription; |
|
|
|
|
|
protected dueAtValue: string; |
|
|
|
|
|
|
|
|
protected users = [ |
|
|
protected users = [ |
|
|
{ id: '/api/users/1', name: 'Daniel Knudsen' }, |
|
|
|
|
|
{ id: '/api/users/2', name: 'Florian Eisenmenger' }, |
|
|
|
|
|
{ id: '/api/users/3', name: 'Francis Donelly' }, |
|
|
|
|
|
{ id: '/api/users/4', name: 'Jaylen Schmitt' }, |
|
|
|
|
|
|
|
|
{ id: '/api/users/63', name: 'Daniel Knudsen' }, |
|
|
|
|
|
{ id: '/api/users/64', name: 'Florian Eisenmenger' }, |
|
|
|
|
|
{ id: '/api/users/65', name: 'Francis Donielly' }, |
|
|
|
|
|
{ id: '/api/users/66', name: 'Jaylen Schmiett' }, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
protected formatter = (apiData: any) => apiData.name; |
|
|
protected formatter = (apiData: any) => apiData.name; |
|
|
@@ -34,25 +35,42 @@ export class NewTaskComponent implements OnInit { |
|
|
debounceTime(200), |
|
|
debounceTime(200), |
|
|
distinctUntilChanged(), |
|
|
distinctUntilChanged(), |
|
|
filter((term) => term.length >= 2), |
|
|
filter((term) => term.length >= 2), |
|
|
map((term) => this.users.filter((state) => new RegExp(term, 'mi').test(state.name)).slice(0, 10)), |
|
|
|
|
|
|
|
|
map((term) => this.users.filter((user) => new RegExp(term, 'mi').test(user.name)).slice(0, 10)), |
|
|
|
|
|
// map((term) => { |
|
|
|
|
|
// this.userService.usersGetCollection(0, 50, term, term).subscribe(data => { |
|
|
|
|
|
// const users: Array<UserJsonld> = data["hydra:member"]; |
|
|
|
|
|
// let res: { id: any; name: any }[] = []; |
|
|
|
|
|
// users.forEach(user => { |
|
|
|
|
|
// res.push({ |
|
|
|
|
|
// id: user.id, |
|
|
|
|
|
// name: user.firstName + " " + user.lastName |
|
|
|
|
|
// }); |
|
|
|
|
|
// }); |
|
|
|
|
|
// return res; |
|
|
|
|
|
// }); |
|
|
|
|
|
// }) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private taskService: TaskService |
|
|
|
|
|
|
|
|
private taskService: TaskService, |
|
|
|
|
|
private userService: UserService |
|
|
) { |
|
|
) { |
|
|
this.taskForm = taskForm; |
|
|
this.taskForm = taskForm; |
|
|
this.taskSub = new Subscription(); |
|
|
this.taskSub = new Subscription(); |
|
|
|
|
|
this.dueAtValue = ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
console.log(this.task); |
|
|
|
|
|
|
|
|
console.log(this.dueAtValue); |
|
|
this.taskForm = FormGroupInitializer.initFormGroup(this.taskForm, this.task); |
|
|
this.taskForm = FormGroupInitializer.initFormGroup(this.taskForm, this.task); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onAssignedToSelect(selectedItem: any): void { |
|
|
onAssignedToSelect(selectedItem: any): void { |
|
|
this.taskForm.get('assignedTo')?.setValue(selectedItem.item.id); |
|
|
this.taskForm.get('assignedTo')?.setValue(selectedItem.item.id); |
|
|
console.log(selectedItem); |
|
|
|
|
|
console.log(this.taskForm); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onDueAtChange(selectedItem: any) { |
|
|
|
|
|
this.taskForm.get('dueAt')?.setValue(selectedItem.target.value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onSubmit() { |
|
|
onSubmit() { |
|
|
|