|
|
@@ -3,7 +3,7 @@ window.ingredientsStrandObj = {
|
|
|
|
|
|
display: function(){
|
|
|
if(!this.isPopulated){
|
|
|
- let categories = this.categorizeIngredients();
|
|
|
+ let categories = categorizeIngredients();
|
|
|
|
|
|
let ingredientStrand = document.querySelector("#ingredientsStrand");
|
|
|
for(let category of categories){
|
|
|
@@ -54,41 +54,6 @@ window.ingredientsStrandObj = {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- categorizeIngredients: function(){
|
|
|
- let ingredientsByCategory = [];
|
|
|
-
|
|
|
- for(let item of merchant.inventory){
|
|
|
- let categoryExists = false;
|
|
|
- for(let category of ingredientsByCategory){
|
|
|
- if(item.ingredient.category === category.name){
|
|
|
- category.ingredients.push({
|
|
|
- id: item.ingredient._id,
|
|
|
- name: item.ingredient.name,
|
|
|
- quantity: item.quantity,
|
|
|
- unit: item.ingredient.unit
|
|
|
- });
|
|
|
-
|
|
|
- categoryExists = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!categoryExists){
|
|
|
- ingredientsByCategory.push({
|
|
|
- name: item.ingredient.category,
|
|
|
- ingredients: [{
|
|
|
- id: item.ingredient._id,
|
|
|
- name: item.ingredient.name,
|
|
|
- quantity: item.quantity,
|
|
|
- unit: item.ingredient.unit
|
|
|
- }]
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return ingredientsByCategory;
|
|
|
- },
|
|
|
-
|
|
|
toggleCategory: function(div, button){
|
|
|
if(div.style.display === "none"){
|
|
|
button.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>';
|