test/dummy/tmp/cache/assets/D58/C00/sprockets%2F7bd61bb28f7ce577f679872a7cc4a477 in collection-json-browser-0.0.10 vs test/dummy/tmp/cache/assets/D58/C00/sprockets%2F7bd61bb28f7ce577f679872a7cc4a477 in collection-json-browser-0.0.11
- old
+ new
@@ -1,8 +1,8 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1378655478.5090969:@value"ÕG{I"
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1379241026.473:@value"D{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-09-08T23:51:16+08:00; FI"length; FiËEI"digest; F"%da3a9cd5915228ec645b2bdc47323abeI"source; FI"ËE/*
+mtime; FI"2013-09-15T18:29:17+08:00; FI"length; FiBI"digest; F"%efe18fb8cdc3a2c38a860bb94a4d46e0I"source; FI"B/*
AngularJS v1.0.6
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
@@ -168,49 +168,35 @@
function ApiController($scope, $http, $location) {
$scope.rootUrl = '/api'
$scope.goTo = function(url, fromRel) {
$scope.fromRel = fromRel
- $location.url(url)
+ get(url)
}
$scope.submit = function() {
- console.log('=============> ', $scope.item)
- $scope.item === $scope.collection.href ? post() : put()
+ $scope.fromRel === 'edit-form' ? put() : post()
}
$scope.destroy = destroy
$scope.$watch(function() {
return $location.url();
}, function(url, oldUrl) {
- if(url !== oldUrl) { get(url) }
+ if(url !== oldUrl)
+ get(url)
});
- $scope.$watch(function() {
- return $scope.item;
- }, function(item, oldItem) {
- if(item != oldItem)
- getTemplate(item)
- });
-
get($scope.rootUrl)
// helpers
- function get(url, successHandler) {
+ function get(url) {
$scope.loading = true
-
- var updateUrl = false
- if(successHandler === undefined) {
- successHandler = responseHandler
- updateUrl = true
- }
-
$http.get(url).success(function(data, status){
- successHandler(data, status)
- if(updateUrl) $location.url(url)
+ responseHandler(data, status)
+ $location.url(url)
}).error(responseHandler)
}
function destroy(url) {
$scope.loading = true
@@ -226,55 +212,30 @@
error(responseHandler)
}
function put() {
$scope.loading = true
- $http.put($scope.collection.items[0].href, formData()).
+ 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) {
+ $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)
-
- setTemplate(data)
-
- var items = data.collection.items
- $scope.itemPaths = [{ name: "-- None (POST create) --", value: data.collection.href}]
- if(items) {
- items.forEach(function(i){
- $scope.itemPaths.push({name: i.href, value: i.href})
- })
- }
- $scope.item = $scope.itemPaths[0].value
-
$scope.status = status
$scope.loading = false
}
-
- function getTemplate(item) {
- if(item !== undefined) { get(item, setTemplate) }
- $scope.loading = false
- }
-
- function setTemplate(data){
- if(data.collection.template) {
- $scope.template = data.collection.template.data
- } else {
- $scope.template = undefined
- }
-
- }
}
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.
@@ -292,6 +253,6 @@
//
;
-; FI"required_assets_digest; F"%eef62df5d37e05a1dc54ae58478bec01I"
_version; F"%6776f581a4329e299531e1d52aa59832
+; FI"required_assets_digest; F"%e8bf406073a7797821ed0d93f01859c9I"
_version; F"%6776f581a4329e299531e1d52aa59832
\ No newline at end of file