diff --git a/src/app/access-control/access-control-routing-paths.ts b/src/app/access-control/access-control-routing-paths.ts
index 259aa311e74..31f39f1c47d 100644
--- a/src/app/access-control/access-control-routing-paths.ts
+++ b/src/app/access-control/access-control-routing-paths.ts
@@ -1,12 +1,22 @@
import { URLCombiner } from '../core/url-combiner/url-combiner';
import { getAccessControlModuleRoute } from '../app-routing-paths';
-export const GROUP_EDIT_PATH = 'groups';
+export const EPERSON_PATH = 'epeople';
+
+export function getEPersonsRoute(): string {
+ return new URLCombiner(getAccessControlModuleRoute(), EPERSON_PATH).toString();
+}
+
+export function getEPersonEditRoute(id: string): string {
+ return new URLCombiner(getEPersonsRoute(), id, 'edit').toString();
+}
+
+export const GROUP_PATH = 'groups';
export function getGroupsRoute() {
- return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH).toString();
+ return new URLCombiner(getAccessControlModuleRoute(), GROUP_PATH).toString();
}
export function getGroupEditRoute(id: string) {
- return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH, id).toString();
+ return new URLCombiner(getGroupsRoute(), id, 'edit').toString();
}
diff --git a/src/app/access-control/access-control-routing.module.ts b/src/app/access-control/access-control-routing.module.ts
index 6f6de6cb263..97d049ad836 100644
--- a/src/app/access-control/access-control-routing.module.ts
+++ b/src/app/access-control/access-control-routing.module.ts
@@ -3,7 +3,7 @@ import { RouterModule } from '@angular/router';
import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.component';
import { GroupFormComponent } from './group-registry/group-form/group-form.component';
import { GroupsRegistryComponent } from './group-registry/groups-registry.component';
-import { GROUP_EDIT_PATH } from './access-control-routing-paths';
+import { EPERSON_PATH, GROUP_PATH } from './access-control-routing-paths';
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
import { GroupPageGuard } from './group-registry/group-page.guard';
import {
@@ -13,12 +13,14 @@ import {
SiteAdministratorGuard
} from '../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
import { BulkAccessComponent } from './bulk-access/bulk-access.component';
+import { EPersonFormComponent } from './epeople-registry/eperson-form/eperson-form.component';
+import { EPersonResolver } from './epeople-registry/eperson-resolver.service';
@NgModule({
imports: [
RouterModule.forChild([
{
- path: 'epeople',
+ path: EPERSON_PATH,
component: EPeopleRegistryComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
@@ -27,7 +29,26 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
canActivate: [SiteAdministratorGuard]
},
{
- path: GROUP_EDIT_PATH,
+ path: `${EPERSON_PATH}/create`,
+ component: EPersonFormComponent,
+ resolve: {
+ breadcrumb: I18nBreadcrumbResolver,
+ },
+ data: { title: 'admin.access-control.epeople.add.title', breadcrumbKey: 'admin.access-control.epeople.add' },
+ canActivate: [SiteAdministratorGuard],
+ },
+ {
+ path: `${EPERSON_PATH}/:id/edit`,
+ component: EPersonFormComponent,
+ resolve: {
+ breadcrumb: I18nBreadcrumbResolver,
+ ePerson: EPersonResolver,
+ },
+ data: { title: 'admin.access-control.epeople.edit.title', breadcrumbKey: 'admin.access-control.epeople.edit' },
+ canActivate: [SiteAdministratorGuard],
+ },
+ {
+ path: GROUP_PATH,
component: GroupsRegistryComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
@@ -36,7 +57,7 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
canActivate: [GroupAdministratorGuard]
},
{
- path: `${GROUP_EDIT_PATH}/newGroup`,
+ path: `${GROUP_PATH}/create`,
component: GroupFormComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
@@ -45,7 +66,7 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
canActivate: [GroupAdministratorGuard]
},
{
- path: `${GROUP_EDIT_PATH}/:groupId`,
+ path: `${GROUP_PATH}/:groupId/edit`,
component: GroupFormComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
diff --git a/src/app/access-control/epeople-registry/epeople-registry.component.html b/src/app/access-control/epeople-registry/epeople-registry.component.html
index e3a8e2c590f..4979f858193 100644
--- a/src/app/access-control/epeople-registry/epeople-registry.component.html
+++ b/src/app/access-control/epeople-registry/epeople-registry.component.html
@@ -4,96 +4,91 @@
-
+
-
+
{{labelPrefix + 'search.head' | translate}}
-
-
{{labelPrefix + 'search.head' | translate}}
-
-
-
diff --git a/src/app/access-control/epeople-registry/epeople-registry.component.spec.ts b/src/app/access-control/epeople-registry/epeople-registry.component.spec.ts
index 4a09913862f..e2cee5e9356 100644
--- a/src/app/access-control/epeople-registry/epeople-registry.component.spec.ts
+++ b/src/app/access-control/epeople-registry/epeople-registry.component.spec.ts
@@ -203,36 +203,6 @@ describe('EPeopleRegistryComponent', () => {
});
});
- describe('toggleEditEPerson', () => {
- describe('when you click on first edit eperson button', () => {
- beforeEach(fakeAsync(() => {
- const editButtons = fixture.debugElement.queryAll(By.css('.access-control-editEPersonButton'));
- editButtons[0].triggerEventHandler('click', {
- preventDefault: () => {/**/
- }
- });
- tick();
- fixture.detectChanges();
- }));
-
- it('editEPerson form is toggled', () => {
- const ePeopleIds = fixture.debugElement.queryAll(By.css('#epeople tr td:first-child'));
- ePersonDataServiceStub.getActiveEPerson().subscribe((activeEPerson: EPerson) => {
- if (ePeopleIds[0] && activeEPerson === ePeopleIds[0].nativeElement.textContent) {
- expect(component.isEPersonFormShown).toEqual(false);
- } else {
- expect(component.isEPersonFormShown).toEqual(true);
- }
-
- });
- });
-
- it('EPerson search section is hidden', () => {
- expect(fixture.debugElement.query(By.css('#search'))).toBeNull();
- });
- });
- });
-
describe('deleteEPerson', () => {
describe('when you click on first delete eperson button', () => {
let ePeopleIdsFoundBeforeDelete;
diff --git a/src/app/access-control/epeople-registry/epeople-registry.component.ts b/src/app/access-control/epeople-registry/epeople-registry.component.ts
index fb045ebb883..4596eec98e3 100644
--- a/src/app/access-control/epeople-registry/epeople-registry.component.ts
+++ b/src/app/access-control/epeople-registry/epeople-registry.component.ts
@@ -22,6 +22,7 @@ import { PageInfo } from '../../core/shared/page-info.model';
import { NoContent } from '../../core/shared/NoContent.model';
import { PaginationService } from '../../core/pagination/pagination.service';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
+import { getEPersonEditRoute, getEPersonsRoute } from '../access-control-routing-paths';
@Component({
selector: 'ds-epeople-registry',
@@ -64,11 +65,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
currentPage: 1
});
- /**
- * Whether or not to show the EPerson form
- */
- isEPersonFormShown: boolean;
-
// The search form
searchForm;
@@ -114,17 +110,11 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
*/
initialisePage() {
this.searching$.next(true);
- this.isEPersonFormShown = false;
this.search({scope: this.currentSearchScope, query: this.currentSearchQuery});
- this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
- if (eperson != null && eperson.id) {
- this.isEPersonFormShown = true;
- }
- }));
this.subs.push(this.ePeople$.pipe(
switchMap((epeople: PaginatedList) => {
if (epeople.pageInfo.totalElements > 0) {
- return combineLatest([...epeople.page.map((eperson: EPerson) => {
+ return combineLatest(epeople.page.map((eperson: EPerson) => {
return this.authorizationService.isAuthorized(FeatureID.CanDelete, hasValue(eperson) ? eperson.self : undefined).pipe(
map((authorized) => {
const epersonDtoModel: EpersonDtoModel = new EpersonDtoModel();
@@ -133,7 +123,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
return epersonDtoModel;
})
);
- })]).pipe(map((dtos: EpersonDtoModel[]) => {
+ })).pipe(map((dtos: EpersonDtoModel[]) => {
return buildPaginatedList(epeople.pageInfo, dtos);
}));
} else {
@@ -160,14 +150,14 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
const query: string = data.query;
const scope: string = data.scope;
if (query != null && this.currentSearchQuery !== query) {
- this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
+ void this.router.navigate([getEPersonsRoute()], {
queryParamsHandling: 'merge'
});
this.currentSearchQuery = query;
this.paginationService.resetPage(this.config.id);
}
if (scope != null && this.currentSearchScope !== scope) {
- this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
+ void this.router.navigate([getEPersonsRoute()], {
queryParamsHandling: 'merge'
});
this.currentSearchScope = scope;
@@ -205,23 +195,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
return this.epersonService.getActiveEPerson();
}
- /**
- * Start editing the selected EPerson
- * @param ePerson
- */
- toggleEditEPerson(ePerson: EPerson) {
- this.getActiveEPerson().pipe(take(1)).subscribe((activeEPerson: EPerson) => {
- if (ePerson === activeEPerson) {
- this.epersonService.cancelEditEPerson();
- this.isEPersonFormShown = false;
- } else {
- this.epersonService.editEPerson(ePerson);
- this.isEPersonFormShown = true;
- }
- });
- this.scrollToTop();
- }
-
/**
* Deletes EPerson, show notification on success/failure & updates EPeople list
*/
@@ -242,7 +215,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
if (restResponse.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: this.dsoNameService.getName(ePerson)}));
} else {
- this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + ePerson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
+ this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { id: ePerson.id, statusCode: restResponse.statusCode, errorMessage: restResponse.errorMessage }));
}
});
}
@@ -264,16 +237,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
}
- scrollToTop() {
- (function smoothscroll() {
- const currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
- if (currentScroll > 0) {
- window.requestAnimationFrame(smoothscroll);
- window.scrollTo(0, currentScroll - (currentScroll / 8));
- }
- })();
- }
-
/**
* Reset all input-fields to be empty and search all search
*/
@@ -284,20 +247,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
this.search({query: ''});
}
- /**
- * This method will set everything to stale, which will cause the lists on this page to update.
- */
- reset(): void {
- this.epersonService.getBrowseEndpoint().pipe(
- take(1),
- switchMap((href: string) => {
- return this.requestService.setStaleByHrefSubstring(href).pipe(
- take(1),
- );
- })
- ).subscribe(()=>{
- this.epersonService.cancelEditEPerson();
- this.isEPersonFormShown = false;
- });
+ getEditEPeoplePage(id: string): string {
+ return getEPersonEditRoute(id);
}
}
diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
index 3aa488b4953..6a7b8b931ff 100644
--- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
+++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
@@ -1,89 +1,97 @@
-
+