Skip to content

Commit

Permalink
Merge pull request evt-project#113 from evt-project/feature/critical-…
Browse files Browse the repository at this point in the history
…text-page-division

Feature/critical text page division
  • Loading branch information
szenzaro authored Jan 31, 2021
2 parents 09445c3 + 02c4222 commit da86999
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions src/app/panels/text-panel/text-panel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@
<evt-edition-level-selector [class.hidden]="hideEditionLevelSelector" [editionLevelID]="editionLevelID" (selectionChange)="currentEdLevel$.next($event)"></evt-edition-level-selector>
</div>
<div content>
<evt-page *ngIf="currentStatus$ | async as currentStatus"
[data]="currentStatus.page"
[editionLevel]="currentStatus.editionLevel"
[textFlow]="textFlow"
[itemsToHighlight]="itemsToHighlight$ | async"></evt-page>
<ng-container *ngIf="(currentStatus$ | async) as currentStatus">
<ng-container *ngIf="isMultiplePageFlow$ | async">
<evt-page *ngFor="let page of currentStatus.pages"
[data]="page"
[textFlow]="textFlow"
[itemsToHighlight]="itemsToHighlight$ | async"></evt-page>
</ng-container>

<evt-page *ngIf="(isMultiplePageFlow$ | async) === false"
[data]="currentStatus.currentPage"
[editionLevel]="currentStatus.editionLevel"
[textFlow]="textFlow"
[itemsToHighlight]="itemsToHighlight$ | async"></evt-page>
</ng-container>
</div>
<div secondary-content>{{ getSecondaryContent() }}</div>

Expand Down
13 changes: 11 additions & 2 deletions src/app/panels/text-panel/text-panel.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
);
Expand All @@ -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,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/app/view-modes/image-text/image-text.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +21,7 @@ export class ImageTextComponent implements OnInit {

public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe(
map(({ editionLevels }) => editionLevels[0]),
shareReplay(1),
);

constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/app/view-modes/reading-text/reading-text.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 = {};

Expand Down
3 changes: 2 additions & 1 deletion src/app/view-modes/text-sources/text-sources.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +21,7 @@ export class TextSourcesComponent implements OnInit {

public currentEditionLevel$ = this.evtStatusService.currentStatus$.pipe(
map(({ editionLevels }) => editionLevels[0]),
shareReplay(1),
);

constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/app/view-modes/text-text/text-text.component.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -23,6 +23,7 @@ export class TextTextComponent implements OnInit, OnDestroy {

public currentEditionLevels$ = this.evtStatusService.currentStatus$.pipe(
map(({ editionLevels }) => editionLevels),
shareReplay(1),
);

private editionLevelPanel1Change$: BehaviorSubject<EditionLevel> = new BehaviorSubject(undefined);
Expand Down
3 changes: 2 additions & 1 deletion src/app/view-modes/text-versions/text-versions.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 } {
Expand Down

0 comments on commit da86999

Please sign in to comment.