From 328b1c87da38cab88833612a1eacdc1e53c32ceb Mon Sep 17 00:00:00 2001 From: Giulia Cacioli Date: Sun, 31 Jan 2021 09:58:28 +0100 Subject: [PATCH 1/3] Add missing shareReplay in currentEditionLevel observable --- src/app/view-modes/image-text/image-text.component.ts | 3 ++- src/app/view-modes/reading-text/reading-text.component.ts | 3 ++- src/app/view-modes/text-sources/text-sources.component.ts | 3 ++- src/app/view-modes/text-text/text-text.component.ts | 3 ++- src/app/view-modes/text-versions/text-versions.component.ts | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/view-modes/image-text/image-text.component.ts b/src/app/view-modes/image-text/image-text.component.ts index 933229139..2f68b91d6 100644 --- a/src/app/view-modes/image-text/image-text.component.ts +++ b/src/app/view-modes/image-text/image-text.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { Page } from 'src/app/models/evt-models'; import { EVTStatusService } from 'src/app/services/evt-status.service'; import { EditionLevel } from '../../app.config'; @@ -21,6 +21,7 @@ export class ImageTextComponent implements OnInit { public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe( map(({ editionLevels }) => editionLevels[0]), + shareReplay(1), ); constructor( diff --git a/src/app/view-modes/reading-text/reading-text.component.ts b/src/app/view-modes/reading-text/reading-text.component.ts index 1e800a306..a5a05fea1 100644 --- a/src/app/view-modes/reading-text/reading-text.component.ts +++ b/src/app/view-modes/reading-text/reading-text.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CompactType, DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; import { Subscription } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { EVTStatusService } from 'src/app/services/evt-status.service'; import { EditionLevel } from '../../app.config'; import { Page } from '../../models/evt-models'; @@ -20,6 +20,7 @@ export class ReadingTextComponent implements OnInit, OnDestroy { public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe( map(({ editionLevels }) => editionLevels[0]), + shareReplay(1), ); public options: GridsterConfig = {}; diff --git a/src/app/view-modes/text-sources/text-sources.component.ts b/src/app/view-modes/text-sources/text-sources.component.ts index 582a6051a..9ee31423e 100644 --- a/src/app/view-modes/text-sources/text-sources.component.ts +++ b/src/app/view-modes/text-sources/text-sources.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { Page } from 'src/app/models/evt-models'; import { EVTStatusService } from 'src/app/services/evt-status.service'; import { EditionLevel } from '../../app.config'; @@ -21,6 +21,7 @@ export class TextSourcesComponent implements OnInit { public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe( map(({ editionLevels }) => editionLevels[0]), + shareReplay(1), ); constructor( diff --git a/src/app/view-modes/text-text/text-text.component.ts b/src/app/view-modes/text-text/text-text.component.ts index e48d3fba4..e63f1c029 100644 --- a/src/app/view-modes/text-text/text-text.component.ts +++ b/src/app/view-modes/text-text/text-text.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; import { BehaviorSubject, combineLatest, Subscription } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { Page } from 'src/app/models/evt-models'; import { EVTStatusService } from 'src/app/services/evt-status.service'; @@ -23,6 +23,7 @@ export class TextTextComponent implements OnInit, OnDestroy { public currentEditionLevels$ = this.evtStatusService.currentStatus$.pipe( map(({ editionLevels }) => editionLevels), + shareReplay(1), ); private editionLevelPanel1Change$: BehaviorSubject = new BehaviorSubject(undefined); diff --git a/src/app/view-modes/text-versions/text-versions.component.ts b/src/app/view-modes/text-versions/text-versions.component.ts index 855a35091..eb379a878 100644 --- a/src/app/view-modes/text-versions/text-versions.component.ts +++ b/src/app/view-modes/text-versions/text-versions.component.ts @@ -1,6 +1,6 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { CompactType, DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { EditionLevel } from 'src/app/app.config'; import { Page } from 'src/app/models/evt-models'; import { EVTStatusService } from 'src/app/services/evt-status.service'; @@ -26,6 +26,7 @@ export class TextVersionsComponent implements OnInit { public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe( map(({ editionLevels }) => editionLevels[0]), + shareReplay(1), ); public get versionBtn(): { label: string, additionalClasses: string, title: string, icon?: EvtIconInfo } { From 4974f9462cb521d932182564526502d4ff75517e Mon Sep 17 00:00:00 2001 From: Giulia Cacioli Date: Sun, 31 Jan 2021 09:59:15 +0100 Subject: [PATCH 2/3] Handle critical text pages division --- CHANGELOG.md | 1 + .../text-panel/text-panel.component.html | 19 ++++++++++++++----- .../panels/text-panel/text-panel.component.ts | 13 +++++++++++-- .../structure-xml-parser.service.ts | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edf110a00..800ffc5ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated to Angular 9 ### Added +- Critical text pages division - Xi:include support for edition text - Manuscript description data extraction - Deletion vizualization diff --git a/src/app/panels/text-panel/text-panel.component.html b/src/app/panels/text-panel/text-panel.component.html index b1e272b96..8d053f3d4 100644 --- a/src/app/panels/text-panel/text-panel.component.html +++ b/src/app/panels/text-panel/text-panel.component.html @@ -10,11 +10,20 @@
- + + + + + + +
{{ getSecondaryContent() }}
diff --git a/src/app/panels/text-panel/text-panel.component.ts b/src/app/panels/text-panel/text-panel.component.ts index a1b9e2362..c79624c86 100644 --- a/src/app/panels/text-panel/text-panel.component.ts +++ b/src/app/panels/text-panel/text-panel.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { BehaviorSubject, combineLatest, Observable, Subject, Subscription } from 'rxjs'; import { delay, distinctUntilChanged, filter, map, shareReplay } from 'rxjs/operators'; +import { EVTStatusService } from 'src/app/services/evt-status.service'; import { AppConfig, EditionLevel, EditionLevelType, TextFlow } from '../../app.config'; import { EntitiesSelectItem } from '../../components/entities-select/entities-select.component'; import { Page } from '../../models/evt-models'; @@ -36,12 +37,14 @@ export class TextPanelComponent implements OnInit, OnDestroy { ); public currentStatus$ = combineLatest([ + this.evtModelService.pages$, this.currentPage$, this.currentEdLevel$, + this.evtStatus.currentViewMode$, ]).pipe( delay(0), - filter(([page, editionLevel]) => !!page && !!editionLevel), - map(([page, editionLevel]) => ({ page, editionLevel })), + filter(([pages, currentPage, editionLevel, currentViewMode]) => !!pages && !!currentPage && !!editionLevel && !!currentViewMode), + map(([pages, currentPage, editionLevel, currentViewMode]) => ({ pages, currentPage, editionLevel, currentViewMode })), distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), shareReplay(1), ); @@ -58,10 +61,16 @@ export class TextPanelComponent implements OnInit, OnDestroy { return { icon: this.textFlow === 'prose' ? 'align-left' : 'align-justify', iconSet: 'fas' }; } + public isMultiplePageFlow$ = this.currentStatus$.pipe( + map((x) => x.editionLevel.id === 'critical' && x.currentViewMode.id !== 'imageText'), + shareReplay(1), + ); + private subscriptions: Subscription[] = []; constructor( public evtModelService: EVTModelService, + public evtStatus: EVTStatusService, ) { } diff --git a/src/app/services/xml-parsers/structure-xml-parser.service.ts b/src/app/services/xml-parsers/structure-xml-parser.service.ts index 8eff35c46..8b24bd769 100644 --- a/src/app/services/xml-parsers/structure-xml-parser.service.ts +++ b/src/app/services/xml-parsers/structure-xml-parser.service.ts @@ -24,7 +24,7 @@ export class StructureXmlParserService { const front: XMLElement = el.querySelector(this.frontTagName); const body: XMLElement = el.querySelector(this.bodyTagName); - const pbs = Array.from(el.querySelectorAll(this.pageTagName)); + const pbs = Array.from(el.querySelectorAll(this.pageTagName)).filter((p) => !p.getAttribute('ed')); const frontPbs = pbs.filter((p) => isNestedInElem(p, this.frontTagName)); const bodyPbs = pbs.filter((p) => isNestedInElem(p, this.bodyTagName)); const doc = el.firstElementChild.ownerDocument; From 02c422238df3eb03630689a9a9ff20b2c0076eb2 Mon Sep 17 00:00:00 2001 From: Giulia Cacioli Date: Sun, 31 Jan 2021 11:07:51 +0100 Subject: [PATCH 3/3] Fix lint error --- src/app/panels/text-panel/text-panel.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/text-panel/text-panel.component.html b/src/app/panels/text-panel/text-panel.component.html index 8d053f3d4..3ff3b95a6 100644 --- a/src/app/panels/text-panel/text-panel.component.html +++ b/src/app/panels/text-panel/text-panel.component.html @@ -18,7 +18,7 @@ [itemsToHighlight]="itemsToHighlight$ | async"> -