Skip to content

Commit a661318

Browse files
author
guylabs
committed
Change version to 0.3.1 and add release notes
1 parent 9eb03e6 commit a661318

File tree

5 files changed

+120
-82
lines changed

5 files changed

+120
-82
lines changed

RELEASENOTES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Release notes of angular-spring-data-rest
22

3+
## Version 0.3.1
4+
5+
* Tag: [0.3.1](https://github.com/guylabs/angular-spring-data-rest/tree/0.3.1)
6+
* Release: [angular-spring-data-rest-0.3.1.zip](https://github.com/guylabs/angular-spring-data-rest/releases/download/0.3.1/angular-spring-data-rest-0.3.1.zip)
7+
8+
### Changes
9+
10+
* Add empty string as default parameter value when returning the available resources instead of undefined.
11+
12+
### Migration notes
13+
14+
* You will need to change the logic on your side if you use the object which is returned if the `_resources` method is called without any parameter. The parameters have now an empty string set as default value instead of `undefined`.
15+
316
## Version 0.3.0
417

518
* Tag: [0.3.0](https://github.com/guylabs/angular-spring-data-rest/tree/0.3.0)

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-spring-data-rest",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "An AngularJS module to ease the work with a Spring Data REST backend.",
55
"main": "./dist/angular-spring-data-rest.js",
66
"license": "MIT",

dist/angular-spring-data-rest.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
/**
66
* @module spring-data-rest
7-
* @version 0.3.0
7+
* @version 0.3.1
88
*
99
* An AngularJS module to ease the work with a Spring Data REST backend.
1010
*/
1111
angular.module("spring-data-rest", ["ngResource"]);
1212

1313
/**
1414
* @module spring-data-rest
15-
* @version 0.3.0
15+
* @version 0.3.1
1616
*
1717
* Provider for the SpringDataRestAdapter which is the core of this module.
1818
*/
@@ -163,6 +163,13 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function ()
163163
}
164164
}
165165

166+
// remove parameters which have an empty string as value
167+
angular.forEach(parameters, function (value, key) {
168+
if (value === "") {
169+
delete parameters[key];
170+
}
171+
});
172+
166173
// process the url and call the resources function with the given parameters
167174
return resourcesFunction(getProcessedUrl(data, resourceObject.name), parameters, actions, options);
168175
} else if (resourceObject in resources) {
@@ -313,7 +320,7 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function ()
313320

314321
/**
315322
* @module spring-data-rest
316-
* @version 0.3.0
323+
* @version 0.3.1
317324
*
318325
* Provider for the interceptor which wraps the SpringDataRestAdapter around the response object.
319326
*/
@@ -431,12 +438,12 @@ function removeTemplateParameters(url) {
431438
}
432439

433440
/**
434-
* Returns the template parameters of the given url as array. e.g. from this url
435-
* 'http://localhost:8080/categories{?page,size,sort}' it will return the following array:
436-
* ['page', 'size', 'sort']
441+
* Returns the template parameters of the given url as object. e.g. from this url
442+
* 'http://localhost:8080/categories{?page,size,sort}' it will return the following object:
443+
* {'page': "", 'size': "", 'sort': ""}
437444
*
438445
* @param {string} url the url with the template parameters
439-
* @returns {object} the array containing the template parameters
446+
* @returns {object} the object containing the template parameters
440447
*/
441448
function extractTemplateParameters(url) {
442449
var templateParametersObject = {};
@@ -445,10 +452,10 @@ function extractTemplateParameters(url) {
445452
var templateParametersArray = regexp.exec(url)[1].split(',');
446453

447454
angular.forEach(templateParametersArray, function (value) {
448-
templateParametersObject[value] = undefined;
455+
templateParametersObject[value] = "";
449456
});
450457

451458
return templateParametersObject;
452459
}
453460

454-
})();
461+
})();
Lines changed: 89 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-spring-data-rest 0.3.0
2+
* angular-spring-data-rest 0.3.1
33
* Copyright 2014 Guy Brûlé (@guy_labs)
44
* https://github.com/guylabs/angular-spring-data-rest
55
*/
@@ -38,85 +38,103 @@
3838
function f(a) {
3939
var b = {}, c = /{\?(.*)}/g, d = c.exec(a)[1].split(",");
4040
return angular.forEach(d, function (a) {
41-
b[a] = void 0
41+
b[a] = ""
4242
}), b
4343
}
4444

