|
|
@@ -11,20 +11,29 @@
|
|
|
<script type="text/javascript" src="static/searchBar.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
var app = angular.module('recipe',
|
|
|
- ['ui.bootstrap', 'Food', 'ieat.ui',
|
|
|
+ ['ui.bootstrap', 'Food', 'ieat.ui', 'ndbDatabase',
|
|
|
'ieat.ui.editors']);
|
|
|
app.controller('SearchController',
|
|
|
- ['$scope', '$uibModal', 'Food', 'Recipe', 'Unit',
|
|
|
- function($scope, $uibModal, Food, Recipe, Unit) {
|
|
|
+ ['$scope', '$uibModal', 'Food', 'Recipe', 'Unit', 'NDBList',
|
|
|
+ function($scope, $uibModal, Food, Recipe, Unit, NDBList) {
|
|
|
$scope.recipe = new Recipe({
|
|
|
steps: [],
|
|
|
ingredients: []
|
|
|
});
|
|
|
+ $scope.categories = NDBList.get({
|
|
|
+ key: "${ndbKey}",
|
|
|
+ type: "g"
|
|
|
+ });
|
|
|
$scope.queryFoods = function(q) {
|
|
|
return Food.query({query: q}).$promise;
|
|
|
};
|
|
|
var primeUnits = $scope.primeUnits = {};
|
|
|
var unitList = Unit.query(function(units) {
|
|
|
+ $scope.unit = units.find(function(u) {
|
|
|
+ return u.symbol == "";
|
|
|
+ });
|
|
|
+ $scope.recipe.unit_type = $scope.unit.type;
|
|
|
+ $scope.unitList = units;
|
|
|
units.forEach(function(u) {
|
|
|
if (u.conversion == 1) {
|
|
|
$scope.primeUnits[u.type] = u;
|
|
|
@@ -84,18 +93,51 @@
|
|
|
</script>
|
|
|
</jsp:attribute>
|
|
|
<jsp:body>
|
|
|
- <div class="section container" data-ng-app="recipe" data-ng-controller="SearchController">
|
|
|
+ <div class="section container" data-ng-app="recipe"
|
|
|
+ data-ng-controller="SearchController">
|
|
|
<h2>Add Recipe</h2>
|
|
|
- <label for="recipeName">Name:</label>
|
|
|
- <input id="recipeName" type="text" data-ng-model="recipe.name" />
|
|
|
- <input type="button" value="Add" class="checkbox-inline" data-ng-click="saveRecipe()" />
|
|
|
+ <div>
|
|
|
+ <label for="recipeName">Name:</label>
|
|
|
+ <input id="recipeName" type="text" data-ng-model="recipe.name" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label for="amount">Creates:</label>
|
|
|
+ <input id="amount" type="number" data-ng-model="amount"
|
|
|
+ data-ng-change="recipe.result_amount = unit.normalize(recipe, amount);" />
|
|
|
+ <select data-ng-model="unit"
|
|
|
+ data-ng-change="recipe.dry = unit.type != 'volume';
|
|
|
+ recipe.unit_type = unit.type;
|
|
|
+ recipe.result_amount = unit.normalize(recipe, amount);"
|
|
|
+ data-ng-options="u as u.symbol for u in unitList">
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label for="group">Food Group:</label>
|
|
|
+ <select id="group" data-ng-model="recipe.food_group"
|
|
|
+ data-ng-options="c.name.trim() as c.name.trim()
|
|
|
+ for c in categories">
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="checkbox">
|
|
|
+ <label for="dry">
|
|
|
+ <input id="dry" type="checkbox" data-ng-model="recipe.dry" />
|
|
|
+ Dry
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label for="density">Density (g/ml):</label>
|
|
|
+ <input id="density" type="number" data-ng-model="recipe.density" />
|
|
|
+ </div>
|
|
|
+ <input type="button" value="Add" class="checkbox-inline"
|
|
|
+ data-ng-click="saveRecipe()" />
|
|
|
<table style="width: 100%;">
|
|
|
<tr>
|
|
|
<td style="width: 50%;">
|
|
|
<ol>
|
|
|
<li data-ng-repeat="step in recipe.steps track by $index">
|
|
|
{{step}}
|
|
|
- <span class="glyphicon glyphicon-remove" data-ng-click="removeStep($index);"></span>
|
|
|
+ <span class="glyphicon glyphicon-remove"
|
|
|
+ data-ng-click="removeStep($index);"></span>
|
|
|
</li>
|
|
|
</ol>
|
|
|
</td>
|