0"
- [paginationOptions]="config"
- [pageInfoState]="(groups | async)?.payload"
- [collectionSize]="(groups | async)?.payload?.totalElements"
+ 0"
+ [paginationOptions]="configSearch"
+ [pageInfoState]="(groupsSearch | async)?.payload"
+ [collectionSize]="(groupsSearch | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
- (pageChange)="onPageChange($event)">
+ (pageChange)="onPageChangeSearch($event)">
-
+
{{messagePrefix + '.table.id' | translate}}
@@ -33,7 +36,7 @@
-
+
{{group.id}}
{{group.name}}
@@ -41,14 +44,14 @@
@@ -58,19 +61,55 @@
-
-
- {{messagePrefix + '.no-subgroups-yet' | translate}}
- {{messagePrefix + '.button.see-all' | translate}}
-
-
-
{{messagePrefix + '.no-items' | translate}}
+ {{messagePrefix + '.headSubgroups' | translate}}
+
+ 0"
+ [paginationOptions]="config"
+ [pageInfoState]="(subgroupsOfGroup | async)?.payload"
+ [collectionSize]="(subgroupsOfGroup | async)?.payload?.totalElements"
+ [hideGear]="true"
+ [hidePagerWhenSinglePage]="true"
+ (pageChange)="onPageChange($event)">
+
+
+
+
+
+ {{messagePrefix + '.table.id' | translate}}
+ {{messagePrefix + '.table.name' | translate}}
+ {{messagePrefix + '.table.edit' | translate}}
+
+
+
+
+ {{group.id}}
+ {{group.name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{messagePrefix + '.no-subgroups-yet' | translate}}
+
+
diff --git a/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts b/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts
index 367f3c050f..4bd088b513 100644
--- a/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts
+++ b/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts
@@ -1,8 +1,9 @@
import { CommonModule } from '@angular/common';
import { NO_ERRORS_SCHEMA } from '@angular/core';
-import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
+import { async, ComponentFixture, fakeAsync, flush, inject, TestBed, tick } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule, By } from '@angular/platform-browser';
+import { Router } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs/internal/Observable';
@@ -14,6 +15,7 @@ import { Group } from '../../../../../core/eperson/models/group.model';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service';
import { getMockFormBuilderService } from '../../../../../shared/mocks/mock-form-builder-service';
+import { MockRouter } from '../../../../../shared/mocks/mock-router';
import { getMockTranslateService } from '../../../../../shared/mocks/mock-translate.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { GroupMock, GroupMock2 } from '../../../../../shared/testing/group-mock';
@@ -31,19 +33,26 @@ describe('SubgroupsListComponent', () => {
let ePersonDataServiceStub: any;
let groupsDataServiceStub: any;
let activeGroup;
+ let subgroups;
let allGroups;
+ let routerStub;
beforeEach(async(() => {
activeGroup = GroupMock;
- allGroups = [GroupMock, GroupMock2]
+ subgroups = [GroupMock2];
+ allGroups = [GroupMock, GroupMock2];
ePersonDataServiceStub = {};
groupsDataServiceStub = {
activeGroup: activeGroup,
+ subgroups: subgroups,
getActiveGroup(): Observable {
return observableOf(this.activeGroup);
},
+ getSubgroups(): Group {
+ return this.activeGroup;
+ },
findAllByHref(href: string): Observable>> {
- return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), this.activeGroup.subgroups))
+ return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), this.subgroups))
},
getGroupEditPageRouterLink(group: Group): string {
return '/admin/access-control/groups/' + group.id;
@@ -55,14 +64,17 @@ describe('SubgroupsListComponent', () => {
return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), []))
},
addSubGroupToGroup(parentGroup, subgroup: Group): Observable {
- this.activeGroup.subgroups = [...this.activeGroup.subgroups, subgroup];
+ this.subgroups = [...this.subgroups, subgroup];
return observableOf(new RestResponse(true, 200, 'Success'));
},
clearGroupsRequests() {
// empty
},
- deleteSubGroupFromGroup(parentGroup, subgroup: Group): Observable {
- this.activeGroup.subgroups = this.activeGroup.subgroups.find((group: Group) => {
+ clearGroupLinkRequests() {
+ // empty
+ },
+ deleteSubGroupFromGroup(parentGroup, subgroup: Group): Observable {
+ this.subgroups = this.subgroups.find((group: Group) => {
if (group.id !== subgroup.id) {
return group;
}
@@ -70,6 +82,7 @@ describe('SubgroupsListComponent', () => {
return observableOf(new RestResponse(true, 200, 'Success'));
}
};
+ routerStub = new MockRouter();
builderService = getMockFormBuilderService();
translateService = getMockTranslateService();
TestBed.configureTestingModule({
@@ -86,6 +99,7 @@ describe('SubgroupsListComponent', () => {
{ provide: GroupDataService, useValue: groupsDataServiceStub },
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
{ provide: FormBuilderService, useValue: builderService },
+ { provide: Router, useValue: routerStub },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
@@ -96,13 +110,18 @@ describe('SubgroupsListComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
});
+ afterEach(fakeAsync(() => {
+ fixture.destroy();
+ flush();
+ component = null;
+ }));
it('should create SubgroupsListComponent', inject([SubgroupsListComponent], (comp: SubgroupsListComponent) => {
expect(comp).toBeDefined();
}));
it('should show list of subgroups of current active group', () => {
- const groupIdsFound = fixture.debugElement.queryAll(By.css('#groups tr td:first-child'));
+ const groupIdsFound = fixture.debugElement.queryAll(By.css('#subgroupsOfGroup tr td:first-child'));
expect(groupIdsFound.length).toEqual(1);
activeGroup.subgroups.map((group: Group) => {
expect(groupIdsFound.find((foundEl) => {
@@ -111,64 +130,76 @@ describe('SubgroupsListComponent', () => {
})
});
+ describe('if first group delete button is pressed', () => {
+ let groupsFound;
+ beforeEach(fakeAsync(() => {
+ const addButton = fixture.debugElement.query(By.css('#subgroupsOfGroup tbody .deleteButton'));
+ addButton.triggerEventHandler('click', {
+ preventDefault: () => {/**/
+ }
+ });
+ tick();
+ fixture.detectChanges();
+ }));
+ it('one less subgroup in list from 1 to 0 (of 2 total groups)', () => {
+ groupsFound = fixture.debugElement.queryAll(By.css('#subgroupsOfGroup tbody tr'));
+ expect(groupsFound.length).toEqual(0);
+ });
+ });
+
describe('search', () => {
- describe('when searching without query', () => {
+ describe('when searching with empty query', () => {
let groupsFound;
beforeEach(fakeAsync(() => {
component.search({ query: '' });
- tick();
- fixture.detectChanges();
- groupsFound = fixture.debugElement.queryAll(By.css('#groups tbody tr'));
+ groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr'));
}));
it('should display all groups', () => {
+ fixture.detectChanges();
+ groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr'));
expect(groupsFound.length).toEqual(2);
+ groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr'));
+ const groupIdsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr td:first-child'));
+ allGroups.map((group: Group) => {
+ expect(groupIdsFound.find((foundEl) => {
+ return (foundEl.nativeElement.textContent.trim() === group.uuid);
+ })).toBeTruthy();
+ })
});
describe('if group is already a subgroup', () => {
it('should have delete button, else it should have add button', () => {
- activeGroup.subgroups.map((group: Group) => {
+ fixture.detectChanges();
+ groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr'));
+ const getSubgroups = groupsDataServiceStub.getSubgroups().subgroups;
+ if (getSubgroups !== undefined && getSubgroups.length > 0) {
groupsFound.map((foundGroupRowElement) => {
if (foundGroupRowElement.debugElement !== undefined) {
- const groupId = foundGroupRowElement.debugElement.query(By.css('td:first-child'));
const addButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-plus'));
const deleteButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt'));
- if (groupId.nativeElement.textContent === group.id) {
- expect(addButton).toBeUndefined();
- expect(deleteButton).toBeDefined();
- } else {
- expect(deleteButton).toBeUndefined();
- expect(addButton).toBeDefined();
- }
+ expect(addButton).toBeUndefined();
+ expect(deleteButton).toBeDefined();
}
})
- })
- });
- });
-
- describe('if first add button is pressed', () => {
- beforeEach(fakeAsync(() => {
- const addButton = fixture.debugElement.query(By.css('#groups tbody .fa-plus'));
- addButton.nativeElement.click();
- tick();
- fixture.detectChanges();
- }));
- it('one more subgroup in list (from 1 to 2 total groups)', () => {
- groupsFound = fixture.debugElement.queryAll(By.css('#groups tbody tr'));
- expect(groupsFound.length).toEqual(2);
- });
- });
-
- describe('if first delete button is pressed', () => {
- beforeEach(fakeAsync(() => {
- const addButton = fixture.debugElement.query(By.css('#groups tbody .fa-trash-alt'));
- addButton.nativeElement.click();
- tick();
- fixture.detectChanges();
- }));
- it('one less subgroup in list from 1 to 0 (of 2 total groups)', () => {
- groupsFound = fixture.debugElement.queryAll(By.css('#groups tbody tr'));
- expect(groupsFound.length).toEqual(0);
+ } else {
+ getSubgroups.map((group: Group) => {
+ groupsFound.map((foundGroupRowElement) => {
+ if (foundGroupRowElement.debugElement !== undefined) {
+ const groupId = foundGroupRowElement.debugElement.query(By.css('td:first-child'));
+ const addButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-plus'));
+ const deleteButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt'));
+ if (groupId.nativeElement.textContent === group.id) {
+ expect(addButton).toBeUndefined();
+ expect(deleteButton).toBeDefined();
+ } else {
+ expect(deleteButton).toBeUndefined();
+ expect(addButton).toBeDefined();
+ }
+ }
+ })
+ })
+ }
});
});
});
diff --git a/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts b/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts
index da23061219..09d38c7c3e 100644
--- a/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts
+++ b/src/app/+admin/admin-access-control/group-registry/group-form/subgroup-list/subgroups-list.component.ts
@@ -1,5 +1,6 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
+import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable, of as observableOf, Subscription } from 'rxjs';
import { map, mergeMap, take } from 'rxjs/operators';
@@ -12,7 +13,6 @@ import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../../cor
import { hasValue } from '../../../../../shared/empty.util';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { PaginationComponentOptions } from '../../../../../shared/pagination/pagination-component-options.model';
-import { followLink } from '../../../../../shared/utils/follow-link-config.model';
@Component({
selector: 'ds-subgroups-list',
@@ -27,9 +27,13 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
messagePrefix: string;
/**
- * Groups being displayed, initially all subgroups, after search result of search
+ * Result of search groups, initially all groups
*/
- groups: Observable>>;
+ groupsSearch: Observable>>;
+ /**
+ * List of all subgroups of group being edited
+ */
+ subgroupsOfGroup: Observable>>;
/**
* List of subscriptions
@@ -37,7 +41,15 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
subs: Subscription[] = [];
/**
- * Pagination config used to display the list of subgroups
+ * Pagination config used to display the list of groups that are result of groups search
+ */
+ configSearch: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
+ id: 'search-subgroups-list-pagination',
+ pageSize: 5,
+ currentPage: 1
+ });
+ /**
+ * Pagination config used to display the list of subgroups of currently active group being edited
*/
config: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'subgroups-list-pagination',
@@ -48,50 +60,55 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
// The search form
searchForm;
- /**
- * Whether or not user has done a search yet
- */
+ // Current search in edit group - groups search form
+ currentSearchQuery: string;
+
+ // Whether or not user has done a Groups search yet
searchDone: boolean;
+ // current active group being edited
+ groupBeingEdited: Group;
+
constructor(public groupDataService: GroupDataService,
private translateService: TranslateService,
private notificationsService: NotificationsService,
- private formBuilder: FormBuilder) {
+ private formBuilder: FormBuilder,
+ private router: Router) {
+ this.currentSearchQuery = '';
}
ngOnInit() {
- this.subs.push(this.groupDataService.getActiveGroup().subscribe((group: Group) => {
- if (group != null) {
- this.groups = this.groupDataService.findAllByHref(group._links.subgroups.href, {
- currentPage: 1,
- elementsPerPage: this.config.pageSize
- })
- }
- }));
this.searchForm = this.formBuilder.group(({
query: '',
}));
- this.searchDone = false;
+ this.subs.push(this.groupDataService.getActiveGroup().subscribe((activeGroup: Group) => {
+ if (activeGroup != null) {
+ this.groupBeingEdited = activeGroup;
+ this.forceUpdateGroups(activeGroup);
+ }
+ }));
}
/**
- * Event triggered when the user changes page
+ * Event triggered when the user changes page on search result
+ * @param event
+ */
+ onPageChangeSearch(event) {
+ this.configSearch.currentPage = event;
+ this.search({ query: this.currentSearchQuery });
+ }
+
+ /**
+ * Event triggered when the user changes page on subgroups of active group
* @param event
*/
onPageChange(event) {
- this.updateSubgroups({
+ this.subgroupsOfGroup = this.groupDataService.findAllByHref(this.groupBeingEdited._links.subgroups.href, {
currentPage: event,
elementsPerPage: this.config.pageSize
});
}
- /**
- * Update the list of subgroups by fetching it from the rest api or cache
- */
- private updateSubgroups(options) {
- this.groups = this.groupDataService.getGroups(options);
- }
-
/**
* Whether or not the given group is a subgroup of the group currently being edited
* @param possibleSubgroup Group that is a possible subgroup (being tested) of the group currently being edited
@@ -152,22 +169,28 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
* @param data Contains query param
*/
search(data: any) {
- this.searchDone = true;
const query: string = data.query;
- this.groups = this.groupDataService.searchGroups(query.trim(), {
- currentPage: 1,
- elementsPerPage: this.config.pageSize
+ if (query != null && this.currentSearchQuery !== query) {
+ this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLink(this.groupBeingEdited));
+ this.currentSearchQuery = query;
+ this.configSearch.currentPage = 1;
+ }
+ this.searchDone = true;
+ this.groupsSearch = this.groupDataService.searchGroups(this.currentSearchQuery, {
+ currentPage: this.configSearch.currentPage,
+ elementsPerPage: this.configSearch.pageSize
});
}
/**
- * Force-update the list of groups by first clearing the cache related to groups, then performing a new REST call
+ * Force-update the list of groups by first clearing the cache of results of this active groups' subgroups, then performing a new REST call
* @param activeGroup Group currently being edited
*/
public forceUpdateGroups(activeGroup: Group) {
- this.groupDataService.clearGroupsRequests();
- this.groups = this.groupDataService.findAllByHref(activeGroup._links.subgroups.href, {
- currentPage: 1,
+ this.groupDataService.clearGroupLinkRequests(activeGroup._links.subgroups.href);
+ this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLink(activeGroup));
+ this.subgroupsOfGroup = this.groupDataService.findAllByHref(activeGroup._links.subgroups.href, {
+ currentPage: this.config.currentPage,
elementsPerPage: this.config.pageSize
});
}
@@ -195,4 +218,14 @@ export class SubgroupsListComponent implements OnInit, OnDestroy {
}
})
}
+
+ /**
+ * Reset all input-fields to be empty and search all search
+ */
+ clearFormAndResetResult() {
+ this.searchForm.patchValue({
+ query: '',
+ });
+ this.search({ query: '' });
+ }
}
diff --git a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.html b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.html
index d0cde805c0..3bd7d7ac4f 100644
--- a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.html
+++ b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.html
@@ -12,7 +12,10 @@
- {{messagePrefix + 'search.head' | translate}}
+ {{messagePrefix + 'search.head' | translate}}
+ {{messagePrefix + 'button.see-all' | translate}}
+
-
diff --git a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts
index ea2fee72b5..7dff4f9bd1 100644
--- a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts
+++ b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts
@@ -3,6 +3,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule, By } from '@angular/platform-browser';
+import { Router } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs/internal/Observable';
@@ -12,12 +13,15 @@ import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { EPerson } from '../../../core/eperson/models/eperson.model';
import { Group } from '../../../core/eperson/models/group.model';
+import { RouteService } from '../../../core/services/route.service';
import { PageInfo } from '../../../core/shared/page-info.model';
+import { MockRouter } from '../../../shared/mocks/mock-router';
import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { EPersonMock, EPersonMock2 } from '../../../shared/testing/eperson-mock';
import { GroupMock, GroupMock2 } from '../../../shared/testing/group-mock';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
+import { routeServiceStub } from '../../../shared/testing/route-service-stub';
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
import { GroupsRegistryComponent } from './groups-registry.component';
@@ -47,9 +51,6 @@ describe('GroupRegistryComponent', () => {
};
groupsDataServiceStub = {
allGroups: mockGroups,
- getGroups(): Observable>> {
- return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allGroups));
- },
findAllByHref(href: string): Observable>> {
switch (href) {
case 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/groups':
@@ -63,7 +64,13 @@ describe('GroupRegistryComponent', () => {
getGroupEditPageRouterLink(group: Group): string {
return '/admin/access-control/groups/' + group.id;
},
+ getGroupRegistryRouterLink(): string {
+ return '/admin/access-control/groups';
+ },
searchGroups(query: string): Observable>> {
+ if (query === '') {
+ return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allGroups));
+ }
const result = this.allGroups.find((group: Group) => {
return (group.id.includes(query))
});
@@ -84,6 +91,8 @@ describe('GroupRegistryComponent', () => {
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
{ provide: GroupDataService, useValue: groupsDataServiceStub },
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
+ { provide: RouteService, useValue: routeServiceStub },
+ { provide: Router, useValue: new MockRouter() },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
diff --git a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.ts b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.ts
index 660591478d..07a000f3f6 100644
--- a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.ts
+++ b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
+import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
@@ -9,10 +10,10 @@ import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { EPerson } from '../../../core/eperson/models/eperson.model';
import { Group } from '../../../core/eperson/models/group.model';
+import { RouteService } from '../../../core/services/route.service';
import { hasValue } from '../../../shared/empty.util';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
-import { followLink } from '../../../shared/utils/follow-link-config.model';
@Component({
selector: 'ds-groups-registry',
@@ -43,21 +44,24 @@ export class GroupsRegistryComponent implements OnInit {
// The search form
searchForm;
+ // Current search in groups registry
+ currentSearchQuery: string;
+
constructor(private groupService: GroupDataService,
private ePersonDataService: EPersonDataService,
private translateService: TranslateService,
private notificationsService: NotificationsService,
- private formBuilder: FormBuilder) {
+ private formBuilder: FormBuilder,
+ protected routeService: RouteService,
+ private router: Router) {
+ this.currentSearchQuery = '';
this.searchForm = this.formBuilder.group(({
- query: '',
+ query: this.currentSearchQuery,
}));
}
ngOnInit() {
- this.updateGroups({
- currentPage: 1,
- elementsPerPage: this.config.pageSize
- });
+ this.search({ query: this.currentSearchQuery });
}
/**
@@ -65,17 +69,8 @@ export class GroupsRegistryComponent implements OnInit {
* @param event
*/
onPageChange(event) {
- this.updateGroups({
- currentPage: event,
- elementsPerPage: this.config.pageSize
- });
- }
-
- /**
- * Update the list of groups by fetching it from the rest api or cache
- */
- private updateGroups(options) {
- this.groups = this.groupService.getGroups(options, followLink('epersons'), followLink('subgroups'));
+ this.config.currentPage = event;
+ this.search({ query: this.currentSearchQuery })
}
/**
@@ -84,8 +79,13 @@ export class GroupsRegistryComponent implements OnInit {
*/
search(data: any) {
const query: string = data.query;
- this.groups = this.groupService.searchGroups(query.trim(), {
- currentPage: 1,
+ if (query != null && this.currentSearchQuery !== query) {
+ this.router.navigateByUrl(this.groupService.getGroupRegistryRouterLink());
+ this.currentSearchQuery = query;
+ this.config.currentPage = 1;
+ }
+ this.groups = this.groupService.searchGroups(this.currentSearchQuery.trim(), {
+ currentPage: this.config.currentPage,
elementsPerPage: this.config.pageSize
});
}
@@ -114,7 +114,7 @@ export class GroupsRegistryComponent implements OnInit {
*/
public forceUpdateGroup() {
this.groupService.clearGroupsRequests();
- this.search({ query: '' })
+ this.search({ query: this.currentSearchQuery })
}
/**
@@ -133,6 +133,16 @@ export class GroupsRegistryComponent implements OnInit {
return this.groupService.findAllByHref(group._links.subgroups.href);
}
+ /**
+ * Reset all input-fields to be empty and search all search
+ */
+ clearFormAndResetResult() {
+ this.searchForm.patchValue({
+ query: '',
+ });
+ this.search({ query: '' });
+ }
+
/**
* Extract optional UUID from a group name => To be resolved to community or collection with link
* (Or will be resolved in backend and added to group object, tbd) //TODO
diff --git a/src/app/core/cache/object-cache.service.ts b/src/app/core/cache/object-cache.service.ts
index 036c9f0ed8..d82a1f31fe 100644
--- a/src/app/core/cache/object-cache.service.ts
+++ b/src/app/core/cache/object-cache.service.ts
@@ -276,8 +276,6 @@ export class ObjectCacheService {
* list of operations to perform
*/
public addPatch(selfLink: string, patch: Operation[]) {
- console.log('selfLink addPatch', selfLink)
- console.log('patch addPatch', patch)
this.store.dispatch(new AddPatchObjectCacheAction(selfLink, patch));
this.store.dispatch(new AddToSSBAction(selfLink, RestRequestMethod.PATCH));
}
diff --git a/src/app/core/eperson/eperson-data.service.ts b/src/app/core/eperson/eperson-data.service.ts
index 964f447ff8..a8cee6f1de 100644
--- a/src/app/core/eperson/eperson-data.service.ts
+++ b/src/app/core/eperson/eperson-data.service.ts
@@ -181,7 +181,7 @@ export class EPersonDataService extends DataService {
}
/**
- * Method that clears a cached EPerson request and returns its REST url
+ * Method that clears a cached EPerson request
*/
public clearEPersonRequests(): void {
this.getBrowseEndpoint().pipe(take(1)).subscribe((link: string) => {
@@ -189,6 +189,13 @@ export class EPersonDataService extends DataService {
});
}
+ /**
+ * Method that clears a link's requests in cache
+ */
+ public clearLinkRequests(href: string): void {
+ this.requestService.removeByHrefSubstring(href);
+ }
+
/**
* Method to retrieve the eperson that is currently being edited
*/
diff --git a/src/app/core/eperson/group-data.service.ts b/src/app/core/eperson/group-data.service.ts
index be8006f392..3776a382a6 100644
--- a/src/app/core/eperson/group-data.service.ts
+++ b/src/app/core/eperson/group-data.service.ts
@@ -246,7 +246,7 @@ export class GroupDataService extends DataService {
}
/**
- * Method that clears a cached groups request and returns its REST url
+ * Method that clears a cached groups request
*/
public clearGroupsRequests(): void {
this.getBrowseEndpoint().pipe(take(1)).subscribe((link: string) => {
@@ -254,6 +254,13 @@ export class GroupDataService extends DataService {
});
}
+ /**
+ * Method that clears a cached get subgroups of certain group request
+ */
+ public clearGroupLinkRequests(href: string): void {
+ this.requestService.removeByHrefSubstring(href);
+ }
+
public getGroupRegistryRouterLink(): string {
return '/admin/access-control/groups';
}
diff --git a/src/app/shared/testing/group-mock.ts b/src/app/shared/testing/group-mock.ts
index 9b91296195..00068a5eea 100644
--- a/src/app/shared/testing/group-mock.ts
+++ b/src/app/shared/testing/group-mock.ts
@@ -2,35 +2,37 @@ import { Group } from '../../core/eperson/models/group.model';
import { EPersonMock } from './eperson-mock';
export const GroupMock2: Group = Object.assign(new Group(), {
- handle: null,
- subgroups: [],
- epersons: [],
- selfRegistered: false,
- _links: {
- self: {
- href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2',
+ handle: null,
+ subgroups: [],
+ epersons: [],
+ permanent: true,
+ selfRegistered: false,
+ _links: {
+ self: {
+ href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2',
+ },
+ subgroups: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/subgroups' },
+ epersons: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/epersons' }
},
- subgroups: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/subgroups' },
- epersons: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/epersons' }
- },
- id: 'testgroupid2',
- uuid: 'testgroupid2',
- type: 'group',
+ id: 'testgroupid2',
+ uuid: 'testgroupid2',
+ type: 'group',
});
export const GroupMock: Group = Object.assign(new Group(), {
- handle: null,
- subgroups: [GroupMock2],
- epersons: [EPersonMock],
- selfRegistered: false,
- _links: {
- self: {
- href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid',
+ handle: null,
+ subgroups: [GroupMock2],
+ epersons: [EPersonMock],
+ selfRegistered: false,
+ permanent: false,
+ _links: {
+ self: {
+ href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid',
+ },
+ subgroups: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/subgroups' },
+ epersons: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/epersons' }
},
- subgroups: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/subgroups' },
- epersons: { href: 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/epersons' }
- },
- id: 'testgroupid',
- uuid: 'testgroupid',
- type: 'group',
+ id: 'testgroupid',
+ uuid: 'testgroupid',
+ type: 'group',
});