Newer
Older
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { Group } from '../../../../core/eperson/models/group.model';
import { Community } from '../../../../core/shared/community.model';
import { EMPTY, Observable } from 'rxjs';
import { getGroupEditPath } from '../../../../+admin/admin-access-control/admin-access-control-routing.module';
import { GroupDataService } from '../../../../core/eperson/group-data.service';
import { Collection } from '../../../../core/shared/collection.model';
import { map } from 'rxjs/operators';
import { followLink } from '../../../utils/follow-link-config.model';
import { LinkService } from '../../../../core/cache/builders/link.service';
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators';
import { ComcolRole } from './comcol-role';
import { RequestService } from '../../../../core/data/request.service';
/**
* Component for managing a community or collection role.
*/
@Component({
selector: 'ds-comcol-role',
styleUrls: ['./comcol-role.component.scss'],
templateUrl: './comcol-role.component.html'
})
export class ComcolRoleComponent implements OnInit {
/**
* The community or collection to manage.
*/
@Input()
dso: Community|Collection;
/**
* The role to manage
*/
@Input()
comcolRole: ComcolRole;
constructor(
protected groupService: GroupDataService,
protected linkService: LinkService,
protected cdr: ChangeDetectorRef,
protected requestService: RequestService,
) {
}
/**
* The group for this role as an observable.
*/
get group$(): Observable<Group> {
if (!this.dso[this.comcolRole.linkName]) {
return EMPTY;
}
return this.dso[this.comcolRole.linkName].pipe(
getSucceededRemoteData(),
getRemoteDataPayload(),
);
}
/**
* The link to the group edit page as an observable.
*/
get editGroupLink$(): Observable<string> {
return this.group$.pipe(
map((group) => getGroupEditPath(group.id)),
);
}
/**
* Create a group for this community or collection role.
*/
create() {
this.groupService.createComcolGroup(this.dso, this.comcolRole)
.subscribe(() => {
this.linkService.resolveLink(this.dso, followLink(this.comcolRole.linkName));
this.cdr.detectChanges();
});
}
/**
* Delete the group for this community or collection role.
*/
delete() {
this.groupService.deleteComcolGroup(this.dso, this.comcolRole)
.subscribe(() => {
this.cdr.detectChanges();
})
}
ngOnInit(): void {
this.linkService.resolveLink(this.dso, followLink(this.comcolRole.linkName));
}
}