mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-30 02:59:49 -04:00
Support tabs in display of multiple strongs numbers
This commit is contained in:
parent
838bfe1491
commit
3a1f5639c6
@ -37,6 +37,7 @@ import { MatBadgeModule } from '@angular/material/badge';
|
|||||||
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
||||||
import { MatDividerModule } from '@angular/material/divider';
|
import { MatDividerModule } from '@angular/material/divider';
|
||||||
import { MatChipsModule } from '@angular/material/chips';
|
import { MatChipsModule } from '@angular/material/chips';
|
||||||
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { MatNativeDateModule, MatRippleModule } from '@angular/material/core';
|
import { MatNativeDateModule, MatRippleModule } from '@angular/material/core';
|
||||||
import { ClipboardModule } from '@angular/cdk/clipboard';
|
import { ClipboardModule } from '@angular/cdk/clipboard';
|
||||||
|
|
||||||
@ -153,6 +154,7 @@ export function markedOptionsFactory(): MarkedOptions {
|
|||||||
MatSnackBarModule,
|
MatSnackBarModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
|
MatTabsModule,
|
||||||
ClipboardModule,
|
ClipboardModule,
|
||||||
],
|
],
|
||||||
providers: [{ provide: APP_ID, useValue: 'ng-cli-universal' }],
|
providers: [{ provide: APP_ID, useValue: 'ng-cli-universal' }],
|
||||||
|
@ -149,16 +149,20 @@ export class PassageCardComponent extends CardComponent implements OnInit {
|
|||||||
async openStrongs(q: string, asModal = false) {
|
async openStrongs(q: string, asModal = false) {
|
||||||
const dict = (this.cardItem.data as BiblePassageResult).dict;
|
const dict = (this.cardItem.data as BiblePassageResult).dict;
|
||||||
const numbers = q.split(' ');
|
const numbers = q.split(' ');
|
||||||
for (const sn of numbers) {
|
|
||||||
if (asModal) {
|
if (asModal) {
|
||||||
|
const cards: CardItem[] = [];
|
||||||
|
for (const sn of numbers) {
|
||||||
const card = await this.appService.getStrongsCard(sn, dict);
|
const card = await this.appService.getStrongsCard(sn, dict);
|
||||||
this.dialog.open(StrongsModalComponent, {
|
cards.push(card);
|
||||||
data: card,
|
|
||||||
autoFocus: 'content',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.appService.getStrongs(sn, dict, this.cardItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dialog.open(StrongsModalComponent, {
|
||||||
|
data: cards,
|
||||||
|
autoFocus: 'content',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.appService.getStrongs(numbers, dict, this.cardItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, ElementRef, ViewChild, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ElementRef, ViewChild, ChangeDetectionStrategy, Input } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Clipboard } from '@angular/cdk/clipboard';
|
import { Clipboard } from '@angular/cdk/clipboard';
|
||||||
import { StrongsModalComponent } from '../modal/strongs-modal.component';
|
import { StrongsModalComponent } from '../modal/strongs-modal.component';
|
||||||
@ -18,6 +18,9 @@ export class StrongsCardComponent extends CardComponent {
|
|||||||
asModal = false;
|
asModal = false;
|
||||||
@ViewChild('strongs') strongsElement: ElementRef;
|
@ViewChild('strongs') strongsElement: ElementRef;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
data: StrongsResult;
|
||||||
|
|
||||||
get strongsResult() {
|
get strongsResult() {
|
||||||
return this.cardItem.data as StrongsResult;
|
return this.cardItem.data as StrongsResult;
|
||||||
}
|
}
|
||||||
@ -52,7 +55,7 @@ export class StrongsCardComponent extends CardComponent {
|
|||||||
autoFocus: 'content',
|
autoFocus: 'content',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.appService.getStrongs(sn, dict, this.cardItem);
|
this.appService.getStrongs([sn], dict, this.cardItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
<mat-toolbar>
|
<mat-toolbar>
|
||||||
<mat-icon aria-hidden="false" aria-label="Strongs Entry Icon">{{
|
<mat-icon aria-hidden="false" aria-label="Strongs Entry Icon">{{
|
||||||
icon$ | async
|
icon$ | async
|
||||||
}}</mat-icon>
|
}}</mat-icon>
|
||||||
<div class="title">{{ cardItem.qry }}</div>
|
<div class="title">{{ this.title }}</div>
|
||||||
<span class="close-button">
|
<span class="close-button">
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
mat-dialog-close
|
mat-dialog-close
|
||||||
aria-label="Exit the Strongs Modal"
|
aria-label="Exit the Strongs Modal"
|
||||||
>
|
>
|
||||||
<mat-icon>cancel</mat-icon>
|
<mat-icon>cancel</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
<mat-dialog-content class="content">
|
<mat-dialog-content class="content">
|
||||||
<br />
|
<mat-tab-group>
|
||||||
<app-strongs
|
<mat-tab *ngFor="let card of strongsResults">
|
||||||
[data]="strongsResult"
|
<ng-template mat-tab-label>{{ card.prefix }}{{ card.sn }}</ng-template>
|
||||||
(openPassage)="openPassage($event)"
|
<app-strongs
|
||||||
></app-strongs>
|
[data]="card"
|
||||||
|
(openPassage)="openPassage($event)"
|
||||||
|
></app-strongs>
|
||||||
|
</mat-tab>
|
||||||
|
</mat-tab-group>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, Inject, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, Inject, ChangeDetectionStrategy, Input } from '@angular/core';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { BibleReference } from 'src/app/common/bible-reference';
|
import { BibleReference } from 'src/app/common/bible-reference';
|
||||||
import { CardItem } from 'src/app/models/card-state';
|
import { CardItem } from 'src/app/models/card-state';
|
||||||
@ -15,14 +16,16 @@ import { AppService } from 'src/app/services/app.service';
|
|||||||
})
|
})
|
||||||
export class StrongsModalComponent {
|
export class StrongsModalComponent {
|
||||||
icon$: Observable<string>;
|
icon$: Observable<string>;
|
||||||
strongsResult: StrongsResult;
|
strongsResults: StrongsResult[];
|
||||||
|
title: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(MAT_DIALOG_DATA) public cardItem: CardItem,
|
@Inject(MAT_DIALOG_DATA) public cardItems: CardItem[],
|
||||||
public dialogRef: MatDialogRef<StrongsModalComponent>,
|
public dialogRef: MatDialogRef<StrongsModalComponent>,
|
||||||
private appService: AppService
|
private appService: AppService
|
||||||
) {
|
) {
|
||||||
this.strongsResult = cardItem.data as StrongsResult;
|
this.title = cardItems.map(o => o.qry).reduce((p, c) => `${p}, ${c}`);
|
||||||
|
this.strongsResults = cardItems.map(o => o.data as StrongsResult);
|
||||||
this.icon$ = appService.select((state) => state.settings.value.cardIcons.strongs);
|
this.icon$ = appService.select((state) => state.settings.value.cardIcons.strongs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +35,6 @@ export class StrongsModalComponent {
|
|||||||
|
|
||||||
openPassage(p: string) {
|
openPassage(p: string) {
|
||||||
const ref = BibleReference.makePassageFromReferenceKey(p);
|
const ref = BibleReference.makePassageFromReferenceKey(p);
|
||||||
this.appService.getPassage(ref, this.cardItem);
|
this.appService.getPassage(ref, this.cardItems[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
export type StrongsDictionary = 'heb' | 'grk';
|
export type StrongsDictionary = 'heb' | 'grk';
|
||||||
|
|
||||||
export interface StrongsResult {
|
export interface StrongsResult {
|
||||||
readonly dict: StrongsDictionary;
|
|
||||||
readonly prefix: string;
|
readonly prefix: string;
|
||||||
readonly sn: number;
|
readonly sn: number;
|
||||||
readonly def: StrongsDefinition;
|
readonly def: StrongsDefinition;
|
||||||
|
@ -286,6 +286,43 @@ export const addCardAction = (card: CardItem, nextToItem: CardItem): AppAction =
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addCardsAction = (cardsToAdd: CardItem[], nextToItem: CardItem): AppAction => {
|
||||||
|
return {
|
||||||
|
handle(state: AppState) {
|
||||||
|
let cards = [...state.currentCards.value];
|
||||||
|
let cache = state.cardCache;
|
||||||
|
|
||||||
|
for (let card of cardsToAdd) {
|
||||||
|
if (nextToItem && state.settings.value.displaySettings.insertCardNextToItem) {
|
||||||
|
const idx = cards.indexOf(nextToItem);
|
||||||
|
|
||||||
|
if (state.settings.value.displaySettings.appendCardToBottom) {
|
||||||
|
const before = cards.slice(0, idx + 1);
|
||||||
|
const after = cards.slice(idx + 1);
|
||||||
|
cards = [...before, card, ...after];
|
||||||
|
} else {
|
||||||
|
const before = cards.slice(0, idx);
|
||||||
|
const after = cards.slice(idx);
|
||||||
|
cards = [...before, card, ...after];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state.settings.value.displaySettings.appendCardToBottom) {
|
||||||
|
cards = [...cards, card];
|
||||||
|
} else {
|
||||||
|
cards = [card, ...cards];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cache = updateInCardCache(card, state.cardCache);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentCards: new Storable(cards),
|
||||||
|
cardCache: cache,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const updateCardAction = (newCard: CardItem, oldCard: CardItem): AppAction => {
|
export const updateCardAction = (newCard: CardItem, oldCard: CardItem): AppAction => {
|
||||||
return {
|
return {
|
||||||
handle(state: AppState) {
|
handle(state: AppState) {
|
||||||
@ -635,7 +672,6 @@ export const deleteNoteAction = (note: NoteItem): AppAction => {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class AppService extends createReducingService(initialState) {
|
export class AppService extends createReducingService(initialState) {
|
||||||
//createStateService(appReducer, initialState) {
|
|
||||||
private wordToStem: Map<string, string>;
|
private wordToStem: Map<string, string>;
|
||||||
private paragraphs: HashTable<Paragraph>;
|
private paragraphs: HashTable<Paragraph>;
|
||||||
private searchIndexArray: string[];
|
private searchIndexArray: string[];
|
||||||
@ -1000,13 +1036,17 @@ export class AppService extends createReducingService(initialState) {
|
|||||||
|
|
||||||
//#region Strongs
|
//#region Strongs
|
||||||
|
|
||||||
async getStrongs(strongsNumber: string, dict: StrongsDictionary, nextToItem: CardItem = null) {
|
async getStrongs(strongsNumber: string[], dict: StrongsDictionary, nextToItem: CardItem = null) {
|
||||||
const card = await this.getStrongsCard(strongsNumber, dict);
|
const cards = [];
|
||||||
if (!card) {
|
for (const sn of strongsNumber) {
|
||||||
return; // nothing was returned. so an error occurred.
|
const card = await this.getStrongsCard(sn, dict);
|
||||||
|
cards.push(card);
|
||||||
|
}
|
||||||
|
if (cards.length < 1) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dispatch(addCardAction(card, nextToItem));
|
this.dispatch(addCardsAction(cards, nextToItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStrongsCard(strongsNumber: string, dict: StrongsDictionary) {
|
async getStrongsCard(strongsNumber: string, dict: StrongsDictionary) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user