Explorar el Código

Add sorting to recipes display

Lee Morgan hace 6 años
padre
commit
9448b18898
Se han modificado 2 ficheros con 2 adiciones y 1 borrados
  1. 0 1
      views/merchantSetupPage/controller.js
  2. 2 0
      views/recipesPage/recipes.js

+ 0 - 1
views/merchantSetupPage/controller.js

@@ -1,7 +1,6 @@
 let controller = {
     data: {},  //For storing all data from user to pass to backend
 
-    //Component divs
     basicInfoStrand: document.querySelector("#basicInfoStrand"),
     addIngredientsStrand: document.querySelector("#addIngredientsStrand"),
     createIngredientsStrand: document.querySelector("#createIngredientsStrand"),

+ 2 - 0
views/recipesPage/recipes.js

@@ -17,6 +17,8 @@ let recipesObj = {
         while(body.children.length > 0){
             body.removeChild(body.firstChild);
         }
+
+        merchant.recipes.sort((a, b) => (a.name > b.name)? 1 : -1);
         
         for(let recipe of merchant.recipes){
             let recipeDiv = document.createElement("div");