1- import { Component , OnInit } from '@angular/core' ;
1+ import { Component , OnInit , OnDestroy } from '@angular/core' ;
22import { RegistryService } from '../../../core/registry/registry.service' ;
3- import { ActivatedRoute , Router } from '@angular/router' ;
3+ import { ActivatedRoute } from '@angular/router' ;
44import {
55 BehaviorSubject ,
66 combineLatest as observableCombineLatest ,
@@ -32,7 +32,7 @@ import { PaginationService } from '../../../core/pagination/pagination.service';
3232 * A component used for managing all existing metadata fields within the current metadata schema.
3333 * The admin can create, edit or delete metadata fields here.
3434 */
35- export class MetadataSchemaComponent implements OnInit {
35+ export class MetadataSchemaComponent implements OnInit , OnDestroy {
3636 /**
3737 * The metadata schema
3838 */
@@ -60,7 +60,6 @@ export class MetadataSchemaComponent implements OnInit {
6060 constructor ( private registryService : RegistryService ,
6161 private route : ActivatedRoute ,
6262 private notificationsService : NotificationsService ,
63- private router : Router ,
6463 private paginationService : PaginationService ,
6564 private translateService : TranslateService ) {
6665
@@ -86,7 +85,7 @@ export class MetadataSchemaComponent implements OnInit {
8685 */
8786 private updateFields ( ) {
8887 this . metadataFields$ = this . paginationService . getCurrentPagination ( this . config . id , this . config ) . pipe (
89- switchMap ( ( currentPagination ) => combineLatest ( this . metadataSchema$ , this . needsUpdate$ , observableOf ( currentPagination ) ) ) ,
88+ switchMap ( ( currentPagination ) => combineLatest ( [ this . metadataSchema$ , this . needsUpdate$ , observableOf ( currentPagination ) ] ) ) ,
9089 switchMap ( ( [ schema , update , currentPagination ] : [ MetadataSchema , boolean , PaginationComponentOptions ] ) => {
9190 if ( update ) {
9291 this . needsUpdate$ . next ( false ) ;
@@ -193,10 +192,10 @@ export class MetadataSchemaComponent implements OnInit {
193192 showNotification ( success : boolean , amount : number ) {
194193 const prefix = 'admin.registries.schema.notification' ;
195194 const suffix = success ? 'success' : 'failure' ;
196- const messages = observableCombineLatest (
195+ const messages = observableCombineLatest ( [
197196 this . translateService . get ( success ? `${ prefix } .${ suffix } ` : `${ prefix } .${ suffix } ` ) ,
198197 this . translateService . get ( `${ prefix } .field.deleted.${ suffix } ` , { amount : amount } )
199- ) ;
198+ ] ) ;
200199 messages . subscribe ( ( [ head , content ] ) => {
201200 if ( success ) {
202201 this . notificationsService . success ( head , content ) ;
@@ -207,6 +206,7 @@ export class MetadataSchemaComponent implements OnInit {
207206 }
208207 ngOnDestroy ( ) : void {
209208 this . paginationService . clearPagination ( this . config . id ) ;
209+ this . registryService . deselectAllMetadataField ( ) ;
210210 }
211211
212212}
0 commit comments