diff options
Diffstat (limited to 'src/ui/ui_projects.cpp')
| -rw-r--r-- | src/ui/ui_projects.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ui/ui_projects.cpp b/src/ui/ui_projects.cpp index 82597b4..94f2be6 100644 --- a/src/ui/ui_projects.cpp +++ b/src/ui/ui_projects.cpp @@ -26,22 +26,24 @@ static project selected_for_cancellation; static project active_project; -void ui::setup_projects() +static void _reset_to_default_view() { current_view_state = ui::view_state::LIST_ALL; active_project = administration::project_create_empty(); } +void ui::setup_projects() +{ + _reset_to_default_view(); +} + static void draw_project_form() { float widthAvailable = ImGui::GetContentRegionAvail().x; bool viewing_only = (current_view_state == ui::view_state::VIEW_EXISTING); - static const char* selected_country = NULL; - if (ImGui::Button(locale::get("form.back"))) { - current_view_state = ui::view_state::LIST_ALL; - active_project = administration::project_create_empty(); - selected_country = 0; + if (ImGui::Button(locale::get("form.back"), true, false)) { + _reset_to_default_view(); return; } ImGui::Spacing(); @@ -63,7 +65,10 @@ static void draw_project_form() if (!can_save) ImGui::BeginDisabled(); // Save button ImGui::Spacing(); - if (ImGui::Button(locale::get("form.save"))) { + if (ImGui::Button(locale::get("form.save"), true)) { + + administration_writer::set_write_completed_event_callback(_reset_to_default_view); + if (current_view_state == ui::view_state::CREATE) { administration::project_add(active_project); } @@ -71,10 +76,6 @@ static void draw_project_form() else if (current_view_state == ui::view_state::EDIT_EXISTING) { administration::project_update(active_project); } - - current_view_state = ui::view_state::LIST_ALL; - selected_country = 0; - active_project = administration::project_create_empty(); } if (!can_save) ImGui::EndDisabled(); } |
