test/dummy/tmp/cache/assets/CC8/CC0/sprockets%2F77ac1342b1ae62c0123f399257a703aa in collection-json-browser-0.0.2 vs test/dummy/tmp/cache/assets/CC8/CC0/sprockets%2F77ac1342b1ae62c0123f399257a703aa in collection-json-browser-0.0.3
- old
+ new
@@ -1,18 +1,17 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1373900105.4103098:@value"3{I"
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374161914.2466571:@value"1{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-07-15T22:55:04+08:00; FI"length; FiQI"digest; F"%33a689ae81c1fc2783e2010054f8bbe4I"source; FI"Q'use strict';
+mtime; FI"2013-07-18T23:37:46+08:00; FI"length; FiOI"digest; F"%eb68a8995751f641b3f082f75b969acfI"source; FI"O'use strict';
function ApiController($scope, $http, $location) {
- $scope.goTo = function(path) {
+ $scope.goTo = function(path, fromRel) {
+ $scope.fromRel = fromRel
$location.path(path)
}
- $scope.post = function() {
- var formData = {};
- $scope.collection.template.data.forEach(function(f){ formData[f.name] = f.value })
- $http.post($scope.collection.href, formData).success(successHandler)
+ $scope.submit = function() {
+ $scope.fromRel === 'edit-form' ? put() : post()
}
$scope.$watch(function() {
return $location.path()
}, function(path, oldPath) {
@@ -25,10 +24,24 @@
function get(path) {
$http.get(path).success(successHandler)
}
+ function post() {
+ $http.post($scope.collection.href, formData()).success(successHandler)
+ }
+
+ function put() {
+ $http.put($scope.collection.href, formData()).success(successHandler)
+ }
+
+ function formData() {
+ var data = {};
+ $scope.collection.template.data.forEach(function(f){ data[f.name] = f.value })
+ return data
+ }
+
function successHandler(data, status) {
$scope.collection = data.collection;
$scope.raw = JSON.stringify(data, undefined, 2)
$scope.status = status
@@ -36,7 +49,7 @@
}
}
ApiController.$inject = ['$scope', '$http', '$location'];
-; FI"dependency_digest; F"%aad615edf2d99327d1e5f76d5b29b683I"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-07-15T22:55:04+08:00; FI"digest; F"%33a689ae81c1fc2783e2010054f8bbe4I"
_version; F"%6776f581a4329e299531e1d52aa59832
+; FI"dependency_digest; F"%b949e9af421592eebb9dc66f4697ba58I"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-07-18T23:37:46+08:00; FI"digest; F"%eb68a8995751f641b3f082f75b969acfI"
_version; F"%6776f581a4329e299531e1d52aa59832
\ No newline at end of file