test/dummy/tmp/cache/assets/D58/C00/sprockets%2F7bd61bb28f7ce577f679872a7cc4a477 in collection-json-browser-0.0.4 vs test/dummy/tmp/cache/assets/D58/C00/sprockets%2F7bd61bb28f7ce577f679872a7cc4a477 in collection-json-browser-0.0.5

- old
+ new

@@ -1,8 +1,8 @@ -o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374161914.2529879: @value"?B{I" +o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374682063.119742: @value"ÎC{I" class:EFI"BundledAsset;FI"logical_path;FI"+collection_json_browser/application.js;TI" pathname;FI"q/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/application.js;TI"content_type;FI"application/javascript;FI" -mtime;FI"2013-07-18T23:37:46+08:00;FI" length;Fi5@I" digest;F"%9e35edc03735c5cf7f315078aaa8b1b2I" source;FI"5@/* +mtime;FI"2013-07-25T00:07:40+08:00;FI" length;FiÄAI" digest;F"%ba029c5623f8a02e456f58b3a1c163b3I" source;FI"ÄA/* AngularJS v1.0.6 (c) 2010-2012 Google, Inc. http://angularjs.org License: MIT */ @@ -164,53 +164,68 @@ ngCloak:Bd,ngController:Cd,ngForm:ld,ngHide:Ld,ngInclude:Fd,ngInit:Gd,ngNonBindable:Hd,ngPluralize:Id,ngRepeat:Jd,ngShow:Kd,ngSubmit:Ed,ngStyle:Md,ngSwitch:Nd,ngSwitchWhen:Od,ngSwitchDefault:Pd,ngOptions:Td,ngView:Rd,ngTransclude:Qd,ngModel:qd,ngList:sd,ngChange:rd,required:dc,ngRequired:dc,ngValue:ud}).directive(mb).directive(ec);a.provider({$anchorScroll:uc,$browser:wc,$cacheFactory:xc,$controller:Bc,$document:Cc,$exceptionHandler:Dc,$filter:Rb,$interpolate:Ec,$http:Vc,$httpBackend:Wc,$location:Ic, $log:Jc,$parse:Nc,$route:Qc,$routeParams:Rc,$rootScope:Sc,$q:Oc,$sniffer:Tc,$templateCache:yc,$timeout:$c,$window:Uc})}])})(Za);u(Y).ready(function(){jc(Y,rb)})})(window,document);angular.element(document).find("head").append('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak{display:none;}ng\\:form{display:block;}</style>'); 'use strict'; function ApiController($scope, $http, $location) { - $scope.goTo = function(path, fromRel) { + $scope.rootUrl = '/api' + + $scope.goTo = function(url, fromRel) { $scope.fromRel = fromRel - $location.path(path) + $location.url(url) } $scope.submit = function() { $scope.fromRel === 'edit-form' ? put() : post() } $scope.$watch(function() { - return $location.path() - }, function(path, oldPath) { - if(path !== oldPath) get(path) - }); + return $location.url() + }, function(url, oldUrl) { + if(url !== oldUrl) { + get(url) + } + }) - get('/api') + get($scope.rootUrl) // helpers - function get(path) { - $http.get(path).success(successHandler) + function get(url) { + $scope.loading = true + $http.get(url).success(responseHandler).error(function(){ $scope.loading = false }) } function post() { - $http.post($scope.collection.href, formData()).success(successHandler) + $scope.loading = true + $http.post($scope.collection.href, formData()). + success(responseHandler). + error(responseHandler) } function put() { - $http.put($scope.collection.href, formData()).success(successHandler) + $scope.loading = true + $http.put($scope.collection.href, formData()). + success(responseHandler). + error(responseHandler) } function formData() { var data = {}; $scope.collection.template.data.forEach(function(f){ data[f.name] = f.value }) return data } - function successHandler(data, status) { + function responseHandler(data, status) { $scope.collection = data.collection; $scope.raw = JSON.stringify(data, undefined, 2) $scope.status = status + $scope.loading = false - $location.path($scope.collection.href) + var collectionHref = $scope.collection.href + if(collectionHref !== $location.path() && collectionHref.match(/^http/) === null) { + $location.url(collectionHref) + } } } ApiController.$inject = ['$scope', '$http', '$location']; @@ -230,6 +245,6 @@ // ; -;FI"required_assets_digest;F"%57f1276a4d19690939baeee55baead84I" _version;F"%6776f581a4329e299531e1d52aa59832 +;FI"required_assets_digest;F"%ceb3c4afa32458e170e37288077d08f4I" _version;F"%6776f581a4329e299531e1d52aa59832 \ No newline at end of file