Refactored table filtering and searching so that they are now relative to the table being filtered/searched on. Also created two new widgets for error messages and popups to make life easier moving forward. Going to refactor table sorting into StatefulTable's as well so all tables can be searched, filtered, and sorted moving forwards.
This commit is contained in:
@@ -12,10 +12,10 @@ use crate::ui::radarr_ui::library::delete_movie_ui::DeleteMovieUi;
|
||||
use crate::ui::radarr_ui::library::edit_movie_ui::EditMovieUi;
|
||||
use crate::ui::radarr_ui::library::movie_details_ui::MovieDetailsUi;
|
||||
use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
||||
use crate::ui::widgets::error_message::ErrorMessage;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::{
|
||||
draw_error_message_popup, draw_input_box_popup, draw_popup_over, draw_prompt_box,
|
||||
draw_prompt_popup_over, DrawUi,
|
||||
draw_input_box_popup, draw_popup_over, draw_prompt_box, draw_prompt_popup_over, DrawUi,
|
||||
};
|
||||
use crate::utils::{convert_runtime, convert_to_gb};
|
||||
|
||||
@@ -92,21 +92,15 @@ impl DrawUi for LibraryUi {
|
||||
}
|
||||
|
||||
pub(super) fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let current_selection =
|
||||
if let Some(filtered_movies) = app.data.radarr_data.filtered_movies.as_ref() {
|
||||
filtered_movies.current_selection().clone()
|
||||
} else if !app.data.radarr_data.movies.items.is_empty() {
|
||||
app.data.radarr_data.movies.current_selection().clone()
|
||||
} else {
|
||||
Movie::default()
|
||||
};
|
||||
let current_selection = if !app.data.radarr_data.movies.items.is_empty() {
|
||||
app.data.radarr_data.movies.current_selection().clone()
|
||||
} else {
|
||||
Movie::default()
|
||||
};
|
||||
let quality_profile_map = &app.data.radarr_data.quality_profile_map;
|
||||
let tags_map = &app.data.radarr_data.tags_map;
|
||||
let downloads_vec = &app.data.radarr_data.downloads.items;
|
||||
let content = match app.data.radarr_data.filtered_movies.as_mut() {
|
||||
Some(filtered_movies) if !app.data.radarr_data.is_filtering => Some(filtered_movies),
|
||||
_ => Some(&mut app.data.radarr_data.movies),
|
||||
};
|
||||
let content = Some(&mut app.data.radarr_data.movies);
|
||||
let help_footer = app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -203,7 +197,7 @@ fn draw_movie_search_box(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
f,
|
||||
area,
|
||||
"Search",
|
||||
app.data.radarr_data.search.as_ref().unwrap(),
|
||||
app.data.radarr_data.movies.search.as_ref().unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,14 +206,17 @@ fn draw_filter_movies_box(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
f,
|
||||
area,
|
||||
"Filter",
|
||||
app.data.radarr_data.filter.as_ref().unwrap(),
|
||||
app.data.radarr_data.movies.filter.as_ref().unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
fn draw_search_movie_error_box(f: &mut Frame<'_>, _: &mut App<'_>, area: Rect) {
|
||||
draw_error_message_popup(f, area, "Movie not found!");
|
||||
f.render_widget(ErrorMessage::new("Movie not found!"), area);
|
||||
}
|
||||
|
||||
fn draw_filter_movies_error_box(f: &mut Frame<'_>, _: &mut App<'_>, area: Rect) {
|
||||
draw_error_message_popup(f, area, "No movies found matching the given filter!");
|
||||
f.render_widget(
|
||||
ErrorMessage::new("No movies found matching the given filter!"),
|
||||
area,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user