form is fixed
This commit is contained in:
parent
56279f45b3
commit
38f68a39c3
2 changed files with 6 additions and 11 deletions
|
@ -35,6 +35,7 @@
|
||||||
matInput
|
matInput
|
||||||
name="description"
|
name="description"
|
||||||
placeholder="Description"
|
placeholder="Description"
|
||||||
|
formControlName="description"
|
||||||
rows="8"
|
rows="8"
|
||||||
cols="200"
|
cols="200"
|
||||||
>{{ inc.description }}</textarea
|
>{{ inc.description }}</textarea
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, computed, inject, ViewChild } from '@angular/core';
|
import { Component, computed, inject, ViewChild } from '@angular/core';
|
||||||
import { map, tap } from 'rxjs/operators';
|
import { map, take, tap } from 'rxjs/operators';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { BehaviorSubject, Subject, Subscription } from 'rxjs';
|
import { BehaviorSubject, Subject, Subscription } from 'rxjs';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
@ -82,19 +82,13 @@ export class IncidentEditDialogComponent {
|
||||||
if (!this.data.new) {
|
if (!this.data.new) {
|
||||||
this.inc$ = this.incSvc.getIncident(this.data.incID).pipe(
|
this.inc$ = this.incSvc.getIncident(this.data.incID).pipe(
|
||||||
tap((inc) => {
|
tap((inc) => {
|
||||||
this.form.patchValue(inc, {
|
this.form.patchValue(inc);
|
||||||
onlySelf: false,
|
|
||||||
emitEvent: false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.form.markAsPristine();
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
console.log(this.form.value);
|
|
||||||
this.incSvc.updateIncident(this.data.incID, <IncidentRecord>{
|
this.incSvc.updateIncident(this.data.incID, <IncidentRecord>{
|
||||||
name: this.form.controls['name'].dirty ? this.form.controls['name'].value : null,
|
name: this.form.controls['name'].dirty ? this.form.controls['name'].value : null,
|
||||||
startTime: this.form.controls['start'].dirty ? this.form.controls['start'].value : null,
|
startTime: this.form.controls['start'].dirty ? this.form.controls['start'].value : null,
|
||||||
|
@ -167,7 +161,7 @@ export class IncidentComponent {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.incID = this.route.snapshot.paramMap.get('id')!;
|
this.incID = this.route.snapshot.paramMap.get('id')!;
|
||||||
this.inc$ = this.incPrime.pipe(map((inc) => inc));
|
this.inc$ = this.incPrime.pipe();
|
||||||
this.incSvc
|
this.incSvc
|
||||||
.getIncident(this.incID)
|
.getIncident(this.incID)
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@ -176,8 +170,7 @@ export class IncidentComponent {
|
||||||
this.callsResult.data = inc.calls;
|
this.callsResult.data = inc.calls;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
).subscribe(this.incPrime);
|
||||||
.subscribe(this.incPrime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
editIncident(incID: string) {
|
editIncident(incID: string) {
|
||||||
|
@ -190,6 +183,7 @@ export class IncidentComponent {
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe((res) => {
|
dialogRef.afterClosed().subscribe((res) => {
|
||||||
if (res !== undefined) {
|
if (res !== undefined) {
|
||||||
|
console.log(res);
|
||||||
this.incPrime.next(res);
|
this.incPrime.next(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue