Prechádzať zdrojové kódy

Now loads catagories from NDB.

At some point in the future I may want to change how the catagories work.
For now, this will work for testing.
Thomas Flucke 7 rokov pred
rodič
commit
d6b43d7ba6

+ 9 - 3
web/js/basicFoodEditor.js

@@ -1,4 +1,4 @@
-angular.module('basicFoodEditor', ['ngResource'])
+angular.module('basicFoodEditor', ['ndbDatabase', 'ngResource'])
     .factory('BasicFood', ['$resource', '$q', function($resource, $q) {
         return $resource('food/:id', {id: "@id"}, {
             'get':    {method: 'GET'},
@@ -14,13 +14,19 @@ angular.module('basicFoodEditor', ['ngResource'])
     }])
     // TODO: Only ever used with editBasicFood template.  See if can auto link.
     .controller('BasicFoodEditorController',
-                ['$scope', '$uibModalInstance', 'BasicFood', 'foodData',
-                 function($scope, $uibModalInstance, BasicFood, foodData) {
+                ['$scope', '$uibModalInstance', 'NDBList', 'BasicFood', 'foodData',
+                 function($scope, $uibModalInstance, NDBList, BasicFood, foodData) {
                      if (foodData == null)
                      {
                          console.error("No food data to edit!");
                          return;
                      }
+
+                     // TODO: Replace with properties file key.
+                     $scope.catagories = NDBList.get({
+                         key: "CfiHcUnSf0RX0jBuqiWjDK2d2ziOmoZG15CTdhQn",
+                         type: "g"
+                     });
                      
                      $scope.food = new BasicFood(foodData);
 

+ 1 - 2
web/js/templates/editBasicFood.html

@@ -28,8 +28,7 @@
         <td>
           <label for="group">Food Group:</label>
           <select id="group" class="form-control" data-ng-model="food.food_group">
-            <!-- TODO: Load these from server -->
-            <option>Dairy and Egg Products</option>
+            <option data-ng-repeat="catagory in catagories">{{catagory.name}}</option>
           </select>
         </td>
       </tr>