diff --git a/src/presentation/web/views/cafes.rs b/src/presentation/web/views/cafes.rs index 71928f5..05af75c 100644 --- a/src/presentation/web/views/cafes.rs +++ b/src/presentation/web/views/cafes.rs @@ -45,6 +45,7 @@ pub struct CafeView { pub name: String, pub city: String, pub country: String, + pub country_flag: String, pub latitude: f64, pub longitude: f64, pub map_url: String, @@ -75,6 +76,9 @@ impl From for CafeView { let has_website = !website.is_empty(); let detail_path = format!("/cafes/{slug}"); let map_url = format!("https://www.google.com/maps?q={latitude},{longitude}"); + let country_flag = country_to_iso(&country) + .map(iso_to_flag_emoji) + .unwrap_or_default(); let created_at_sort_key = created_at.timestamp(); let created_date = created_at.format("%Y-%m-%d").to_string(); @@ -85,6 +89,7 @@ impl From for CafeView { id: id.to_string(), name, city, + country_flag, country, latitude, longitude, diff --git a/src/presentation/web/views/roasters.rs b/src/presentation/web/views/roasters.rs index e1e713c..a7d58d0 100644 --- a/src/presentation/web/views/roasters.rs +++ b/src/presentation/web/views/roasters.rs @@ -66,6 +66,7 @@ pub struct RoasterView { pub detail_path: String, pub name: String, pub country: String, + pub country_flag: String, pub city: String, pub has_homepage: bool, pub homepage_url: String, @@ -90,6 +91,9 @@ impl From for RoasterView { let homepage = homepage.unwrap_or_default(); let has_homepage = !homepage.is_empty(); let detail_path = format!("/roasters/{slug}"); + let country_flag = country_to_iso(&country) + .map(iso_to_flag_emoji) + .unwrap_or_default(); let created_at_sort_key = created_at.timestamp(); let created_date = created_at.format("%Y-%m-%d").to_string(); @@ -99,6 +103,7 @@ impl From for RoasterView { detail_path, id: id.to_string(), name, + country_flag, country, city: city.unwrap_or_else(|| "—".to_string()), has_homepage, diff --git a/src/presentation/web/views/roasts.rs b/src/presentation/web/views/roasts.rs index 0f7aaa7..37ae5f0 100644 --- a/src/presentation/web/views/roasts.rs +++ b/src/presentation/web/views/roasts.rs @@ -1,3 +1,4 @@ +use crate::domain::countries::{country_to_iso, iso_to_flag_emoji}; use crate::domain::roasters::Roaster; use crate::domain::roasts::{Roast, RoastWithRoaster}; @@ -11,6 +12,7 @@ pub struct RoastView { pub name: String, pub roaster_label: String, pub origin: String, + pub origin_flag: String, pub region: String, pub producer: String, pub process: String, @@ -55,6 +57,11 @@ impl RoastView { } else { roaster_name.to_string() }; + let origin_flag = origin + .as_deref() + .and_then(country_to_iso) + .map(iso_to_flag_emoji) + .unwrap_or_default(); let origin = origin.unwrap_or_else(|| "—".to_string()); let region = region.unwrap_or_else(|| "—".to_string()); let producer = producer.unwrap_or_else(|| "—".to_string()); @@ -81,6 +88,7 @@ impl RoastView { name, roaster_label, origin, + origin_flag, region, producer, process, diff --git a/templates/partials/lists/cafe_list.html b/templates/partials/lists/cafe_list.html index 61c66d3..c21c484 100644 --- a/templates/partials/lists/cafe_list.html +++ b/templates/partials/lists/cafe_list.html @@ -25,8 +25,8 @@ {{ table::sortable_header("Added", "created-at", navigator, "#cafe-list") }} {{ table::sortable_header("Name", "name", navigator, "#cafe-list") }} - {{ table::sortable_header("City", "city", navigator, "#cafe-list") }} {{ table::sortable_header("Country", "country", navigator, "#cafe-list") }} + {{ table::sortable_header("City", "city", navigator, "#cafe-list") }} @@ -48,10 +48,10 @@ {{ cafe.name }} - {{ cafe.country }} + {% if !cafe.country_flag.is_empty() %}{{ cafe.country_flag }} {% endif %}{{ cafe.country }} {{ cafe.city }} + {% if !cafe.country_flag.is_empty() %}{{ cafe.country_flag }} {% endif %}{{ cafe.country }} {{ cafe.city }} - {{ cafe.country }} diff --git a/templates/partials/lists/roast_list.html b/templates/partials/lists/roast_list.html index bf16daa..1e5f173 100644 --- a/templates/partials/lists/roast_list.html +++ b/templates/partials/lists/roast_list.html @@ -52,7 +52,7 @@ {{ roast.roaster_label }} - {{ roast.origin }} + {% if !roast.origin_flag.is_empty() %}{{ roast.origin_flag }} {% endif %}{{ roast.origin }} {% if !roast.producer.is_empty() %} {% endif %} diff --git a/templates/partials/lists/roaster_list.html b/templates/partials/lists/roaster_list.html index f27dc8b..9114bf5 100644 --- a/templates/partials/lists/roaster_list.html +++ b/templates/partials/lists/roaster_list.html @@ -48,11 +48,11 @@ {{ roaster.name }} - {{ roaster.country }} + {% if !roaster.country_flag.is_empty() %}{{ roaster.country_flag }} {% endif %}{{ roaster.country }} {% if !roaster.city.is_empty() %} {{ roaster.city }} {% endif %} - {{ roaster.country }} + {% if !roaster.country_flag.is_empty() %}{{ roaster.country_flag }} {% endif %}{{ roaster.country }} {{ roaster.city }}