69111: Links to edit EPerson page and edit Group page from members list in edit group page

This commit is contained in:
Marie Verdonck
2020-03-06 17:15:38 +01:00
parent b9401b46b1
commit 5b76ed6d52
10 changed files with 104 additions and 34 deletions

View File

@@ -192,9 +192,9 @@
"admin.access-control.epeople.table.edit": "Edit",
"item.access-control.epeople.table.edit.buttons.edit": "Edit",
"admin.access-control.epeople.table.edit.buttons.edit": "Edit",
"item.access-control.epeople.table.edit.buttons.remove": "Remove",
"admin.access-control.epeople.table.edit.buttons.remove": "Remove",
"admin.access-control.epeople.no-items": "No EPeople to show.",
@@ -241,6 +241,7 @@
"admin.access-control.epeople.notification.deleted.success": "Successfully deleted EPerson: \"{{name}}\"",
"admin.access-control.groups.title": "DSpace Angular :: Groups",
"admin.access-control.groups.head": "Groups",
@@ -276,8 +277,6 @@
"admin.access-control.groups.form.groupDescription": "Description",
"admin.access-control.groups.form.button.return": "Return",
"admin.access-control.groups.form.notification.created.success": "Successfully created group \"{{name}}\"",
"admin.access-control.groups.form.notification.created.failure": "Failed to create group \"{{name}}\"",
@@ -350,7 +349,7 @@
"admin.access-control.groups.form.subgroups-list.button.see-all": "Search all",
"admin.access-control.groups.form.return": "Return",
"admin.access-control.groups.form.return": "Return to groups",

View File

