Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deselect all metadata fields when switching between metadata schemas in registry #2652

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
* 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 @@
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 @@
*/
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 @@
showNotification(success: boolean, amount: number) {
const prefix = 'admin.registries.schema.notification';
const suffix = success ? 'success' : 'failure';
const messages = observableCombineLatest(
const messages = observableCombineLatest([

Check warning on line 195 in src/app/admin/admin-registries/metadata-schema/metadata-schema.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/admin/admin-registries/metadata-schema/metadata-schema.component.ts#L195

Added line #L195 was not covered by tests
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 @@
}
ngOnDestroy(): void {
this.paginationService.clearPagination(this.config.id);
this.registryService.deselectAllMetadataField();
}

}
Loading