Guest User

Untitled

a guest
Aug 19th, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export class IssueDataComponent implements OnInit {
  2.  
  3. // properties for mat-table settings
  4. @ViewChild(MatPaginator) paginator: MatPaginator;
  5. @ViewChild(MatSort) sort: MatSort;
  6. IssueDataDTOList = [];
  7. dataSource: MatTableDataSource<PeriodicElement> = new MatTableDataSource([]);
  8. savedPageSize: number;
  9. modelData = {}
  10.  
  11. @Input()
  12. columns: ListColumn[] = [
  13. { name: 'Name', property: 'name', visible: true },
  14. { name: 'Backlog', property: 'backlog', visible: true },
  15. { name: 'Status', property: 'status', visible: true },
  16. { name: 'Update Status Field', property: 'action2', visible: true, isModelProperty: true },
  17. { name: 'Action Field', property: 'action3', visible: true, isModelProperty: true }
  18. ] as ListColumn[];
  19.  
  20. constructor(private issueService: IssueService,
  21. private dialog: MatDialog,
  22. private snackBar: MatSnackBar,
  23. ) {
  24. }
  25.  
  26. ngOnInit() {
  27. this.getIssueStatusList();
  28. this.dataSource.paginator = this.paginator;
  29. }
  30.  
  31. addStatus() {
  32. const dialogConfig = new MatDialogConfig();
  33.  
  34. this.modelData = {
  35. list: this.IssueDataDTOList,
  36. type: "add",
  37. toBeEditedDTO: null
  38. }
  39.  
  40. dialogConfig.data = this.modelData;
  41. dialogConfig.disableClose = true;//disable default close operation
  42. dialogConfig.width = '30%';
  43.  
  44. this.dialog.open(EditIssueDataComponent, dialogConfig).afterClosed().subscribe(
  45. res => {
  46. //updating data source array
  47. this.updatingDataSource(res);
  48. }
  49. )
  50. }
  51.  
  52. updatingDataSource(result) {
  53. this.dataSource = new MatTableDataSource(result);
  54. this.dataSource.paginator = this.paginator;
  55. this.dataSource.sort = this.sort;
  56. }
  57.  
  58. }
  59.  
  60. export class EditIssueDataComponent implements OnInit {
  61.  
  62. statusForm: FormGroup;
  63. IssueDataDTOList = [];
  64. statusArray: string[] = ['Active', 'Inactive'];
  65. isStatusExist = false;
  66. dataFromParent = { list: [], type: '', toBeEditedDTO: { id: 0, name: '', backlog: '', status: '' } };
  67.  
  68. constructor(private matDialogRef: MatDialogRef<DefineCalenderComponent>,
  69. private formBuilder: FormBuilder,
  70. private issueService: IssueService,
  71. private snackBar: MatSnackBar,
  72. public dialogRef: MatDialogRef<any>,
  73. @Inject(MAT_DIALOG_DATA) public data: any, ) {
  74. }
  75.  
  76. ngOnInit() {
  77. this.dataFromParent = this.data;
  78. this.IssueDataDTOList = this.dataFromParent.list;
  79. this.statusForm = new FormGroup({
  80. name: new FormControl('', [Validators.required]),
  81. backlog: new FormControl('', [Validators.required]),
  82. // status: new FormControl('', [Validators.required]),
  83. });
  84. }
  85.  
  86. addStatus() {
  87. const IssueDataDTO = {};
  88. IssueDataDTO['name'] = this.statusForm.value.name;
  89. IssueDataDTO['backlog'] = this.statusForm.value.backlog;
  90. IssueDataDTO['status'] = "ACTIVE";
  91.  
  92. this.issueService.updateIssueData(IssueDataDTO).subscribe(res => {
  93. this.IssueDataDTOList.push(res);
  94. this.cancelPopup();
  95. }
  96. );
  97. }
RAW Paste Data