Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import {
  3. GetApplicationLanguages,
  4. GetLanguagesBaseContainer,
  5. RemoveLanguageActions,
  6. ChangeDefaultLanguageActios
  7. } from '@hr-portal/features';
  8. import { Store } from '@ngrx/store';
  9. import { LocalizationService } from 'abp-ng2-module/dist/src/localization/localization.service';
  10. import { CreateOrEditDialogActions } from '../../../create-or-edit-language-dialog';
  11. import { ApplicationLanguageListDto } from '@hr-portal/shared';
  12. import { Router, ActivatedRoute } from '@angular/router';
  13.  
  14. @Component({
  15. selector: 'hr-portal-languages-table',
  16. templateUrl: './language-table.container.html'
  17. })
  18. export class AppLanguagesTableContainer extends GetLanguagesBaseContainer {
  19. cols = [
  20. {
  21. field: 'name',
  22. header: this.localization.localize('Language', 'HRPortal')
  23. },
  24. {
  25. field: 'displayName',
  26. header: this.localization.localize('Language_Name', 'HRPortal')
  27. },
  28. {
  29. field: 'isDisabled',
  30. header: this.localization.localize('IsDisabled', 'HRPortal')
  31. },
  32. {
  33. field: 'isDefault',
  34. header: this.localization.localize('DefaultLanguage', 'HRPortal')
  35. }
  36. ];
  37.  
  38. optionsMenuforDefault = [
  39. {
  40. label: this.localization.localize('Language_SetAsDefault', 'HRPortal'),
  41. icon: 'la la-eye',
  42. command: () => {
  43. this.setAsDefault();
  44. }
  45. },
  46. {
  47. label: this.localization.localize('Edit', 'HRPortal'),
  48. icon: 'la la-edit',
  49. command: () => {
  50. this.editLanguage();
  51. }
  52. }
  53. ];
  54. optionsMenu = [
  55. ...this.optionsMenuforDefault,
  56. {
  57. label: this.localization.localize('Remove', 'HRPortal'),
  58. icon: 'pi pi-times',
  59. command: () => {
  60. this.removeLanguage();
  61. }
  62. }
  63. ];
  64. selectedRow: any;
  65.  
  66. getBooleanTranslation(value: boolean): string {
  67. if (value) return this.localization.localize('Yes', 'HRPortal');
  68. else return this.localization.localize('No', 'HRPortal');
  69. }
  70.  
  71. constructor(
  72. store$: Store<any>,
  73. private router: Router,
  74. private activatedRoute: ActivatedRoute,
  75. private localization: LocalizationService
  76. ) {
  77. super(store$);
  78. }
  79.  
  80. ngOnInit(): void {
  81. this.store$.dispatch(GetApplicationLanguages.getLanguages());
  82. }
  83.  
  84. setUpSelectedRow(selectedRow) {
  85. this.selectedRow = selectedRow;
  86. }
  87.  
  88. removeLanguage() {
  89. if (this.selectedRow && this.selectedRow.id)
  90. this.store$.dispatch(
  91. RemoveLanguageActions.removeLanguage({ id: this.selectedRow.id })
  92. );
  93. }
  94.  
  95. editLanguage() {
  96. if (this.selectedRow && this.selectedRow.id)
  97. this.store$.dispatch(
  98. CreateOrEditDialogActions.openCreateOrEditAcitonsDialog({
  99. id: this.selectedRow.id
  100. })
  101. );
  102. }
  103.  
  104. navigate(name: string) {
  105. this.router.navigate(['.', 'texts', name], {
  106. relativeTo: this.activatedRoute
  107. });
  108. }
  109.  
  110. setAsDefault() {
  111. if (this.selectedRow && this.selectedRow.name)
  112. this.store$.dispatch(
  113. ChangeDefaultLanguageActios.changeDefaultLanguage({
  114. input: {
  115. name: this.selectedRow.name
  116. }
  117. })
  118. );
  119. }
  120.  
  121. onPage(paginator: any) {}
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement