Languages list is now sorted.
authorGreg Burri <greg.burri@gmail.com>
Fri, 3 Jan 2025 18:32:41 +0000 (19:32 +0100)
committerGreg Burri <greg.burri@gmail.com>
Fri, 3 Jan 2025 18:32:41 +0000 (19:32 +0100)
backend/src/consts.rs
backend/src/services/recipe.rs
backend/templates/recipe_edit.html
frontend/src/handles.rs

index 4385309..1b85736 100644 (file)
@@ -1,4 +1,4 @@
-use std::time::Duration;
+use std::{sync::LazyLock, time::Duration};
 
 pub const FILE_CONF: &str = "conf.ron";
 pub const DB_DIRECTORY: &str = "data";
@@ -21,4 +21,8 @@ pub const REVERSE_PROXY_IP_HTTP_FIELD: &str = "x-real-ip"; // Set by the reverse
 
 pub const MAX_DB_CONNECTION: u32 = 1; // To avoid database lock.
 
-pub const LANGUAGES: [(&str, &str); 2] = [("Français", "fr"), ("English", "en")];
+pub static LANGUAGES: LazyLock<[(&str, &str); 2]> = LazyLock::new(|| {
+    let mut langs = [("Français", "fr"), ("English", "en")];
+    langs.sort();
+    langs
+});
index aa69ce0..b6c872f 100644 (file)
@@ -47,7 +47,7 @@ pub async fn edit_recipe(
                     user: Some(user),
                     recipes,
                     recipe,
-                    languages: consts::LANGUAGES,
+                    languages: *consts::LANGUAGES,
                 }
                 .into_response())
             } else {
index 4b96b90..923d6d8 100644 (file)
         <option value="3" {%+ call is_difficulty(common::ron_api::Difficulty::Hard) %}>Hard</option>
     </select>
 
+    <!--
+    * Event on 'input':
+        * Trim left
+        * for all w in "<word> ":
+            * Call recipe/add_tags with all w
+            * Add all w to tag list (DOM)
+    * Event on 'click' on del tag button:
+            * Call recipe/rm_tags
+            * Remove the tag to the html list (DOM)
+    * 'enter' key to add the current tag
+    -->
+    <div id="widget-tags">
+        <label for="input-tags" >Tags</label>
+        <div class="tags"></div>
+        <input
+            id="input-tags"
+            type="text"
+            value="" />
+    </div>
+
     <label for="select-language">Language</label>
     <select id="select-language">
     {% for lang in languages %}
index 3097ea2..a65e948 100644 (file)
@@ -162,6 +162,11 @@ pub fn recipe_edit(recipe_id: i64) -> Result<(), JsValue> {
         .forget();
     }
 
+    // Tags.
+    {
+        
+    }
+
     // Language.
     {
         let language: HtmlSelectElement = by_id("select-language");