From 047b7ff54ab8d980c1a5f9506120bd88298025de Mon Sep 17 00:00:00 2001 From: Erik Donohoo Date: Sat, 20 Dec 2014 12:57:47 -0700 Subject: [PATCH] release v0.7.0 --- bower.json | 2 +- dist/resourcify.js | 17 +++++++++++++---- dist/resourcify.min.js | 4 ++-- package.json | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 5f52c91..13c1ad6 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "resourcify", - "version": "0.6.0", + "version": "0.7.0", "authors": [ "Erik Donohoo " ], diff --git a/dist/resourcify.js b/dist/resourcify.js index 3f2cd14..eb2e0c8 100644 --- a/dist/resourcify.js +++ b/dist/resourcify.js @@ -298,17 +298,26 @@ function resourcificator ($http, $q, utils, Cache) { // Before fn (config.before || angular.noop).apply(value); + // Strip $ from value for data + var sendData = {}; + angular.forEach(value, function (v, key) { + if (value.hasOwnProperty(key) && key.charAt(0) !== '$') { + sendData[key] = v; + } + }); + var classConfig = config.$Const.$$builder.config.httpConfig; - httpConfig.data = /^(POST|PUT|PATCH|DELETE)$/i.test(config.method) ? value : undefined; + httpConfig.data = /^(POST|PUT|PATCH|DELETE)$/i.test(config.method) ? sendData : undefined; $http(utils.extendDeep({}, classConfig, config.config || {}, httpConfig)).then(function ok(response) { - if ((config.isArray && !angular.isArray(response.data)) || (!config.isArray && angular.isArray(response.data))) { + var dataToUse = config.propName ? response.data[config.propName] : response.data; + if ((config.isArray && !angular.isArray(dataToUse)) || (!config.isArray && angular.isArray(dataToUse))) { throw new Error('Saw array or object when expecting the opposite when making ' + config.method + ' call to ' + url); } // Build item and handle cache if (config.isArray) { - angular.forEach(response.data, function (item) { + angular.forEach(dataToUse, function (item) { var model = typeof item === 'object' ? (Maybe.prototype instanceof config.$Const ? new Maybe(item) : new config.$Const(item)) : {data: item}; model.$invalid = (config.invalidateListModels && cache); @@ -318,7 +327,7 @@ function resourcificator ($http, $q, utils, Cache) { value = cache.addList(url, value); } } else { - value = (typeof response.data === 'object') ? angular.extend(value, response.data) : angular.extend(value, {data: response.data}); + value = (typeof dataToUse === 'object') ? angular.extend(value, dataToUse) : angular.extend(value, {data: dataToUse}); if (cache && !config.noCache) { value = cache.add(value, (config.method === cache.$options.saveMethod)); } diff --git a/dist/resourcify.min.js b/dist/resourcify.min.js index 337876a..874f50d 100644 --- a/dist/resourcify.min.js +++ b/dist/resourcify.min.js @@ -1,2 +1,2 @@ -/*! resourcify 20-12-2014 v0.6.0 */ -!function(a,b){"use strict";function c(){function b(b){this.$cache={},this.$options=a.extend({id:"id",saveMethod:"POST",key:["id"]},b),this.$lists={}}return b.prototype.add=function(b,c){for(var d=this.getKey(b),e=this.$cache,f=0;f