74179: Delete group cache cleared, redirect & delete button moved on group edit page

This commit is contained in:
Marie Verdonck
2020-10-23 17:14:40 +02:00
parent e3578a6b0f
commit f8a8af32da
3 changed files with 20 additions and 13 deletions

View File

@@ -9,11 +9,6 @@
</ng-template>
<ng-template #editheader>
<div>
<button class="btn btn-light delete-button float-right" [disabled]="!(canDelete$ | async)" (click)="delete()">
<i class="fa fa-trash"></i> {{ messagePrefix + '.actions.delete' | translate}}
</button>
</div>
<h2 class="border-bottom pb-2">{{messagePrefix + '.head.edit' | translate}}</h2>
</ng-template>
@@ -23,6 +18,9 @@
[formLayout]="formLayout"
(cancel)="onCancel()"
(submitForm)="onSubmit()">
<button class="btn btn-light delete-button" [disabled]="!(canDelete$ | async)" (click)="delete()">
<i class="fa fa-trash"></i> {{ messagePrefix + '.actions.delete' | translate}}
</button>
</ds-form>
<ds-members-list *ngIf="groupBeingEdited != null" [messagePrefix]="messagePrefix + '.members-list'"></ds-members-list>

View File

@@ -214,6 +214,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
if (isNotEmpty(resp.resourceSelfLinks)) {
const groupSelfLink = resp.resourceSelfLinks[0];
this.setActiveGroupWithLink(groupSelfLink);
this.groupDataService.clearGroupsRequests();
this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLinkWithID(this.groupDataService.getUUIDFromString(groupSelfLink)));
}
} else {
@@ -333,7 +334,6 @@ export class GroupFormComponent implements OnInit, OnDestroy {
if (success) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: group.name }));
this.reset();
this.onCancel();
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: group.name }),
@@ -352,7 +352,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((group: Group) => {
this.requestService.removeByHrefSubstring(group.self);
});
this.initialisePage();
this.onCancel();
}
/**

View File

@@ -3,12 +3,14 @@ import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { filter } from 'rxjs/internal/operators/filter';
import { Subscription } from 'rxjs/internal/Subscription';
import { map, switchMap, take } from 'rxjs/operators';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
import { PaginatedList } from '../../../core/data/paginated-list';
import { RemoteData } from '../../../core/data/remote-data';
import { RequestService } from '../../../core/data/request.service';
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { GroupDataService } from '../../../core/eperson/group-data.service';
import { EPerson } from '../../../core/eperson/models/eperson.model';
@@ -75,7 +77,8 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
private formBuilder: FormBuilder,
protected routeService: RouteService,
private router: Router,
private authorizationService: AuthorizationDataService) {
private authorizationService: AuthorizationDataService,
public requestService: RequestService) {
this.currentSearchQuery = '';
this.searchForm = this.formBuilder.group(({
query: this.currentSearchQuery,
@@ -145,7 +148,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
.subscribe(([success, optionalErrorMessage]: [boolean, string]) => {
if (success) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: group.name }));
this.forceUpdateGroup();
this.reset();
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: group.name }),
@@ -156,11 +159,17 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
}
/**
* Force-update the list of groups by first clearing the cache related to groups, then performing a new REST call
* This method will ensure that the page gets reset and that the cache is cleared
*/
public forceUpdateGroup() {
this.groupService.clearGroupsRequests();
this.search({ query: this.currentSearchQuery })
reset() {
this.groupService.getBrowseEndpoint().pipe(
switchMap((href) => this.requestService.removeByHrefSubstring(href)),
filter((isCached) => isCached),
take(1)
).subscribe(() => {
this.cleanupSubscribes();
this.search({ query: this.currentSearchQuery });
});
}
/**