| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /**
- * Provides interface for unit apis.
- */
- (function() {
- var restResource = function($resource) {
- return function() {
- arguments[2]["create"] = {
- method: "PUT"
- };
- arguments[2]["update"] = {
- method: "POST"
- };
- var res = $resource.apply(null, arguments);
- res.prototype.$save = function() {
- return this[this.id? "$update":"$create"].apply(this, arguments);
- };
- return res;
- };
- };
- angular.module('Units', ['ngResource'])
- /*
- * Collection of unit apis.
- *
- * Methods:
- * get: Gets information for a unit by id
- * query: Get a list of all units
- * delete: Deletes a unit with an id
- * create: Creates a unit
- * update: Updates a unit
- * save: Creates a new unit or updates an existing unit
- */
- .factory('Unit', ['$resource', function($resource) {
- return restResource($resource)("unit/:id", {id: "@id"}, {
- "query": {
- method: 'GET',
- isArray: true,
- url: "unit/type/:type"
- },
- "primary": {
- method: 'GET',
- isArray: true,
- url: "unit/primary/:type"
- }
- });
- }]);
- })();
|