summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_contacts.cpp56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp
index e00fb78..0ade9b0 100644
--- a/src/ui/ui_contacts.cpp
+++ b/src/ui/ui_contacts.cpp
@@ -31,29 +31,31 @@ bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool vi
}
}
ImGui::Spacing();
-
- ImGui::BeginDisabled();
-
float widthAvailable = ImGui::GetContentRegionAvail().x;
- ImGui::SetNextItemWidth(widthAvailable*0.2f);
- ImGui::InputText(localize("contact.form.identifier"), buffer->id, IM_ARRAYSIZE(buffer->id));
- if (!viewing_only) ImGui::EndDisabled();
+ // 1. Identifier
+ //ImGui::BeginDisabled();
+ //ImGui::SetNextItemWidth(widthAvailable*0.2f);
+ //ImGui::InputText(localize("contact.form.identifier"), buffer->id, IM_ARRAYSIZE(buffer->id));
+ //if (!viewing_only) ImGui::EndDisabled();
+ // 2. Full name
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.fullname"), localize("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name));
ImGui::SameLine();ui_helper_draw_required_tag();
+ // 3. Address line 1
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.address1"), localize("contact.form.address1"), buffer->address.address1, IM_ARRAYSIZE(buffer->address.address1));
ImGui::SameLine();ui_helper_draw_required_tag();
+ // 4. Address line 2
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.address2"), localize("contact.form.address2"), buffer->address.address2, IM_ARRAYSIZE(buffer->address.address2));
ImGui::SameLine();ui_helper_draw_required_tag();
+ // 5. Country dropdown.
ImGui::SetNextItemWidth(widthAvailable*0.5f);
-
const char* countries[] = { localize("country.AT"),localize("country.BE"),localize("country.BG"),localize("country.HR"),localize("country.CY"),localize("country.CZ"),localize("country.DK"),localize("country.EE"),localize("country.FI"),localize("country.FR"),localize("country.DE"),localize("country.GR"),localize("country.HU"),localize("country.IE"),localize("country.IT"),localize("country.LV"),localize("country.LT"),localize("country.LU"),localize("country.MT"),localize("country.NL"),localize("country.PL"),localize("country.PT"),localize("country.RO"),localize("country.SK"),localize("country.SI"),localize("country.ES"),localize("country.SE") };
const char* country_codes[] = {
"AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR",
@@ -64,7 +66,7 @@ bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool vi
if (selected_country == 0) {
for (int i = 0; i < country_count; i++)
{
- if (strcmp(country_codes[i], buffer->address.country) == 0)
+ if (strcmp(country_codes[i], buffer->address.country_code) == 0)
{
selected_country = countries[i];
break;
@@ -86,22 +88,40 @@ bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool vi
ImGui::EndCombo();
}
if (selected_country_index != -1) {
- strops_copy(buffer->address.country, country_codes[selected_country_index], IM_ARRAYSIZE(buffer->address.country));
+ strops_copy(buffer->address.country_code, country_codes[selected_country_index], IM_ARRAYSIZE(buffer->address.country_code));
}
ImGui::SameLine();ui_helper_draw_required_tag();
-
- ImGui::SetNextItemWidth(widthAvailable*0.5f);
- ImGui::InputTextWithHint(localize("contact.form.taxnumber"), localize("contact.form.taxnumber"), buffer->taxid, IM_ARRAYSIZE(buffer->taxid));
-
+
+ // 6. Contact type dropdown.
ImGui::SetNextItemWidth(widthAvailable*0.5f);
- ImGui::InputTextWithHint(localize("contact.form.businessnumber"), localize("contact.form.businessnumber"), buffer->businessid, IM_ARRAYSIZE(buffer->businessid));
-
+ const char* customer_types[2] = { localize("contact.form.type.business"), localize("contact.form.type.consumer") };
+ int currentItem = static_cast<int>(buffer->type);
+ if (ImGui::Combo(localize("contact.form.type"), &currentItem, customer_types, IM_ARRAYSIZE(customer_types)))
+ {
+ buffer->type = static_cast<contact_type>(currentItem);
+ }
+
+ // Fields only required for businesses.
+ if (buffer->type == contact_type::CONTACT_BUSINESS)
+ {
+ // 7. Tax number
+ ImGui::SetNextItemWidth(widthAvailable*0.5f);
+ ImGui::InputTextWithHint(localize("contact.form.taxnumber"), localize("contact.form.taxnumber"), buffer->taxid, IM_ARRAYSIZE(buffer->taxid));
+
+ // 8. Business number / Chamber of commerce
+ ImGui::SetNextItemWidth(widthAvailable*0.5f);
+ ImGui::InputTextWithHint(localize("contact.form.businessnumber"), localize("contact.form.businessnumber"), buffer->businessid, IM_ARRAYSIZE(buffer->businessid));
+ }
+
+ // 9. Email
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.email"), localize("contact.form.email"), buffer->email, IM_ARRAYSIZE(buffer->email));
+ // 10. Phone number
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.phonenumber"), localize("contact.form.phonenumber"), buffer->phone_number, IM_ARRAYSIZE(buffer->phone_number));
+ // 11. Bank account.
ImGui::SetNextItemWidth(widthAvailable*0.5f);
ImGui::InputTextWithHint(localize("contact.form.bankaccount"), localize("contact.form.bankaccount"), buffer->bank_account, IM_ARRAYSIZE(buffer->bank_account));
@@ -109,7 +129,7 @@ bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool vi
if (!viewing_only) {
bool can_save = strlen(buffer->name) > 0 && strlen(buffer->address.address1) > 0 &&
- strlen(buffer->address.address2) > 0 && strlen(buffer->address.country) > 0;
+ strlen(buffer->address.address2) > 0 && strlen(buffer->address.country_code) > 0;
if (!can_save) ImGui::BeginDisabled();
// Save button
@@ -132,6 +152,7 @@ static void draw_contact_list()
s32 max_page = (administration_get_contact_count() + items_per_page - 1) / items_per_page;
if (max_page == 0) max_page = 1;
+ // Table header controls: create button and pagination.
if (ImGui::Button(localize("form.create")))
{
current_view_state = view_state::CREATE;
@@ -142,6 +163,7 @@ static void draw_contact_list()
if (current_page >= max_page-1) current_page = max_page-1;
if (current_page < 0) current_page = 0;
+ // Navigate to prev page button.
ImGui::SameLine();
bool enable_prev = current_page > 0;
if (!enable_prev) ImGui::BeginDisabled();
@@ -151,6 +173,7 @@ static void draw_contact_list()
ImGui::SameLine();
ImGui::Text("(%d/%d)", current_page+1, max_page);
+ // Navigate to next page button.
ImGui::SameLine();
bool enable_next = current_page < max_page-1;
if (!enable_next) ImGui::BeginDisabled();
@@ -206,6 +229,7 @@ static void draw_contact_list()
}
}
+ // Confirmation popup before contact is deleted definitively.
if (ImGui::BeginPopupModal("ConfirmDeletePopup", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoTitleBar)) {
ImGui::Text(localize("form.confirmDelete"));
ImGui::Separator();