| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
- <t:template>
- <jsp:attribute name="title">Add 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', ['ndbDatabase', 'basicFoodEditor', 'ui.bootstrap', 'ieat.ui']);
- // TODO: Disable debug info in prod version
- app.controller('SearchController', ['$scope', '$uibModal', 'NDBSearch', 'NDBFood', 'BasicFood',
- function($scope, $uibModal, NDBSearch, NDBFood, BasicFood) {
- $scope.searchResults = [];
- $scope.table = [
- {
- name: "NDB #",
- col: "ndbno",
- size: 1
- }, {
- name: "Name",
- col: "name",
- size: 6
- }, {
- name: "Group",
- col: "group"
- }, {
- name: "Manufacturer",
- col: "manu"
- }
- ];
- $scope.searchFn = function(searchTerm) {
- NDBSearch.get({
- "key": "${ndbKey}",
- "query": searchTerm
- }, function(data) {
- $scope.searchResults = data;
- }, function (err) {
- // TODO: Actual error handling
- console.error(err);
- })
- };
-
- $scope.promptWindow = function(item) {
- var foodRequest = NDBFood.get(
- {
- "key": "${ndbKey}",
- "ndbno": item.ndbno,
- "type": "f"
- }).$promise.then(function(data) {
- return BasicFood.fromNdb(data);
- }, function (err) {
- // TODO: Proper error handling
- console.error(err);
- });
- $uibModal.open({
- // TODO: Figure out what these are and how they work
- //ariaLabelledBy: 'modal-title',
- //ariaDescribedBy: 'modal-body',
- templateUrl: '${url}/static/templates/editBasicFood.html',
- controller: 'BasicFoodEditorController',
- size: "md",
- resolve: {
- foodData: function() {return foodRequest;},
- ndbKey: function() {return "${ndbKey}";}
- }
- }).result.then(function() {
- // TODO: Push put response into array.
- });
- };
- }]);
- </script>
- </jsp:attribute>
- <jsp:body>
- <div class="section container"
- data-ng-app="ingredients"
- data-ng-controller="SearchController">
- <h2>Ingredient Querier</h2>
- <div class="form-group">
- <label for="search">Search: </label>
- <search-bar id="search"
- data-on-change="searchFn(searchTerm);"
- data-delay="100">
- </search-bar>
- </div>
- <food-list data-table-data="searchResults"
- data-structure="table"
- data-on-select="promptWindow(item)">
- </food-list>
- </div>
- </jsp:body>
- </t:template>
|