mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-24 16:00:11 -04:00
add support for appending top/bottom and next to item
This commit is contained in:
parent
1fce38d244
commit
a033801f29
@ -150,7 +150,7 @@ export class PassageComponent extends CardComponent implements OnInit {
|
|||||||
openStrongs(q: string) {
|
openStrongs(q: string) {
|
||||||
const dict = this.cardItem.dict === 'H' ? 'heb' : 'grk';
|
const dict = this.cardItem.dict === 'H' ? 'heb' : 'grk';
|
||||||
const strongsNumber = q.substring(1, q.length);
|
const strongsNumber = q.substring(1, q.length);
|
||||||
this.appService.getNewStrongs(strongsNumber, dict);
|
this.appService.getNewStrongs(strongsNumber, dict, this.cardItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
isPunct(c: string) {
|
isPunct(c: string) {
|
||||||
|
@ -45,6 +45,6 @@ export class StrongsComponent extends CardComponent {
|
|||||||
|
|
||||||
openPassage(p: string) {
|
openPassage(p: string) {
|
||||||
const ref = this.makePassage(p);
|
const ref = this.makePassage(p);
|
||||||
this.appService.getNewPassage(ref);
|
this.appService.getNewPassage(ref, this.cardItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ type AppAction =
|
|||||||
| {
|
| {
|
||||||
type: 'ADD_CARD';
|
type: 'ADD_CARD';
|
||||||
card: CardItem;
|
card: CardItem;
|
||||||
|
nextToItem: CardItem;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'UPDATE_CARD';
|
type: 'UPDATE_CARD';
|
||||||
@ -96,9 +97,30 @@ function reducer(state: AppState, action: AppAction): AppState {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'ADD_CARD': {
|
case 'ADD_CARD': {
|
||||||
|
let cards = [];
|
||||||
|
|
||||||
|
if (action.nextToItem && state.displaySettings.insertCardNextToItem) {
|
||||||
|
const idx = state.cards.indexOf(action.nextToItem);
|
||||||
|
|
||||||
|
if (state.displaySettings.appendCardToBottom) {
|
||||||
|
const before = state.cards.slice(0, idx + 1);
|
||||||
|
const after = state.cards.slice(idx + 1);
|
||||||
|
cards = [before, action.card, after];
|
||||||
|
} else {
|
||||||
|
const before = state.cards.slice(0, idx);
|
||||||
|
const after = state.cards.slice(idx);
|
||||||
|
cards = [before, action.card, after];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state.displaySettings.appendCardToBottom) {
|
||||||
|
cards = [...state.cards, action.card];
|
||||||
|
} else {
|
||||||
|
cards = [action.card, ...state.cards];
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
cards: [...state.cards, action.card],
|
cards,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'UPDATE_CARD': {
|
case 'UPDATE_CARD': {
|
||||||
@ -186,7 +208,11 @@ export class AppService extends createStateService(reducer, initialState) {
|
|||||||
|
|
||||||
//#region Strongs
|
//#region Strongs
|
||||||
|
|
||||||
async getNewStrongs(strongsNumber: string, dict: DictionaryType) {
|
async getNewStrongs(
|
||||||
|
strongsNumber: string,
|
||||||
|
dict: DictionaryType,
|
||||||
|
nextToItem: CardItem = null
|
||||||
|
) {
|
||||||
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';
|
||||||
|
|
||||||
@ -200,6 +226,7 @@ export class AppService extends createStateService(reducer, initialState) {
|
|||||||
this.dispatch({
|
this.dispatch({
|
||||||
type: 'ADD_CARD',
|
type: 'ADD_CARD',
|
||||||
card,
|
card,
|
||||||
|
nextToItem,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,11 +358,12 @@ export class AppService extends createStateService(reducer, initialState) {
|
|||||||
|
|
||||||
//#region Bible Passages
|
//#region Bible Passages
|
||||||
|
|
||||||
async getNewPassage(ref: BibleReference) {
|
async getNewPassage(ref: BibleReference, nextToItem: CardItem = null) {
|
||||||
const card = await this.composeBiblePassageCardItem(ref);
|
const card = await this.composeBiblePassageCardItem(ref);
|
||||||
this.dispatch({
|
this.dispatch({
|
||||||
type: 'ADD_CARD',
|
type: 'ADD_CARD',
|
||||||
card,
|
card,
|
||||||
|
nextToItem,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user