bug fixes in passage (conditionally show note cross references)

This commit is contained in:
Jason Wall 2020-08-15 16:44:31 -04:00
parent fb3b261ccd
commit c1544f79b2
4 changed files with 42 additions and 25 deletions

View File

@ -39,7 +39,7 @@
> >
<ng-container *ngFor="let w of vs.w"> <ng-container *ngFor="let w of vs.w">
<a <a
[title]="this.cardItem.dict + w.s" [title]="getDict(this.cardItem) + w.s"
*ngIf="w.s != null" *ngIf="w.s != null"
(click)="openStrongs(w.s, display.showStrongsAsModal)" (click)="openStrongs(w.s, display.showStrongsAsModal)"
>{{ w.t }}</a >{{ w.t }}</a
@ -52,18 +52,20 @@
</ng-container> </ng-container>
</div> </div>
</ng-container> </ng-container>
<mat-expansion-panel *ngIf="notes$ | async as notes"> <ng-container *ngIf="notes$ | async as notes">
<mat-expansion-panel-header> <mat-expansion-panel *ngIf="notes.length > 0">
<mat-panel-title> <mat-expansion-panel-header>
Note References <mat-panel-title>
</mat-panel-title> Note References
</mat-expansion-panel-header> </mat-panel-title>
<div *ngFor="let note of notes"> </mat-expansion-panel-header>
<button mat-raised-button class="reference" (click)="openNote(note)"> <div *ngFor="let note of notes">
{{ note.title }} <button mat-raised-button class="reference" (click)="openNote(note)">
</button> {{ note.title }}
</div> </button>
</mat-expansion-panel> </div>
</mat-expansion-panel>
</ng-container>
</div> </div>
<div class="card-actions"> <div class="card-actions">
<span class="card-actions-left"> <span class="card-actions-left">

View File

@ -6,6 +6,7 @@ import { CardComponent } from 'src/app/components/card.component';
import { BibleReference, Overlap } from 'src/app/common/bible-reference'; import { BibleReference, Overlap } from 'src/app/common/bible-reference';
import { AppService } from 'src/app/services/app.service'; import { AppService } from 'src/app/services/app.service';
import { Paragraph, BiblePassageResult } from 'src/app/models/passage-state'; import { Paragraph, BiblePassageResult } from 'src/app/models/passage-state';
import { CardItem } from 'src/app/models/card-state';
@Component({ @Component({
selector: 'app-passage-card', selector: 'app-passage-card',
@ -20,10 +21,15 @@ export class PassageCardComponent extends CardComponent implements OnInit {
// whenever the notes changes, look for any notes that reference this passage. // whenever the notes changes, look for any notes that reference this passage.
notes$ = this.appService.select((state) => notes$ = this.appService.select((state) =>
state.notes.value.filter((o) => { state.notes.value !== null && this.ref !== undefined
const refs = o.xref.split(';').map((r) => new BibleReference(r)); ? state.notes.value.filter((o) => {
return refs.filter((r) => BibleReference.overlap(this.ref, r) !== Overlap.None).length > 0; const refs = o.xref
}) .split(';')
.map((r) => new BibleReference(r))
.filter((r) => BibleReference.overlap(this.ref, r) !== Overlap.None);
return refs.length > 0;
})
: []
); );
hasNotes = false; hasNotes = false;
@ -38,6 +44,10 @@ export class PassageCardComponent extends CardComponent implements OnInit {
this.ref = new BibleReference(this.cardItem.qry); this.ref = new BibleReference(this.cardItem.qry);
} }
getDict(item: CardItem) {
return (item.data as BiblePassageResult).dict === 'grk' ? 'G' : 'H';
}
copy() { copy() {
const html = this.passageElement.nativeElement.innerHTML; const html = this.passageElement.nativeElement.innerHTML;
const text = this.passageElement.nativeElement.innerText; const text = this.passageElement.nativeElement.innerText;

View File

@ -6,24 +6,29 @@ import { Overlap } from '../common/bible-reference';
import { CardType, CardItem } from '../models/card-state'; import { CardType, CardItem } from '../models/card-state';
import { NoteItem } from '../models/note-state'; import { NoteItem } from '../models/note-state';
const note: NoteItem = {
id: UUID.UUID(),
xref: '1 pe 2:16; jn 3:16',
title: 'Title Here',
content: '# Content Here\nIn Markdown format.',
} as NoteItem;
export const initialState: AppState = { export const initialState: AppState = {
user: null, user: null,
cards: [ cards: [
{ {
qry: 'UUIDGOESHERE', qry: 'UUIDGOESHERE',
type: CardType.Note, type: CardType.Note,
data: { data: note,
id: UUID.UUID(),
xref: '1 pe 2:16; jn 3:16',
title: 'Title Here',
content: '# Content Here\nIn Markdown format.',
} as NoteItem,
} as CardItem, } as CardItem,
], ],
autocomplete: [], autocomplete: [],
currentSavedPage: null, currentSavedPage: null,
savedPages: null, savedPages: null,
notes: null, notes: {
createdOn: new Date(0).toISOString(),
value: [note],
},
savedPagesLoaded: false, savedPagesLoaded: false,
mainPages: [ mainPages: [
{ title: PageTitles.Search, icon: PageIcons.Search, route: 'search' }, { title: PageTitles.Search, icon: PageIcons.Search, route: 'search' },

View File

@ -223,7 +223,7 @@ export class AppService extends createStateService(reducer, initialState) {
}); });
} }
async getStrongsCard(strongsNumber: string, dict: string) { async getStrongsCard(strongsNumber: string, dict: StrongsDictionary) {
const result = await this.getStrongsFromApi(strongsNumber, dict); const result = await this.getStrongsFromApi(strongsNumber, dict);
const d = dict === 'grk' ? 'G' : 'H'; const d = dict === 'grk' ? 'G' : 'H';