|
@@ -1,3 +1,6 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * Provides interface for food apis.
|
|
|
|
|
+ */
|
|
|
(function() {
|
|
(function() {
|
|
|
// Basic api template all foods follow
|
|
// Basic api template all foods follow
|
|
|
var abstractFood = function($resource, path) {
|
|
var abstractFood = function($resource, path) {
|
|
@@ -37,6 +40,18 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
angular.module('Food', ['ngResource'])
|
|
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) {
|
|
.factory('BasicFood', ['$resource', function($resource) {
|
|
|
var res = abstractFood($resource, 'basic/');
|
|
var res = abstractFood($resource, 'basic/');
|
|
|
res.fromNdb = function(ndbItem) {
|
|
res.fromNdb = function(ndbItem) {
|
|
@@ -54,9 +69,31 @@
|
|
|
};
|
|
};
|
|
|
return res;
|
|
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) {
|
|
.factory('Recipe', ['$resource', function($resource) {
|
|
|
return abstractFood($resource, 'recipe/');
|
|
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) {
|
|
.factory('Food', ['$resource', 'BasicFood', 'Recipe', function($resource, BasicFood, Recipe) {
|
|
|
var absFood = abstractFood($resource, "");
|
|
var absFood = abstractFood($resource, "");
|
|
|
absFood.prototype.cast = function() {
|
|
absFood.prototype.cast = function() {
|