Skip to content

Commit 7f3b0fc

Browse files
committed
[DURACOM-327] Reorganize code to remove dependency between core and app classes
1 parent 4c4a948 commit 7f3b0fc

10 files changed

Lines changed: 35 additions & 24 deletions

File tree

src/app/access-control/access-control-routing-paths.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import { Group } from '@dspace/core/eperson/models/group.model';
12
import { URLCombiner } from '@dspace/core/url-combiner/url-combiner';
23

3-
import { getAccessControlModuleRoute } from '../app-routing-paths';
4-
54
export const EPERSON_PATH = 'epeople';
65

6+
export const ACCESS_CONTROL_MODULE_PATH = 'access-control';
7+
8+
export function getAccessControlModuleRoute() {
9+
return `/${ACCESS_CONTROL_MODULE_PATH}`;
10+
}
11+
712
export function getEPersonsRoute(): string {
813
return new URLCombiner(getAccessControlModuleRoute(), EPERSON_PATH).toString();
914
}
@@ -21,3 +26,11 @@ export function getGroupsRoute() {
2126
export function getGroupEditRoute(id: string) {
2227
return new URLCombiner(getGroupsRoute(), id, 'edit').toString();
2328
}
29+
30+
/**
31+
* Get Edit page of group
32+
* @param group Group we want edit page for
33+
*/
34+
export function getGroupEditPageRouterLink(group: Group): string {
35+
return getGroupEditRoute(group.id);
36+
}

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
8282
<td class="align-middle">{{group.id}}</td>
8383
<td class="align-middle">
8484
<a (click)="groupRegistryService.startEditingNewGroup(group)"
85-
[routerLink]="[groupsDataService.getGroupEditPageRouterLink(group)]">
85+
[routerLink]="[getGroupEditPageRouterLink(group)]">
8686
{{ dsoNameService.getName(group) }}
8787
</a>
8888
</td>

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ import { FormComponent } from '../../../shared/form/form.component';
7171
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
7272
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
7373
import { HasNoValuePipe } from '../../../shared/utils/has-no-value.pipe';
74-
import { getEPersonsRoute } from '../../access-control-routing-paths';
74+
import {
75+
getEPersonsRoute,
76+
getGroupEditPageRouterLink,
77+
} from '../../access-control-routing-paths';
7578
import { GroupRegistryService } from '../../group-registry/group-registry.service';
7679
import { EpeopleRegistryService } from '../epeople-registry.service';
7780
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
@@ -238,6 +241,8 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
238241
*/
239242
emailValueChangeSubscribe: Subscription;
240243

244+
protected readonly getGroupEditPageRouterLink = getGroupEditPageRouterLink;
245+
241246
constructor(
242247
protected changeDetectorRef: ChangeDetectorRef,
243248
public epersonService: EPersonDataService,
@@ -636,4 +641,5 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
636641
this.groups$ = this.groupsDataService.findListByHref(eperson._links.groups.href, options);
637642
}));
638643
}
644+
639645
}

src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h4>{{messagePrefix + '.headSubgroups' | translate}}</h4>
2525
<td class="align-middle">{{group.id}}</td>
2626
<td class="align-middle">
2727
<a (click)="groupRegistryService.startEditingNewGroup(group)"
28-
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">
28+
[routerLink]="[getGroupEditPageRouterLink(group)]">
2929
{{ dsoNameService.getName(group) }}
3030
</a>
3131
</td>
@@ -108,7 +108,7 @@ <h4 id="search" class="border-bottom pb-2">
108108
<td class="align-middle">{{group.id}}</td>
109109
<td class="align-middle">
110110
<a (click)="groupRegistryService.startEditingNewGroup(group)"
111-
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">
111+
[routerLink]="[getGroupEditPageRouterLink(group)]">
112112
{{ dsoNameService.getName(group) }}
113113
</a>
114114
</td>

src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545

4646
import { ContextHelpDirective } from '../../../../shared/context-help.directive';
4747
import { PaginationComponent } from '../../../../shared/pagination/pagination.component';
48+
import { getGroupEditPageRouterLink } from '../../../access-control-routing-paths';
4849
import { GroupRegistryService } from '../../group-registry.service';
4950

