Project

General

Profile

1
import { Right } from './../../../shared/models/right.interface';
2
import { USER_RIGHTS } from './../../../shared/enums/USER_RIGHTS.enum';
3
import { AuthService } from 'src/app/shared/services/auth.service';
4
import { VerificationRule } from './../../../shared/models/verification-rule.interface';
5
import { Component, OnInit } from '@angular/core';
6
import { Page } from '../../../shared/models/paging/page.interface';
7
import { TranslateService } from '@ngx-translate/core';
8
import { environment } from 'src/environments/environment';
9

    
10
@Component({
11
  selector: 'app-verification-rules-configuration',
12
  templateUrl: './verification-rules-configuration.component.html',
13
  styleUrls: ['./verification-rules-configuration.component.scss']
14
})
15
export class VerificationRulesConfigurationComponent implements OnInit {
16

    
17
  displayTemplateCreationDialog = false;
18
  searchResults: Page<VerificationRule>;
19
  paginationEventRequest: { page: number, offset: number };
20
  header: string;
21
  valueOfTableChanged: any;
22
  loading: boolean;
23

    
24
  constructor(private authService: AuthService, private translate: TranslateService) { }
25

    
26
  ngOnInit(): void {
27
  }
28

    
29
  searchMade(results) {
30
    this.searchResults = results;
31
  }
32

    
33
  passLoadingForTable(loading) {
34
    this.loading = loading;
35
  }
36

    
37
  paginationEvent(paginationEvent) {
38
    this.paginationEventRequest = paginationEvent;
39
  }
40

    
41
  addRule(): void {
42
    this.header = this.translate.instant('ADD-NEW-RULE');
43
    this.displayTemplateCreationDialog = true;
44
  }
45

    
46
  /*
47
   * What would you do if they told you that, "if the user cannot add rules, disable this button", but the "add-new-rule" right is granted on a per-client basis?
48
   * But of course, you would check to see if the "add-new-rule" right is granted for ANY client and, if so, you would then allow him to proceed.
49
   */
50
  canAddAnyRule(): boolean {
51
    return this.authService.userHasRightForClient(USER_RIGHTS.B03, environment.globalRightsClientID);
52
  }
53

    
54
  passEvent(passEvent: any) {
55
    if (passEvent) {
56
      this.valueOfTableChanged = passEvent;
57
  }
58

    
59
}
60

    
61

    
62
}
(4-4/4)