4545
angular.module("spring-data-rest", ["ngResource"]), angular.module("spring-data-rest").provider("SpringDataRestAdapter", function () {
46-
var e = {linksKey: "_links", linksHrefKey: "href", linksSelfLinkName: "self", embeddedKey: "_embedded", embeddedNewKey: "_embeddedItems", resourcesKey: "_resources", resourcesFunction: void 0, fetchFunction: void 0, fetchAllKey: "_allLinks"};
47-
return{config: function (b) {
48-
if ("undefined" != typeof b) {
49-
if (!angular.isObject(b))throw new Error("The given configuration '" + b + "' is not an object.");
50-
if (void 0 != b.resourcesFunction && "function" != typeof b.resourcesFunction)throw new Error("The given resource function '" + b.resourcesFunction + "' is not of type function.");
51-
if (void 0 != b.fetchFunction && "function" != typeof b.fetchFunction)throw new Error("The given fetch function '" + b.fetchFunction + "' is not of type function.");
52-
e = a(e, b)
53-
}
54-
return e
55-
}, $get: ["$injector", function (a) {
56-
function g(b, c, d, f) {
57-
return void 0 == e.resourcesFunction ? a.get("$resource")(b, c, d, f) : e.resourcesFunction(b, c, d, f)
58-
}
59-
60-
function h(b, c, d, f, g) {
61-
void 0 == e.fetchFunction ? a.get("$http").get(b).success(function (a) {
62-
d[c] = g ? i(a, f, !0) : a
63-
}).error(function (a, c) {
64-
throw new Error("There was an error (" + c + ") retrieving the data from '" + b + "'")
65-
}) : e.fetchFunction(b, c, d, f, g)
66-
}
46+
var e = {
47+
linksKey: "_links",
48+
linksHrefKey: "href",
49+
linksSelfLinkName: "self",
50+
embeddedKey: "_embedded",
51+
embeddedNewKey: "_embeddedItems",
52+
resourcesKey: "_resources",
53+
resourcesFunction: void 0,
54+
fetchFunction: void 0,
55+
fetchAllKey: "_allLinks"
56+
};
57+
return {
58+
config: function (b) {
59+
if ("undefined" != typeof b) {
60+
if (!angular.isObject(b))throw new Error("The given configuration '" + b + "' is not an object.");
61+
if (void 0 != b.resourcesFunction && "function" != typeof b.resourcesFunction)throw new Error("The given resource function '" + b.resourcesFunction + "' is not of type function.");
62+
if (void 0 != b.fetchFunction && "function" != typeof b.fetchFunction)throw new Error("The given fetch function '" + b.fetchFunction + "' is not of type function.");
63+
e = a(e, b)
64+
}
65+
return e
66+
}, $get: ["$injector", function (a) {
67+
function g(b, c, d, f) {
68+
return void 0 == e.resourcesFunction ? a.get("$resource")(b, c, d, f) : e.resourcesFunction(b, c, d, f)
69+
}
6770

68-
var i = function k(a, i, j) {
69-
function l(a, b) {
70-
var f = d(a[e.linksKey][b][e.linksHrefKey], b, e.linksHrefKey);
71-
return c(f, a[e.linksKey][b].templated)
71+
function h(b, c, d, f, g) {
72+
void 0 == e.fetchFunction ? a.get("$http").get(b).success(function (a) {
73+
d[c] = g ? i(a, f, !0) : a
74+
}).error(function (a, c) {
75+
throw new Error("There was an error (" + c + ") retrieving the data from '" + b + "'")
76+
}) : e.fetchFunction(b, c, d, f, g)
7277
}
7378

74-
var m = function (b, c, d, h) {
75-
var i = this[e.linksKey], j = c;
76-
if (angular.isObject(b)) {
77-
if (!b.name)throw new Error("The provided resource object must contain a name property.");
78-
var k = b.parameters;
79-
return c && angular.isObject(c) ? j = k && angular.isObject(k) ? angular.extend(angular.copy(c), angular.copy(k)) : angular.copy(c) : k && angular.isObject(k) && (j = angular.copy(k)), g(l(a, b.name), j, d, h)
79+
var i = function k(a, i, j) {
80+
function l(a, b) {
81+
var f = d(a[e.linksKey][b][e.linksHrefKey], b, e.linksHrefKey);
82+
return c(f, a[e.linksKey][b].templated)
83+
}
84+
85+
var m = function (b, c, d, h) {
86+
var i = this[e.linksKey], j = c;
87+
if (angular.isObject(b)) {
88+
if (!b.name)throw new Error("The provided resource object must contain a name property.");
89+
var k = b.parameters;
90+
return c && angular.isObject(c) ? j = k && angular.isObject(k) ? angular.extend(angular.copy(c), angular.copy(k)) : angular.copy(c) : k && angular.isObject(k) && (j = angular.copy(k)), angular.forEach(j, function (a, b) {
91+
"" === a && delete j[b]
92+
}), g(l(a, b.name), j, d, h)
93+
}
94+
if (b in i)return g(l(a, b), j, d, h);
95+
var m = [];
96+
return angular.forEach(i, function (a, b) {
97+
if (a.templated) {
98+
var c = f(a[e.linksHrefKey]);
99+
m.push({name: b, parameters: c})
100+
} else m.push({name: b})
101+
}), m
102+
};
103+
if (!angular.isObject(a) || a instanceof Array)throw new Error("Given data '" + a + "' is not of type object.");
104+
if (void 0 != i && !(i instanceof Array || "string" == typeof i))throw new Error("Given fetch links '" + i + "' is not of type array or string.");
105+
var n = void 0;
106+
if (e.linksKey in a) {
107+
var o = {};
108+
o[e.resourcesKey] = m, n = angular.extend(angular.copy(a), o), void 0 != i && (n || (n = angular.copy(a)), angular.forEach(a[e.linksKey], function (b, c) {
109+
c != e.linksSelfLinkName && (i == e.fetchAllKey || "string" == typeof i && c == i || i instanceof Array && i.indexOf(c) >= 0) && h(l(a, c), c, n, i, j)
110+
}))
80111
}
81-
if (b in i)return g(l(a, b), j, d, h);
82-
var m = [];
83-
return angular.forEach(i, function (a, b) {
84-
if (a.templated) {
85-
var c = f(a[e.linksHrefKey]);
86-
m.push({name: b, parameters: c})
87-
} else m.push({name: b})
88-
}), m
112+
return e.embeddedKey in a && (n || (n = angular.copy(a)), n = b(n, e.embeddedKey, e.embeddedNewKey), angular.forEach(n[e.embeddedNewKey], function (a, b) {
113+
n[e.embeddedNewKey][b] = k(a, i, j)
114+
})), n ? n : a
115+
}, j = function (b, c, d) {
116+
var e = a.get("$q").when(b), f = a.get("$q").defer();
117+
return e.then(function (a) {
118+
var b = i(a.data, c, d);
119+
f.resolve(b)
120+
}, function (b) {
121+
return f.reject(b), a.get("$q").reject(b)
122+
}), f.promise
89123
};
90-
if (!angular.isObject(a) || a instanceof Array)throw new Error("Given data '" + a + "' is not of type object.");
91-
if (void 0 != i && !(i instanceof Array || "string" == typeof i))throw new Error("Given fetch links '" + i + "' is not of type array or string.");
92-
var n = void 0;
93-
if (e.linksKey in a) {
94-
var o = {};
95-
o[e.resourcesKey] = m, n = angular.extend(angular.copy(a), o), void 0 != i && (n || (n = angular.copy(a)), angular.forEach(a[e.linksKey], function (b, c) {
96-
c != e.linksSelfLinkName && (i == e.fetchAllKey || "string" == typeof i && c == i || i instanceof Array && i.indexOf(c) >= 0) && h(l(a, c), c, n, i, j)
97-
}))
98-
}
99-
return e.embeddedKey in a && (n || (n = angular.copy(a)), n = b(n, e.embeddedKey, e.embeddedNewKey), angular.forEach(n[e.embeddedNewKey], function (a, b) {
100-
n[e.embeddedNewKey][b] = k(a, i, j)
101-
})), n ? n : a
102-
}, j = function (b, c, d) {
103-
var e = a.get("$q").when(b), f = a.get("$q").defer();
104-
return e.then(function (a) {
105-
var b = i(a.data, c, d);
106-
f.resolve(b)
107-
}, function (b) {
108-
return f.reject(b), a.get("$q").reject(b)
109-
}), f.promise
110-
};
111-
return{process: i, processWithPromise: j}
112-
}]}
124+
return {process: i, processWithPromise: j}
125+
}]
126+
}
113127
}), angular.module("spring-data-rest").provider("SpringDataRestInterceptor", ["$httpProvider", "SpringDataRestAdapterProvider", function (a) {
114-
return{apply: function () {
115-
a.interceptors.push("SpringDataRestInterceptor")
116-
}, $get: ["SpringDataRestAdapter", "$q", function (a, b) {
117-
return{response: function (c) {
118-
return c && angular.isObject(c.data) && (c.data = a.process(c.data)), c || b.when(c)
119-
}}
120-
}]}
128+
return {
129+
apply: function () {
130+
a.interceptors.push("SpringDataRestInterceptor")
131+
}, $get: ["SpringDataRestAdapter", "$q", function (a, b) {
132+
return {
133+
response: function (c) {
134+
return c && angular.isObject(c.data) && (c.data = a.process(c.data)), c || b.when(c)
135+
}
136+
}
137+
}]
138+
}
121139
}])
122140
}();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-spring-data-rest",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "An AngularJS module to ease the work with a Spring Data REST backend.",
55
"keywords": ["AngularJS", "angular", "Spring", "Spring Data", "REST", "Spring Data REST"],
66
"homepage": "http://guylabs.ch/project/angular-spring-data-rest",

0 commit comments

Comments
 (0)