Просмотр исходного кода

Update frontend to send the converted quantity.
Not yet tested working.

Lee Morgan 5 лет назад
Родитель
Сommit
672ff13292
1 измененных файлов с 10 добавлено и 3 удалено
  1. 10 3
      views/dashboardPage/js/modal.js

+ 10 - 3
views/dashboardPage/js/modal.js

@@ -248,7 +248,6 @@ let modal = {
                     }
                     div.children[1].children[0].children[1].value = merchant.inventory[i].ingredient.unit;
 
-
                     createOptGroup(
                         div.children[1].children[2].children[1],
                         ingredient.unitType,
@@ -277,10 +276,18 @@ let modal = {
             };
 
             for(let i = 0; i < right.children.length; i++){
+                let leftQuantity = parseFloat(right.children[i].children[1].children[0].children[0].value);
+                let leftUnit = right.children[i].children[1].children[0].children[1].value;
+                let rightQuantity = parseFloat(right.children[i].children[1].children[2].children[0].value);
+                let rightUnit = right.children[i].children[1].children[2].children[1].value;
+
+                let leftBase = controller.baseUnit(leftQuantity, leftUnit);
+                let rightBase = controller.baseUnit(rightQuantity, rightUnit);
+
                 data.ingredients.push({
                     ingredient: right.children[i].ingredient.id,
-                    quantity: parseFloat(right.children[i].children[1].children[0].value),
-                    unit: right.children[i].children[1].children[1].value
+                    quantity: leftBase / rightBase,
+                    unit: right.children[i].children[1].children[0].children[1].value
                 });
             }