1
- import { Component , OnInit } from '@angular/core' ;
1
+ import { Component , Input , OnInit } from '@angular/core' ;
2
2
import { MatDialog } from '@angular/material/dialog' ;
3
3
import { Subject } from 'rxjs' ;
4
4
import { ApplicationDecisionConditionTypeDto } from '../../../services/application/decision/application-decision-v2/application-decision-v2.dto' ;
5
- import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service' ;
6
5
import { ConfirmationDialogService } from '../../../shared/confirmation-dialog/confirmation-dialog.service' ;
7
6
import { DecisionConditionTypesDialogComponent } from './decision-condition-types-dialog/decision-condition-types-dialog.component' ;
7
+ import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service' ;
8
+ import { NoticeofIntentDecisionConditionTypesService } from '../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service' ;
9
+ import { NoticeOfIntentDecisionConditionTypeDto } from '../../../services/notice-of-intent/decision-v2/notice-of-intent-decision.dto' ;
8
10
9
11
@Component ( {
10
12
selector : 'app-decision-condition-types' ,
11
13
templateUrl : './decision-condition-types.component.html' ,
12
14
styleUrls : [ './decision-condition-types.component.scss' ] ,
13
15
} )
14
16
export class DecisionConditionTypesComponent implements OnInit {
17
+
18
+ @Input ( ) public service : ApplicationDecisionConditionTypesService | NoticeofIntentDecisionConditionTypesService | undefined ;
19
+
15
20
destroy = new Subject < void > ( ) ;
16
21
17
- decisionConditionTypeDtos : ApplicationDecisionConditionTypeDto [ ] = [ ] ;
22
+ decisionConditionTypeDtos : ApplicationDecisionConditionTypeDto [ ] | NoticeOfIntentDecisionConditionTypeDto [ ] = [ ] ;
18
23
displayedColumns : string [ ] = [ 'label' , 'description' , 'code' , 'actions' ] ;
19
24
20
25
constructor (
21
- private decisionConditionTypesService : ApplicationDecisionConditionTypesService ,
22
26
public dialog : MatDialog ,
23
27
private confirmationDialogService : ConfirmationDialogService
24
28
) { }
@@ -28,14 +32,18 @@ export class DecisionConditionTypesComponent implements OnInit {
28
32
}
29
33
30
34
async fetch ( ) {
31
- this . decisionConditionTypeDtos = await this . decisionConditionTypesService . fetch ( ) ;
35
+ if ( ! this . service ) return ;
36
+ this . decisionConditionTypeDtos = await this . service . fetch ( ) ;
32
37
}
33
38
34
39
async onCreate ( ) {
35
40
const dialog = this . dialog . open ( DecisionConditionTypesDialogComponent , {
36
41
minWidth : '600px' ,
37
42
maxWidth : '800px' ,
38
43
width : '70%' ,
44
+ data : {
45
+ service : this . service ,
46
+ } ,
39
47
} ) ;
40
48
dialog . beforeClosed ( ) . subscribe ( async ( result ) => {
41
49
if ( result ) {
@@ -44,12 +52,15 @@ export class DecisionConditionTypesComponent implements OnInit {
44
52
} ) ;
45
53
}
46
54
47
- async onEdit ( decisionConditionTypeDto : ApplicationDecisionConditionTypeDto ) {
55
+ async onEdit ( dto : ApplicationDecisionConditionTypeDto | NoticeOfIntentDecisionConditionTypeDto ) {
48
56
const dialog = this . dialog . open ( DecisionConditionTypesDialogComponent , {
49
57
minWidth : '600px' ,
50
58
maxWidth : '800px' ,
51
59
width : '70%' ,
52
- data : decisionConditionTypeDto ,
60
+ data : {
61
+ service : this . service ,
62
+ content : dto ,
63
+ } ,
53
64
} ) ;
54
65
dialog . beforeClosed ( ) . subscribe ( async ( result ) => {
55
66
if ( result ) {
@@ -58,14 +69,15 @@ export class DecisionConditionTypesComponent implements OnInit {
58
69
} ) ;
59
70
}
60
71
61
- async onDelete ( decisionConditionTypeDto : ApplicationDecisionConditionTypeDto ) {
72
+ async onDelete ( dto : ApplicationDecisionConditionTypeDto | NoticeOfIntentDecisionConditionTypeDto ) {
62
73
this . confirmationDialogService
63
74
. openDialog ( {
64
- body : `Are you sure you want to delete ${ decisionConditionTypeDto . label } ?` ,
75
+ body : `Are you sure you want to delete ${ dto . label } ?` ,
65
76
} )
66
77
. subscribe ( async ( answer ) => {
67
78
if ( answer ) {
68
- await this . decisionConditionTypesService . delete ( decisionConditionTypeDto . code ) ;
79
+ if ( ! this . service ) return ;
80
+ await this . service . delete ( dto . code ) ;
69
81
await this . fetch ( ) ;
70
82
}
71
83
} ) ;
0 commit comments