feat: Add simple form of ADD SWITCHER keyword without AS clause
- ADD_SWITCHER "tables" now works (label defaults to switcher ID) - ADD_SWITCHER "tables" AS "Tabelas" still works (custom label) - Follows same pattern as ADD_SUGGESTION simple/AS forms - Fixes #495
This commit is contained in:
parent
8a97c0517f
commit
3048832a2d
1 changed files with 21 additions and 0 deletions
|
|
@ -89,6 +89,8 @@ pub fn add_switcher_keyword(
|
|||
engine: &mut Engine,
|
||||
) {
|
||||
let cache = state.cache.clone();
|
||||
let cache2 = state.cache.clone();
|
||||
let user_session2 = user_session.clone();
|
||||
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
|
|
@ -109,6 +111,25 @@ pub fn add_switcher_keyword(
|
|||
},
|
||||
)
|
||||
.expect("valid syntax registration");
|
||||
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
["ADD_SWITCHER", "$expr$"],
|
||||
true,
|
||||
move |context, inputs| {
|
||||
let switcher_id = context.eval_expression_tree(&inputs[0])?.to_string();
|
||||
|
||||
add_switcher(
|
||||
cache2.as_ref(),
|
||||
&user_session2,
|
||||
&switcher_id,
|
||||
&switcher_id,
|
||||
)?;
|
||||
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.expect("valid syntax registration");
|
||||
}
|
||||
|
||||
fn add_switcher(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue