Fix card update after edit
This commit is contained in:
parent
38f68a39c3
commit
355ecc361e
3 changed files with 49 additions and 37 deletions
|
@ -83,12 +83,15 @@
|
||||||
<button class="sbButton" (click)="refresh()">
|
<button class="sbButton" (click)="refresh()">
|
||||||
<mat-icon>refresh</mat-icon>
|
<mat-icon>refresh</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button [ngClass]="{ sbButton: true, hidden: !selection.hasValue() }" [matMenuTriggerFor]="callMenu">
|
<button
|
||||||
|
[ngClass]="{ sbButton: true, hidden: !selection.hasValue() }"
|
||||||
|
[matMenuTriggerFor]="callMenu"
|
||||||
|
>
|
||||||
<mat-icon>playlist_add</mat-icon>
|
<mat-icon>playlist_add</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<mat-menu #callMenu="matMenu">
|
<mat-menu #callMenu="matMenu">
|
||||||
<button mat-menu-item>Add to new incident...</button>
|
<button mat-menu-item>Add to new incident...</button>
|
||||||
<button mat-menu-item>Add to existing incident...</button>
|
<button mat-menu-item>Add to existing incident...</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { debounceTime } from 'rxjs/operators';
|
||||||
import { ToolbarContextService } from '../navigation/toolbar-context.service';
|
import { ToolbarContextService } from '../navigation/toolbar-context.service';
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import { CallPlayerComponent } from './player/call-player/call-player.component';
|
import { CallPlayerComponent } from './player/call-player/call-player.component';
|
||||||
import {MatMenuModule} from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: 'grabDate',
|
name: 'grabDate',
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import { Component, computed, inject, ViewChild } from '@angular/core';
|
import { Component, computed, inject, ViewChild } from '@angular/core';
|
||||||
import { map, take, 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,
|
||||||
|
forkJoin,
|
||||||
|
merge,
|
||||||
|
Subject,
|
||||||
|
Subscription,
|
||||||
|
zip,
|
||||||
|
} from 'rxjs';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
|
@ -82,26 +89,36 @@ 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);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.incSvc.updateIncident(this.data.incID, <IncidentRecord>{
|
this.incSvc
|
||||||
name: this.form.controls['name'].dirty ? this.form.controls['name'].value : null,
|
.updateIncident(this.data.incID, <IncidentRecord>{
|
||||||
startTime: this.form.controls['start'].dirty ? this.form.controls['start'].value : null,
|
name: this.form.controls['name'].dirty
|
||||||
endTime: this.form.controls['end'].dirty ? this.form.controls['end'].value : null,
|
? this.form.controls['name'].value
|
||||||
description: this.form.controls['description'].dirty ? this.form.controls['description'].value : null,
|
: null,
|
||||||
}).subscribe({
|
startTime: this.form.controls['start'].dirty
|
||||||
next: (ok) => {
|
? this.form.controls['start'].value
|
||||||
this.dialogRef.close(ok);
|
: null,
|
||||||
},
|
endTime: this.form.controls['end'].dirty
|
||||||
error: (er) => {
|
? this.form.controls['end'].value
|
||||||
alert(er);
|
: null,
|
||||||
},
|
description: this.form.controls['description'].dirty
|
||||||
});
|
? this.form.controls['description'].value
|
||||||
|
: null,
|
||||||
|
})
|
||||||
|
.subscribe({
|
||||||
|
next: (ok) => {
|
||||||
|
this.dialogRef.close(ok);
|
||||||
|
},
|
||||||
|
error: (er) => {
|
||||||
|
alert(er);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
@ -133,7 +150,7 @@ export class IncidentEditDialogComponent {
|
||||||
styleUrl: './incident.component.scss',
|
styleUrl: './incident.component.scss',
|
||||||
})
|
})
|
||||||
export class IncidentComponent {
|
export class IncidentComponent {
|
||||||
incPrime = new Subject<IncidentRecord>();
|
incPrime = new BehaviorSubject<IncidentRecord>(<IncidentRecord>{});
|
||||||
inc$!: Observable<IncidentRecord>;
|
inc$!: Observable<IncidentRecord>;
|
||||||
subscriptions: Subscription = new Subscription();
|
subscriptions: Subscription = new Subscription();
|
||||||
dialog = inject(MatDialog);
|
dialog = inject(MatDialog);
|
||||||
|
@ -161,16 +178,13 @@ 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();
|
this.inc$ = merge(this.incSvc.getIncident(this.incID), this.incPrime).pipe(
|
||||||
this.incSvc
|
tap((inc) => {
|
||||||
.getIncident(this.incID)
|
if (inc.calls) {
|
||||||
.pipe(
|
this.callsResult.data = inc.calls;
|
||||||
tap((inc) => {
|
}
|
||||||
if (inc.calls) {
|
}),
|
||||||
this.callsResult.data = inc.calls;
|
);
|
||||||
}
|
|
||||||
}),
|
|
||||||
).subscribe(this.incPrime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
editIncident(incID: string) {
|
editIncident(incID: string) {
|
||||||
|
@ -181,12 +195,7 @@ export class IncidentComponent {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe((res) => {
|
dialogRef.afterClosed().subscribe(this.incPrime);
|
||||||
if (res !== undefined) {
|
|
||||||
console.log(res);
|
|
||||||
this.incPrime.next(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
Loading…
Reference in a new issue