Remove code to sql
This commit is contained in:
@@ -9,18 +9,18 @@ use crate::app::{
|
||||
pub fn AdvancedOptionsMenu() -> impl IntoView {
|
||||
let state = expect_context::<Store<GlobalState>>();
|
||||
|
||||
let value = move || *state.run_selected_code().read();
|
||||
let is_default = move || !*state.run_selected_code().read();
|
||||
let value = move || *state.run_selected_sql().read();
|
||||
let is_default = move || !*state.run_selected_sql().read();
|
||||
let on_change = move |value: &bool| {
|
||||
state.run_selected_code().set(*value);
|
||||
state.run_selected_sql().set(*value);
|
||||
};
|
||||
|
||||
view! {
|
||||
<>
|
||||
<MenuGroup title="Advanced options".into()>
|
||||
<Either
|
||||
id="run_selected_code".into()
|
||||
name="Run Selected Code".into()
|
||||
id="run_selected_sql".into()
|
||||
name="Run Selected SQL".into()
|
||||
a=true
|
||||
b=false
|
||||
a_label=Some("On".to_string())
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn Editor() -> impl IntoView {
|
||||
"ace/keyboard/{}",
|
||||
state.editor_config().read_untracked().keyboard
|
||||
))
|
||||
.value(&shared_code().unwrap_or_else(|| state.code().get_untracked()))
|
||||
.value(&shared_code().unwrap_or_else(|| state.sql().get_untracked()))
|
||||
.build();
|
||||
|
||||
match aceditor::Editor::open("ace_editor", Some(&opt)) {
|
||||
|
||||
@@ -65,9 +65,9 @@ pub fn execute(state: Store<GlobalState>) -> Box<dyn Fn() + Send + 'static> {
|
||||
return;
|
||||
};
|
||||
|
||||
let run_selected_code = state.run_selected_code().get();
|
||||
let run_selected_code = state.run_selected_sql().get();
|
||||
|
||||
state.code().set(code.clone());
|
||||
state.sql().set(code.clone());
|
||||
change_focus(state, Some(Focus::Execute));
|
||||
std::mem::take(&mut *state.output().write());
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ fn hanlde_save_state(state: Store<GlobalState>) {
|
||||
state.orientation().track();
|
||||
state.theme().track();
|
||||
state.keep_ctx().track();
|
||||
state.code().track();
|
||||
state.run_selected_code().track();
|
||||
state.sql().track();
|
||||
state.run_selected_sql().track();
|
||||
|
||||
state.read_untracked().save();
|
||||
});
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct GlobalState {
|
||||
orientation: Orientation,
|
||||
theme: Theme,
|
||||
keep_ctx: bool,
|
||||
code: String,
|
||||
run_selected_code: bool,
|
||||
sql: String,
|
||||
run_selected_sql: bool,
|
||||
// runtime state below
|
||||
#[serde(skip)]
|
||||
worker: Option<WorkerHandle>,
|
||||
@@ -44,7 +44,7 @@ impl Default for GlobalState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
editor_config: EditorConfig::default(),
|
||||
code: DEFAULT_CODE.into(),
|
||||
sql: DEFAULT_CODE.into(),
|
||||
focus: None,
|
||||
show_something: false,
|
||||
orientation: Orientation::Automatic,
|
||||
@@ -58,7 +58,7 @@ impl Default for GlobalState {
|
||||
worker: None,
|
||||
editor: None,
|
||||
last_error: None,
|
||||
run_selected_code: false,
|
||||
run_selected_sql: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user