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

- old
+ new

@@ -1,8 +1,8 @@ -o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374682063.119742: @value"ÎC{I" +o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374996223.539937: @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-25T00:07:40+08:00;FI" length;FiÄAI" digest;F"%ba029c5623f8a02e456f58b3a1c163b3I" source;FI"ÄA/* +mtime;FI"2013-07-28T15:23:11+08:00;FI" length;FiqAI" digest;F"%1d078738c813f061a0c4e3647e1d6e2fI" source;FI"qA/* AngularJS v1.0.6 (c) 2010-2012 Google, Inc. http://angularjs.org License: MIT */ @@ -168,34 +168,38 @@ function ApiController($scope, $http, $location) { $scope.rootUrl = '/api' $scope.goTo = function(url, fromRel) { $scope.fromRel = fromRel - $location.url(url) + get(url) } $scope.submit = function() { $scope.fromRel === 'edit-form' ? put() : post() } - $scope.$watch(function() { - return $location.url() - }, function(url, oldUrl) { - if(url !== oldUrl) { - get(url) - } - }) + $scope.destroy = destroy get($scope.rootUrl) // helpers function get(url) { $scope.loading = true - $http.get(url).success(responseHandler).error(function(){ $scope.loading = false }) + $http.get(url).success(function(data, status){ + responseHandler(data, status) + $location.url(url) + }).error(function(){ $scope.loading = false }) } + function destroy(url) { + $scope.loading = true + $http.delete(url). + success(responseHandler). + error(responseHandler) + } + function post() { $scope.loading = true $http.post($scope.collection.href, formData()). success(responseHandler). error(responseHandler) @@ -217,19 +221,13 @@ function responseHandler(data, status) { $scope.collection = data.collection; $scope.raw = JSON.stringify(data, undefined, 2) $scope.status = status $scope.loading = false - - var collectionHref = $scope.collection.href - if(collectionHref !== $location.path() && collectionHref.match(/^http/) === null) { - $location.url(collectionHref) - } } } - ApiController.$inject = ['$scope', '$http', '$location']; // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, @@ -245,6 +243,6 @@ // ; -;FI"required_assets_digest;F"%ceb3c4afa32458e170e37288077d08f4I" _version;F"%6776f581a4329e299531e1d52aa59832 +;FI"required_assets_digest;F"%4cfc63b5e80e6443f4a2d7127803fe06I" _version;F"%6776f581a4329e299531e1d52aa59832 \ No newline at end of file