todo_rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/todo_rails/version.rb +1 -1
- data/vendor/assets/bower.json +8 -0
- data/vendor/assets/bower_components/angular-animate/README.md +68 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.js +3721 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.min.js +52 -0
- data/vendor/assets/bower_components/angular-animate/angular-animate.min.js.map +8 -0
- data/vendor/assets/bower_components/angular-animate/bower.json +9 -0
- data/vendor/assets/bower_components/angular-animate/index.js +2 -0
- data/vendor/assets/bower_components/angular-animate/package.json +26 -0
- data/vendor/assets/bower_components/angular-aria/README.md +67 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.js +393 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.min.js +13 -0
- data/vendor/assets/bower_components/angular-aria/angular-aria.min.js.map +8 -0
- data/vendor/assets/bower_components/angular-aria/bower.json +9 -0
- data/vendor/assets/bower_components/angular-aria/index.js +2 -0
- data/vendor/assets/bower_components/angular-aria/package.json +27 -0
- data/vendor/assets/bower_components/angular-material/CHANGELOG.md +1599 -0
- data/vendor/assets/bower_components/angular-material/LICENSE +21 -0
- data/vendor/assets/bower_components/angular-material/README.md +211 -0
- data/vendor/assets/bower_components/angular-material/angular-material-mocks.js +77 -0
- data/vendor/assets/bower_components/angular-material/angular-material.css +7183 -0
- data/vendor/assets/bower_components/angular-material/angular-material.js +15406 -0
- data/vendor/assets/bower_components/angular-material/angular-material.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/angular-material.min.js +14 -0
- data/vendor/assets/bower_components/angular-material/bower.json +14 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/copy2.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/facebook.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/hangout.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/mail.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/message.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/print.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/share-arrow.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/twitter.svg +2 -0
- data/vendor/assets/bower_components/angular-material/demos/bottomSheet/demoBasicUsage/img/icons/upload.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/chips/demoBasicUsage/style.scss +39 -0
- data/vendor/assets/bower_components/angular-material/demos/chips/demoContactChips/style.scss +47 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoBasicUsage/style.scss +75 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoDynamicTiles/style.scss +78 -0
- data/vendor/assets/bower_components/angular-material/demos/gridList/demoResponsiveUsage/style.scss +0 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/addShoppingCart.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoLoadSvgIconsFromUrl/img/icons/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/core-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconSets/assets/social-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/addShoppingCart.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoSvgIconsFromURL/img/icons/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/android.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/cake.svg +1 -0
- data/vendor/assets/bower_components/angular-material/demos/icon/demoUsingTemplateCache/assets/core-icons.svg +26 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_email_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_person_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_phone_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/icons/ic_place_24px.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/input/demoIcons/style.scss +18 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-0.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-1.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/list/demoListControls/img/100-2.jpeg +0 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoDynamicHeight/style.scss +13 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoDynamicTabs/style.scss +44 -0
- data/vendor/assets/bower_components/angular-material/demos/tabs/demoStaticTabs/style.scss +25 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/favorite.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/menu.svg +4 -0
- data/vendor/assets/bower_components/angular-material/demos/toolbar/demoBasicUsage/img/icons/more_vert.svg +4 -0
- data/vendor/assets/bower_components/angular-material/index.js +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/autocomplete/autocomplete.js +951 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop.css +59 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/backdrop/backdrop.js +38 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/bottomSheet/bottomSheet.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button-default-theme.css +94 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button.css +158 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/button/button.js +135 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card.css +34 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/card/card.js +84 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox.css +124 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/checkbox/checkbox.js +166 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips.css +131 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/chips/chips.js +949 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/content/content.js +84 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/core.css +2594 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/core.js +3772 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/core/default-theme.js +4 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/dialog/dialog.js +713 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider.css +14 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/divider/divider.js +45 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabActions/fabActions.js +57 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabSpeedDial/fabSpeedDial.css +100 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabSpeedDial/fabSpeedDial.js +236 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabToolbar/fabToolbar.css +74 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabToolbar/fabToolbar.js +218 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/fabTrigger/fabTrigger.js +54 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList-default-theme.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList.css +68 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/gridList/gridList.js +762 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon-default-theme.css +15 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/icon/icon.js +783 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input-default-theme.css +46 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input.css +162 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/input/input.js +371 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list-default-theme.css +23 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list.css +147 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/list/list.js +273 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu.css +121 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/menu/menu.js +620 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular-default-theme.css +36 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular.css +1409 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressCircular/progressCircular.js +109 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear-default-theme.css +27 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear.css +287 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/progressLinear/progressLinear.js +126 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton.css +91 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/radioButton/radioButton.js +312 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select-default-theme.css +42 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/select/select.js +1055 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav.css +99 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sidenav/sidenav.js +424 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider-default-theme.css +56 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/slider/slider.js +403 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sticky/sticky.css +21 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/sticky/sticky.js +315 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader.css +63 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/subheader/subheader.js +93 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/swipe/swipe.js +72 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch-default-theme.css +33 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch.css +110 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/switch/switch.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs-arrow.svg +7 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs-default-theme.css +82 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs.css +274 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tabs/tabs.js +1060 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField-default-theme.css +30 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/textField/textField.js +145 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast-default-theme.css +18 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast.css +119 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toast/toast.js +265 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar-default-theme.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar.css +83 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/toolbar/toolbar.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip.css +72 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/tooltip/tooltip.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/whiteframe/whiteframe.css +25 -0
- data/vendor/assets/bower_components/angular-material/modules/closure/whiteframe/whiteframe.js +15 -0
- data/vendor/assets/bower_components/angular-material/modules/css/angular-material-layout.css +2375 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.js +951 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/autocomplete.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/autocomplete/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.css +59 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.js +39 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/backdrop.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/backdrop/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.js +267 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bottomSheet.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/bottomSheet/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button-default-theme.css +94 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.css +158 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.js +136 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/button/button.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.css +34 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.js +85 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/card/card.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.css +124 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.js +167 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/checkbox/checkbox.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips-default-theme.css +24 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.css +131 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.js +949 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/chips/chips.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.js +85 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/content/content.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.css +2594 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.js +3772 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/core.min.js +10 -0
- data/vendor/assets/bower_components/angular-material/modules/js/core/default-theme.js +4 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog-default-theme.css +12 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.js +713 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/dialog/dialog.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.css +14 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.js +46 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/divider/divider.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/fabActions.js +58 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabActions/fabActions.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/bower.json +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.css +100 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.js +235 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabSpeedDial/fabSpeedDial.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/bower.json +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.css +74 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.js +217 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabToolbar/fabToolbar.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/fabTrigger.js +55 -0
- data/vendor/assets/bower_components/angular-material/modules/js/fabTrigger/fabTrigger.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.css +68 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.js +763 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/gridList/gridList.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon-default-theme.css +15 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.js +784 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/icon/icon.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input-default-theme.css +46 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.css +162 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.js +372 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/input/input.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list-default-theme.css +23 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.css +147 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.js +274 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/list/list.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.css +121 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.js +620 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/menu/menu.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.css +36 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.css +1409 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.js +110 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressCircular/progressCircular.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.css +27 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.css +287 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.js +127 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/progressLinear/progressLinear.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.css +47 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.css +91 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.js +313 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/radioButton/radioButton.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select-default-theme.css +42 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.css +170 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.js +1055 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/select/select.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.css +9 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.css +99 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.js +424 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sidenav/sidenav.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider-default-theme.css +56 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.css +220 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.js +404 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/slider/slider.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.css +21 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.js +315 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/sticky/sticky.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader-default-theme.css +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.css +63 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.js +93 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/subheader/subheader.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/swipe.js +73 -0
- data/vendor/assets/bower_components/angular-material/modules/js/swipe/swipe.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch-default-theme.css +33 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.css +110 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/switch/switch.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs-default-theme.css +82 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.css +274 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.js +1060 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tabs/tabs.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField-default-theme.css +30 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.css +111 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.js +143 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/textField/textField.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast-default-theme.css +18 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.css +119 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.js +265 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toast/toast.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/bower.json +8 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.css +20 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.css +83 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.js +169 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/toolbar/toolbar.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/bower.json +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.css +11 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip-default-theme.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.css +72 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.js +268 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/tooltip/tooltip.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/bower.json +5 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.css +25 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.js +16 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.css +6 -0
- data/vendor/assets/bower_components/angular-material/modules/js/whiteframe/whiteframe.min.js +7 -0
- data/vendor/assets/bower_components/angular-material/package.json +48 -0
- data/vendor/assets/bower_components/angular/README.md +64 -0
- data/vendor/assets/bower_components/angular/angular-csp.css +21 -0
- data/vendor/assets/bower_components/angular/angular.js +28364 -0
- data/vendor/assets/bower_components/angular/angular.min.js +290 -0
- data/vendor/assets/bower_components/angular/angular.min.js.gzip +0 -0
- data/vendor/assets/bower_components/angular/angular.min.js.map +8 -0
- data/vendor/assets/bower_components/angular/bower.json +8 -0
- data/vendor/assets/bower_components/angular/index.js +2 -0
- data/vendor/assets/bower_components/angular/package.json +25 -0
- data/vendor/assets/bower_components/lodash/LICENSE +22 -0
- data/vendor/assets/bower_components/lodash/bower.json +19 -0
- data/vendor/assets/bower_components/lodash/lodash.js +12351 -0
- data/vendor/assets/bower_components/lodash/lodash.min.js +99 -0
- data/vendor/assets/bower_components/restangular/CHANGELOG.md +18 -0
- data/vendor/assets/bower_components/restangular/CONTRIBUTE.md +31 -0
- data/vendor/assets/bower_components/restangular/Gruntfile.js +149 -0
- data/vendor/assets/bower_components/restangular/README.md +1336 -0
- data/vendor/assets/bower_components/restangular/bower.json +19 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.js +1355 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.min.js +6 -0
- data/vendor/assets/bower_components/restangular/dist/restangular.zip +0 -0
- data/vendor/assets/bower_components/restangular/karma.conf.js +74 -0
- data/vendor/assets/bower_components/restangular/karma.underscore.conf.js +74 -0
- data/vendor/assets/bower_components/restangular/license.md +21 -0
- data/vendor/assets/bower_components/restangular/package.json +55 -0
- data/vendor/assets/bower_components/restangular/src/restangular.js +1350 -0
- data/vendor/assets/bower_components/restangular/test/restangularSpec.js +1136 -0
- metadata +424 -1
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "restangular",
|
3
|
+
"version": "1.5.1",
|
4
|
+
"main": "./dist/restangular.js",
|
5
|
+
"description": "Restful Resources service for AngularJS apps",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "git://github.com/mgonto/restangular.git"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"lodash": ">=1.3.0",
|
12
|
+
"angular": "~1.x"
|
13
|
+
},
|
14
|
+
"ignore": [
|
15
|
+
"node_modules",
|
16
|
+
"components",
|
17
|
+
"lib"
|
18
|
+
]
|
19
|
+
}
|
@@ -0,0 +1,1355 @@
|
|
1
|
+
/**
|
2
|
+
* Restful Resources service for AngularJS apps
|
3
|
+
* @version v1.4.0 - 2015-04-03 * @link https://github.com/mgonto/restangular
|
4
|
+
* @author Martin Gontovnikas <martin@gon.to>
|
5
|
+
* @license MIT License, http://www.opensource.org/licenses/MIT
|
6
|
+
*/(function() {
|
7
|
+
|
8
|
+
var restangular = angular.module('restangular', []);
|
9
|
+
|
10
|
+
restangular.provider('Restangular', function() {
|
11
|
+
// Configuration
|
12
|
+
var Configurer = {};
|
13
|
+
Configurer.init = function(object, config) {
|
14
|
+
object.configuration = config;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Those are HTTP safe methods for which there is no need to pass any data with the request.
|
18
|
+
*/
|
19
|
+
var safeMethods= ['get', 'head', 'options', 'trace', 'getlist'];
|
20
|
+
config.isSafe = function(operation) {
|
21
|
+
return _.contains(safeMethods, operation.toLowerCase());
|
22
|
+
};
|
23
|
+
|
24
|
+
var absolutePattern = /^https?:\/\//i;
|
25
|
+
config.isAbsoluteUrl = function(string) {
|
26
|
+
return _.isUndefined(config.absoluteUrl) || _.isNull(config.absoluteUrl) ?
|
27
|
+
string && absolutePattern.test(string) :
|
28
|
+
config.absoluteUrl;
|
29
|
+
};
|
30
|
+
|
31
|
+
config.absoluteUrl = _.isUndefined(config.absoluteUrl) ? true : config.absoluteUrl;
|
32
|
+
object.setSelfLinkAbsoluteUrl = function(value) {
|
33
|
+
config.absoluteUrl = value;
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* This is the BaseURL to be used with Restangular
|
37
|
+
*/
|
38
|
+
config.baseUrl = _.isUndefined(config.baseUrl) ? '' : config.baseUrl;
|
39
|
+
object.setBaseUrl = function(newBaseUrl) {
|
40
|
+
config.baseUrl = /\/$/.test(newBaseUrl) ?
|
41
|
+
newBaseUrl.substring(0, newBaseUrl.length-1) :
|
42
|
+
newBaseUrl;
|
43
|
+
return this;
|
44
|
+
};
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Sets the extra fields to keep from the parents
|
48
|
+
*/
|
49
|
+
config.extraFields = config.extraFields || [];
|
50
|
+
object.setExtraFields = function(newExtraFields) {
|
51
|
+
config.extraFields = newExtraFields;
|
52
|
+
return this;
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Some default $http parameter to be used in EVERY call
|
57
|
+
**/
|
58
|
+
config.defaultHttpFields = config.defaultHttpFields || {};
|
59
|
+
object.setDefaultHttpFields = function(values) {
|
60
|
+
config.defaultHttpFields = values;
|
61
|
+
return this;
|
62
|
+
};
|
63
|
+
|
64
|
+
config.withHttpValues = function(httpLocalConfig, obj) {
|
65
|
+
return _.defaults(obj, httpLocalConfig, config.defaultHttpFields);
|
66
|
+
};
|
67
|
+
|
68
|
+
config.encodeIds = _.isUndefined(config.encodeIds) ? true : config.encodeIds;
|
69
|
+
object.setEncodeIds = function(encode) {
|
70
|
+
config.encodeIds = encode;
|
71
|
+
};
|
72
|
+
|
73
|
+
config.defaultRequestParams = config.defaultRequestParams || {
|
74
|
+
get: {},
|
75
|
+
post: {},
|
76
|
+
put: {},
|
77
|
+
remove: {},
|
78
|
+
common: {}
|
79
|
+
};
|
80
|
+
|
81
|
+
object.setDefaultRequestParams = function(param1, param2) {
|
82
|
+
var methods = [],
|
83
|
+
params = param2 || param1;
|
84
|
+
if (!_.isUndefined(param2)) {
|
85
|
+
if (_.isArray(param1)) {
|
86
|
+
methods = param1;
|
87
|
+
} else {
|
88
|
+
methods.push(param1);
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
methods.push('common');
|
92
|
+
}
|
93
|
+
|
94
|
+
_.each(methods, function (method) {
|
95
|
+
config.defaultRequestParams[method] = params;
|
96
|
+
});
|
97
|
+
return this;
|
98
|
+
};
|
99
|
+
|
100
|
+
object.requestParams = config.defaultRequestParams;
|
101
|
+
|
102
|
+
config.defaultHeaders = config.defaultHeaders || {};
|
103
|
+
object.setDefaultHeaders = function(headers) {
|
104
|
+
config.defaultHeaders = headers;
|
105
|
+
object.defaultHeaders = config.defaultHeaders;
|
106
|
+
return this;
|
107
|
+
};
|
108
|
+
|
109
|
+
object.defaultHeaders = config.defaultHeaders;
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Method overriders will set which methods are sent via POST with an X-HTTP-Method-Override
|
113
|
+
**/
|
114
|
+
config.methodOverriders = config.methodOverriders || [];
|
115
|
+
object.setMethodOverriders = function(values) {
|
116
|
+
var overriders = _.extend([], values);
|
117
|
+
if (config.isOverridenMethod('delete', overriders)) {
|
118
|
+
overriders.push('remove');
|
119
|
+
}
|
120
|
+
config.methodOverriders = overriders;
|
121
|
+
return this;
|
122
|
+
};
|
123
|
+
|
124
|
+
config.jsonp = _.isUndefined(config.jsonp) ? false : config.jsonp;
|
125
|
+
object.setJsonp = function(active) {
|
126
|
+
config.jsonp = active;
|
127
|
+
};
|
128
|
+
|
129
|
+
config.isOverridenMethod = function(method, values) {
|
130
|
+
var search = values || config.methodOverriders;
|
131
|
+
return !_.isUndefined(_.find(search, function(one) {
|
132
|
+
return one.toLowerCase() === method.toLowerCase();
|
133
|
+
}));
|
134
|
+
};
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Sets the URL creator type. For now, only Path is created. In the future we'll have queryParams
|
138
|
+
**/
|
139
|
+
config.urlCreator = config.urlCreator || 'path';
|
140
|
+
object.setUrlCreator = function(name) {
|
141
|
+
if (!_.has(config.urlCreatorFactory, name)) {
|
142
|
+
throw new Error('URL Path selected isn\'t valid');
|
143
|
+
}
|
144
|
+
|
145
|
+
config.urlCreator = name;
|
146
|
+
return this;
|
147
|
+
};
|
148
|
+
|
149
|
+
/**
|
150
|
+
* You can set the restangular fields here. The 3 required fields for Restangular are:
|
151
|
+
*
|
152
|
+
* id: Id of the element
|
153
|
+
* route: name of the route of this element
|
154
|
+
* parentResource: the reference to the parent resource
|
155
|
+
*
|
156
|
+
* All of this fields except for id, are handled (and created) by Restangular. By default,
|
157
|
+
* the field values will be id, route and parentResource respectively
|
158
|
+
*/
|
159
|
+
config.restangularFields = config.restangularFields || {
|
160
|
+
id: 'id',
|
161
|
+
route: 'route',
|
162
|
+
parentResource: 'parentResource',
|
163
|
+
restangularCollection: 'restangularCollection',
|
164
|
+
cannonicalId: '__cannonicalId',
|
165
|
+
etag: 'restangularEtag',
|
166
|
+
selfLink: 'href',
|
167
|
+
get: 'get',
|
168
|
+
getList: 'getList',
|
169
|
+
put: 'put',
|
170
|
+
post: 'post',
|
171
|
+
remove: 'remove',
|
172
|
+
head: 'head',
|
173
|
+
trace: 'trace',
|
174
|
+
options: 'options',
|
175
|
+
patch: 'patch',
|
176
|
+
getRestangularUrl: 'getRestangularUrl',
|
177
|
+
getRequestedUrl: 'getRequestedUrl',
|
178
|
+
putElement: 'putElement',
|
179
|
+
addRestangularMethod: 'addRestangularMethod',
|
180
|
+
getParentList: 'getParentList',
|
181
|
+
clone: 'clone',
|
182
|
+
ids: 'ids',
|
183
|
+
httpConfig: '_$httpConfig',
|
184
|
+
reqParams: 'reqParams',
|
185
|
+
one: 'one',
|
186
|
+
all: 'all',
|
187
|
+
several: 'several',
|
188
|
+
oneUrl: 'oneUrl',
|
189
|
+
allUrl: 'allUrl',
|
190
|
+
customPUT: 'customPUT',
|
191
|
+
customPOST: 'customPOST',
|
192
|
+
customDELETE: 'customDELETE',
|
193
|
+
customGET: 'customGET',
|
194
|
+
customGETLIST: 'customGETLIST',
|
195
|
+
customOperation: 'customOperation',
|
196
|
+
doPUT: 'doPUT',
|
197
|
+
doPOST: 'doPOST',
|
198
|
+
doDELETE: 'doDELETE',
|
199
|
+
doGET: 'doGET',
|
200
|
+
doGETLIST: 'doGETLIST',
|
201
|
+
fromServer: 'fromServer',
|
202
|
+
withConfig: 'withConfig',
|
203
|
+
withHttpConfig: 'withHttpConfig',
|
204
|
+
singleOne: 'singleOne',
|
205
|
+
plain: 'plain',
|
206
|
+
save: 'save',
|
207
|
+
restangularized: 'restangularized'
|
208
|
+
};
|
209
|
+
object.setRestangularFields = function(resFields) {
|
210
|
+
config.restangularFields =
|
211
|
+
_.extend(config.restangularFields, resFields);
|
212
|
+
return this;
|
213
|
+
};
|
214
|
+
|
215
|
+
config.isRestangularized = function(obj) {
|
216
|
+
return !!obj[config.restangularFields.restangularized];
|
217
|
+
};
|
218
|
+
|
219
|
+
config.setFieldToElem = function(field, elem, value) {
|
220
|
+
var properties = field.split('.');
|
221
|
+
var idValue = elem;
|
222
|
+
_.each(_.initial(properties), function(prop) {
|
223
|
+
idValue[prop] = {};
|
224
|
+
idValue = idValue[prop];
|
225
|
+
});
|
226
|
+
idValue[_.last(properties)] = value;
|
227
|
+
return this;
|
228
|
+
};
|
229
|
+
|
230
|
+
config.getFieldFromElem = function(field, elem) {
|
231
|
+
var properties = field.split('.');
|
232
|
+
var idValue = elem;
|
233
|
+
_.each(properties, function(prop) {
|
234
|
+
if (idValue) {
|
235
|
+
idValue = idValue[prop];
|
236
|
+
}
|
237
|
+
});
|
238
|
+
return angular.copy(idValue);
|
239
|
+
};
|
240
|
+
|
241
|
+
config.setIdToElem = function(elem, id /*, route */) {
|
242
|
+
config.setFieldToElem(config.restangularFields.id, elem, id);
|
243
|
+
return this;
|
244
|
+
};
|
245
|
+
|
246
|
+
config.getIdFromElem = function(elem) {
|
247
|
+
return config.getFieldFromElem(config.restangularFields.id, elem);
|
248
|
+
};
|
249
|
+
|
250
|
+
config.isValidId = function(elemId) {
|
251
|
+
return '' !== elemId && !_.isUndefined(elemId) && !_.isNull(elemId);
|
252
|
+
};
|
253
|
+
|
254
|
+
config.setUrlToElem = function(elem, url /*, route */) {
|
255
|
+
config.setFieldToElem(config.restangularFields.selfLink, elem, url);
|
256
|
+
return this;
|
257
|
+
};
|
258
|
+
|
259
|
+
config.getUrlFromElem = function(elem) {
|
260
|
+
return config.getFieldFromElem(config.restangularFields.selfLink, elem);
|
261
|
+
};
|
262
|
+
|
263
|
+
config.useCannonicalId = _.isUndefined(config.useCannonicalId) ? false : config.useCannonicalId;
|
264
|
+
object.setUseCannonicalId = function(value) {
|
265
|
+
config.useCannonicalId = value;
|
266
|
+
return this;
|
267
|
+
};
|
268
|
+
|
269
|
+
config.getCannonicalIdFromElem = function(elem) {
|
270
|
+
var cannonicalId = elem[config.restangularFields.cannonicalId];
|
271
|
+
var actualId = config.isValidId(cannonicalId) ? cannonicalId : config.getIdFromElem(elem);
|
272
|
+
return actualId;
|
273
|
+
};
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Sets the Response parser. This is used in case your response isn't directly the data.
|
277
|
+
* For example if you have a response like {meta: {'meta'}, data: {name: 'Gonto'}}
|
278
|
+
* you can extract this data which is the one that needs wrapping
|
279
|
+
*
|
280
|
+
* The ResponseExtractor is a function that receives the response and the method executed.
|
281
|
+
*/
|
282
|
+
|
283
|
+
config.responseInterceptors = config.responseInterceptors || [];
|
284
|
+
|
285
|
+
config.defaultResponseInterceptor = function(data /*, operation, what, url, response, deferred */) {
|
286
|
+
return data;
|
287
|
+
};
|
288
|
+
|
289
|
+
config.responseExtractor = function(data, operation, what, url, response, deferred) {
|
290
|
+
var interceptors = angular.copy(config.responseInterceptors);
|
291
|
+
interceptors.push(config.defaultResponseInterceptor);
|
292
|
+
var theData = data;
|
293
|
+
_.each(interceptors, function(interceptor) {
|
294
|
+
theData = interceptor(theData, operation,
|
295
|
+
what, url, response, deferred);
|
296
|
+
});
|
297
|
+
return theData;
|
298
|
+
};
|
299
|
+
|
300
|
+
object.addResponseInterceptor = function(extractor) {
|
301
|
+
config.responseInterceptors.push(extractor);
|
302
|
+
return this;
|
303
|
+
};
|
304
|
+
|
305
|
+
config.errorInterceptors = config.errorInterceptors || [];
|
306
|
+
object.addErrorInterceptor = function(interceptor) {
|
307
|
+
config.errorInterceptors.push(interceptor);
|
308
|
+
return this;
|
309
|
+
};
|
310
|
+
|
311
|
+
object.setResponseInterceptor = object.addResponseInterceptor;
|
312
|
+
object.setResponseExtractor = object.addResponseInterceptor;
|
313
|
+
object.setErrorInterceptor = object.addErrorInterceptor;
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Response interceptor is called just before resolving promises.
|
317
|
+
*/
|
318
|
+
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Request interceptor is called before sending an object to the server.
|
322
|
+
*/
|
323
|
+
config.requestInterceptors = config.requestInterceptors || [];
|
324
|
+
|
325
|
+
config.defaultInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
|
326
|
+
return {
|
327
|
+
element: element,
|
328
|
+
headers: headers,
|
329
|
+
params: params,
|
330
|
+
httpConfig: httpConfig
|
331
|
+
};
|
332
|
+
};
|
333
|
+
|
334
|
+
config.fullRequestInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
|
335
|
+
var interceptors = angular.copy(config.requestInterceptors);
|
336
|
+
var defaultRequest = config.defaultInterceptor(element, operation, path, url, headers, params, httpConfig);
|
337
|
+
return _.reduce(interceptors, function(request, interceptor) {
|
338
|
+
return _.extend(request, interceptor(request.element, operation,
|
339
|
+
path, url, request.headers, request.params, request.httpConfig));
|
340
|
+
}, defaultRequest);
|
341
|
+
};
|
342
|
+
|
343
|
+
object.addRequestInterceptor = function(interceptor) {
|
344
|
+
config.requestInterceptors.push(function(elem, operation, path, url, headers, params, httpConfig) {
|
345
|
+
return {
|
346
|
+
headers: headers,
|
347
|
+
params: params,
|
348
|
+
element: interceptor(elem, operation, path, url),
|
349
|
+
httpConfig: httpConfig
|
350
|
+
};
|
351
|
+
});
|
352
|
+
return this;
|
353
|
+
};
|
354
|
+
|
355
|
+
object.setRequestInterceptor = object.addRequestInterceptor;
|
356
|
+
|
357
|
+
object.addFullRequestInterceptor = function(interceptor) {
|
358
|
+
config.requestInterceptors.push(interceptor);
|
359
|
+
return this;
|
360
|
+
};
|
361
|
+
|
362
|
+
object.setFullRequestInterceptor = object.addFullRequestInterceptor;
|
363
|
+
|
364
|
+
config.onBeforeElemRestangularized = config.onBeforeElemRestangularized || function(elem) {
|
365
|
+
return elem;
|
366
|
+
};
|
367
|
+
object.setOnBeforeElemRestangularized = function(post) {
|
368
|
+
config.onBeforeElemRestangularized = post;
|
369
|
+
return this;
|
370
|
+
};
|
371
|
+
|
372
|
+
object.setRestangularizePromiseInterceptor = function(interceptor) {
|
373
|
+
config.restangularizePromiseInterceptor = interceptor;
|
374
|
+
return this;
|
375
|
+
};
|
376
|
+
|
377
|
+
/**
|
378
|
+
* This method is called after an element has been "Restangularized".
|
379
|
+
*
|
380
|
+
* It receives the element, a boolean indicating if it's an element or a collection
|
381
|
+
* and the name of the model
|
382
|
+
*
|
383
|
+
*/
|
384
|
+
config.onElemRestangularized = config.onElemRestangularized || function(elem) {
|
385
|
+
return elem;
|
386
|
+
};
|
387
|
+
object.setOnElemRestangularized = function(post) {
|
388
|
+
config.onElemRestangularized = post;
|
389
|
+
return this;
|
390
|
+
};
|
391
|
+
|
392
|
+
config.shouldSaveParent = config.shouldSaveParent || function() {
|
393
|
+
return true;
|
394
|
+
};
|
395
|
+
object.setParentless = function(values) {
|
396
|
+
if (_.isArray(values)) {
|
397
|
+
config.shouldSaveParent = function(route) {
|
398
|
+
return !_.contains(values, route);
|
399
|
+
};
|
400
|
+
} else if (_.isBoolean(values)) {
|
401
|
+
config.shouldSaveParent = function() {
|
402
|
+
return !values;
|
403
|
+
};
|
404
|
+
}
|
405
|
+
return this;
|
406
|
+
};
|
407
|
+
|
408
|
+
/**
|
409
|
+
* This lets you set a suffix to every request.
|
410
|
+
*
|
411
|
+
* For example, if your api requires that for JSon requests you do /users/123.json, you can set that
|
412
|
+
* in here.
|
413
|
+
*
|
414
|
+
*
|
415
|
+
* By default, the suffix is null
|
416
|
+
*/
|
417
|
+
config.suffix = _.isUndefined(config.suffix) ? null : config.suffix;
|
418
|
+
object.setRequestSuffix = function(newSuffix) {
|
419
|
+
config.suffix = newSuffix;
|
420
|
+
return this;
|
421
|
+
};
|
422
|
+
|
423
|
+
/**
|
424
|
+
* Add element transformers for certain routes.
|
425
|
+
*/
|
426
|
+
config.transformers = config.transformers || {};
|
427
|
+
object.addElementTransformer = function(type, secondArg, thirdArg) {
|
428
|
+
var isCollection = null;
|
429
|
+
var transformer = null;
|
430
|
+
if (arguments.length === 2) {
|
431
|
+
transformer = secondArg;
|
432
|
+
} else {
|
433
|
+
transformer = thirdArg;
|
434
|
+
isCollection = secondArg;
|
435
|
+
}
|
436
|
+
|
437
|
+
var typeTransformers = config.transformers[type];
|
438
|
+
if (!typeTransformers) {
|
439
|
+
typeTransformers = config.transformers[type] = [];
|
440
|
+
}
|
441
|
+
|
442
|
+
typeTransformers.push(function(coll, elem) {
|
443
|
+
if (_.isNull(isCollection) || (coll === isCollection)) {
|
444
|
+
return transformer(elem);
|
445
|
+
}
|
446
|
+
return elem;
|
447
|
+
});
|
448
|
+
|
449
|
+
return object;
|
450
|
+
};
|
451
|
+
|
452
|
+
object.extendCollection = function(route, fn) {
|
453
|
+
return object.addElementTransformer(route, true, fn);
|
454
|
+
};
|
455
|
+
|
456
|
+
object.extendModel = function(route, fn) {
|
457
|
+
return object.addElementTransformer(route, false, fn);
|
458
|
+
};
|
459
|
+
|
460
|
+
config.transformElem = function(elem, isCollection, route, Restangular, force) {
|
461
|
+
if (!force && !config.transformLocalElements && !elem[config.restangularFields.fromServer]) {
|
462
|
+
return elem;
|
463
|
+
}
|
464
|
+
var typeTransformers = config.transformers[route];
|
465
|
+
var changedElem = elem;
|
466
|
+
if (typeTransformers) {
|
467
|
+
_.each(typeTransformers, function(transformer) {
|
468
|
+
changedElem = transformer(isCollection, changedElem);
|
469
|
+
});
|
470
|
+
}
|
471
|
+
return config.onElemRestangularized(changedElem, isCollection, route, Restangular);
|
472
|
+
};
|
473
|
+
|
474
|
+
config.transformLocalElements = _.isUndefined(config.transformLocalElements) ?
|
475
|
+
false :
|
476
|
+
config.transformLocalElements;
|
477
|
+
|
478
|
+
object.setTransformOnlyServerElements = function(active) {
|
479
|
+
config.transformLocalElements = !active;
|
480
|
+
};
|
481
|
+
|
482
|
+
config.fullResponse = _.isUndefined(config.fullResponse) ? false : config.fullResponse;
|
483
|
+
object.setFullResponse = function(full) {
|
484
|
+
config.fullResponse = full;
|
485
|
+
return this;
|
486
|
+
};
|
487
|
+
|
488
|
+
|
489
|
+
//Internal values and functions
|
490
|
+
config.urlCreatorFactory = {};
|
491
|
+
|
492
|
+
/**
|
493
|
+
* Base URL Creator. Base prototype for everything related to it
|
494
|
+
**/
|
495
|
+
|
496
|
+
var BaseCreator = function() {
|
497
|
+
};
|
498
|
+
|
499
|
+
BaseCreator.prototype.setConfig = function(config) {
|
500
|
+
this.config = config;
|
501
|
+
return this;
|
502
|
+
};
|
503
|
+
|
504
|
+
BaseCreator.prototype.parentsArray = function(current) {
|
505
|
+
var parents = [];
|
506
|
+
while(current) {
|
507
|
+
parents.push(current);
|
508
|
+
current = current[this.config.restangularFields.parentResource];
|
509
|
+
}
|
510
|
+
return parents.reverse();
|
511
|
+
};
|
512
|
+
|
513
|
+
function RestangularResource(config, $http, url, configurer) {
|
514
|
+
var resource = {};
|
515
|
+
_.each(_.keys(configurer), function(key) {
|
516
|
+
var value = configurer[key];
|
517
|
+
|
518
|
+
// Add default parameters
|
519
|
+
value.params = _.extend({}, value.params, config.defaultRequestParams[value.method.toLowerCase()]);
|
520
|
+
// We don't want the ? if no params are there
|
521
|
+
if (_.isEmpty(value.params)) {
|
522
|
+
delete value.params;
|
523
|
+
}
|
524
|
+
|
525
|
+
if (config.isSafe(value.method)) {
|
526
|
+
|
527
|
+
resource[key] = function() {
|
528
|
+
return $http(_.extend(value, {
|
529
|
+
url: url
|
530
|
+
}));
|
531
|
+
};
|
532
|
+
|
533
|
+
} else {
|
534
|
+
|
535
|
+
resource[key] = function(data) {
|
536
|
+
return $http(_.extend(value, {
|
537
|
+
url: url,
|
538
|
+
data: data
|
539
|
+
}));
|
540
|
+
};
|
541
|
+
|
542
|
+
}
|
543
|
+
});
|
544
|
+
|
545
|
+
return resource;
|
546
|
+
}
|
547
|
+
|
548
|
+
BaseCreator.prototype.resource = function(current, $http, localHttpConfig, callHeaders, callParams, what, etag,operation) {
|
549
|
+
|
550
|
+
var params = _.defaults(callParams || {}, this.config.defaultRequestParams.common);
|
551
|
+
var headers = _.defaults(callHeaders || {}, this.config.defaultHeaders);
|
552
|
+
|
553
|
+
if (etag) {
|
554
|
+
if (!config.isSafe(operation)) {
|
555
|
+
headers['If-Match'] = etag;
|
556
|
+
} else {
|
557
|
+
headers['If-None-Match'] = etag;
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
var url = this.base(current);
|
562
|
+
|
563
|
+
if (what) {
|
564
|
+
var add = '';
|
565
|
+
if (!/\/$/.test(url)) {
|
566
|
+
add += '/';
|
567
|
+
}
|
568
|
+
add += what;
|
569
|
+
url += add;
|
570
|
+
}
|
571
|
+
|
572
|
+
if (this.config.suffix &&
|
573
|
+
url.indexOf(this.config.suffix, url.length - this.config.suffix.length) === -1 &&
|
574
|
+
!this.config.getUrlFromElem(current)) {
|
575
|
+
url += this.config.suffix;
|
576
|
+
}
|
577
|
+
|
578
|
+
current[this.config.restangularFields.httpConfig] = undefined;
|
579
|
+
|
580
|
+
return RestangularResource(this.config, $http, url, {
|
581
|
+
getList: this.config.withHttpValues(localHttpConfig,
|
582
|
+
{method: 'GET',
|
583
|
+
params: params,
|
584
|
+
headers: headers}),
|
585
|
+
|
586
|
+
get: this.config.withHttpValues(localHttpConfig,
|
587
|
+
{method: 'GET',
|
588
|
+
params: params,
|
589
|
+
headers: headers}),
|
590
|
+
|
591
|
+
jsonp: this.config.withHttpValues(localHttpConfig,
|
592
|
+
{method: 'jsonp',
|
593
|
+
params: params,
|
594
|
+
headers: headers}),
|
595
|
+
|
596
|
+
put: this.config.withHttpValues(localHttpConfig,
|
597
|
+
{method: 'PUT',
|
598
|
+
params: params,
|
599
|
+
headers: headers}),
|
600
|
+
|
601
|
+
post: this.config.withHttpValues(localHttpConfig,
|
602
|
+
{method: 'POST',
|
603
|
+
params: params,
|
604
|
+
headers: headers}),
|
605
|
+
|
606
|
+
remove: this.config.withHttpValues(localHttpConfig,
|
607
|
+
{method: 'DELETE',
|
608
|
+
params: params,
|
609
|
+
headers: headers}),
|
610
|
+
|
611
|
+
head: this.config.withHttpValues(localHttpConfig,
|
612
|
+
{method: 'HEAD',
|
613
|
+
params: params,
|
614
|
+
headers: headers}),
|
615
|
+
|
616
|
+
trace: this.config.withHttpValues(localHttpConfig,
|
617
|
+
{method: 'TRACE',
|
618
|
+
params: params,
|
619
|
+
headers: headers}),
|
620
|
+
|
621
|
+
options: this.config.withHttpValues(localHttpConfig,
|
622
|
+
{method: 'OPTIONS',
|
623
|
+
params: params,
|
624
|
+
headers: headers}),
|
625
|
+
|
626
|
+
patch: this.config.withHttpValues(localHttpConfig,
|
627
|
+
{method: 'PATCH',
|
628
|
+
params: params,
|
629
|
+
headers: headers})
|
630
|
+
});
|
631
|
+
};
|
632
|
+
|
633
|
+
/**
|
634
|
+
* This is the Path URL creator. It uses Path to show Hierarchy in the Rest API.
|
635
|
+
* This means that if you have an Account that then has a set of Buildings, a URL to a building
|
636
|
+
* would be /accounts/123/buildings/456
|
637
|
+
**/
|
638
|
+
var Path = function() {
|
639
|
+
};
|
640
|
+
|
641
|
+
Path.prototype = new BaseCreator();
|
642
|
+
|
643
|
+
Path.prototype.normalizeUrl = function (url){
|
644
|
+
var parts = /(http[s]?:\/\/)?(.*)?/.exec(url);
|
645
|
+
parts[2] = parts[2].replace(/[\\\/]+/g, '/');
|
646
|
+
return (typeof parts[1] !== 'undefined')? parts[1] + parts[2] : parts[2];
|
647
|
+
};
|
648
|
+
|
649
|
+
Path.prototype.base = function(current) {
|
650
|
+
var __this = this;
|
651
|
+
return _.reduce(this.parentsArray(current), function(acum, elem) {
|
652
|
+
var elemUrl;
|
653
|
+
var elemSelfLink = __this.config.getUrlFromElem(elem);
|
654
|
+
if (elemSelfLink) {
|
655
|
+
if (__this.config.isAbsoluteUrl(elemSelfLink)) {
|
656
|
+
return elemSelfLink;
|
657
|
+
} else {
|
658
|
+
elemUrl = elemSelfLink;
|
659
|
+
}
|
660
|
+
} else {
|
661
|
+
elemUrl = elem[__this.config.restangularFields.route];
|
662
|
+
|
663
|
+
if (elem[__this.config.restangularFields.restangularCollection]) {
|
664
|
+
var ids = elem[__this.config.restangularFields.ids];
|
665
|
+
if (ids) {
|
666
|
+
elemUrl += '/' + ids.join(',');
|
667
|
+
}
|
668
|
+
} else {
|
669
|
+
var elemId;
|
670
|
+
if (__this.config.useCannonicalId) {
|
671
|
+
elemId = __this.config.getCannonicalIdFromElem(elem);
|
672
|
+
} else {
|
673
|
+
elemId = __this.config.getIdFromElem(elem);
|
674
|
+
}
|
675
|
+
|
676
|
+
if (config.isValidId(elemId) && !elem.singleOne) {
|
677
|
+
elemUrl += '/' + (__this.config.encodeIds ? encodeURIComponent(elemId) : elemId);
|
678
|
+
}
|
679
|
+
}
|
680
|
+
}
|
681
|
+
acum = acum.replace(/\/$/, '') + '/' + elemUrl;
|
682
|
+
return __this.normalizeUrl(acum);
|
683
|
+
|
684
|
+
}, this.config.baseUrl);
|
685
|
+
};
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
Path.prototype.fetchUrl = function(current, what) {
|
690
|
+
var baseUrl = this.base(current);
|
691
|
+
if (what) {
|
692
|
+
baseUrl += '/' + what;
|
693
|
+
}
|
694
|
+
return baseUrl;
|
695
|
+
};
|
696
|
+
|
697
|
+
Path.prototype.fetchRequestedUrl = function(current, what) {
|
698
|
+
var url = this.fetchUrl(current, what);
|
699
|
+
var params = current[config.restangularFields.reqParams];
|
700
|
+
|
701
|
+
// From here on and until the end of fetchRequestedUrl,
|
702
|
+
// the code has been kindly borrowed from angular.js
|
703
|
+
// The reason for such code bloating is coherence:
|
704
|
+
// If the user were to use this for cache management, the
|
705
|
+
// serialization of parameters would need to be identical
|
706
|
+
// to the one done by angular for cache keys to match.
|
707
|
+
function sortedKeys(obj) {
|
708
|
+
var keys = [];
|
709
|
+
for (var key in obj) {
|
710
|
+
if (obj.hasOwnProperty(key)) {
|
711
|
+
keys.push(key);
|
712
|
+
}
|
713
|
+
}
|
714
|
+
return keys.sort();
|
715
|
+
}
|
716
|
+
|
717
|
+
function forEachSorted(obj, iterator, context) {
|
718
|
+
var keys = sortedKeys(obj);
|
719
|
+
for ( var i = 0; i < keys.length; i++) {
|
720
|
+
iterator.call(context, obj[keys[i]], keys[i]);
|
721
|
+
}
|
722
|
+
return keys;
|
723
|
+
}
|
724
|
+
|
725
|
+
function encodeUriQuery(val, pctEncodeSpaces) {
|
726
|
+
return encodeURIComponent(val).
|
727
|
+
replace(/%40/gi, '@').
|
728
|
+
replace(/%3A/gi, ':').
|
729
|
+
replace(/%24/g, '$').
|
730
|
+
replace(/%2C/gi, ',').
|
731
|
+
replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
|
732
|
+
}
|
733
|
+
|
734
|
+
if (!params) { return url + (this.config.suffix || ''); }
|
735
|
+
|
736
|
+
var parts = [];
|
737
|
+
forEachSorted(params, function(value, key) {
|
738
|
+
if (value === null || value === undefined) { return; }
|
739
|
+
if (!angular.isArray(value)) { value = [value]; }
|
740
|
+
|
741
|
+
angular.forEach(value, function(v) {
|
742
|
+
if (angular.isObject(v)) {
|
743
|
+
v = angular.toJson(v);
|
744
|
+
}
|
745
|
+
parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(v));
|
746
|
+
});
|
747
|
+
});
|
748
|
+
|
749
|
+
return url + (this.config.suffix || '') + ((url.indexOf('?') === -1) ? '?' : '&') + parts.join('&');
|
750
|
+
};
|
751
|
+
|
752
|
+
config.urlCreatorFactory.path = Path;
|
753
|
+
};
|
754
|
+
|
755
|
+
var globalConfiguration = {};
|
756
|
+
|
757
|
+
Configurer.init(this, globalConfiguration);
|
758
|
+
|
759
|
+
|
760
|
+
|
761
|
+
this.$get = ['$http', '$q', function($http, $q) {
|
762
|
+
|
763
|
+
function createServiceForConfiguration(config) {
|
764
|
+
var service = {};
|
765
|
+
|
766
|
+
var urlHandler = new config.urlCreatorFactory[config.urlCreator]();
|
767
|
+
urlHandler.setConfig(config);
|
768
|
+
|
769
|
+
function restangularizeBase(parent, elem, route, reqParams, fromServer) {
|
770
|
+
elem[config.restangularFields.route] = route;
|
771
|
+
elem[config.restangularFields.getRestangularUrl] = _.bind(urlHandler.fetchUrl, urlHandler, elem);
|
772
|
+
elem[config.restangularFields.getRequestedUrl] = _.bind(urlHandler.fetchRequestedUrl, urlHandler, elem);
|
773
|
+
elem[config.restangularFields.addRestangularMethod] = _.bind(addRestangularMethodFunction, elem);
|
774
|
+
elem[config.restangularFields.clone] = _.bind(copyRestangularizedElement, elem, elem);
|
775
|
+
elem[config.restangularFields.reqParams] = _.isEmpty(reqParams) ? null : reqParams;
|
776
|
+
elem[config.restangularFields.withHttpConfig] = _.bind(withHttpConfig, elem);
|
777
|
+
elem[config.restangularFields.plain] = _.bind(stripRestangular, elem, elem);
|
778
|
+
|
779
|
+
// Tag element as restangularized
|
780
|
+
elem[config.restangularFields.restangularized] = true;
|
781
|
+
|
782
|
+
// RequestLess connection
|
783
|
+
elem[config.restangularFields.one] = _.bind(one, elem, elem);
|
784
|
+
elem[config.restangularFields.all] = _.bind(all, elem, elem);
|
785
|
+
elem[config.restangularFields.several] = _.bind(several, elem, elem);
|
786
|
+
elem[config.restangularFields.oneUrl] = _.bind(oneUrl, elem, elem);
|
787
|
+
elem[config.restangularFields.allUrl] = _.bind(allUrl, elem, elem);
|
788
|
+
|
789
|
+
elem[config.restangularFields.fromServer] = !!fromServer;
|
790
|
+
|
791
|
+
if (parent && config.shouldSaveParent(route)) {
|
792
|
+
var parentId = config.getIdFromElem(parent);
|
793
|
+
var parentUrl = config.getUrlFromElem(parent);
|
794
|
+
|
795
|
+
var restangularFieldsForParent = _.union(
|
796
|
+
_.values( _.pick(config.restangularFields, ['route', 'singleOne', 'parentResource']) ),
|
797
|
+
config.extraFields
|
798
|
+
);
|
799
|
+
var parentResource = _.pick(parent, restangularFieldsForParent);
|
800
|
+
|
801
|
+
if (config.isValidId(parentId)) {
|
802
|
+
config.setIdToElem(parentResource, parentId, route);
|
803
|
+
}
|
804
|
+
if (config.isValidId(parentUrl)) {
|
805
|
+
config.setUrlToElem(parentResource, parentUrl, route);
|
806
|
+
}
|
807
|
+
|
808
|
+
elem[config.restangularFields.parentResource] = parentResource;
|
809
|
+
} else {
|
810
|
+
elem[config.restangularFields.parentResource] = null;
|
811
|
+
}
|
812
|
+
return elem;
|
813
|
+
}
|
814
|
+
|
815
|
+
function one(parent, route, id, singleOne) {
|
816
|
+
var error;
|
817
|
+
if (_.isNumber(route) || _.isNumber(parent)) {
|
818
|
+
error = 'You\'re creating a Restangular entity with the number ';
|
819
|
+
error += 'instead of the route or the parent. For example, you can\'t call .one(12).';
|
820
|
+
throw new Error(error);
|
821
|
+
}
|
822
|
+
if (_.isUndefined(route)) {
|
823
|
+
error = 'You\'re creating a Restangular entity either without the path. ';
|
824
|
+
error += 'For example you can\'t call .one(). Please check if your arguments are valid.';
|
825
|
+
throw new Error(error);
|
826
|
+
}
|
827
|
+
var elem = {};
|
828
|
+
config.setIdToElem(elem, id, route);
|
829
|
+
config.setFieldToElem(config.restangularFields.singleOne, elem, singleOne);
|
830
|
+
return restangularizeElem(parent, elem , route, false);
|
831
|
+
}
|
832
|
+
|
833
|
+
|
834
|
+
function all(parent, route) {
|
835
|
+
return restangularizeCollection(parent, [] , route, false);
|
836
|
+
}
|
837
|
+
|
838
|
+
function several(parent, route /*, ids */) {
|
839
|
+
var collection = [];
|
840
|
+
collection[config.restangularFields.ids] = Array.prototype.splice.call(arguments, 2);
|
841
|
+
return restangularizeCollection(parent, collection , route, false);
|
842
|
+
}
|
843
|
+
|
844
|
+
function oneUrl(parent, route, url) {
|
845
|
+
if (!route) {
|
846
|
+
throw new Error('Route is mandatory when creating new Restangular objects.');
|
847
|
+
}
|
848
|
+
var elem = {};
|
849
|
+
config.setUrlToElem(elem, url, route);
|
850
|
+
return restangularizeElem(parent, elem , route, false);
|
851
|
+
}
|
852
|
+
|
853
|
+
|
854
|
+
function allUrl(parent, route, url) {
|
855
|
+
if (!route) {
|
856
|
+
throw new Error('Route is mandatory when creating new Restangular objects.');
|
857
|
+
}
|
858
|
+
var elem = {};
|
859
|
+
config.setUrlToElem(elem, url, route);
|
860
|
+
return restangularizeCollection(parent, elem , route, false);
|
861
|
+
}
|
862
|
+
// Promises
|
863
|
+
function restangularizePromise(promise, isCollection, valueToFill) {
|
864
|
+
promise.call = _.bind(promiseCall, promise);
|
865
|
+
promise.get = _.bind(promiseGet, promise);
|
866
|
+
promise[config.restangularFields.restangularCollection] = isCollection;
|
867
|
+
if (isCollection) {
|
868
|
+
promise.push = _.bind(promiseCall, promise, 'push');
|
869
|
+
}
|
870
|
+
promise.$object = valueToFill;
|
871
|
+
if (config.restangularizePromiseInterceptor) {
|
872
|
+
config.restangularizePromiseInterceptor(promise);
|
873
|
+
}
|
874
|
+
return promise;
|
875
|
+
}
|
876
|
+
|
877
|
+
function promiseCall(method) {
|
878
|
+
var deferred = $q.defer();
|
879
|
+
var callArgs = arguments;
|
880
|
+
var filledValue = {};
|
881
|
+
this.then(function(val) {
|
882
|
+
var params = Array.prototype.slice.call(callArgs, 1);
|
883
|
+
var func = val[method];
|
884
|
+
func.apply(val, params);
|
885
|
+
filledValue = val;
|
886
|
+
deferred.resolve(val);
|
887
|
+
});
|
888
|
+
return restangularizePromise(deferred.promise, this[config.restangularFields.restangularCollection], filledValue);
|
889
|
+
}
|
890
|
+
|
891
|
+
function promiseGet(what) {
|
892
|
+
var deferred = $q.defer();
|
893
|
+
var filledValue = {};
|
894
|
+
this.then(function(val) {
|
895
|
+
filledValue = val[what];
|
896
|
+
deferred.resolve(filledValue);
|
897
|
+
});
|
898
|
+
return restangularizePromise(deferred.promise, this[config.restangularFields.restangularCollection], filledValue);
|
899
|
+
}
|
900
|
+
|
901
|
+
function resolvePromise(deferred, response, data, filledValue) {
|
902
|
+
_.extend(filledValue, data);
|
903
|
+
|
904
|
+
// Trigger the full response interceptor.
|
905
|
+
if (config.fullResponse) {
|
906
|
+
return deferred.resolve(_.extend(response, {
|
907
|
+
data: data
|
908
|
+
}));
|
909
|
+
} else {
|
910
|
+
deferred.resolve(data);
|
911
|
+
}
|
912
|
+
}
|
913
|
+
|
914
|
+
|
915
|
+
// Elements
|
916
|
+
function stripRestangular(elem) {
|
917
|
+
if (_.isArray(elem)) {
|
918
|
+
var array = [];
|
919
|
+
_.each(elem, function(value) {
|
920
|
+
array.push(config.isRestangularized(value) ? stripRestangular(value) : value);
|
921
|
+
});
|
922
|
+
return array;
|
923
|
+
} else {
|
924
|
+
return _.omit(elem, _.values(_.omit(config.restangularFields, 'id')));
|
925
|
+
}
|
926
|
+
}
|
927
|
+
|
928
|
+
function addCustomOperation(elem) {
|
929
|
+
elem[config.restangularFields.customOperation] = _.bind(customFunction, elem);
|
930
|
+
_.each(['put', 'post', 'get', 'delete'], function(oper) {
|
931
|
+
_.each(['do', 'custom'], function(alias) {
|
932
|
+
var callOperation = oper === 'delete' ? 'remove' : oper;
|
933
|
+
var name = alias + oper.toUpperCase();
|
934
|
+
var callFunction;
|
935
|
+
|
936
|
+
if (callOperation !== 'put' && callOperation !== 'post') {
|
937
|
+
callFunction = customFunction;
|
938
|
+
} else {
|
939
|
+
callFunction = function(operation, elem, path, params, headers) {
|
940
|
+
return _.bind(customFunction, this)(operation, path, params, headers, elem);
|
941
|
+
};
|
942
|
+
}
|
943
|
+
elem[name] = _.bind(callFunction, elem, callOperation);
|
944
|
+
});
|
945
|
+
});
|
946
|
+
elem[config.restangularFields.customGETLIST] = _.bind(fetchFunction, elem);
|
947
|
+
elem[config.restangularFields.doGETLIST] = elem[config.restangularFields.customGETLIST];
|
948
|
+
}
|
949
|
+
|
950
|
+
function copyRestangularizedElement(fromElement, toElement) {
|
951
|
+
var copiedElement = angular.copy(fromElement, toElement);
|
952
|
+
return restangularizeElem(copiedElement[config.restangularFields.parentResource],
|
953
|
+
copiedElement, copiedElement[config.restangularFields.route], true);
|
954
|
+
}
|
955
|
+
|
956
|
+
function restangularizeElem(parent, element, route, fromServer, collection, reqParams) {
|
957
|
+
var elem = config.onBeforeElemRestangularized(element, false, route);
|
958
|
+
|
959
|
+
var localElem = restangularizeBase(parent, elem, route, reqParams, fromServer);
|
960
|
+
|
961
|
+
if (config.useCannonicalId) {
|
962
|
+
localElem[config.restangularFields.cannonicalId] = config.getIdFromElem(localElem);
|
963
|
+
}
|
964
|
+
|
965
|
+
if (collection) {
|
966
|
+
localElem[config.restangularFields.getParentList] = function() {
|
967
|
+
return collection;
|
968
|
+
};
|
969
|
+
}
|
970
|
+
|
971
|
+
localElem[config.restangularFields.restangularCollection] = false;
|
972
|
+
localElem[config.restangularFields.get] = _.bind(getFunction, localElem);
|
973
|
+
localElem[config.restangularFields.getList] = _.bind(fetchFunction, localElem);
|
974
|
+
localElem[config.restangularFields.put] = _.bind(putFunction, localElem);
|
975
|
+
localElem[config.restangularFields.post] = _.bind(postFunction, localElem);
|
976
|
+
localElem[config.restangularFields.remove] = _.bind(deleteFunction, localElem);
|
977
|
+
localElem[config.restangularFields.head] = _.bind(headFunction, localElem);
|
978
|
+
localElem[config.restangularFields.trace] = _.bind(traceFunction, localElem);
|
979
|
+
localElem[config.restangularFields.options] = _.bind(optionsFunction, localElem);
|
980
|
+
localElem[config.restangularFields.patch] = _.bind(patchFunction, localElem);
|
981
|
+
localElem[config.restangularFields.save] = _.bind(save, localElem);
|
982
|
+
|
983
|
+
addCustomOperation(localElem);
|
984
|
+
return config.transformElem(localElem, false, route, service, true);
|
985
|
+
}
|
986
|
+
|
987
|
+
function restangularizeCollection(parent, element, route, fromServer, reqParams) {
|
988
|
+
var elem = config.onBeforeElemRestangularized(element, true, route);
|
989
|
+
|
990
|
+
var localElem = restangularizeBase(parent, elem, route, reqParams, fromServer);
|
991
|
+
localElem[config.restangularFields.restangularCollection] = true;
|
992
|
+
localElem[config.restangularFields.post] = _.bind(postFunction, localElem, null);
|
993
|
+
localElem[config.restangularFields.remove] = _.bind(deleteFunction, localElem);
|
994
|
+
localElem[config.restangularFields.head] = _.bind(headFunction, localElem);
|
995
|
+
localElem[config.restangularFields.trace] = _.bind(traceFunction, localElem);
|
996
|
+
localElem[config.restangularFields.putElement] = _.bind(putElementFunction, localElem);
|
997
|
+
localElem[config.restangularFields.options] = _.bind(optionsFunction, localElem);
|
998
|
+
localElem[config.restangularFields.patch] = _.bind(patchFunction, localElem);
|
999
|
+
localElem[config.restangularFields.get] = _.bind(getById, localElem);
|
1000
|
+
localElem[config.restangularFields.getList] = _.bind(fetchFunction, localElem, null);
|
1001
|
+
|
1002
|
+
addCustomOperation(localElem);
|
1003
|
+
return config.transformElem(localElem, true, route, service, true);
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
function restangularizeCollectionAndElements(parent, element, route) {
|
1007
|
+
var collection = restangularizeCollection(parent, element, route, false);
|
1008
|
+
_.each(collection, function(elem) {
|
1009
|
+
restangularizeElem(parent, elem, route, false);
|
1010
|
+
});
|
1011
|
+
return collection;
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
function getById(id, reqParams, headers){
|
1015
|
+
return this.customGET(id.toString(), reqParams, headers);
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
function putElementFunction(idx, params, headers) {
|
1019
|
+
var __this = this;
|
1020
|
+
var elemToPut = this[idx];
|
1021
|
+
var deferred = $q.defer();
|
1022
|
+
var filledArray = [];
|
1023
|
+
filledArray = config.transformElem(filledArray, true, elemToPut[config.restangularFields.route], service);
|
1024
|
+
elemToPut.put(params, headers).then(function(serverElem) {
|
1025
|
+
var newArray = copyRestangularizedElement(__this);
|
1026
|
+
newArray[idx] = serverElem;
|
1027
|
+
filledArray = newArray;
|
1028
|
+
deferred.resolve(newArray);
|
1029
|
+
}, function(response) {
|
1030
|
+
deferred.reject(response);
|
1031
|
+
});
|
1032
|
+
|
1033
|
+
return restangularizePromise(deferred.promise, true, filledArray);
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
function parseResponse(resData, operation, route, fetchUrl, response, deferred) {
|
1037
|
+
var data = config.responseExtractor(resData, operation, route, fetchUrl, response, deferred);
|
1038
|
+
var etag = response.headers('ETag');
|
1039
|
+
if (data && etag) {
|
1040
|
+
data[config.restangularFields.etag] = etag;
|
1041
|
+
}
|
1042
|
+
return data;
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
|
1046
|
+
function fetchFunction(what, reqParams, headers) {
|
1047
|
+
var __this = this;
|
1048
|
+
var deferred = $q.defer();
|
1049
|
+
var operation = 'getList';
|
1050
|
+
var url = urlHandler.fetchUrl(this, what);
|
1051
|
+
var whatFetched = what || __this[config.restangularFields.route];
|
1052
|
+
|
1053
|
+
var request = config.fullRequestInterceptor(null, operation,
|
1054
|
+
whatFetched, url, headers || {}, reqParams || {}, this[config.restangularFields.httpConfig] || {});
|
1055
|
+
|
1056
|
+
var filledArray = [];
|
1057
|
+
filledArray = config.transformElem(filledArray, true, whatFetched, service);
|
1058
|
+
|
1059
|
+
var method = 'getList';
|
1060
|
+
|
1061
|
+
if (config.jsonp) {
|
1062
|
+
method = 'jsonp';
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
var okCallback = function(response) {
|
1066
|
+
var resData = response.data;
|
1067
|
+
var fullParams = response.config.params;
|
1068
|
+
var data = parseResponse(resData, operation, whatFetched, url, response, deferred);
|
1069
|
+
|
1070
|
+
// support empty response for getList() calls (some APIs respond with 204 and empty body)
|
1071
|
+
if (_.isUndefined(data) || '' === data) {
|
1072
|
+
data = [];
|
1073
|
+
}
|
1074
|
+
if (!_.isArray(data)) {
|
1075
|
+
throw new Error('Response for getList SHOULD be an array and not an object or something else');
|
1076
|
+
}
|
1077
|
+
var processedData = _.map(data, function(elem) {
|
1078
|
+
if (!__this[config.restangularFields.restangularCollection]) {
|
1079
|
+
return restangularizeElem(__this, elem, what, true, data);
|
1080
|
+
} else {
|
1081
|
+
return restangularizeElem(__this[config.restangularFields.parentResource],
|
1082
|
+
elem, __this[config.restangularFields.route], true, data);
|
1083
|
+
}
|
1084
|
+
});
|
1085
|
+
|
1086
|
+
processedData = _.extend(data, processedData);
|
1087
|
+
|
1088
|
+
if (!__this[config.restangularFields.restangularCollection]) {
|
1089
|
+
resolvePromise(
|
1090
|
+
deferred,
|
1091
|
+
response,
|
1092
|
+
restangularizeCollection(
|
1093
|
+
__this,
|
1094
|
+
processedData,
|
1095
|
+
what,
|
1096
|
+
true,
|
1097
|
+
fullParams
|
1098
|
+
),
|
1099
|
+
filledArray
|
1100
|
+
);
|
1101
|
+
} else {
|
1102
|
+
resolvePromise(
|
1103
|
+
deferred,
|
1104
|
+
response,
|
1105
|
+
restangularizeCollection(
|
1106
|
+
__this[config.restangularFields.parentResource],
|
1107
|
+
processedData,
|
1108
|
+
__this[config.restangularFields.route],
|
1109
|
+
true,
|
1110
|
+
fullParams
|
1111
|
+
),
|
1112
|
+
filledArray
|
1113
|
+
);
|
1114
|
+
}
|
1115
|
+
};
|
1116
|
+
|
1117
|
+
urlHandler.resource(this, $http, request.httpConfig, request.headers, request.params, what,
|
1118
|
+
this[config.restangularFields.etag], operation)[method]().then(okCallback, function error(response) {
|
1119
|
+
if (response.status === 304 && __this[config.restangularFields.restangularCollection]) {
|
1120
|
+
resolvePromise(deferred, response, __this, filledArray);
|
1121
|
+
} else if ( _.every(config.errorInterceptors, function(cb) { return cb(response, deferred, okCallback) !== false; }) ) {
|
1122
|
+
// triggered if no callback returns false
|
1123
|
+
deferred.reject(response);
|
1124
|
+
}
|
1125
|
+
});
|
1126
|
+
|
1127
|
+
return restangularizePromise(deferred.promise, true, filledArray);
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
function withHttpConfig(httpConfig) {
|
1131
|
+
this[config.restangularFields.httpConfig] = httpConfig;
|
1132
|
+
return this;
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
function save(params, headers) {
|
1136
|
+
if (this[config.restangularFields.fromServer]) {
|
1137
|
+
return this[config.restangularFields.put](params, headers);
|
1138
|
+
} else {
|
1139
|
+
return _.bind(elemFunction, this)('post', undefined, params, undefined, headers);
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
function elemFunction(operation, what, params, obj, headers) {
|
1144
|
+
var __this = this;
|
1145
|
+
var deferred = $q.defer();
|
1146
|
+
var resParams = params || {};
|
1147
|
+
var route = what || this[config.restangularFields.route];
|
1148
|
+
var fetchUrl = urlHandler.fetchUrl(this, what);
|
1149
|
+
|
1150
|
+
var callObj = obj || this;
|
1151
|
+
// fallback to etag on restangular object (since for custom methods we probably don't explicitly specify the etag field)
|
1152
|
+
var etag = callObj[config.restangularFields.etag] || (operation !== 'post' ? this[config.restangularFields.etag] : null);
|
1153
|
+
|
1154
|
+
if (_.isObject(callObj) && config.isRestangularized(callObj)) {
|
1155
|
+
callObj = stripRestangular(callObj);
|
1156
|
+
}
|
1157
|
+
var request = config.fullRequestInterceptor(callObj, operation, route, fetchUrl,
|
1158
|
+
headers || {}, resParams || {}, this[config.restangularFields.httpConfig] || {});
|
1159
|
+
|
1160
|
+
var filledObject = {};
|
1161
|
+
filledObject = config.transformElem(filledObject, false, route, service);
|
1162
|
+
|
1163
|
+
var okCallback = function(response) {
|
1164
|
+
var resData = response.data;
|
1165
|
+
var fullParams = response.config.params;
|
1166
|
+
var elem = parseResponse(resData, operation, route, fetchUrl, response, deferred);
|
1167
|
+
if (elem) {
|
1168
|
+
|
1169
|
+
if (operation === 'post' && !__this[config.restangularFields.restangularCollection]) {
|
1170
|
+
var data = restangularizeElem(
|
1171
|
+
__this[config.restangularFields.parentResource],
|
1172
|
+
elem,
|
1173
|
+
route,
|
1174
|
+
true,
|
1175
|
+
null,
|
1176
|
+
fullParams
|
1177
|
+
);
|
1178
|
+
resolvePromise(deferred, response, data, filledObject);
|
1179
|
+
} else {
|
1180
|
+
var data = restangularizeElem(
|
1181
|
+
__this[config.restangularFields.parentResource],
|
1182
|
+
elem,
|
1183
|
+
__this[config.restangularFields.route],
|
1184
|
+
true,
|
1185
|
+
null,
|
1186
|
+
fullParams
|
1187
|
+
);
|
1188
|
+
|
1189
|
+
data[config.restangularFields.singleOne] = __this[config.restangularFields.singleOne];
|
1190
|
+
resolvePromise(deferred, response, data, filledObject);
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
} else {
|
1194
|
+
resolvePromise(deferred, response, undefined, filledObject);
|
1195
|
+
}
|
1196
|
+
};
|
1197
|
+
|
1198
|
+
var errorCallback = function(response) {
|
1199
|
+
if (response.status === 304 && config.isSafe(operation)) {
|
1200
|
+
resolvePromise(deferred, response, __this, filledObject);
|
1201
|
+
} else if ( _.every(config.errorInterceptors, function(cb) { return cb(response, deferred, okCallback) !== false; }) ) {
|
1202
|
+
// triggered if no callback returns false
|
1203
|
+
deferred.reject(response);
|
1204
|
+
}
|
1205
|
+
};
|
1206
|
+
// Overriding HTTP Method
|
1207
|
+
var callOperation = operation;
|
1208
|
+
var callHeaders = _.extend({}, request.headers);
|
1209
|
+
var isOverrideOperation = config.isOverridenMethod(operation);
|
1210
|
+
if (isOverrideOperation) {
|
1211
|
+
callOperation = 'post';
|
1212
|
+
callHeaders = _.extend(callHeaders, {'X-HTTP-Method-Override': operation === 'remove' ? 'DELETE' : operation.toUpperCase()});
|
1213
|
+
} else if (config.jsonp && callOperation === 'get') {
|
1214
|
+
callOperation = 'jsonp';
|
1215
|
+
}
|
1216
|
+
|
1217
|
+
if (config.isSafe(operation)) {
|
1218
|
+
if (isOverrideOperation) {
|
1219
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1220
|
+
what, etag, callOperation)[callOperation]({}).then(okCallback, errorCallback);
|
1221
|
+
} else {
|
1222
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1223
|
+
what, etag, callOperation)[callOperation]().then(okCallback, errorCallback);
|
1224
|
+
}
|
1225
|
+
} else {
|
1226
|
+
urlHandler.resource(this, $http, request.httpConfig, callHeaders, request.params,
|
1227
|
+
what, etag, callOperation)[callOperation](request.element).then(okCallback, errorCallback);
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
return restangularizePromise(deferred.promise, false, filledObject);
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
function getFunction(params, headers) {
|
1234
|
+
return _.bind(elemFunction, this)('get', undefined, params, undefined, headers);
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
function deleteFunction(params, headers) {
|
1238
|
+
return _.bind(elemFunction, this)('remove', undefined, params, undefined, headers);
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
function putFunction(params, headers) {
|
1242
|
+
return _.bind(elemFunction, this)('put', undefined, params, undefined, headers);
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
function postFunction(what, elem, params, headers) {
|
1246
|
+
return _.bind(elemFunction, this)('post', what, params, elem, headers);
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
function headFunction(params, headers) {
|
1250
|
+
return _.bind(elemFunction, this)('head', undefined, params, undefined, headers);
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
function traceFunction(params, headers) {
|
1254
|
+
return _.bind(elemFunction, this)('trace', undefined, params, undefined, headers);
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
function optionsFunction(params, headers) {
|
1258
|
+
return _.bind(elemFunction, this)('options', undefined, params, undefined, headers);
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
function patchFunction(elem, params, headers) {
|
1262
|
+
return _.bind(elemFunction, this)('patch', undefined, params, elem, headers);
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
function customFunction(operation, path, params, headers, elem) {
|
1266
|
+
return _.bind(elemFunction, this)(operation, path, params, elem, headers);
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
function addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem) {
|
1270
|
+
var bindedFunction;
|
1271
|
+
if (operation === 'getList') {
|
1272
|
+
bindedFunction = _.bind(fetchFunction, this, path);
|
1273
|
+
} else {
|
1274
|
+
bindedFunction = _.bind(customFunction, this, operation, path);
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
var createdFunction = function(params, headers, elem) {
|
1278
|
+
var callParams = _.defaults({
|
1279
|
+
params: params,
|
1280
|
+
headers: headers,
|
1281
|
+
elem: elem
|
1282
|
+
}, {
|
1283
|
+
params: defaultParams,
|
1284
|
+
headers: defaultHeaders,
|
1285
|
+
elem: defaultElem
|
1286
|
+
});
|
1287
|
+
return bindedFunction(callParams.params, callParams.headers, callParams.elem);
|
1288
|
+
};
|
1289
|
+
|
1290
|
+
if (config.isSafe(operation)) {
|
1291
|
+
this[name] = createdFunction;
|
1292
|
+
} else {
|
1293
|
+
this[name] = function(elem, params, headers) {
|
1294
|
+
return createdFunction(params, headers, elem);
|
1295
|
+
};
|
1296
|
+
}
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
function withConfigurationFunction(configurer) {
|
1300
|
+
var newConfig = angular.copy(_.omit(config, 'configuration'));
|
1301
|
+
Configurer.init(newConfig, newConfig);
|
1302
|
+
configurer(newConfig);
|
1303
|
+
return createServiceForConfiguration(newConfig);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
function toService(route, parent) {
|
1307
|
+
var knownCollectionMethods = _.values(config.restangularFields);
|
1308
|
+
var serv = {};
|
1309
|
+
var collection = (parent || service).all(route);
|
1310
|
+
serv.one = _.bind(one, (parent || service), parent, route);
|
1311
|
+
serv.post = _.bind(collection.post, collection);
|
1312
|
+
serv.getList = _.bind(collection.getList, collection);
|
1313
|
+
|
1314
|
+
for (var prop in collection) {
|
1315
|
+
if (collection.hasOwnProperty(prop) && _.isFunction(collection[prop]) && !_.contains(knownCollectionMethods, prop)) {
|
1316
|
+
serv[prop] = _.bind(collection[prop], collection);
|
1317
|
+
}
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
return serv;
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
|
1324
|
+
Configurer.init(service, config);
|
1325
|
+
|
1326
|
+
service.copy = _.bind(copyRestangularizedElement, service);
|
1327
|
+
|
1328
|
+
service.service = _.bind(toService, service);
|
1329
|
+
|
1330
|
+
service.withConfig = _.bind(withConfigurationFunction, service);
|
1331
|
+
|
1332
|
+
service.one = _.bind(one, service, null);
|
1333
|
+
|
1334
|
+
service.all = _.bind(all, service, null);
|
1335
|
+
|
1336
|
+
service.several = _.bind(several, service, null);
|
1337
|
+
|
1338
|
+
service.oneUrl = _.bind(oneUrl, service, null);
|
1339
|
+
|
1340
|
+
service.allUrl = _.bind(allUrl, service, null);
|
1341
|
+
|
1342
|
+
service.stripRestangular = _.bind(stripRestangular, service);
|
1343
|
+
|
1344
|
+
service.restangularizeElement = _.bind(restangularizeElem, service);
|
1345
|
+
|
1346
|
+
service.restangularizeCollection = _.bind(restangularizeCollectionAndElements, service);
|
1347
|
+
|
1348
|
+
return service;
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
return createServiceForConfiguration(globalConfiguration);
|
1352
|
+
}];
|
1353
|
+
});
|
1354
|
+
|
1355
|
+
})();
|