feat: sort projects by title internationally
This commit is contained in:
parent
0a092f5763
commit
5cb0241e07
@ -6,15 +6,15 @@ use crate::models::task::NewTask;
|
||||
use crate::models::task::Task;
|
||||
use crate::query::{QueryErrors, QueryKey, QueryValue};
|
||||
use crate::route::Route;
|
||||
use crate::server::projects::get_projects;
|
||||
use crate::server::tasks::{create_task, delete_task, edit_task};
|
||||
use chrono::Duration;
|
||||
use dioxus::core_macro::{component, rsx};
|
||||
use dioxus::dioxus_core::Element;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_query::prelude::use_query_client;
|
||||
use dioxus_query::prelude::{use_query_client, QueryResult};
|
||||
use dioxus_sdk::i18n::use_i18;
|
||||
use dioxus_sdk::translate;
|
||||
use crate::query::projects::use_projects_query;
|
||||
|
||||
const REMINDER_OFFSETS: [Option<Duration>; 17] = [
|
||||
None,
|
||||
@ -38,7 +38,7 @@ const REMINDER_OFFSETS: [Option<Duration>; 17] = [
|
||||
|
||||
#[component]
|
||||
pub(crate) fn TaskForm(task: Option<Task>, on_successful_submit: EventHandler<()>) -> Element {
|
||||
let projects = use_server_future(get_projects)?.unwrap().unwrap();
|
||||
let projects_query = use_projects_query();
|
||||
|
||||
let route = use_route::<Route>();
|
||||
let selected_category = use_signal(|| if let Some(task) = &task {
|
||||
@ -178,6 +178,12 @@ pub(crate) fn TaskForm(task: Option<Task>, on_successful_submit: EventHandler<()
|
||||
value: 0,
|
||||
{translate!(i18, "none")}
|
||||
},
|
||||
match projects_query.result().value() {
|
||||
QueryResult::Ok(QueryValue::Projects(projects))
|
||||
| QueryResult::Loading(Some(QueryValue::Projects(projects))) => {
|
||||
let mut projects = projects.clone();
|
||||
projects.sort();
|
||||
rsx! {
|
||||
for project in projects {
|
||||
option {
|
||||
value: project.id().to_string(),
|
||||
@ -187,6 +193,18 @@ pub(crate) fn TaskForm(task: Option<Task>, on_successful_submit: EventHandler<()
|
||||
{project.title()}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
QueryResult::Loading(None) => rsx! {
|
||||
// TODO: Add a loading indicator.
|
||||
},
|
||||
QueryResult::Err(errors) => rsx! {
|
||||
div {
|
||||
"Errors occurred: {errors:?}"
|
||||
}
|
||||
},
|
||||
value => panic!("Unexpected query result: {value:?}")
|
||||
}
|
||||
},
|
||||
},
|
||||
div {
|
||||
|
@ -2,6 +2,7 @@ use std::cmp::Ordering;
|
||||
use chrono::NaiveDateTime;
|
||||
use crate::schema::projects;
|
||||
use diesel::prelude::*;
|
||||
use feruca::Collator;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
@ -46,7 +47,7 @@ impl PartialOrd<Self> for Project {
|
||||
|
||||
impl Ord for Project {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.title().cmp(other.title())
|
||||
Collator::default().collate(self.title(), other.title())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user