summaryrefslogtreecommitdiff
path: root/src/ui/ui_contacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_contacts.cpp')
-rw-r--r--src/ui/ui_contacts.cpp76
1 files changed, 4 insertions, 72 deletions
diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp
index 4e15bb1..0f1716f 100644
--- a/src/ui/ui_contacts.cpp
+++ b/src/ui/ui_contacts.cpp
@@ -28,17 +28,6 @@ static contact selected_for_removal;
static contact active_contact;
-void draw_address_form(address* buffer, a_err last_err, bool active_countries_only = false)
-{
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.address1"), buffer->address1, IM_ARRAYSIZE(buffer->address1), last_err & A_ERR_MISSING_ADDRESS1);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.address2"), buffer->address2, IM_ARRAYSIZE(buffer->address2), 0);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.city"), buffer->city, IM_ARRAYSIZE(buffer->city), last_err & A_ERR_MISSING_CITY);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.postal"), buffer->postal, IM_ARRAYSIZE(buffer->postal), last_err & A_ERR_MISSING_POSTAL);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.region"), buffer->region, IM_ARRAYSIZE(buffer->region), 0);
-
- ImGui::FormCountryCombo(buffer->country_code, IM_ARRAYSIZE(buffer->country_code), active_countries_only);
-}
-
void ui::setup_contacts()
{
current_view_state = ui::view_state::LIST_ALL;
@@ -46,63 +35,6 @@ void ui::setup_contacts()
memops::zero(&selected_for_removal, sizeof(contact));
}
-void draw_addressee_form_ex(delivery_info* buffer, bool viewing_only = false)
-{
- a_err last_err = administration::addressee_is_valid(*buffer);
-
- ImGui::PushID(buffer);
-
- ImGui::Spacing();
- ImGui::BeginDisabled();
-
- if (!viewing_only) ImGui::EndDisabled();
-
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME);
-
- draw_address_form(&buffer->address, last_err);
-
- if (viewing_only) ImGui::EndDisabled();
- ImGui::PopID();
-}
-
-void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_autocomplete = false, bool active_countries_only = false)
-{
- a_err last_err = administration::contact_is_valid(*buffer);
-
- ImGui::PushID(buffer);
-
- ImGui::Spacing();
- ImGui::BeginDisabled();
-
- if (!viewing_only) ImGui::EndDisabled();
-
- if (with_autocomplete) ImGui::FormContactAutocomplete(buffer, last_err & A_ERR_MISSING_NAME);
- else ImGui::FormInputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME);
-
- draw_address_form(&buffer->address, last_err, active_countries_only);
-
- ImGui::FormContactTypeCombo(&buffer->type);
-
- // Fields only required for businesses.
- if (buffer->type == contact_type::CONTACT_BUSINESS)
- {
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.taxnumber"), buffer->taxid, IM_ARRAYSIZE(buffer->taxid), last_err & A_ERR_MISSING_TAXID);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.businessnumber"), buffer->businessid, IM_ARRAYSIZE(buffer->businessid), last_err & A_ERR_MISSING_BUSINESSID);
- }
-
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.email"), buffer->email, IM_ARRAYSIZE(buffer->email), last_err & A_ERR_MISSING_EMAIL);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.phonenumber"), buffer->phone_number, IM_ARRAYSIZE(buffer->phone_number), 0);
- ImGui::FormInputTextWithErrorHint(locale::get("contact.form.bankaccount"), buffer->bank_account, IM_ARRAYSIZE(buffer->bank_account), 0);
-
- if (viewing_only) ImGui::EndDisabled();
- ImGui::PopID();
-}
-
-void draw_contact_form(contact* buffer, bool viewing_only = false)
-{
- draw_contact_form_ex(buffer, viewing_only, false);
-}
-
static void draw_contact_list()
{
static char search_buffer[MAX_LEN_LONG_DESC];
@@ -169,7 +101,7 @@ static void draw_contact_list()
if (administration::contact_is_valid(c) != A_ERR_SUCCESS)
{
- if (ImGui::DrawWarningIcon(8.0f)) {
+ if (ImGui::WarningIcon(8.0f)) {
ImGui::SetTooltip(locale::get("ui.tooltip.invalidContact"));
}
}
@@ -228,7 +160,7 @@ static void draw_contacts_create()
current_view_state = ui::view_state::LIST_ALL;
}
- draw_contact_form(&active_contact);
+ ImGui::ContactForm(&active_contact, false, false);
a_err contact_validation_err = administration::contact_is_valid(active_contact);
bool can_save = contact_validation_err == A_ERR_SUCCESS;
@@ -248,7 +180,7 @@ static void draw_contacts_update()
current_view_state = ui::view_state::LIST_ALL;
}
- draw_contact_form(&active_contact);
+ ImGui::ContactForm(&active_contact, false, false);
a_err contact_validation_err = administration::contact_is_valid(active_contact);
bool can_save = contact_validation_err == A_ERR_SUCCESS;
@@ -275,7 +207,7 @@ void ui::draw_contacts()
current_view_state = ui::view_state::LIST_ALL;
}
- draw_contact_form(&active_contact, true);
+ ImGui::ContactForm(&active_contact, true, false);
break;
}
} \ No newline at end of file