2020-10-04 21:58:28 +00:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from "@glimmer/tracking";
|
|
|
|
import { books } from "../data/book-chapter-verse";
|
2020-10-05 04:06:09 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-10-04 21:58:28 +00:00
|
|
|
|
|
|
|
export default class ScriptureNavBarComponent extends Component {
|
2020-10-05 04:06:09 +00:00
|
|
|
@service router;
|
2020-10-06 22:05:33 +00:00
|
|
|
@service store;
|
2020-10-05 04:06:09 +00:00
|
|
|
|
2020-10-04 21:58:28 +00:00
|
|
|
@tracked chaptersVisible = false;
|
|
|
|
@tracked versesVisible = false;
|
|
|
|
@tracked currentBook = null;
|
|
|
|
@tracked currentChapter = null;
|
2020-10-06 22:05:33 +00:00
|
|
|
@tracked books = [];
|
2020-10-04 21:58:28 +00:00
|
|
|
|
|
|
|
constructor(...args) {
|
|
|
|
super(...args);
|
2020-10-06 22:05:33 +00:00
|
|
|
console.log(books);
|
2020-10-07 01:09:05 +00:00
|
|
|
this.books = this.getBooks();
|
2020-10-06 22:05:33 +00:00
|
|
|
// console.log(this.books);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get only the books that we have backend data for
|
2020-10-07 01:09:05 +00:00
|
|
|
async getBooks()
|
2020-10-06 22:05:33 +00:00
|
|
|
{
|
2020-10-07 01:09:05 +00:00
|
|
|
const results = await this.store.findAll('book');
|
|
|
|
|
|
|
|
this.books = results.map((book) => {
|
|
|
|
let foundValue = books.find(function(value) {
|
|
|
|
return value['name'] == book.id
|
|
|
|
});
|
|
|
|
if(foundValue) {
|
|
|
|
return foundValue;
|
|
|
|
}
|
2020-10-06 22:05:33 +00:00
|
|
|
});
|
2020-10-04 21:58:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
showChapters(book) {
|
|
|
|
this.chaptersVisible = true;
|
|
|
|
this.versesVisible = false;
|
|
|
|
this.currentBook = book;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
showVerses(book, chapter) {
|
|
|
|
this.versesVisible = true;
|
|
|
|
this.currentChapter = chapter;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
verseSelected(book, chapter, verse) {
|
2020-10-06 14:46:24 +00:00
|
|
|
// Load the DOM with verse page
|
2020-10-05 21:30:11 +00:00
|
|
|
console.log('[verseSelected] called: ' + book + ' ' + chapter.chapter + ':' + verse);
|
|
|
|
console.log(chapter);
|
2020-10-06 14:46:24 +00:00
|
|
|
this.router.transitionTo('verse', book + '-' + chapter.chapter + '-' + verse);
|
2020-10-04 21:58:28 +00:00
|
|
|
}
|
|
|
|
}
|