@csmart/ngc-smart-victim 0.1.5 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. package/karma.conf.js +32 -0
  2. package/ng-package.json +7 -0
  3. package/package.json +13 -26
  4. package/src/lib/caseNote/caseNote.component.css +20 -0
  5. package/src/lib/caseNote/caseNote.component.html +188 -0
  6. package/src/lib/caseNote/caseNote.component.ts +248 -0
  7. package/src/lib/common-dialog/common-dialog.component.css +10 -0
  8. package/src/lib/common-dialog/common-dialog.component.html +23 -0
  9. package/src/lib/common-dialog/common-dialog.component.spec.ts +25 -0
  10. package/src/lib/common-dialog/common-dialog.component.ts +21 -0
  11. package/src/lib/common-dialog/common-dialog.module.ts +25 -0
  12. package/src/lib/common-dialog/common-dialog.service.ts +35 -0
  13. package/src/lib/contact/contact.component.css +20 -0
  14. package/src/lib/contact/contact.component.html +124 -0
  15. package/src/lib/contact/contact.component.ts +176 -0
  16. package/src/lib/intake.service.ts +82 -0
  17. package/src/lib/safetyPlan/serviceProvider.component.ts +94 -0
  18. package/src/lib/safetyPlan/victimSafetyPlan.component.css +27 -0
  19. package/src/lib/safetyPlan/victimSafetyPlan.component.html +85 -0
  20. package/src/lib/safetyPlan/victimSafetyPlan.component.ts +178 -0
  21. package/src/lib/safetyPlan/victimSafetyPlanDetail.component.html +234 -0
  22. package/src/lib/safetyPlan/victimSafetyPlanDetail.component.ts +492 -0
  23. package/src/lib/shared/app.shared.module.ts +118 -0
  24. package/src/lib/shared/directives/phone-mask.directive.ts +41 -0
  25. package/src/lib/shared/validators/date.validator.ts +73 -0
  26. package/src/lib/shared/validators/index.ts +1 -0
  27. package/src/lib/smart-victim-delete-confirm.component.ts +35 -0
  28. package/src/lib/smart-victim-detail/smart-victim-detail.component.css +43 -0
  29. package/src/lib/smart-victim-detail/smart-victim-detail.component.html +860 -0
  30. package/src/lib/smart-victim-detail/smart-victim-detail.component.spec.ts +25 -0
  31. package/src/lib/smart-victim-detail/smart-victim-detail.component.ts +1241 -0
  32. package/src/lib/smart-victim.component.css +192 -0
  33. package/src/lib/smart-victim.component.html +133 -0
  34. package/src/lib/smart-victim.component.spec.ts +25 -0
  35. package/src/lib/smart-victim.component.ts +323 -0
  36. package/src/lib/smart-victim.model.ts +301 -0
  37. package/src/lib/smart-victim.module.ts +116 -0
  38. package/src/lib/smart-victim.service.spec.ts +12 -0
  39. package/src/lib/smart-victim.service.ts +563 -0
  40. package/src/lib/victim-routing.module.ts +34 -0
  41. package/{lib/victimSearch/VictimSearchFilter.d.ts → src/lib/victimSearch/VictimSearchFilter.ts} +4 -2
  42. package/src/lib/victimSearch/victimSearchForm.component.html +35 -0
  43. package/src/lib/victimSearch/victimSearchForm.component.ts +41 -0
  44. package/src/public-api.ts +12 -0
  45. package/src/test.ts +22 -0
  46. package/tsconfig.lib.json +37 -0
  47. package/tsconfig.spec.json +17 -0
  48. package/tslint.json +17 -0
  49. package/bundles/csmart-ngc-smart-victim.umd.js +0 -6426
  50. package/bundles/csmart-ngc-smart-victim.umd.js.map +0 -1
  51. package/bundles/csmart-ngc-smart-victim.umd.min.js +0 -16
  52. package/bundles/csmart-ngc-smart-victim.umd.min.js.map +0 -1
  53. package/csmart-ngc-smart-victim.d.ts +0 -19
  54. package/csmart-ngc-smart-victim.metadata.json +0 -1
  55. package/esm2015/csmart-ngc-smart-victim.js +0 -25
  56. package/esm2015/lib/caseNote/caseNote.component.js +0 -349
  57. package/esm2015/lib/common-dialog/common-dialog.component.js +0 -46
  58. package/esm2015/lib/common-dialog/common-dialog.module.js +0 -32
  59. package/esm2015/lib/common-dialog/common-dialog.service.js +0 -63
  60. package/esm2015/lib/contact/contact.component.js +0 -228
  61. package/esm2015/lib/intake.service.js +0 -183
  62. package/esm2015/lib/safetyPlan/serviceProvider.component.js +0 -130
  63. package/esm2015/lib/safetyPlan/victimSafetyPlan.component.js +0 -257
  64. package/esm2015/lib/safetyPlan/victimSafetyPlanDetail.component.js +0 -556
  65. package/esm2015/lib/shared/app.shared.module.js +0 -81
  66. package/esm2015/lib/shared/directives/phone-mask.directive.js +0 -168
  67. package/esm2015/lib/shared/validators/date.validator.js +0 -108
  68. package/esm2015/lib/shared/validators/index.js +0 -7
  69. package/esm2015/lib/smart-victim-delete-confirm.component.js +0 -61
  70. package/esm2015/lib/smart-victim-detail/smart-victim-detail.component.js +0 -1405
  71. package/esm2015/lib/smart-victim.component.js +0 -476
  72. package/esm2015/lib/smart-victim.model.js +0 -631
  73. package/esm2015/lib/smart-victim.module.js +0 -84
  74. package/esm2015/lib/smart-victim.service.js +0 -792
  75. package/esm2015/lib/victim-routing.module.js +0 -40
  76. package/esm2015/lib/victimSearch/VictimSearchFilter.js +0 -20
  77. package/esm2015/lib/victimSearch/victimSearchForm.component.js +0 -59
  78. package/esm2015/public-api.js +0 -13
  79. package/esm5/csmart-ngc-smart-victim.js +0 -25
  80. package/esm5/lib/caseNote/caseNote.component.js +0 -372
  81. package/esm5/lib/common-dialog/common-dialog.component.js +0 -48
  82. package/esm5/lib/common-dialog/common-dialog.module.js +0 -36
  83. package/esm5/lib/common-dialog/common-dialog.service.js +0 -75
  84. package/esm5/lib/contact/contact.component.js +0 -281
  85. package/esm5/lib/intake.service.js +0 -194
  86. package/esm5/lib/safetyPlan/serviceProvider.component.js +0 -99
  87. package/esm5/lib/safetyPlan/victimSafetyPlan.component.js +0 -306
  88. package/esm5/lib/safetyPlan/victimSafetyPlanDetail.component.js +0 -628
  89. package/esm5/lib/shared/app.shared.module.js +0 -85
  90. package/esm5/lib/shared/directives/phone-mask.directive.js +0 -184
  91. package/esm5/lib/shared/validators/date.validator.js +0 -108
  92. package/esm5/lib/shared/validators/index.js +0 -7
  93. package/esm5/lib/smart-victim-delete-confirm.component.js +0 -51
  94. package/esm5/lib/smart-victim-detail/smart-victim-detail.component.js +0 -1497
  95. package/esm5/lib/smart-victim.component.js +0 -528
  96. package/esm5/lib/smart-victim.model.js +0 -541
  97. package/esm5/lib/smart-victim.module.js +0 -84
  98. package/esm5/lib/smart-victim.service.js +0 -1063
  99. package/esm5/lib/victim-routing.module.js +0 -44
  100. package/esm5/lib/victimSearch/VictimSearchFilter.js +0 -24
  101. package/esm5/lib/victimSearch/victimSearchForm.component.js +0 -70
  102. package/esm5/public-api.js +0 -13
  103. package/fesm2015/csmart-ngc-smart-victim.js +0 -5682
  104. package/fesm2015/csmart-ngc-smart-victim.js.map +0 -1
  105. package/fesm5/csmart-ngc-smart-victim.js +0 -6203
  106. package/fesm5/csmart-ngc-smart-victim.js.map +0 -1
  107. package/lib/caseNote/caseNote.component.d.ts +0 -45
  108. package/lib/common-dialog/common-dialog.component.d.ts +0 -11
  109. package/lib/common-dialog/common-dialog.module.d.ts +0 -2
  110. package/lib/common-dialog/common-dialog.service.d.ts +0 -8
  111. package/lib/contact/contact.component.d.ts +0 -37
  112. package/lib/intake.service.d.ts +0 -54
  113. package/lib/safetyPlan/serviceProvider.component.d.ts +0 -16
  114. package/lib/safetyPlan/victimSafetyPlan.component.d.ts +0 -49
  115. package/lib/safetyPlan/victimSafetyPlanDetail.component.d.ts +0 -57
  116. package/lib/shared/app.shared.module.d.ts +0 -2
  117. package/lib/shared/directives/phone-mask.directive.d.ts +0 -14
  118. package/lib/shared/validators/date.validator.d.ts +0 -9
  119. package/lib/shared/validators/index.d.ts +0 -1
  120. package/lib/smart-victim-delete-confirm.component.d.ts +0 -9
  121. package/lib/smart-victim-detail/smart-victim-detail.component.d.ts +0 -109
  122. package/lib/smart-victim.component.d.ts +0 -63
  123. package/lib/smart-victim.model.d.ts +0 -204
  124. package/lib/smart-victim.module.d.ts +0 -2
  125. package/lib/smart-victim.service.d.ts +0 -67
  126. package/lib/victim-routing.module.d.ts +0 -2
  127. package/lib/victimSearch/victimSearchForm.component.d.ts +0 -11
  128. package/public-api.d.ts +0 -4
