o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1379241026.467016: @value" {I" class:EFI"ProcessedAsset;FI"logical_path;FI"Bcollection_json_browser/angular/controllers/api_controller.js;TI" pathname;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-09-15T18:29:17+08:00;FI" length;Fi I" digest;F"%33d1ce3cd7f23f97a7d49977930645d3I" source;FI" 'use strict'; function ApiController($scope, $http, $location) { $scope.rootUrl = '/api' $scope.goTo = function(url, fromRel) { $scope.fromRel = fromRel get(url) } $scope.submit = function() { $scope.fromRel === 'edit-form' ? put() : post() } $scope.destroy = destroy $scope.$watch(function() { return $location.url(); }, function(url, oldUrl) { if(url !== oldUrl) get(url) }); get($scope.rootUrl) // helpers function get(url) { $scope.loading = true $http.get(url).success(function(data, status){ responseHandler(data, status) $location.url(url) }).error(responseHandler) } 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) } function put() { $scope.loading = true var href = $scope.collection.items[0].href $http.put(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 responseHandler(data, status) { $scope.collection = data.collection; $scope.raw = JSON.stringify(data, undefined, 2) $scope.status = status $scope.loading = false } } ApiController.$inject = ['$scope', '$http', '$location']; ;FI"dependency_digest;F"%2a62bb4cf557ef123202b9d15d056e0fI"required_paths;F[I"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"dependency_paths;F[{I" path;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI" mtime;FI"2013-09-15T18:29:17+08:00;FI" digest;F"%33d1ce3cd7f23f97a7d49977930645d3I" _version;F"%6776f581a4329e299531e1d52aa59832