feat(core): add built-in filter in search bar

This commit is contained in:
Federico Terzi 2021-08-18 15:52:19 +02:00
parent d4cede1862
commit 0f361ba6d0
5 changed files with 8 additions and 1 deletions

View File

@ -48,7 +48,7 @@ pub fn search_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 {
// Overwrite the icon
config.icon = icon_paths.logo.as_deref().map(|path| path.to_string_lossy().to_string());
let algorithm = algorithm::get_algorithm(&config.algorithm);
let algorithm = algorithm::get_algorithm(&config.algorithm, true);
let search = generator::generate(config);
let result = show(search, algorithm);

View File

@ -32,6 +32,7 @@ pub struct MatchSummary<'a> {
pub id: i32,
pub label: &'a str,
pub tag: Option<&'a str>,
pub is_builtin: bool,
}
pub struct MatchSelectorAdapter<'a> {
@ -60,6 +61,7 @@ impl<'a> MatchSelector for MatchSelectorAdapter<'a> {
id: m.id.to_string(),
label: clipped_label.to_string(),
tag: m.tag.map(String::from),
is_builtin: m.is_builtin,
}
})
.collect();

View File

@ -128,11 +128,13 @@ impl<'a> super::engine::process::middleware::match_select::MatchProvider<'a>
id: m.id,
label: m.description(),
tag: m.cause_description(),
is_builtin: false,
},
MatchVariant::Builtin(m) => MatchSummary {
id: m.id,
label: m.label,
tag: m.triggers.first().map(String::as_ref),
is_builtin: true,
},
})
.collect()

View File

@ -32,6 +32,7 @@ pub struct SearchItem {
pub id: String,
pub label: String,
pub tag: Option<String>,
pub is_builtin: bool,
}
pub trait FormUI {

View File

@ -75,6 +75,7 @@ struct ModuloSearchItemConfig<'a> {
id: &'a str,
label: &'a str,
trigger: Option<&'a str>,
is_builtin: bool,
}
// TODO: test
@ -83,5 +84,6 @@ fn convert_items<'a>(items: &'a [SearchItem]) -> Vec<ModuloSearchItemConfig<'a>>
id: &item.id,
label: &item.label,
trigger: item.tag.as_deref(),
is_builtin: item.is_builtin,
}).collect()
}