Skip to content

Commit

Permalink
Add entity highlight after navigation to occurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaraDipi committed Nov 26, 2020
1 parent ce2328f commit a16cc83
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<span class="namedEntityRef {{ data.entityType }}" (click)="toggleEntityData($event)" [ngClass]="{
opened: opened,
entityHighlight: (evtStatusService.currentNamedEntityId$ | async) === data.entityId && !opened,
noDetails: (availableEntities$ | async) === false
}" [evtHighlight]="highlightData" [evtHtmlAttributes]="data?.attributes">
<evt-content-viewer *ngFor="let element of data.content" [content]="element" [editionLevel]="editionLevel" [itemsToHighlight]="itemsToHighlight" [textFlow]="textFlow"></evt-content-viewer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@
}
.not-found-msg {
font-size: .9rem;
}

.entityHighlight {
background: #ffffcc !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NamedEntityRef } from '../../models/evt-models';
import { register } from '../../services/component-register.service';
import { EntitiesSelectService } from '../../services/entities-select.service';
import { EVTModelService } from '../../services/evt-model.service';
import { EVTStatusService } from '../../services/evt-status.service';
import { EditionlevelSusceptible, Highlightable, TextFlowSusceptible } from '../components-mixins';

export interface NamedEntityRefComponent extends EditionlevelSusceptible, Highlightable, TextFlowSusceptible { }
Expand Down Expand Up @@ -41,6 +42,7 @@ export class NamedEntityRefComponent {
public opened = false;

constructor(
public evtStatusService: EVTStatusService,
private evtModelService: EVTModelService,
private entitiesSelectService: EntitiesSelectService,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EVTStatusService } from '../../../services/evt-status.service';
})
export class NamedEntityOccurrenceComponent {
@Input() occurrence: NamedEntityOccurrence;
@Input() entityId: string;

constructor(
private evtModelService: EVTModelService,
Expand All @@ -24,6 +25,7 @@ export class NamedEntityOccurrenceComponent {
const page = pages.find(p => p.id === this.occurrence.pageId);
this.evtStatusService.updateDocument$.next(ref.docId);
this.evtStatusService.updatePage$.next(page);
this.evtStatusService.currentNamedEntityId$.next(this.entityId);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ng-template ngbNavContent>
<div class="ne-detail-content ui-font" *ngIf="occurrences$ | async as occurrences">
<span *ngIf="occurrences.length === 0">{{'noOccurrences' | translate}}</span>
<evt-named-entity-occurrence *ngFor="let occurrence of occurrences" [occurrence]="occurrence"></evt-named-entity-occurrence>
<evt-named-entity-occurrence *ngFor="let occurrence of occurrences" [occurrence]="occurrence" [entityId]="data.id"></evt-named-entity-occurrence>
</div>
</ng-template>
</li>
Expand Down
12 changes: 9 additions & 3 deletions src/app/services/evt-status.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
import { BehaviorSubject, combineLatest, merge, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, filter, first, map, shareReplay } from 'rxjs/operators';
import { BehaviorSubject, combineLatest, merge, Observable, Subject, timer } from 'rxjs';
import { distinctUntilChanged, filter, first, map, shareReplay, switchMap } from 'rxjs/operators';

import { AppConfig, EditionLevelType } from '../app.config';
import { Page, ViewMode } from '../models/evt-models';
Expand Down Expand Up @@ -56,7 +56,7 @@ export class EVTStatusService {
this.updatePage$.pipe(map(p => p.id)),
),
this.evtModelService.pages$.pipe(
filter((pages)=> !!pages && pages.length > 0),
filter((pages) => !!pages && pages.length > 0),
),
]).pipe(
map(([id, pages]) => !id ? pages[0] : pages.find((p) => p.id === id) || pages[0]),
Expand Down Expand Up @@ -121,6 +121,8 @@ export class EVTStatusService {
map(currentStatus => this.getUrlFromStatus(currentStatus)),
);

public currentNamedEntityId$: BehaviorSubject<string> = new BehaviorSubject(undefined);

constructor(
private evtModelService: EVTModelService,
private router: Router,
Expand Down Expand Up @@ -148,6 +150,10 @@ export class EVTStatusService {
}
}
});
this.currentNamedEntityId$.pipe(
filter(id => !!id),
switchMap(id => timer(5000).pipe(map(() => id))),
).subscribe(() => this.currentNamedEntityId$.next(undefined));
}

getUrlFromStatus(status: AppStatus) {
Expand Down

0 comments on commit a16cc83

Please sign in to comment.