1
- import { Component } from '@angular/core' ;
1
+ import { Component , OnDestroy } from '@angular/core' ;
2
+ import { MatDialog } from '@angular/material/dialog' ;
2
3
import { TranslateService } from '@ngx-translate/core' ;
4
+ import { Subscription } from 'rxjs' ;
3
5
import {
4
6
API_ROUTE_CONTACTS_FOLLOW_UP ,
5
7
EXPORT_TYPES ,
8
+ MODAL_LARGE_WIDTH ,
6
9
SMALL_NOTIFICATION_MODAL_WIDTH ,
7
10
TableAppearanceOptions ,
8
11
} from '../../../app.constants' ;
12
+ import { FollowUpVisitAddComponent } from '../../../shared/follow-up-visit-add/follow-up-visit-add.component' ;
13
+ import { AddEditBaseModalComponent } from '../../../shared/modals/add-edit-base-modal/add-edit-base-modal.component' ;
9
14
import { Filter , TableColumn } from '../../../_models/common' ;
10
15
import { CaseDataDto , VisitDto } from '../../../_models/models' ;
11
16
import { BaseService } from '../../../_services/api/base.service' ;
@@ -19,19 +24,21 @@ import { defaultColumnDefs } from './contact-follow-up-table-data';
19
24
templateUrl : './contact-follow-up.component.html' ,
20
25
styleUrls : [ './contact-follow-up.component.scss' ] ,
21
26
} )
22
- export class ContactFollowUpComponent {
27
+ export class ContactFollowUpComponent implements OnDestroy {
23
28
visits : VisitDto [ ] = [ ] ;
24
29
defaultColumns : TableColumn [ ] = defaultColumnDefs ;
25
30
tableAppearanceOptions = TableAppearanceOptions ;
26
31
preSetFilters : Filter [ ] ;
27
32
28
33
public resourceService : BaseService < any > ;
34
+ private subscriptions : Subscription = new Subscription ( ) ;
29
35
30
36
constructor (
31
37
public visitService : VisitService ,
32
38
private notificationService : NotificationService ,
33
39
private translateService : TranslateService ,
34
- private exportService : ExportService
40
+ private exportService : ExportService ,
41
+ private dialog : MatDialog
35
42
) { }
36
43
37
44
updateComponent ( caseItem : CaseDataDto , resourceService : BaseService < any > ) : void {
@@ -53,4 +60,26 @@ export class ContactFollowUpComponent {
53
60
54
61
this . exportService . executeExport ( EXPORT_TYPES . BASIC , API_ROUTE_CONTACTS_FOLLOW_UP . EXPORT ) ;
55
62
}
63
+
64
+ openAddVisitModal ( ) : void {
65
+ const dialogRef = this . dialog . open ( AddEditBaseModalComponent , {
66
+ maxWidth : MODAL_LARGE_WIDTH ,
67
+ data : {
68
+ title : this . translateService . instant ( 'strings.headingCreateNewVisit' ) ,
69
+ component : FollowUpVisitAddComponent ,
70
+ } ,
71
+ } ) ;
72
+
73
+ this . subscriptions . add (
74
+ dialogRef . afterClosed ( ) . subscribe ( ( result ) => {
75
+ if ( result ) {
76
+ // callback
77
+ }
78
+ } )
79
+ ) ;
80
+ }
81
+
82
+ ngOnDestroy ( ) : void {
83
+ this . subscriptions . unsubscribe ( ) ;
84
+ }
56
85
}
0 commit comments