66156: Removal of redundant fields, message update and aciveTab as observable

This commit is contained in:
Kristof De Langhe
2019-11-27 18:01:31 +01:00
parent 2ef02864f2
commit 1b978124d1
6 changed files with 14 additions and 33 deletions

View File

@@ -822,9 +822,9 @@
"item.page.relationships.isJournalOfPublication": "Publications",
"item.page.relationships.isOrgUnitOfPerson": "Persons",
"item.page.relationships.isOrgUnitOfPerson": "Authors",
"item.page.relationships.isOrgUnitOfProject": "Projects",
"item.page.relationships.isOrgUnitOfProject": "Research Projects",
"item.page.subject": "Keywords",

View File

@@ -1,4 +1,4 @@
<ngb-tabset *ngIf="relationTypes.length > 1" [destroyOnHide]="true" #tabs="ngbTabset" [activeId]="activeTab" (tabChange)="onTabChange($event)">
<ngb-tabset *ngIf="relationTypes.length > 1" [destroyOnHide]="true" #tabs="ngbTabset" [activeId]="activeTab$ | async" (tabChange)="onTabChange($event)">
<ngb-tab *ngFor="let relationType of relationTypes" title="{{'item.page.relationships.' + relationType.label | translate}}" [id]="relationType.filter">
<ng-template ngbTabContent>
<div class="mt-4">

View File

@@ -8,6 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { MockRouter } from '../../../../shared/mocks/mock-router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { VarDirective } from '../../../../shared/utils/var.directive';
import { of as observableOf } from 'rxjs';
describe('TabbedRelatedEntitiesSearchComponent', () => {
let comp: TabbedRelatedEntitiesSearchComponent;
@@ -34,11 +35,7 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
{
provide: ActivatedRoute,
useValue: {
snapshot: {
queryParams: {
tab: mockRelationType
}
}
queryParams: observableOf({ tab: mockRelationType })
},
},
{ provide: Router, useValue: router }
@@ -56,7 +53,9 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
});
it('should initialize the activeTab depending on the current query parameters', () => {
expect(comp.activeTab).toEqual(mockRelationType);
comp.activeTab$.subscribe((activeTab) => {
expect(activeTab).toEqual(mockRelationType);
});
});
describe('onTabChange', () => {

View File

@@ -1,6 +1,8 @@
import { Component, Input, OnInit } from '@angular/core';
import { Item } from '../../../../core/shared/item.model';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { map } from 'rxjs/operators';
@Component({
selector: 'ds-tabbed-related-entities-search',
@@ -42,7 +44,7 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
/**
* The active tab
*/
activeTab: string;
activeTab$: Observable<string>;
constructor(private route: ActivatedRoute,
private router: Router) {
@@ -52,7 +54,9 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
* If the url contains a "tab" query parameter, set this tab to be the active tab
*/
ngOnInit(): void {
this.activeTab = this.route.snapshot.queryParams.tab;
this.activeTab$ = this.route.queryParams.pipe(
map((params) => params.tab)
);
}
/**

View File

@@ -24,16 +24,6 @@
</ds-generic-item-page-field>
</div>
<div class="col-xs-12 col-md-6">
<ds-related-items
[parentItem]="object"
[relationType]="'isPersonOfOrgUnit'"
[label]="'relationships.isPersonOf' | translate">
</ds-related-items>
<ds-related-items
[parentItem]="object"
[relationType]="'isProjectOfOrgUnit'"
[label]="'relationships.isProjectOf' | translate">
</ds-related-items>
<ds-related-items
[parentItem]="object"
[relationType]="'isPublicationOfOrgUnit'"

View File

@@ -53,18 +53,6 @@
<div class="relationships-item-page">
<div class="container">
<div class="row">
<ds-related-items
class="col-12 col-md-4"
[parentItem]="object"
[relationType]="'isPersonOfOrgUnit'"
[label]="'relationships.isPersonOf' | translate">
</ds-related-items>
<ds-related-items
class="col-12 col-md-4"
[parentItem]="object"
[relationType]="'isProjectOfOrgUnit'"
[label]="'relationships.isProjectOf' | translate">
</ds-related-items>
<ds-related-items
class="col-12 col-md-4"
[parentItem]="object"