1
1
/*!
2
2
* 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/>
4
4
* @author Jason Dobry <jason.dobry@gmail.com>
5
5
* @copyright (c) 2014-2015 Jason Dobry
6
6
* @license MIT <https://github.com/js-data/js-data-angular/blob/master/LICENSE>
@@ -65,29 +65,15 @@ return /******/ (function(modules) { // webpackBootstrap
65
65
/* 0 */
66
66
/***/ function ( module , exports , __webpack_require__ ) {
67
67
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' ) ; } }
69
69
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
- } ) ;
75
70
/*jshint loopfunc:true*/
71
+ var JSData = __webpack_require__ ( 1 ) ;
72
+ var DSHttpAdapter = __webpack_require__ ( 4 ) ;
73
+ var angular = __webpack_require__ ( 2 ) ;
76
74
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 ;
91
77
var isString = DSUtils . isString ;
92
78
var isNumber = DSUtils . isNumber ;
93
79
var isObject = DSUtils . isObject ;
@@ -127,7 +113,7 @@ return /******/ (function(modules) { // webpackBootstrap
127
113
128
114
if ( Adapter ) {
129
115
adapter . loaded = true ;
130
- _angular2 [ 'default' ] . module ( 'js-data' ) . provider ( adapter [ 'class' ] , function ( ) {
116
+ angular . module ( 'js-data' ) . provider ( adapter [ 'class' ] , function ( ) {
131
117
var _this = this ;
132
118
_this . defaults = { } ;
133
119
_this . $get = [ function ( ) {
@@ -145,7 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
145
131
146
132
this . $get = [ '$http' , 'DS' , function ( $http , DS ) {
147
133
defaults . http = defaults . http || $http ;
148
- var adapter = new _DSHttpAdapter2 [ 'default' ] ( defaults ) ;
134
+ var adapter = new DSHttpAdapter ( defaults ) ;
149
135
DS . registerAdapter ( 'http' , adapter , { 'default' : true } ) ;
150
136
return adapter ;
151
137
} ] ;
@@ -165,7 +151,7 @@ return /******/ (function(modules) { // webpackBootstrap
165
151
166
152
_this . defaults = { } ;
167
153
168
- _JSData2 [ 'default' ] . DS . prototype . bindAll = function ( resourceName , params , scope , expr , cb ) {
154
+ JSData . DS . prototype . bindAll = function ( resourceName , params , scope , expr , cb ) {
169
155
var _this = this ;
170
156
171
157
params = params || { } ;
@@ -199,7 +185,7 @@ return /******/ (function(modules) { // webpackBootstrap
199
185
}
200
186
} ;
201
187
202
- _JSData2 [ 'default' ] . DS . prototype . bindOne = function ( resourceName , id , scope , expr , cb ) {
188
+ JSData . DS . prototype . bindOne = function ( resourceName , id , scope , expr , cb ) {
203
189
var _this = this ;
204
190
205
191
id = resolveId ( _this . definitions [ resourceName ] , id ) ;
@@ -242,14 +228,14 @@ return /******/ (function(modules) { // webpackBootstrap
242
228
243
229
var $rootScope = args [ args . length - 2 ] ;
244
230
var $q = args [ args . length - 1 ] ;
245
- var store = new _JSData2 [ 'default' ] . DS ( _this . defaults ) ;
231
+ var store = new JSData . DS ( _this . defaults ) ;
246
232
var originals = { } ;
247
233
248
234
function QPromise ( executor ) {
249
235
var deferred = $q . defer ( ) ;
250
236
251
237
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 ) ) ;
253
239
} catch ( err ) {
254
240
deferred . reject ( err ) ;
255
241
}
@@ -315,7 +301,7 @@ return /******/ (function(modules) { // webpackBootstrap
315
301
_this . $get = deps ;
316
302
} ;
317
303
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 ) {
319
305
DS . registerAdapter ( 'http' , DSHttpAdapter , { 'default' : true } ) ;
320
306
} ] ) ;
321
307
@@ -324,8 +310,8 @@ return /******/ (function(modules) { // webpackBootstrap
324
310
}
325
311
326
312
// 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' ;
329
315
330
316
/***/ } ,
331
317
/* 1 */
@@ -362,27 +348,18 @@ return /******/ (function(modules) { // webpackBootstrap
362
348
/* 4 */
363
349
/***/ function ( module , exports , __webpack_require__ ) {
364
350
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
-
369
351
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 ; } ; } ) ( ) ;
370
352
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' ) ; } }
378
354
355
+ var JSData = __webpack_require__ ( 1 ) ;
379
356
var axios = null ;
380
357
381
358
try {
382
359
axios = __webpack_require__ ( 5 ) ;
383
360
} catch ( e ) { }
384
361
385
- var DSUtils = _JSData2 [ 'default' ] . DSUtils ;
362
+ var DSUtils = JSData . DSUtils ;
386
363
var deepMixIn = DSUtils . deepMixIn ;
387
364
var removeCircular = DSUtils . removeCircular ;
388
365
var copy = DSUtils . copy ;
@@ -449,11 +426,62 @@ return /******/ (function(modules) { // webpackBootstrap
449
426
}
450
427
451
428
_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
+ } , {
452
480
key : 'getPath' ,
453
481
value : function getPath ( method , resourceConfig , id , options ) {
454
482
var _this = this ;
455
483
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 ) ] ;
457
485
if ( method === 'find' || method === 'update' || method === 'destroy' ) {
458
486
args . push ( id ) ;
459
487
}
@@ -479,7 +507,7 @@ return /******/ (function(modules) { // webpackBootstrap
479
507
}
480
508
481
509
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' ;
483
511
if ( data . status >= 200 && data . status < 300 ) {
484
512
if ( _this . defaults . log ) {
485
513
_this . defaults . log ( str , data ) ;
@@ -644,8 +672,7 @@ return /******/ (function(modules) { // webpackBootstrap
644
672
return DSHttpAdapter ;
645
673
} ) ( ) ;
646
674
647
- exports [ 'default' ] = DSHttpAdapter ;
648
- module . exports = exports [ 'default' ] ;
675
+ module . exports = DSHttpAdapter ;
649
676
650
677
/***/ } ,
651
678
/* 5 */
0 commit comments