| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
- <t:template>
- <jsp:attribute name="title">Manage Food</jsp:attribute>
- <jsp:attribute name="head">
- <script type="text/javascript" src="static/ndbDatabase.js"></script>
- <script type="text/javascript" src="static/basicFoodEditor.js"></script>
- <script type="text/javascript" src="static/searchBar.js"></script>
- <script type="text/javascript" src="static/foodList.js"></script>
- <script type="text/javascript">
- var app = angular.module('ingredients', ['basicFoodEditor', 'ui.bootstrap', 'ieat.ui']);
- app.controller('SearchController', ['$scope', '$timeout', '$uibModal', 'Food', 'BasicFood', 'Recipe',
- function($scope, $timeout, $uibModal, Food, BasicFood, Recipe) {
- $scope.table = [{
- name: "Name",
- col: "name",
- size: 6
- }, {
- name: "Group",
- col: "food_group"
- }, {
- name: "Calories",
- col: "calories_p_100"
- }
- ];
-
- $scope.searchFn = function(searchTerm) {
- Food.query({
- "key": "${ndbKey}",
- "query": searchTerm
- }, function(data) {
- $scope.searchResults = data;
- }, function (err) {
- // TODO: Actual error handling
- console.error(err);
- })
- };
- $scope.searchFn("");
-
- $scope.promptWindow = function(item) {
- $uibModal.open({
- // TODO: Figure out what these are and how they work
- //ariaLabelledBy: 'modal-title',
- //ariaDescribedBy: 'modal-body',
- templateUrl: 'static/templates/editBasicFood.html',
- controller: 'BasicFoodEditorController',
- size: "md",
- resolve: {
- foodData: function() {return item.cast();},
- ndbKey: function() {return "${ndbKey}";}
- }
- }).result.then(function() {
- // TODO: Push post response into array.
- });
- };
- }]);
- </script>
- </jsp:attribute>
- <jsp:body>
- <div class="section container" data-ng-app="ingredients" data-ng-controller="SearchController">
- <h2>Ingredients</h2>
- <div class="form-group">
- <label for="search">Search: </label>
- <search-bar id="search" data-on-change="searchFn(searchTerm);" data-delay="100" />
- </div>
- <food-list data-table-data="searchResults"
- data-structure="table"
- data-select-text="Edit"
- data-on-select="promptWindow(item)">
- </food-list>
- </div>
- </jsp:body>
- </t:template>
|