Skip to content

Commit

Permalink
Merge pull request #2652 from alexandrevryghem/deslect-metadata-field…
Browse files Browse the repository at this point in the history
…s-from-different-shemas_contribute-main

Deselect all metadata fields when switching between metadata schemas in registry
  • Loading branch information
alanorth authored Nov 23, 2023
2 parents 7e2f23a + ecca828 commit 727df56
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 727df56

Please sign in to comment.