fix bug in passage expand.

This commit is contained in:
Jason Wall 2020-09-01 13:55:44 -04:00
parent ed2e65fb8a
commit 92eff31716
2 changed files with 43 additions and 36 deletions

View File

@ -20,3 +20,4 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
- setup CI/CD - setup CI/CD
- ignore reserved search words (the ones that are too big to fit in the index) - ignore reserved search words (the ones that are too big to fit in the index)
- migration path for old data to new - migration path for old data to new
- strongs numbers with more than one number should appear in tabs or you need to update your text to assign only one number per word(s)

View File

@ -59,75 +59,81 @@ export class PassageCardComponent extends CardComponent implements OnInit {
} }
next() { next() {
const lastVerseForEnd = this.ref.section.book.chapters[this.ref.section.end.chapter]; const newRef = new BibleReference(this.ref.toString());
if (this.ref.section.end.verse !== 0 && this.ref.section.end.verse !== lastVerseForEnd) { const lastVerseForEnd = newRef.section.book.chapters[newRef.section.end.chapter];
this.ref.section.end.chapter = this.ref.section.end.chapter;
if (newRef.section.end.verse !== 0 && newRef.section.end.verse !== lastVerseForEnd) {
newRef.section.end.chapter = newRef.section.end.chapter;
} else { } else {
this.ref.section.end.chapter = this.ref.section.end.chapter + 1; newRef.section.end.chapter = newRef.section.end.chapter + 1;
} }
this.ref.section.start.chapter = this.ref.section.end.chapter; newRef.section.start.chapter = newRef.section.end.chapter;
this.ref.section.start.verse = 1; newRef.section.start.verse = 1;
this.ref.section.end.verse = this.ref.section.book.chapters[this.ref.section.end.chapter]; newRef.section.end.verse = newRef.section.book.chapters[newRef.section.end.chapter];
this.appService.updatePassage(this.cardItem, this.ref); this.appService.updatePassage(this.cardItem, newRef);
} }
prev() { prev() {
if (this.ref.section.start.verse !== 1) { const newRef = new BibleReference(this.ref.toString());
this.ref.section.start.chapter = this.ref.section.start.chapter;
if (newRef.section.start.verse !== 1) {
newRef.section.start.chapter = newRef.section.start.chapter;
} else { } else {
this.ref.section.start.chapter = this.ref.section.start.chapter - 1; newRef.section.start.chapter = newRef.section.start.chapter - 1;
} }
this.ref.section.end.chapter = this.ref.section.start.chapter; newRef.section.end.chapter = newRef.section.start.chapter;
this.ref.section.start.verse = 1; newRef.section.start.verse = 1;
this.ref.section.end.verse = this.ref.section.book.chapters[this.ref.section.end.chapter]; newRef.section.end.verse = newRef.section.book.chapters[newRef.section.end.chapter];
this.appService.updatePassage(this.cardItem, this.ref); this.appService.updatePassage(this.cardItem, newRef);
} }
expand() { expand() {
const lastVerseForEnd = this.ref.section.book.chapters[this.ref.section.end.chapter]; const newRef = new BibleReference(this.ref.toString());
const lastVerseForEnd = newRef.section.book.chapters[newRef.section.end.chapter];
// if your verse is at the beginning, to go the prev chapter and add 3 verses from that // if your verse is at the beginning, to go the prev chapter and add 3 verses from that
if (this.ref.section.start.verse < 4) { if (newRef.section.start.verse < 4) {
this.ref.section.start.chapter = this.ref.section.start.chapter - 1; newRef.section.start.chapter = newRef.section.start.chapter - 1;
this.ref.section.start.verse = newRef.section.start.verse =
this.ref.section.book.chapters[this.ref.section.start.chapter] - (3 - this.ref.section.start.verse); newRef.section.book.chapters[newRef.section.start.chapter] - (3 - newRef.section.start.verse);
if (this.ref.section.start.chapter === 0) { if (newRef.section.start.chapter === 0) {
this.ref.section.start.chapter = 1; newRef.section.start.chapter = 1;
this.ref.section.start.verse = 1; newRef.section.start.verse = 1;
} }
} else { } else {
// or go back 3 verses // or go back 3 verses
this.ref.section.start.verse = this.ref.section.start.verse - 3; newRef.section.start.verse = newRef.section.start.verse - 3;
} }
// if your verse is at the end, go to the next chapter // if your verse is at the end, go to the next chapter
if (this.ref.section.end.verse === 0 || this.ref.section.end.verse + 3 > lastVerseForEnd) { if (newRef.section.end.verse === 0 || newRef.section.end.verse + 3 > lastVerseForEnd) {
this.ref.section.end.chapter = this.ref.section.end.chapter + 1; newRef.section.end.chapter = newRef.section.end.chapter + 1;
if (this.ref.section.end.verse === 0) { if (newRef.section.end.verse === 0) {
this.ref.section.end.verse = 3; newRef.section.end.verse = 3;
} else { } else {
this.ref.section.end.verse = this.ref.section.end.verse + 3 - lastVerseForEnd; newRef.section.end.verse = newRef.section.end.verse + 3 - lastVerseForEnd;
} }
if (this.ref.section.end.chapter === this.ref.section.book.lastChapter + 1) { if (newRef.section.end.chapter === newRef.section.book.lastChapter + 1) {
this.ref.section.end.chapter = this.ref.section.book.lastChapter; newRef.section.end.chapter = newRef.section.book.lastChapter;
this.ref.section.end.verse = lastVerseForEnd; newRef.section.end.verse = lastVerseForEnd;
} }
} else { } else {
// or add 3 verses // or add 3 verses
this.ref.section.end.verse = this.ref.section.end.verse + 3; newRef.section.end.verse = newRef.section.end.verse + 3;
} }
if (this.ref.section.start.verse === 0) { if (newRef.section.start.verse === 0) {
this.ref.section.start.verse = 1; newRef.section.start.verse = 1;
} }
this.appService.updatePassage(this.cardItem, this.ref); this.appService.updatePassage(this.cardItem, newRef);
} }
openNote(note: NoteItem) { openNote(note: NoteItem) {