1
1
import { Component , OnDestroy } from '@angular/core' ;
2
- import { Router } from '@angular/router' ;
2
+ import { MatDialog } from '@angular/material/dialog' ;
3
+ import { TranslateService } from '@ngx-translate/core' ;
3
4
import { Subscription } from 'rxjs' ;
5
+ import { AddEditBaseModalComponent } from '../../../shared/modals/add-edit-base-modal/add-edit-base-modal.component' ;
6
+ import { ADD_MODAL_MAX_WIDTH } from '../../../_constants/common' ;
4
7
import { TableAppearanceOptions } from '../../../_constants/enums' ;
5
8
import { NavItem , TableColumn } from '../../../_models/common' ;
6
9
import { EventGroupService } from '../../../_services/api/event-group.service' ;
10
+ import { EventAddComponent } from '../../event-add/event-add.component' ;
7
11
import { viewOptionsDefs } from './event-groups-list-action-data' ;
8
12
import { defaultColumnDefs } from './event-groups-list-table-data' ;
9
13
@@ -18,7 +22,29 @@ export class EventGroupsListComponent implements OnDestroy {
18
22
tableAppearanceOptions = TableAppearanceOptions ;
19
23
20
24
private subscription : Subscription [ ] = [ ] ;
21
- constructor ( public eventGroupService : EventGroupService , private router : Router ) { }
25
+ constructor (
26
+ public eventGroupService : EventGroupService ,
27
+ private dialog : MatDialog ,
28
+ private translateService : TranslateService
29
+ ) { }
30
+
31
+ openAddEventModal ( ) : void {
32
+ const dialogRef = this . dialog . open ( AddEditBaseModalComponent , {
33
+ maxWidth : ADD_MODAL_MAX_WIDTH ,
34
+ data : {
35
+ title : this . translateService . instant ( 'strings.headingCreateNewEvent' ) ,
36
+ component : EventAddComponent ,
37
+ } ,
38
+ } ) ;
39
+
40
+ this . subscription . push (
41
+ dialogRef . afterClosed ( ) . subscribe ( ( result ) => {
42
+ if ( result ) {
43
+ // callback
44
+ }
45
+ } )
46
+ ) ;
47
+ }
22
48
23
49
ngOnDestroy ( ) : void {
24
50
this . subscription . forEach ( ( subscription ) => subscription . unsubscribe ( ) ) ;
0 commit comments