@@ -1,7 +1,8 @@
import { Component } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { Subscription } from 'rxjs/internal/Subscription';
import { map, take } from 'rxjs/operators';
import { PaginatedList } from '../../../core/data/paginated-list';
import { RemoteData } from '../../../core/data/remote-data';
@@ -19,7 +20,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
* A component used for managing all existing epeople within the repository.
* The admin can create, edit or delete epeople here.
*/
export class EPeopleRegistryComponent {
export class EPeopleRegistryComponent implements OnInit, OnDestroy {
labelPrefix = 'admin.access-control.epeople.';
@@ -45,15 +46,28 @@ export class EPeopleRegistryComponent {
// The search form
searchForm;
/**
* List of subscriptions
*/
subs: Subscription[] = [];
constructor(private epersonService: EPersonDataService,
private translateService: TranslateService,
private notificationsService: NotificationsService,
private formBuilder: FormBuilder) {
}
ngOnInit() {
this.isEPersonFormShown = false;
this.updateEPeople({
currentPage: 1,
elementsPerPage: this.config.pageSize
});
this.isEPersonFormShown = false;
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
if (eperson != null && eperson.id) {
this.isEPersonFormShown = true;
}
}));
this.searchForm = this.formBuilder.group(({
scope: 'metadata',
query: '',
@@ -151,6 +165,13 @@ export class EPeopleRegistryComponent {
}
}
/**
* Unsub all subscriptions
*/
ngOnDestroy(): void {
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
}
scrollToTop() {
(function smoothscroll() {
const currentScroll = document.documentElement.scrollTop || document.body.scrollTop;

View File

@@ -39,7 +39,8 @@
<tbody>
<tr *ngFor="let group of (groups | async)?.payload?.page">
<td>{{group.id}}</td>
<td><a [routerLink]="[groupsDataService.getGroupEditPageRouterLink(group.id)]">{{group.name}}</a></td>
<td><a (click)="groupsDataService.startEditingNewGroup(group)"
[routerLink]="[groupsDataService.getGroupEditPageRouterLink(group)]">{{group.name}}</a></td>
</tr>
</tbody>
</table>

View File

@@ -134,7 +134,6 @@ export class GroupFormComponent implements OnInit, OnDestroy {
onCancel() {
this.groupDataService.cancelEditGroup();
this.cancelForm.emit();
this.router.navigate([this.groupDataService.getGroupRegistryRouterLink()]);
}
/**

View File

@@ -41,7 +41,8 @@
<tbody>
<tr *ngFor="let ePerson of (ePeople | async)?.payload?.page">
<td>{{ePerson.id}}</td>
<td>{{ePerson.name}}</td>
<td><a (click)="ePersonDataService.startEditingNewEPerson(ePerson)"
[routerLink]="[ePersonDataService.getEPeoplePageRouterLink()]">{{ePerson.name}}</a></td>
<td>
<div class="btn-group edit-field">
<button *ngIf="(isMemberOfGroup(ePerson) | async)"
@@ -66,12 +67,15 @@
</ds-pagination>
<div *ngIf="(ePeople | async)?.payload.totalElements == 0 && !searchDone" class="alert alert-info w-100 mb-2" role="alert">
<div *ngIf="(ePeople | async)?.payload.totalElements == 0 && !searchDone" class="alert alert-info w-100 mb-2"
role="alert">
{{messagePrefix + '.no-members-yet' | translate}}
<button (click)="search({query: ''})" class="btn btn-primary">{{messagePrefix + '.button.see-all' | translate}}</button>
<button (click)="search({query: ''})"
class="btn btn-primary">{{messagePrefix + '.button.see-all' | translate}}</button>
</div>
<div *ngIf="(ePeople | async)?.payload.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2" role="alert">
<div *ngIf="(ePeople | async)?.payload.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2"
role="alert">
{{messagePrefix + '.no-items' | translate}}
</div>

View File

@@ -55,7 +55,7 @@ export class MembersListComponent implements OnInit, OnDestroy {
searchDone: boolean;
constructor(private groupDataService: GroupDataService,
private ePersonDataService: EPersonDataService,
public ePersonDataService: EPersonDataService,
private translateService: TranslateService,
private notificationsService: NotificationsService,
private formBuilder: FormBuilder) {

View File

@@ -35,7 +35,8 @@
<tbody>
<tr *ngFor="let group of (groups | async)?.payload?.page">
<td>{{group.id}}</td>
<td>{{group.name}}</td>
<td><a (click)="groupDataService.startEditingNewGroup(group)"
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">{{group.name}}</a></td>
<td>
<div class="btn-group edit-field">
<button *ngIf="(isSubgroupOfGroup(group) | async)"
@@ -60,12 +61,15 @@
</ds-pagination>
<div *ngIf="(groups | async)?.payload.totalElements == 0 && !searchDone" class="alert alert-info w-100 mb-2" role="alert">
<div *ngIf="(groups | async)?.payload.totalElements == 0 && !searchDone" class="alert alert-info w-100 mb-2"
role="alert">
{{messagePrefix + '.no-subgroups-yet' | translate}}
<button (click)="search({query: ''})" class="btn btn-primary">{{messagePrefix + '.button.see-all' | translate}}</button>
<button (click)="search({query: ''})"
class="btn btn-primary">{{messagePrefix + '.button.see-all' | translate}}</button>
</div>
<div *ngIf="(groups | async)?.payload.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2" role="alert">
<div *ngIf="(groups | async)?.payload.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2"
role="alert">
{{messagePrefix + '.no-items' | translate}}
</div>

View File

@@ -54,7 +54,7 @@
<!-- <td>{{getOptionalComColFromName(group.name)}}</td>-->
<td>
<div class="btn-group edit-field">
<button [routerLink]="[group.id]" class="btn btn-outline-primary btn-sm"
<button [routerLink]="groupService.getGroupEditPageRouterLink(group)" class="btn btn-outline-primary btn-sm"
title="{{messagePrefix + 'table.edit.buttons.edit' | translate}}">
<i class="fas fa-edit fa-fw"></i>
</button>

View File

@@ -219,4 +219,27 @@ export class EPersonDataService extends DataService<EPerson> {
return this.delete(ePerson.id);
}
/**
* Change which ePerson is being edited and return the link for EPeople edit page
* @param ePerson New EPerson to edit
*/
public startEditingNewEPerson(ePerson: EPerson): string {
this.getActiveEPerson().pipe(take(1)).subscribe((activeEPerson: EPerson) => {
if (ePerson === activeEPerson) {
this.cancelEditEPerson();
} else {
this.editEPerson(ePerson);
}
});
return '/admin/access-control/epeople';
}
/**
* Get EPeople admin page
* @param ePerson New EPerson to edit
*/
public getEPeoplePageRouterLink(): string {
return '/admin/access-control/epeople';
}
}

View File

@@ -259,8 +259,27 @@ export class GroupDataService extends DataService<Group> {
return '/admin/access-control/groups';
}
public getGroupEditPageRouterLink(groupId: string): string {
return '/admin/access-control/groups/' + groupId;
/**
* Change which group is being edited and return the link for the edit page of the new group being edited
* @param newGroup New group to edit
*/
public startEditingNewGroup(newGroup: Group): string {
this.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
if (newGroup === activeGroup) {
this.cancelEditGroup()
} else {
this.editGroup(newGroup)
}
});
return '/admin/access-control/groups/' + newGroup.id;
}
/**
* Get Edit page of group
* @param group Group we want edit page for
*/
public getGroupEditPageRouterLink(group: Group): string {
return '/admin/access-control/groups/' + group.id;
}
}