Project

General

Profile

1
import { Right } from './../models/right.interface';
2

    
3
export class USER_RIGHTS {
4
  static readonly A01 = new USER_RIGHTS('A01', 'Configuration of Repetition Frequency', 1, true);
5
  static readonly A02 = new USER_RIGHTS('A02', 'Preview of Scheduling Procedure', 1, true);
6
  static readonly A03 = new USER_RIGHTS('A03', 'Preview of Scheduling Procedure according to User\'s Access Rights', 1, false);
7
  static readonly A04 = new USER_RIGHTS('A04', 'Rescheduling of Downloading Procedure (change of visiting sequence to clients workspaces)', 1, false);
8

    
9
  static readonly B01 = new USER_RIGHTS('B01', 'Preview of all Rules', 2, true);
10
  static readonly B02 = new USER_RIGHTS('B02', 'Preview of Rules, according to User\'s Access Rights', 2, false);
11
  static readonly B03 = new USER_RIGHTS('B03', 'Add New Rule', 2, true); //
12
  static readonly B04 = new USER_RIGHTS('B04', 'Edit Rule', 2, true); //
13
  static readonly B05 = new USER_RIGHTS('B05', 'Delete Rule', 2, true); //
14
  static readonly B06 = new USER_RIGHTS('B06', 'Change Rule Status', 2, true); //
15
  static readonly B07 = new USER_RIGHTS('B07', 'Define Confidence Level Range', 2, true); //
16
  static readonly B08 = new USER_RIGHTS('B08', 'Edit Rule, according to User\'s Access Rights', 2, false);
17

    
18
  static readonly C01 = new USER_RIGHTS('C01', 'Preview of Inbox, according to User\'s Access Rights', 3, false);
19
  static readonly C02 = new USER_RIGHTS('C02', 'Documents Manipulation(Documents Classification and Marking a file as "Ignore")', 3, false);
20
  static readonly C03 = new USER_RIGHTS('C03', 'Preview of Inbox', 3, true);
21

    
22
  static readonly D01 = new USER_RIGHTS('D01', 'Preview of all Processes', 4, true);
23
  static readonly D02 = new USER_RIGHTS('D02', 'Preview of Processes, according to User\'s Access Rights', 4, false);
24
  static readonly D03 = new USER_RIGHTS('D03', 'Documents Re - classification', 4, false);
25
  static readonly D04 = new USER_RIGHTS('D04', 'Data Capturing and Verification', 4, false);
26
  static readonly D05 = new USER_RIGHTS('D05', 'Validation of Journal Entries', 4, false);
27
  static readonly D06 = new USER_RIGHTS('D06', 'Manipulation of Exceptions', 4, false);
28
  static readonly D07 = new USER_RIGHTS('D07', 'Manipulation of Unhandled Data', 4, false);
29
  static readonly D08 = new USER_RIGHTS('D08', 'Execution of Undo Procedure', 4, false);
30

    
31
  static readonly E01 = new USER_RIGHTS('E01', 'Handling of all Clients Personal Data', 5, true);
32
  static readonly E02 = new USER_RIGHTS('E02', 'Handling of Clients Personal Data, according to User\'s Access Rights', 5, false);
33

    
34
  static readonly F01 = new USER_RIGHTS('F01', 'Access to all Reports', 6, true);
35
  static readonly F02 = new USER_RIGHTS('F02', 'Access to Reports, according to User\'s Access Rights', 6, false);
36

    
37
  static readonly G01 = new USER_RIGHTS('G01', 'Create New Roles', 7, true);
38
  static readonly G02 = new USER_RIGHTS('G02', 'Edit Roles', 7, true);
39
  static readonly G03 = new USER_RIGHTS('G03', 'Assign Rights to a Role', 7, true);
40
  static readonly G04 = new USER_RIGHTS('G04', 'Assign Roles to Users', 7, true);
41

    
42
  static readonly H01 = new USER_RIGHTS('H01', 'Preview of all Categories', 8, true);
43
  static readonly H02 = new USER_RIGHTS('H02', 'Add New Category', 8, true);
44
  static readonly H03 = new USER_RIGHTS('H03', 'Edit Category', 8, true);
45
  static readonly H04 = new USER_RIGHTS('H04', 'Delete Category', 8, true);
46

    
47
  static readonly I01 = new USER_RIGHTS('I01', 'Preview of all Templates', 9, true);
48
  static readonly I02 = new USER_RIGHTS('I02', 'Add New Template', 9, true);
49
  static readonly I03 = new USER_RIGHTS('I03', 'Edit Template', 9, true);
50
  static readonly I04 = new USER_RIGHTS('I04', 'Delete Template', 9, true);
51

    
52
  static readonly K01 = new USER_RIGHTS('K01', 'View Application Level Exceptions', 11, true);
53

    
54
  static readonly J01 = new USER_RIGHTS('J01', 'Edit Parameter Values', 10, true);
55

    
56
  // Private constructor to disallow the creation of other instances.
57
  private constructor(public readonly code: string, public readonly description: string, public readonly categoryId: number, isGlobal: boolean) { }
58

    
59
  public toString(): string {
60
    return this.code;
61
  }
62

    
63
  /*
64
   * WARNING:
65
   * Normally there is "normally" NO reason to use this method and you should use 'AuthService.userHasRightForClient(right: USER_RIGHTS, clientId: string)' instead.
66
   * Besides that, do what god lights you to do.
67
   */
68
  public isGrantedToUser(userRights: Right[]): boolean {
69

    
70
    // return true;   // Bypass. Also has to be set in AuthService.userHasRightForClient()
71

    
72
    if (userRights == null) {
73
      return false;
74
    }
75

    
76
    let found = userRights.find(r => r.code == this.code);
77
    return found != null;
78
  }
79
}
(4-4/5)