-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange-set-service.content.ts
More file actions
42 lines (36 loc) · 1.61 KB
/
change-set-service.content.ts
File metadata and controls
42 lines (36 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// eslint-disable-next-line jsdoc/require-jsdoc
export const changeSetServiceContent: string = `import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BaseChangeSetService, ChangeSet } from 'ngx-material-change-sets';
import { AdminService } from './entities/admin.service';
import { Admin } from '../models/admin.model';
@Injectable({ providedIn: 'root' })
export class ChangeSetService extends BaseChangeSetService {
protected override readonly displayValueForEmptyCreatedBy: boolean = true;
constructor(http: HttpClient, private readonly adminService: AdminService) {
super(http);
}
override async openCreatedBy(changeSet: ChangeSet): Promise<void> {
if (!changeSet.createdBy) {
return;
}
const admin: Admin | undefined = (await this.adminService.read()).find(a => a.baseUserId === changeSet.createdBy);
if (!admin) {
throw new Error(\`Could not find user with baseUserId \${changeSet.createdBy}\`);
}
if (admin.id === changeSet.changeSetEntityId) {
return;
}
this.adminService.editAdmin(admin);
}
override async getDisplayValueForCreatedBy(changeSet: ChangeSet): Promise<string> {
if (changeSet.createdBy == undefined) {
return 'System';
}
const admin: Admin | undefined = (await this.adminService.read()).find(a => a.baseUserId === changeSet.createdBy);
if (!admin) {
throw new Error(\`Could not find user with baseUserId \${changeSet.createdBy}\`);
}
return admin.name;
}
}`;