Преглед на файлове

Added documentation to Food objects.

Thomas Flucke преди 7 години
родител
ревизия
12880701f1
променени са 1 файла, в които са добавени 37 реда и са изтрити 0 реда
  1. 37 0
      web/js/Food.js

+ 37 - 0
web/js/Food.js

@@ -1,3 +1,6 @@
+/**
+ * Provides interface for food apis.
+ */
 (function() {
     // Basic api template all foods follow
     var abstractFood = function($resource, path) {
@@ -37,6 +40,18 @@
         }
     };
     angular.module('Food', ['ngResource'])
+    /*
+     * Collection of basic food apis.
+     *  
+     * Methods:
+     * get: Gets information for a basic food by id
+     * query: Get a list of basic foods whose name contains the given string
+     * delete: Deletes a basic food with an id
+     * create: Creates a new basic food
+     * update: Updates a basic food
+     * submit: Save a new basic food or update it if it already exists.
+     * fromNdb (static): Returns a new basic food adapted from an ndb object
+     */
         .factory('BasicFood', ['$resource', function($resource) {
             var res = abstractFood($resource, 'basic/');
             res.fromNdb = function(ndbItem) {
@@ -54,9 +69,31 @@
             };
             return res;
         }])
+    /*
+     * Collection of recipe apis.
+     *  
+     * Methods:
+     * get: Gets information for a recipe by id
+     * query: Get a list of recipes whose name contains the given string
+     * delete: Deletes a recipe with an id
+     * create: Creates a new recipe
+     * update: Updates a recipe
+     * submit: Save a new recipe or update it if it already exists.
+     */
         .factory('Recipe', ['$resource', function($resource) {
             return abstractFood($resource, 'recipe/');
         }])
+    /*
+     * Generic Food query interface.
+     * 
+     * Useful for getting a list of mixed food types.
+     * 
+     * Methods:
+     * get: Gets information for a specific food by id
+     * query: Get a list of foods whose name contains the given string
+     * delete: Deletes a food with an id
+     * cast: Convert from a generic food to it's designated type
+     */
         .factory('Food', ['$resource', 'BasicFood', 'Recipe', function($resource, BasicFood, Recipe) {
             var absFood = abstractFood($resource, "");
             absFood.prototype.cast = function() {