@@ -0,0 +1,492 @@
1
+ import { Component, OnInit,Inject } from '@angular/core';
2
+ import { NgcSmartVictimService } from '../smart-victim.service';
3
+ import { FormControl, FormGroup, FormBuilder,Validators } from '@angular/forms';
4
+ import { VictimSafetyPlan,VictimServiceDetail,
5
+ VictimServiceStatusHistory,VictimServiceTypeProgramProviderModel,
6
+ ProviderListCollectionModel } from '../smart-victim.model';
7
+ import { MatDialog } from '@angular/material/dialog';
8
+ import { CommonDialogService} from '.././common-dialog/common-dialog.service';
9
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
10
+ import { Observable } from 'rxjs';
11
+ import { Router, ActivatedRoute } from '@angular/router';
12
+ import { SelectedOffender, LoginStaff } from '@csmart/ngc-smart-core';
13
+ import { dateValidator, passDateValidator } from '../shared/validators';
14
+ import { SeriveProviderComponent} from '../safetyPlan/serviceProvider.component'
15
+ import { ProvidersDialogData} from '../smart-victim.model';
16
+ import { MatSnackBar } from '@angular/material/snack-bar';
17
+ import { MatTableDataSource } from '@angular/material/table';
18
+
19
+ @Component({
20
+ templateUrl: './victimSafetyPlanDetail.component.html',
21
+ providers: [CommonDialogService],
22
+ styleUrls: ['./victimSafetyPlan.component.css']
23
+
24
+ })
25
+
26
+ export class VictimSafetyPlanDetailComponent implements OnInit {
27
+
28
+
29
+ hiddenAddNewFlag: boolean;
30
+ safetyPlans: VictimSafetyPlan[];
31
+ safetyPlan: VictimSafetyPlan;
32
+ editSafetyPlan: VictimSafetyPlan = <VictimSafetyPlan>{};
33
+ errorMessage: string;
34
+ contactTypes: any[];
35
+ contactPurposes: any[];
36
+ victimServiceTypes: any[];
37
+ victimSafetyPlans: VictimSafetyPlan[];
38
+ victimServiceStatus: any[];
39
+ providerList: VictimServiceTypeProgramProviderModel[];
40
+ providerListCollection:ProviderListCollectionModel[]=[];
41
+ victimServiceDetail: VictimServiceDetail[];
42
+ indx:any;
43
+ serviceCheck = [];
44
+ victimName: string;
45
+ isDisplay: boolean;
46
+ staffId: number;
47
+ victimId: number;
48
+ victimServiceId: number;
49
+ offenderId: number;
50
+ loginStaff: LoginStaff;
51
+ private sub: any;
52
+ result: any;
53
+ victimServiceStatusHistoriesDataSource= new MatTableDataSource();
54
+ providerId: string;
55
+ selected: string;
56
+
57
+
58
+ spForm: FormGroup;
59
+
60
+ constructor(
61
+ public dialog: MatDialog,
62
+ private _victimServicesComponent: NgcSmartVictimService,
63
+ private http: HttpClient,
64
+ public snackBar: MatSnackBar,
65
+ private route: ActivatedRoute,
66
+ private router: Router,
67
+ private commonDialogService: CommonDialogService,
68
+ private formBuilder: FormBuilder,
69
+
70
+ ) {
71
+
72
+ this.initForm();
73
+ }
74
+
75
+ private initForm() {
76
+
77
+
78
+ this.spForm = this.formBuilder.group({
79
+ serviceGoal: new FormControl('', Validators.compose([
80
+ Validators.required ])),
81
+ goalStatus: new FormControl('', Validators.compose([
82
+ Validators.required ])),
83
+ goalStatusDate: new FormControl('', Validators.compose([
84
+ Validators.required,dateValidator() ])),
85
+ comment: new FormControl('',Validators.required)
86
+ });
87
+ this.spForm.markAsPristine();
88
+ this.spForm.markAsUntouched();
89
+
90
+ }
91
+
92
+ ngOnInit() {
93
+
94
+
95
+
96
+ var data = this.route.snapshot.data;
97
+ this.loginStaff = data.loginStaff;
98
+ this.staffId = this.loginStaff.staffId;
99
+
100
+ this.sub = this.route.params.subscribe(params => {
101
+ this.victimServiceId = params['victimServiceId'];
102
+ this.victimId = params['victimId'];
103
+
104
+ });
105
+
106
+ this.hiddenAddNewFlag = false;
107
+ this.isDisplay = false;
108
+
109
+
110
+
111
+ this._victimServicesComponent.getVictimServiceTypes().subscribe(
112
+ (items: any) => {
113
+ this.victimServiceTypes = items;
114
+ }
115
+ );
116
+
117
+ this._victimServicesComponent.getVictimServiceStatus().subscribe(
118
+ (items: any) => {
119
+ this.victimServiceStatus = items;
120
+ }
121
+ );
122
+
123
+ this._victimServicesComponent.getVictim(this.victimId).subscribe(
124
+ (items: any) => {
125
+ this.victimName = items.firstName + ', ' + items.lastName;
126
+ }
127
+ );
128
+
129
+
130
+
131
+ //---------------graphQL--------------------------------------
132
+ // this.getVictimServiceTypeProgramProviders().subscribe(result => {
133
+ // this.providerList = result;
134
+ // });
135
+ // console.log('this.victimServiceId');
136
+ // console.log(this.victimServiceId);
137
+
138
+ if (this.victimServiceId!=0){
139
+ this._victimServicesComponent.getVictimServices(this.victimServiceId).subscribe(
140
+ victimSafetyPlans => {
141
+ console.log('victimSafetyPlans');
142
+ console.log(victimSafetyPlans);
143
+
144
+ this.editSafetyPlan = victimSafetyPlans[0];
145
+ this.victimId = victimSafetyPlans[0].victimId;
146
+
147
+ console.log('this.editSafetyPlan');
148
+ console.log(this.editSafetyPlan);
149
+ // console.log('this.editSafetyPlan.goal');
150
+ // console.log(this.editSafetyPlan.goal);
151
+ // console.log('this.editSafetyPlan[0].goal');
152
+ // console.log(this.editSafetyPlan[0].goal);
153
+
154
+ }
155
+ );
156
+
157
+ this._victimServicesComponent.getServiceStatusHistories(this.victimServiceId).subscribe(
158
+ victimServiceStatusHistories => {
159
+ // this.victimServiceStatusHistories = victimServiceStatusHistories;
160
+ this.victimServiceStatusHistoriesDataSource.data = victimServiceStatusHistories;
161
+ }
162
+ );
163
+
164
+ }
165
+
166
+ this.loadProvider();
167
+
168
+ }
169
+ //pass in id
170
+ isInArray(providerListCollectionKey:string, serviceTypeName: string, event){
171
+
172
+ console.log('providerListCollectionKey');
173
+ console.log(providerListCollectionKey);
174
+
175
+
176
+ console.log('serviceTypeName');
177
+ console.log(serviceTypeName);
178
+
179
+ console.log('event.source.value');
180
+ console.log(event.checked);
181
+
182
+ if (event.checked == true){
183
+
184
+ for(let j=0;j<this.providerListCollection.length;j++){
185
+ if(providerListCollectionKey==this.providerListCollection[j].groupId){
186
+ this.providerListCollection[j].isDisplay=!this.providerListCollection[j].isDisplay;
187
+
188
+
189
+
190
+ const dialogRef = this.dialog.open(SeriveProviderComponent, {
191
+ width: '500px',
192
+ data: <ProvidersDialogData>{
193
+
194
+ serviceType:serviceTypeName,
195
+ serviceTypeId: providerListCollectionKey,
196
+ providerCollections: [...this.providerListCollection],
197
+ },
198
+ panelClass: 'formFieldWidth480',
199
+ });
200
+
201
+
202
+
203
+ dialogRef.afterClosed().subscribe((result: any) => {
204
+ console.log('The dialog was closed');
205
+ console.log(result);
206
+ if (result) {
207
+ console.log('The dialog was closed, inside result');
208
+ this.savePlanProvider(providerListCollectionKey,result.voteeProviderId);
209
+
210
+ }
211
+
212
+
213
+ });
214
+
215
+ // return;
216
+ }
217
+ }
218
+
219
+ }//if event.checked == true
220
+ //this.router.navigate(['saftyPlanDetail', this.victimServiceId, this.victimId ]);
221
+
222
+ }
223
+
224
+ loadProvider(){
225
+
226
+ this.providerListCollection=[];
227
+ this._victimServicesComponent.getvVictimServiceTypeProgramProviders()
228
+ .subscribe(
229
+ (providerList:VictimServiceTypeProgramProviderModel[] )=>{
230
+ if(providerList){
231
+
232
+ let providers = Object.create(null);
233
+ for(let i=0;i<providerList.length;i++){
234
+
235
+ if (!providers[providerList[i].victimServiceTypeId]) {
236
+ providers[providerList[i].victimServiceTypeId] = [];
237
+
238
+ if ( this.editSafetyPlan.vVictimServiceDetails != null ){
239
+ for (let j=0; j<this.editSafetyPlan.vVictimServiceDetails.length; j++){
240
+ if ( providerList[i].victimServiceTypeId == this.editSafetyPlan.vVictimServiceDetails[j].victimServiceId.toString() ){
241
+ this.isDisplay = true;
242
+ }
243
+ }
244
+ }
245
+ this.providerListCollection.push({ groupId: providerList[i].victimServiceTypeId,isDisplay:this.isDisplay, collection: providers[providerList[i].victimServiceTypeId] });
246
+ }
247
+
248
+ providers[providerList[i].victimServiceTypeId].push(providerList[i]);
249
+
250
+ }
251
+
252
+
253
+ }
254
+
255
+ });
256
+
257
+ }
258
+ //---------------graphQL--------------------------------------
259
+ // getVictimServiceTypeProgramProviders(): Observable<VictimServiceTypeProgramProviderModel[]> {
260
+ // const queryString = `
261
+ // {
262
+ // findVictimServiceTypeProgramProviders {
263
+ // data {
264
+ // victimServiceTypeProgramProviderId
265
+ // victimServiceType
266
+ // victimProgramProvider
267
+ // }
268
+ // }
269
+ // }`;
270
+
271
+ // return this.http.post<any>(environment.smartApiUrl, { query: queryString })
272
+ // .map(result => {
273
+ // return result.data.findVictimServiceTypeProgramProviders.data;
274
+ // });
275
+ // }
276
+
277
+ evaluateSelection(victimServiceTypeId: string) {
278
+ if (this.editSafetyPlan.vVictimServiceDetails) {
279
+ return this.editSafetyPlan.vVictimServiceDetails.findIndex(r => r.victimServiceTypeId === victimServiceTypeId) >= 0;
280
+ }
281
+ }
282
+
283
+
284
+ savePlanProvider(victimServiceTypeId: string,victimProgramProviderId: string){
285
+
286
+ console.log('savePlanProvider');
287
+ console.log(victimServiceTypeId);
288
+ console.log(victimProgramProviderId);
289
+
290
+ if (victimProgramProviderId === "" || victimProgramProviderId=== null || victimProgramProviderId === undefined){
291
+
292
+ this.snackBar.open('Please pick a program on the drop down list !', '', { duration: 120,});
293
+ // alert('Please pick a program on the drop down list !');
294
+
295
+ }else
296
+ {
297
+
298
+ if ( this.victimServiceId == 0){
299
+ //insert
300
+ console.log('insert new plan');
301
+ const safetyPlan: VictimSafetyPlan = {
302
+ victimId:this.victimId,
303
+ fullName: null,
304
+ victimServiceId: 0,
305
+ goal:this.editSafetyPlan.goal,
306
+ comment: this.editSafetyPlan.comment,
307
+ modifiedBy:this.staffId,
308
+ victimServiceStatusId: null,
309
+ status: null,
310
+ startDate: null,
311
+ vVictimServiceDetails: null,
312
+ victimName: null
313
+ };
314
+ this._victimServicesComponent.addSafetyPlan(safetyPlan).subscribe(
315
+ (itms:any)=>{
316
+ const victimServiceStatus: VictimServiceStatusHistory= {
317
+ victimServiceStatusHistoryId:0,
318
+ victimServiceId: itms.victimServiceId,
319
+ victimServiceStatusId: this.editSafetyPlan.victimServiceStatusId ,
320
+ startDate: this.editSafetyPlan.startDate,
321
+ modifiedBy:this.staffId,
322
+ comment:'test add safety plan'
323
+ };
324
+
325
+ this._victimServicesComponent.addVictimServiceStatus(victimServiceStatus).subscribe(
326
+
327
+ () =>{
328
+ console.log('check itms.victimServiceId iniside add victim serive status');
329
+ console.log(itms.victimServiceId);
330
+
331
+ const victimServiceDetail: VictimServiceDetail = {
332
+ victimServiceId: itms.victimServiceId,
333
+ victimServiceDetailId: 0,
334
+ victimServiceTypeId: victimServiceTypeId,
335
+ victimProgramProviderId: victimProgramProviderId,
336
+ modifiedBy: this.staffId,
337
+ victimProgramProvider: null
338
+ };
339
+
340
+ console.log('add plan provider here at insert');
341
+
342
+ this._victimServicesComponent.addPlanProvider(victimServiceDetail).subscribe(
343
+
344
+ () =>{
345
+
346
+ this.router.navigate(['saftyPlanDetail', itms.victimServiceId, this.victimId ]);
347
+
348
+ }
349
+ );
350
+
351
+ }
352
+ );
353
+
354
+
355
+
356
+ }
357
+
358
+
359
+ );
360
+ }
361
+ else//update
362
+ {
363
+ const victimServiceDetail: VictimServiceDetail = {
364
+ victimServiceId: this.victimServiceId,
365
+ victimServiceDetailId: 0,
366
+ victimServiceTypeId: victimServiceTypeId,
367
+ victimProgramProviderId: victimProgramProviderId,
368
+ modifiedBy: this.staffId,
369
+ victimProgramProvider: null
370
+ };
371
+ console.log('add plan provider here at update');
372
+ this._victimServicesComponent.addPlanProvider(victimServiceDetail).subscribe(
373
+
374
+ () =>{
375
+
376
+ this.router.navigate(['saftyPlanDetail', this.victimServiceId, this.victimId ]);
377
+
378
+ }
379
+ );
380
+ }
381
+ }
382
+
383
+
384
+ }
385
+
386
+
387
+ deleteProvider(victimProgramProviderId: string){
388
+
389
+ this.commonDialogService
390
+ .confirm('', 'Do you want to delete this provider?', 'Yes', 'No')
391
+ .subscribe(res => {this.result = res;
392
+ if (this.result) {
393
+ this._victimServicesComponent.deleteProvider(victimProgramProviderId, this.staffId)
394
+ .subscribe(result => {
395
+ this.snackBar.open('delete provider Successfully !', '', {
396
+ duration: 3000,
397
+ });
398
+
399
+ location.reload();
400
+
401
+ }
402
+ );
403
+
404
+ }
405
+
406
+ });
407
+
408
+ // location.reload();
409
+
410
+ }
411
+ saveSafetyPlan() {
412
+
413
+ if (this.editSafetyPlan.victimServiceId === undefined ) {
414
+
415
+ const safetyPlan: VictimSafetyPlan = {
416
+ victimId: this.victimId,
417
+ fullName: null,
418
+ victimServiceId: 0,
419
+ goal:this.editSafetyPlan.goal,
420
+ comment: this.editSafetyPlan.comment,
421
+ modifiedBy:this.staffId,
422
+ victimServiceStatusId: null,
423
+ status: null,
424
+ startDate: null,
425
+ vVictimServiceDetails: null,
426
+ victimName: null
427
+ };
428
+ this._victimServicesComponent.addSafetyPlan(safetyPlan).subscribe(
429
+ (itms:any)=>{
430
+ const victimServiceStatus: VictimServiceStatusHistory= {
431
+ victimServiceStatusHistoryId:0,
432
+ victimServiceId: itms.victimServiceId,
433
+ victimServiceStatusId: this.editSafetyPlan.victimServiceStatusId ,
434
+ startDate: this.editSafetyPlan.startDate,
435
+ modifiedBy:this.staffId,
436
+ comment:'test add safety Plan'
437
+ };
438
+
439
+ this._victimServicesComponent.addVictimServiceStatus(victimServiceStatus).subscribe(
440
+ resp=>{
441
+ this.snackBar.open('Insert status successfully!', '', {
442
+ duration: 3000,
443
+ });
444
+
445
+ }
446
+ );
447
+
448
+
449
+ this.router.navigate(['saftyPlanDetail', itms.victimServiceId, this.victimId ]);
450
+ }
451
+
452
+
453
+ );
454
+ } else {
455
+ // this.editSafetyPlan.modifiedBy=this.loginStaff.staffId;
456
+ this.editSafetyPlan.modifiedBy =this.staffId;
457
+ this._victimServicesComponent.updateSafetyPlan(this.editSafetyPlan).subscribe(
458
+ resp=>{
459
+ // this.snackBar.open('update Successfully!', '', {
460
+ // duration: 3000,
461
+ // });
462
+
463
+
464
+
465
+ const victimServiceStatus: VictimServiceStatusHistory= {
466
+ victimServiceStatusHistoryId:0,
467
+ victimServiceId: this.editSafetyPlan.victimServiceId.toString(),
468
+ victimServiceStatusId: this.editSafetyPlan.victimServiceStatusId ,
469
+ startDate: this.editSafetyPlan.startDate,
470
+ modifiedBy:this.staffId,
471
+ comment:'test update safety Plan'
472
+ };
473
+
474
+ this._victimServicesComponent.addVictimServiceStatus(victimServiceStatus).subscribe();
475
+
476
+
477
+ this.router.navigate(['saftyPlanDetail', this.editSafetyPlan.victimServiceId, this.victimId ]);
478
+
479
+ }
480
+ );
481
+ }
482
+ }
483
+
484
+ back(){
485
+ console.log('this.victimId');
486
+ console.log(this.victimId);
487
+ this.router.navigate(['saftyPlan', this.victimId]);
488
+ }
489
+
490
+
491
+ }
492
+
@@ -0,0 +1,118 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
+ //import {MAT_MOMENT_DATE_FORMATS, MomentDateAdapter} from '@angular/material-moment-adapter';
4
+ import {BrowserModule} from '@angular/platform-browser';
5
+ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
6
+ import {CdkTableModule} from '@angular/cdk/table';
7
+ import {DateAdapter, MatNativeDateModule, MatRippleModule, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
8
+ import {MatIconModule} from '@angular/material/icon';
9
+
10
+
11
+ // import {
12
+ // MatButtonModule, MatCardModule, MatCheckboxModule, MatToolbarModule, MatSelectModule, MatDatepickerModule,
13
+ // MatProgressSpinnerModule, MatGridListModule, MatTableModule, MatSidenavModule, MatRadioModule, MatPaginatorModule,
14
+ // // tslint:disable-next-line:whitespace
15
+ // MatNativeDateModule, MatSliderModule, MatDialogModule, MatChipsModule,MatSortModule,
16
+ // MatTabsModule, MatRippleModule, MatListModule, MatInputModule, MatFormFieldModule, MatStepperModule, MatExpansionModule,
17
+
18
+
19
+ // } from '@angular/material';
20
+ import {MatSnackBarModule} from '@angular/material/snack-bar';
21
+ import { MatButtonModule } from '@angular/material/button';
22
+ import { MatCardModule } from '@angular/material/card';
23
+ import { MatCheckboxModule } from '@angular/material/checkbox';
24
+ import { MatDatepickerModule } from '@angular/material/datepicker';
25
+ import { MatDialogModule } from '@angular/material/dialog';
26
+ import { MatExpansionModule } from '@angular/material/expansion';
27
+ import { MatGridListModule } from '@angular/material/grid-list';
28
+ import { MatInputModule } from '@angular/material/input';
29
+ import { MatListModule } from '@angular/material/list';
30
+ import { MatPaginatorModule } from '@angular/material/paginator';
31
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
32
+ import { MatRadioModule } from '@angular/material/radio';
33
+ import { MatSelectModule } from '@angular/material/select';
34
+ import { MatSidenavModule } from '@angular/material/sidenav';
35
+ import { MatSliderModule } from '@angular/material/slider';
36
+ import { MatSortModule } from '@angular/material/sort';
37
+ import { MatTableModule } from '@angular/material/table';
38
+ import { MatTabsModule } from '@angular/material/tabs';
39
+ import { MatToolbarModule } from '@angular/material/toolbar';
40
+ import { MatStepperModule } from "@angular/material/stepper";
41
+ import { MatChipsModule } from "@angular/material/chips";
42
+
43
+
44
+
45
+ @NgModule(
46
+ {
47
+
48
+ imports: [
49
+ MatButtonModule,
50
+ MatCardModule,
51
+ MatCheckboxModule,
52
+ MatToolbarModule,
53
+ MatSelectModule,
54
+ MatDatepickerModule,
55
+ MatNativeDateModule,
56
+ MatDialogModule,
57
+ MatTabsModule,
58
+ MatListModule,
59
+ MatInputModule,
60
+ MatStepperModule,
61
+ BrowserAnimationsModule,
62
+ MatGridListModule,
63
+ MatProgressSpinnerModule,
64
+ MatTableModule,
65
+ MatSidenavModule,
66
+ MatRadioModule,
67
+ MatIconModule,
68
+ MatSliderModule,
69
+ MatChipsModule,
70
+ MatSnackBarModule,
71
+ CdkTableModule,
72
+ MatSortModule,
73
+ MatPaginatorModule,
74
+ MatExpansionModule,
75
+ MatRippleModule,
76
+
77
+
78
+ ],
79
+ exports: [
80
+
81
+ MatButtonModule,
82
+ MatCardModule,
83
+ MatCheckboxModule,
84
+ MatToolbarModule,
85
+ MatSelectModule,
86
+ MatDatepickerModule,
87
+ MatNativeDateModule,
88
+ MatDialogModule,
89
+ MatTabsModule,
90
+ MatListModule,
91
+ MatInputModule,
92
+ MatStepperModule,
93
+ BrowserAnimationsModule,
94
+ MatGridListModule,
95
+ MatProgressSpinnerModule,
96
+ MatTableModule,
97
+ MatSidenavModule,
98
+ MatRadioModule,
99
+ MatIconModule,
100
+ MatSliderModule,
101
+ MatChipsModule,
102
+ MatSnackBarModule,
103
+ CdkTableModule,
104
+ MatSortModule,
105
+ MatPaginatorModule,
106
+ MatExpansionModule,
107
+ MatRippleModule,
108
+
109
+
110
+ ],
111
+ entryComponents: [
112
+ // SpinnerComponent,
113
+ ],
114
+
115
+
116
+ }
117
+ )
118
+ export class SharedModule { }
@@ -0,0 +1,41 @@
1
+ import { Directive, HostListener } from '@angular/core';
2
+ import { NgControl } from '@angular/forms';
3
+
4
+ @Directive({
5
+ selector: '[formControlName][appPhoneMask]',
6
+ })
7
+ export class PhoneMaskDirective {
8
+
9
+ constructor(public ngControl: NgControl) { }
10
+
11
+ @HostListener('ngModelChange', ['$event'])
12
+ onModelChange(event) {
13
+ this.onInputChange(event, false);
14
+ }
15
+
16
+ @HostListener('keydown.backspace', ['$event'])
17
+ keydownBackspace(event) {
18
+ this.onInputChange(event.target.value, true);
19
+ }
20
+
21
+
22
+ onInputChange(event, backspace) {
23
+ let newVal = event.replace(/\D/g, '');
24
+ if (backspace && newVal.length <= 6) {
25
+ newVal = newVal.substring(0, newVal.length - 1);
26
+ }
27
+ if (newVal.length === 0) {
28
+ newVal = '';
29
+ } else if (newVal.length <= 3) {
30
+ newVal = newVal.replace(/^(\d{0,3})/, '($1)');
31
+ } else if (newVal.length <= 6) {
32
+ newVal = newVal.replace(/^(\d{0,3})(\d{0,3})/, '($1) $2');
33
+ } else if (newVal.length <= 10) {
34
+ newVal = newVal.replace(/^(\d{0,3})(\d{0,3})(\d{0,4})/, '($1) $2-$3');
35
+ } else {
36
+ newVal = newVal.substring(0, 10);
37
+ newVal = newVal.replace(/^(\d{0,3})(\d{0,3})(\d{0,4})/, '($1) $2-$3');
38
+ }
39
+ this.ngControl.valueAccessor.writeValue(newVal);
40
+ }
41
+ }