mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[groups/epeople admin pages] No adding current active group itself as own subgroup:
* Added message if trying to add current group (that is being edited) as own subgroup * Removed possible add/delete button from current group being edited in subgroups list, replace with message
This commit is contained in:
@@ -349,6 +349,8 @@
|
|||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.table.edit.buttons.add": "Add subgroup with name \"{{name}}\"",
|
"admin.access-control.groups.form.subgroups-list.table.edit.buttons.add": "Add subgroup with name \"{{name}}\"",
|
||||||
|
|
||||||
|
"admin.access-control.groups.form.subgroups-list.table.edit.currentGroup": "Current group",
|
||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.notification.success.addSubgroup": "Successfully added subgroup: \"{{name}}\"",
|
"admin.access-control.groups.form.subgroups-list.notification.success.addSubgroup": "Successfully added subgroup: \"{{name}}\"",
|
||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.notification.failure.addSubgroup": "Failed to add subgroup: \"{{name}}\"",
|
"admin.access-control.groups.form.subgroups-list.notification.failure.addSubgroup": "Failed to add subgroup: \"{{name}}\"",
|
||||||
@@ -359,6 +361,8 @@
|
|||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.notification.failure.noActiveGroup": "No current active group, submit a name first.",
|
"admin.access-control.groups.form.subgroups-list.notification.failure.noActiveGroup": "No current active group, submit a name first.",
|
||||||
|
|
||||||
|
"admin.access-control.groups.form.subgroups-list.notification.failure.subgroupToAddIsActiveGroup": "This is the current group, can't be added.",
|
||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.no-items": "No groups found with this in their name or this as UUID",
|
"admin.access-control.groups.form.subgroups-list.no-items": "No groups found with this in their name or this as UUID",
|
||||||
|
|
||||||
"admin.access-control.groups.form.subgroups-list.no-subgroups-yet": "No subgroups in group yet.",
|
"admin.access-control.groups.form.subgroups-list.no-subgroups-yet": "No subgroups in group yet.",
|
||||||
|
@@ -42,14 +42,16 @@
|
|||||||
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">{{group.name}}</a></td>
|
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">{{group.name}}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group edit-field">
|
<div class="btn-group edit-field">
|
||||||
<button *ngIf="(isSubgroupOfGroup(group) | async)"
|
<button *ngIf="(isSubgroupOfGroup(group) | async) && !(isActiveGroup(group) | async)"
|
||||||
(click)="deleteSubgroupFromGroup(group)"
|
(click)="deleteSubgroupFromGroup(group)"
|
||||||
class="btn btn-outline-danger btn-sm deleteButton"
|
class="btn btn-outline-danger btn-sm deleteButton"
|
||||||
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: {name: group.name} }}">
|
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: {name: group.name} }}">
|
||||||
<i class="fas fa-trash-alt fa-fw"></i>
|
<i class="fas fa-trash-alt fa-fw"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button *ngIf="!(isSubgroupOfGroup(group) | async)"
|
<p *ngIf="(isActiveGroup(group) | async)">{{ messagePrefix + '.table.edit.currentGroup' | translate }}</p>
|
||||||
|
|
||||||
|
<button *ngIf="!(isSubgroupOfGroup(group) | async) && !(isActiveGroup(group) | async)"
|
||||||
(click)="addSubgroupToGroup(group)"
|
(click)="addSubgroupToGroup(group)"
|
||||||
class="btn btn-outline-primary btn-sm addButton"
|
class="btn btn-outline-primary btn-sm addButton"
|
||||||
title="{{messagePrefix + '.table.edit.buttons.add' | translate: {name: group.name} }}">
|
title="{{messagePrefix + '.table.edit.buttons.add' | translate: {name: group.name} }}">
|
||||||
|
@@ -115,23 +115,41 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
isSubgroupOfGroup(possibleSubgroup: Group): Observable<boolean> {
|
isSubgroupOfGroup(possibleSubgroup: Group): Observable<boolean> {
|
||||||
return this.groupDataService.getActiveGroup().pipe(take(1),
|
return this.groupDataService.getActiveGroup().pipe(take(1),
|
||||||
mergeMap((group: Group) => {
|
mergeMap((activeGroup: Group) => {
|
||||||
if (group != null) {
|
if (activeGroup != null) {
|
||||||
return this.groupDataService.findAllByHref(group._links.subgroups.href, {
|
if (activeGroup.uuid === possibleSubgroup.uuid) {
|
||||||
currentPage: 0,
|
return observableOf(false);
|
||||||
elementsPerPage: Number.MAX_SAFE_INTEGER
|
} else {
|
||||||
})
|
return this.groupDataService.findAllByHref(activeGroup._links.subgroups.href, {
|
||||||
.pipe(
|
currentPage: 0,
|
||||||
getSucceededRemoteData(),
|
elementsPerPage: Number.MAX_SAFE_INTEGER
|
||||||
getRemoteDataPayload(),
|
})
|
||||||
map((listTotalGroups: PaginatedList<Group>) => listTotalGroups.page.filter((groupInList: Group) => groupInList.id === possibleSubgroup.id)),
|
.pipe(
|
||||||
map((groups: Group[]) => groups.length > 0))
|
getSucceededRemoteData(),
|
||||||
} else {
|
getRemoteDataPayload(),
|
||||||
|
map((listTotalGroups: PaginatedList<Group>) => listTotalGroups.page.filter((groupInList: Group) => groupInList.id === possibleSubgroup.id)),
|
||||||
|
map((groups: Group[]) => groups.length > 0))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return observableOf(false);
|
return observableOf(false);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the given group is the current group being edited
|
||||||
|
* @param group Group that is possibly the current group being edited
|
||||||
|
*/
|
||||||
|
isActiveGroup(group: Group): Observable<boolean> {
|
||||||
|
return this.groupDataService.getActiveGroup().pipe(take(1),
|
||||||
|
mergeMap((activeGroup: Group) => {
|
||||||
|
if (activeGroup != null && activeGroup.uuid === group.uuid) {
|
||||||
|
return observableOf(true);
|
||||||
|
}
|
||||||
|
return observableOf(false);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes given subgroup from the group currently being edited
|
* Deletes given subgroup from the group currently being edited
|
||||||
* @param subgroup Group we want to delete from the subgroups of the group currently being edited
|
* @param subgroup Group we want to delete from the subgroups of the group currently being edited
|
||||||
@@ -155,9 +173,13 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
|
|||||||
addSubgroupToGroup(subgroup: Group) {
|
addSubgroupToGroup(subgroup: Group) {
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
||||||
if (activeGroup != null) {
|
if (activeGroup != null) {
|
||||||
const response = this.groupDataService.addSubGroupToGroup(activeGroup, subgroup);
|
if (activeGroup.uuid !== subgroup.uuid) {
|
||||||
this.showNotifications('addSubgroup', response, subgroup.name, activeGroup);
|
const response = this.groupDataService.addSubGroupToGroup(activeGroup, subgroup);
|
||||||
this.forceUpdateGroups(activeGroup);
|
this.showNotifications('addSubgroup', response, subgroup.name, activeGroup);
|
||||||
|
this.forceUpdateGroups(activeGroup);
|
||||||
|
} else {
|
||||||
|
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.subgroupToAddIsActiveGroup'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user