Skip to content

Commit c083e7e

Browse files
committed
Stable Version 3.0.0-rc.1.
1 parent ab5575c commit c083e7e

File tree

11 files changed

+108
-79
lines changed

11 files changed

+108
-79
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##### 3.0.0-rc.1 - 28 June 2015
2+
3+
Stable Version 3.0.0-rc.1
4+
15
##### 3.0.0-beta.2 - 19 April 2015
26

37
Added examples of various build setups `./build_examples/`

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Angular wrapper for [js-data](http://www.js-data.io).
66

77
#### What happened Angular-data?
8-
Js-data-angular is Angular-data 2.0, with [js-data](http://www.js-data.io) as the framework-agnostic core. Documentation for Angular-data 1.x can be found at [angular-data.pseudobry.com](http://angular-data.pseudobry.com).
8+
Angular-data is deprecated. js-data + js-data-angular is the new hotness.
99

1010
### Guides
1111
- [Angular + JSData (js-data-angular)](http://www.js-data.io/docs/js-data-angular)
@@ -41,7 +41,7 @@ __Latest Release:__ [![Latest Release](https://img.shields.io/github/release/js-
4141

4242
__Status:__
4343

44-
[![Dependency Status](https://img.shields.io/gemnasium/js-data/js-data-angular.svg?style=flat-square)](https://gemnasium.com/js-data/js-data-angular) [![Coverage Status](https://img.shields.io/coveralls/js-data/js-data-angular/master.svg?style=flat-square)](https://coveralls.io/r/js-data/js-data-angular?branch=master) [![Codacity](https://img.shields.io/codacy/e7690b906dfa471ebcc8b2bdc52e9662.svg?style=flat-square)](https://www.codacy.com/public/jasondobry/js-data-angular/dashboard)
44+
[![Dependency Status](https://img.shields.io/gemnasium/js-data/js-data-angular.svg?style=flat-square)](https://gemnasium.com/js-data/js-data-angular) [![Coverage Status](https://img.shields.io/coveralls/js-data/js-data-angular/master.svg?style=flat-square)](https://coveralls.io/r/js-data/js-data-angular?branch=master) [![Codacity](https://img.shields.io/codacy/e7690b906dfa471ebcc8b2bdc52e9662.svg?style=flat-square)](https://www.codacy.com/public/jasondobry/js-data-angular/dashboard)
4545

4646
__Supported Platforms:__
4747

bower.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
"angular-mocks-1.3.2": "angular-mocks#1.3.2"
2929
},
3030
"dependencies": {
31-
"js-data": "2.0.0-beta.3",
32-
"js-data-http": "2.0.0-beta.3",
31+
"js-data": "2.0.0-rc.1",
32+
"js-data-http": "2.0.0-rc.1",
3333
"angular": ">=1.1.0"
34-
},
35-
"resolutions": {
36-
"angular": "1.3.2"
3734
}
3835
}

build_examples/browserify/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
`browserify -x axios app.js > bundle.js` will produce `bundle.js`
1+
Running `browserify -x axios app.js > bundle.js` in this directory will produce `bundle.js`
22

33
Note the external dependency "axios" that is excluded from the build (it's not needed when using js-data-angular).

build_examples/r.js/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
`r.js -o require.config.js` will produce `bundle.js`
1+
Running `r.js -o require.config.js` in this directory will produce `bundle.js`
22

33
In `index.html` switch `script/main` between `main` (load scripts dynamically) and `bundle` (load bundled scripts)

build_examples/webpack/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
`browserify -x axios app.js > bundle.js` will produce `bundle.js`
1+
Running `webpack` in this directory will produce `bundle.js`
22

33
Note the external dependency "axios" that is excluded from the build (it's not needed when using js-data-angular).

dist/js-data-angular.js

+73-46
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* js-data-angular
3-
* @version 3.0.0-beta.2 - Homepage <https://www.js-data.io/docs/js-data-angular/>
3+
* @version 3.0.0-rc.1 - Homepage <https://www.js-data.io/docs/js-data-angular/>
44
* @author Jason Dobry <jason.dobry@gmail.com>
55
* @copyright (c) 2014-2015 Jason Dobry
66
* @license MIT <https://github.com/js-data/js-data-angular/blob/master/LICENSE>
@@ -65,29 +65,15 @@ return /******/ (function(modules) { // webpackBootstrap
6565
/* 0 */
6666
/***/ function(module, exports, __webpack_require__) {
6767

68-
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
68+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
6969

70-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
71-
72-
Object.defineProperty(exports, '__esModule', {
73-
value: true
74-
});
7570
/*jshint loopfunc:true*/
71+
var JSData = __webpack_require__(1);
72+
var DSHttpAdapter = __webpack_require__(4);
73+
var angular = __webpack_require__(2);
7674

77-
var _JSData = __webpack_require__(1);
78-
79-
var _JSData2 = _interopRequireWildcard(_JSData);
80-
81-
var _DSHttpAdapter = __webpack_require__(4);
82-
83-
var _DSHttpAdapter2 = _interopRequireWildcard(_DSHttpAdapter);
84-
85-
var _angular = __webpack_require__(2);
86-
87-
var _angular2 = _interopRequireWildcard(_angular);
88-
89-
var DSUtils = _JSData2['default'].DSUtils;
90-
var DSErrors = _JSData2['default'].DSErrors;
75+
var DSUtils = JSData.DSUtils;
76+
var DSErrors = JSData.DSErrors;
9177
var isString = DSUtils.isString;
9278
var isNumber = DSUtils.isNumber;
9379
var isObject = DSUtils.isObject;
@@ -127,7 +113,7 @@ return /******/ (function(modules) { // webpackBootstrap
127113

128114
if (Adapter) {
129115
adapter.loaded = true;
130-
_angular2['default'].module('js-data').provider(adapter['class'], function () {
116+
angular.module('js-data').provider(adapter['class'], function () {
131117
var _this = this;
132118
_this.defaults = {};
133119
_this.$get = [function () {
@@ -145,7 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
145131

146132
this.$get = ['$http', 'DS', function ($http, DS) {
147133
defaults.http = defaults.http || $http;
148-
var adapter = new _DSHttpAdapter2['default'](defaults);
134+
var adapter = new DSHttpAdapter(defaults);
149135
DS.registerAdapter('http', adapter, { 'default': true });
150136
return adapter;
151137
}];
@@ -165,7 +151,7 @@ return /******/ (function(modules) { // webpackBootstrap
165151

166152
_this.defaults = {};
167153

168-
_JSData2['default'].DS.prototype.bindAll = function (resourceName, params, scope, expr, cb) {
154+
JSData.DS.prototype.bindAll = function (resourceName, params, scope, expr, cb) {
169155
var _this = this;
170156

171157
params = params || {};
@@ -199,7 +185,7 @@ return /******/ (function(modules) { // webpackBootstrap
199185
}
200186
};
201187

202-
_JSData2['default'].DS.prototype.bindOne = function (resourceName, id, scope, expr, cb) {
188+
JSData.DS.prototype.bindOne = function (resourceName, id, scope, expr, cb) {
203189
var _this = this;
204190

205191
id = resolveId(_this.definitions[resourceName], id);
@@ -242,14 +228,14 @@ return /******/ (function(modules) { // webpackBootstrap
242228

243229
var $rootScope = args[args.length - 2];
244230
var $q = args[args.length - 1];
245-
var store = new _JSData2['default'].DS(_this.defaults);
231+
var store = new JSData.DS(_this.defaults);
246232
var originals = {};
247233

248234
function QPromise(executor) {
249235
var deferred = $q.defer();
250236

251237
try {
252-
executor.call(undefined, _angular2['default'].bind(deferred, deferred.resolve), _angular2['default'].bind(deferred, deferred.reject));
238+
executor.call(undefined, angular.bind(deferred, deferred.resolve), angular.bind(deferred, deferred.reject));
253239
} catch (err) {
254240
deferred.reject(err);
255241
}
@@ -315,7 +301,7 @@ return /******/ (function(modules) { // webpackBootstrap
315301
_this.$get = deps;
316302
};
317303

318-
_angular2['default'].module('js-data', ['ng']).value('DSUtils', DSUtils).value('DSErrors', DSErrors).value('DSVersion', _JSData2['default'].version).provider('DS', DSProvider).provider('DSHttpAdapter', DSHttpAdapterProvider).run(['DS', 'DSHttpAdapter', function (DS, DSHttpAdapter) {
304+
angular.module('js-data', ['ng']).value('DSUtils', DSUtils).value('DSErrors', DSErrors).value('DSVersion', JSData.version).provider('DS', DSProvider).provider('DSHttpAdapter', DSHttpAdapterProvider).run(['DS', 'DSHttpAdapter', function (DS, DSHttpAdapter) {
319305
DS.registerAdapter('http', DSHttpAdapter, { 'default': true });
320306
}]);
321307

@@ -324,8 +310,8 @@ return /******/ (function(modules) { // webpackBootstrap
324310
}
325311

326312
// return the module name
327-
exports['default'] = 'js-data';
328-
module.exports = exports['default'];
313+
module.exports = 'js-data';
314+
module.exports.name = 'js-data';
329315

330316
/***/ },
331317
/* 1 */
@@ -362,27 +348,18 @@ return /******/ (function(modules) { // webpackBootstrap
362348
/* 4 */
363349
/***/ function(module, exports, __webpack_require__) {
364350

365-
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
366-
367-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
368-
369351
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
370352

371-
Object.defineProperty(exports, '__esModule', {
372-
value: true
373-
});
374-
375-
var _JSData = __webpack_require__(1);
376-
377-
var _JSData2 = _interopRequireWildcard(_JSData);
353+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
378354

355+
var JSData = __webpack_require__(1);
379356
var axios = null;
380357

381358
try {
382359
axios = __webpack_require__(5);
383360
} catch (e) {}
384361

385-
var DSUtils = _JSData2['default'].DSUtils;
362+
var DSUtils = JSData.DSUtils;
386363
var deepMixIn = DSUtils.deepMixIn;
387364
var removeCircular = DSUtils.removeCircular;
388365
var copy = DSUtils.copy;
@@ -449,11 +426,62 @@ return /******/ (function(modules) { // webpackBootstrap
449426
}
450427

451428
_createClass(DSHttpAdapter, [{
429+
key: 'getEndpoint',
430+
value: function getEndpoint(resourceConfig, id, options) {
431+
var _this2 = this;
432+
433+
options = options || {};
434+
options.params = options.params || {};
435+
436+
var item = undefined;
437+
var parentKey = resourceConfig.parentKey;
438+
var endpoint = options.hasOwnProperty('endpoint') ? options.endpoint : resourceConfig.endpoint;
439+
var parentField = resourceConfig.parentField;
440+
var parentDef = resourceConfig.getResource(resourceConfig.parent);
441+
var parentId = options.params[parentKey];
442+
443+
if (parentId === false || !parentKey || !parentDef) {
444+
if (parentId === false) {
445+
delete options.params[parentKey];
446+
}
447+
return endpoint;
448+
} else {
449+
delete options.params[parentKey];
450+
451+
if (DSUtils._sn(id)) {
452+
item = resourceConfig.get(id);
453+
} else if (DSUtils._o(id)) {
454+
item = id;
455+
}
456+
457+
if (item) {
458+
parentId = parentId || item[parentKey] || (item[parentField] ? item[parentField][parentDef.idAttribute] : null);
459+
}
460+
461+
if (parentId) {
462+
var _ret = (function () {
463+
delete options.endpoint;
464+
var _options = {};
465+
DSUtils.forOwn(options, function (value, key) {
466+
_options[key] = value;
467+
});
468+
return {
469+
v: DSUtils.makePath(_this2.getEndpoint(parentDef, parentId, DSUtils._(parentDef, _options)), parentId, endpoint)
470+
};
471+
})();
472+
473+
if (typeof _ret === 'object') return _ret.v;
474+
} else {
475+
return endpoint;
476+
}
477+
}
478+
}
479+
}, {
452480
key: 'getPath',
453481
value: function getPath(method, resourceConfig, id, options) {
454482
var _this = this;
455483
options = options || {};
456-
var args = [options.basePath || _this.defaults.basePath || resourceConfig.basePath, resourceConfig.getEndpoint(isString(id) || isNumber(id) || method === 'create' ? id : null, options)];
484+
var args = [options.basePath || _this.defaults.basePath || resourceConfig.basePath, this.getEndpoint(resourceConfig, isString(id) || isNumber(id) || method === 'create' ? id : null, options)];
457485
if (method === 'find' || method === 'update' || method === 'destroy') {
458486
args.push(id);
459487
}
@@ -479,7 +507,7 @@ return /******/ (function(modules) { // webpackBootstrap
479507
}
480508

481509
function logResponse(data) {
482-
var str = '' + start.toUTCString() + ' - ' + data.config.method.toUpperCase() + ' ' + data.config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms';
510+
var str = start.toUTCString() + ' - ' + data.config.method.toUpperCase() + ' ' + data.config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms';
483511
if (data.status >= 200 && data.status < 300) {
484512
if (_this.defaults.log) {
485513
_this.defaults.log(str, data);
@@ -644,8 +672,7 @@ return /******/ (function(modules) { // webpackBootstrap
644672
return DSHttpAdapter;
645673
})();
646674

647-
exports['default'] = DSHttpAdapter;
648-
module.exports = exports['default'];
675+
module.exports = DSHttpAdapter;
649676

650677
/***/ },
651678
/* 5 */

0 commit comments

Comments
 (0)