Attempt to load only avaialable books

This commit is contained in:
Leonard Smith 2020-10-06 17:05:33 -05:00
parent a98f0363cf
commit 14ade53db5
1 changed files with 27 additions and 1 deletions

View File

@ -6,15 +6,41 @@ import { inject as service } from '@ember/service';
export default class ScriptureNavBarComponent extends Component {
@service router;
@service store;
@tracked chaptersVisible = false;
@tracked versesVisible = false;
@tracked currentBook = null;
@tracked currentChapter = null;
@tracked books = [];
constructor(...args) {
super(...args);
this.books = books;
console.log(books);
this.books = this.availableBooks;
// console.log(this.books);
}
// get only the books that we have backend data for
get
availableBooks()
{
return this.store.findAll('book').then(function(backendBooks) {
let available = [];
backendBooks.forEach(
value => {
let foundValue = books.find(function(book) {
return book['name'] == value.id
});
if(foundValue) {
available.push(foundValue);
}
});
return available;
}).then(function(response) {
console.log(response);
return response;
});
}
@action