-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Edit assoc. authors for Book using combobox
- Loading branch information
1 parent
a51e730
commit 74482f9
Showing
19 changed files
with
444 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::sync::{Arc, Mutex}; | ||
|
||
use libcalibre::{ | ||
application::services::domain::author::service::{AuthorService, AuthorServiceTrait}, | ||
infrastructure::domain::author::repository::AuthorRepository, | ||
}; | ||
|
||
use crate::book::LibraryAuthor; | ||
|
||
impl From<&libcalibre::Author> for LibraryAuthor { | ||
fn from(author: &libcalibre::Author) -> Self { | ||
LibraryAuthor { | ||
id: author.id.to_string(), | ||
name: author.name.clone(), | ||
sortable_name: author.sort.clone().unwrap_or("".to_string()), | ||
} | ||
} | ||
} | ||
|
||
pub fn list_all(library_root: String) -> Vec<LibraryAuthor> { | ||
let database_path = libcalibre::util::get_db_path(&library_root); | ||
match database_path { | ||
None => vec![], | ||
Some(database_path) => { | ||
let author_repo = Box::new(AuthorRepository::new(&database_path)); | ||
let author_service = Arc::new(Mutex::new(AuthorService::new(author_repo))); | ||
|
||
{ | ||
let mut guarded_as = author_service.lock().unwrap(); | ||
match guarded_as.all() { | ||
Ok(authors) => authors.iter().map(|a| LibraryAuthor::from(a)).collect(), | ||
Err(_) => vec![], | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.