5051
/**
@@ -122,6 +123,8 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
122123
// current active group being edited
123124
groupBeingEdited: Group;
124125

126+
protected readonly getGroupEditPageRouterLink = getGroupEditPageRouterLink;
127+
125128
constructor(public groupDataService: GroupDataService,
126129
public groupRegistryService: GroupRegistryService,
127130
private translateService: TranslateService,
@@ -305,4 +308,5 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
305308
});
306309
this.search({ query: '' });
307310
}
311+
308312
}

src/app/access-control/group-registry/groups-registry.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ <h2 id="search" class="border-bottom pb-2">{{messagePrefix + 'search.head' | tra
6565
@switch (groupDto.ableToEdit) {
6666
@case (true) {
6767
<button
68-
[routerLink]="groupService.getGroupEditPageRouterLink(groupDto.group)"
68+
[routerLink]="getGroupEditPageRouterLink(groupDto.group)"
6969
class="btn btn-outline-primary btn-sm btn-edit"
7070
title="{{messagePrefix + 'table.edit.buttons.edit' | translate: {name: dsoNameService.getName(groupDto.group) } }}"
7171
>

src/app/access-control/group-registry/groups-registry.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import { BtnDisabledDirective } from '../../shared/btn-disabled.directive';
6868
import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component';
6969
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
7070
import { PaginationComponent } from '../../shared/pagination/pagination.component';
71+
import { getGroupEditPageRouterLink } from '../access-control-routing-paths';
7172

7273
@Component({
7374
selector: 'ds-groups-registry',
@@ -136,6 +137,8 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
136137
*/
137138
subs: Subscription[] = [];
138139

140+
protected readonly getGroupEditPageRouterLink = getGroupEditPageRouterLink;
141+
139142
constructor(public groupService: GroupDataService,
140143
private ePersonDataService: EPersonDataService,
141144
private dSpaceObjectDataService: DSpaceObjectDataService,
@@ -346,4 +349,5 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
346349
});
347350
}
348351

352+
349353
}

src/app/app-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import {
2323
} from '@dspace/core/router/core-routing-paths';
2424
import { ServerCheckGuard } from '@dspace/core/server-check/server-check.guard';
2525

26+
import { ACCESS_CONTROL_MODULE_PATH } from './access-control/access-control-routing-paths';
2627
import { NOTIFICATIONS_MODULE_PATH } from './admin/admin-routing-paths';
2728
import {
28-
ACCESS_CONTROL_MODULE_PATH,
2929
ADMIN_MODULE_PATH,
3030
FORGOT_PASSWORD_PATH,
3131
HEALTH_PAGE_PATH,

src/app/app-routing-paths.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ export function getInfoModulePath() {
4949
return `/${INFO_MODULE_PATH}`;
5050
}
5151

52-
export const ACCESS_CONTROL_MODULE_PATH = 'access-control';
53-
54-
export function getAccessControlModuleRoute() {
55-
return `/${ACCESS_CONTROL_MODULE_PATH}`;
56-
}
57-
5852
export const REQUEST_COPY_MODULE_PATH = 'request-a-copy';
5953
export function getRequestCopyModulePath() {
6054
return `/${REQUEST_COPY_MODULE_PATH}`;

src/app/core/eperson/group-data.service.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from 'rxjs';
99
import { take } from 'rxjs/operators';
1010

11-
import { getGroupEditRoute } from '../../access-control/access-control-routing-paths';
1211
import { DSONameService } from '../breadcrumbs/dso-name.service';
1312
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
1413
import { RequestParam } from '../cache/models/request-param.model';
@@ -237,15 +236,6 @@ export class GroupDataService extends IdentifiableDataService<Group> implements
237236
return '/access-control/groups';
238237
}
239238

240-
/**
241-
* Get Edit page of group
242-
* @param group Group we want edit page for
243-
*/
244-
public getGroupEditPageRouterLink(group: Group): string {
245-
return getGroupEditRoute(group.id);
246-
}
247-
248-
249239
/**
250240
* Extract optional UUID from a string
251241
* @param stringWithUUID String with possible UUID

0 commit comments

Comments
 (0)