summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-06 12:21:47 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:51 +0300
commitd772d10d6632018f884595d85cacc37ba94caede (patch)
tree550f9d49fcdb85870221922f79432999632a572a
parentb6c0236d24a6252aad0e6f14b5a5f41052ed854d (diff)
merge FirstName/LastName fields in Contacts
First names and Last names are an anglocentric concept and do not apply cleanly to the rest of the world's cultures.
-rw-r--r--melib/src/addressbook.rs27
-rw-r--r--ui/src/components/contacts.rs4
-rw-r--r--ui/src/components/contacts/contact_list.rs42
-rw-r--r--ui/src/components/mail/view.rs2
4 files changed, 19 insertions, 56 deletions
diff --git a/melib/src/addressbook.rs b/melib/src/addressbook.rs
index 3d5e2f8d..8a79041b 100644
--- a/melib/src/addressbook.rs
+++ b/melib/src/addressbook.rs
@@ -38,8 +38,7 @@ pub struct AddressBook {
pub struct Card {
id: CardId,
title: String,
- firstname: String,
- lastname: String,
+ name: String,
additionalname: String,
name_prefix: String,
name_suffix: String,
@@ -94,8 +93,7 @@ impl Card {
Card {
id: Uuid::new_v4(),
title: String::new(),
- firstname: String::new(),
- lastname: String::new(),
+ name: String::new(),
additionalname: String::new(),
name_prefix: String::new(),
name_suffix: String::new(),
@@ -118,11 +116,8 @@ impl Card {
pub fn title(&self) -> &str {
self.title.as_str()
}
- pub fn firstname(&self) -> &str {
- self.firstname.as_str()
- }
- pub fn lastname(&self) -> &str {
- self.lastname.as_str()
+ pub fn name(&self) -> &str {
+ self.name.as_str()
}
pub fn additionalname(&self) -> &str {
self.additionalname.as_str()
@@ -152,11 +147,8 @@ impl Card {
pub fn set_title(&mut self, new: String) {
self.title = new;
}
- pub fn set_firstname(&mut self, new: String) {
- self.firstname = new;
- }
- pub fn set_lastname(&mut self, new: String) {
- self.lastname = new;
+ pub fn set_name(&mut self, new: String) {
+ self.name = new;
}
pub fn set_additionalname(&mut self, new: String) {
self.additionalname = new;
@@ -191,11 +183,8 @@ impl From<FnvHashMap<String, String>> for Card {
if let Some(val) = map.remove("Title") {
card.title = val;
}
- if let Some(val) = map.remove("First Name") {
- card.firstname = val;
- }
- if let Some(val) = map.remove("Last Name") {
- card.lastname = val;
+ if let Some(val) = map.remove("Name") {
+ card.name = val;
}
if let Some(val) = map.remove("Additional Name") {
card.additionalname = val;
diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs
index 5bc9fbdf..3f844b85 100644
--- a/ui/src/components/contacts.rs
+++ b/ui/src/components/contacts.rs
@@ -98,9 +98,7 @@ impl ContactManager {
self.form = FormWidget::new("Save".into());
self.form.add_button(("Cancel".into(), false));
self.form
- .push(("First Name".into(), self.card.firstname().to_string()));
- self.form
- .push(("Last Name".into(), self.card.lastname().to_string()));
+ .push(("Name".into(), self.card.name().to_string()));
self.form.push((
"Additional Name".into(),
self.card.additionalname().to_string(),
diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs
index ff23dd81..5fd5b3ae 100644
--- a/ui/src/components/contacts/contact_list.rs
+++ b/ui/src/components/contacts/contact_list.rs
@@ -77,25 +77,17 @@ impl ContactList {
if self.id_positions.capacity() < book.len() {
self.id_positions.reserve(book.len());
}
- let mut maxima = (
- "First Name".len(),
- "Last Name".len(),
- "E-mail".len(),
- "URL".len(),
- );
+ let mut maxima = ("Name".len(), "E-mail".len());
for c in book.values() {
self.id_positions.push(*c.id());
- maxima.0 = std::cmp::max(maxima.0, c.firstname().split_graphemes().len());
- maxima.1 = std::cmp::max(maxima.1, c.lastname().split_graphemes().len());
- maxima.2 = std::cmp::max(maxima.2, c.email().split_graphemes().len());
- maxima.3 = std::cmp::max(maxima.3, c.url().split_graphemes().len());
+ maxima.0 = std::cmp::max(maxima.0, c.name().split_graphemes().len());
+ maxima.1 = std::cmp::max(maxima.1, c.email().split_graphemes().len());
}
maxima.0 += 5;
maxima.1 += maxima.0 + 5;
- maxima.2 += maxima.1 + 5;
write_string_to_grid(
- "First Name",
+ "Name",
&mut self.content,
Color::Default,
Color::Default,
@@ -103,19 +95,11 @@ impl ContactList {
false,
);
write_string_to_grid(
- "Last Name",
- &mut self.content,
- Color::Default,
- Color::Default,
- ((maxima.0, 0), (MAX_COLS - 1, self.length)),
- false,
- );
- write_string_to_grid(
"E-mail",
&mut self.content,
Color::Default,
Color::Default,
- ((maxima.1, 0), (MAX_COLS - 1, self.length)),
+ ((maxima.0, 0), (MAX_COLS - 1, self.length)),
false,
);
write_string_to_grid(
@@ -123,14 +107,14 @@ impl ContactList {
&mut self.content,
Color::Default,
Color::Default,
- ((maxima.2, 0), (MAX_COLS - 1, self.length)),
+ ((maxima.1, 0), (MAX_COLS - 1, self.length)),
false,
);
for (i, c) in book.values().enumerate() {
self.id_positions.push(*c.id());
write_string_to_grid(
- c.firstname(),
+ c.name(),
&mut self.content,
Color::Default,
Color::Default,
@@ -138,19 +122,11 @@ impl ContactList {
false,
);
write_string_to_grid(
- c.lastname(),
- &mut self.content,
- Color::Default,
- Color::Default,
- ((maxima.0, i + 1), (MAX_COLS - 1, self.length)),
- false,
- );
- write_string_to_grid(
c.email(),
&mut self.content,
Color::Default,
Color::Default,
- ((maxima.1, i + 1), (MAX_COLS - 1, self.length)),
+ ((maxima.0, i + 1), (MAX_COLS - 1, self.length)),
false,
);
write_string_to_grid(
@@ -158,7 +134,7 @@ impl ContactList {
&mut self.content,
Color::Default,
Color::Default,
- ((maxima.2, i + 1), (MAX_COLS - 1, self.length)),
+ ((maxima.1, i + 1), (MAX_COLS - 1, self.length)),
false,
);
}
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index c787aae0..5d44c0c1 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -550,7 +550,7 @@ impl Component for MailView {
let mut new_card: Card = Card::new();
new_card.set_email(env.get_email());
- new_card.set_lastname(env.get_display_name());
+ new_card.set_name(env.get_display_name());
results.push(new_card);
}
}