Skip to content

Commit

Permalink
Merge pull request DSpace#2659 from DSpace/backport-2652-to-dspace-7_x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] Deselect all metadata fields when switching between metadata schemas in registry
  • Loading branch information
alanorth authored Nov 23, 2023
2 parents 6758b4c + c3f424d commit 714652e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { RegistryService } from '../../../core/registry/registry.service';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import {
BehaviorSubject,
combineLatest as observableCombineLatest,
Expand Down Expand Up @@ -32,7 +32,7 @@ import { PaginationService } from '../../../core/pagination/pagination.service';
* A component used for managing all existing metadata fields within the current metadata schema.
* The admin can create, edit or delete metadata fields here.
*/
export class MetadataSchemaComponent implements OnInit {
export class MetadataSchemaComponent implements OnInit, OnDestroy {
/**
* The metadata schema
*/
Expand Down Expand Up @@ -60,7 +60,6 @@ export class MetadataSchemaComponent implements OnInit {
constructor(private registryService: RegistryService,
private route: ActivatedRoute,
private notificationsService: NotificationsService,
private router: Router,
private paginationService: PaginationService,
private translateService: TranslateService) {

Expand All @@ -86,7 +85,7 @@ export class MetadataSchemaComponent implements OnInit {
*/
private updateFields() {
this.metadataFields$ = this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
switchMap((currentPagination) => combineLatest(this.metadataSchema$, this.needsUpdate$, observableOf(currentPagination))),
switchMap((currentPagination) => combineLatest([this.metadataSchema$, this.needsUpdate$, observableOf(currentPagination)])),
switchMap(([schema, update, currentPagination]: [MetadataSchema, boolean, PaginationComponentOptions]) => {
if (update) {
this.needsUpdate$.next(false);
Expand Down Expand Up @@ -193,10 +192,10 @@ export class MetadataSchemaComponent implements OnInit {
showNotification(success: boolean, amount: number) {
const prefix = 'admin.registries.schema.notification';
const suffix = success ? 'success' : 'failure';
const messages = observableCombineLatest(
const messages = observableCombineLatest([
this.translateService.get(success ? `${prefix}.${suffix}` : `${prefix}.${suffix}`),
this.translateService.get(`${prefix}.field.deleted.${suffix}`, { amount: amount })
);
]);
messages.subscribe(([head, content]) => {
if (success) {
this.notificationsService.success(head, content);
Expand All @@ -207,6 +206,7 @@ export class MetadataSchemaComponent implements OnInit {
}
ngOnDestroy(): void {
this.paginationService.clearPagination(this.config.id);
this.registryService.deselectAllMetadataField();
}

}

0 comments on commit 714652e

Please sign in to comment.