test/dummy/tmp/cache/assets/D01/390/sprockets%2F152365a6c64bdbf13d80c22762c0f48b in collection-json-browser-0.0.9 vs test/dummy/tmp/cache/assets/D01/390/sprockets%2F152365a6c64bdbf13d80c22762c0f48b in collection-json-browser-0.0.10
- old
+ new
@@ -1,28 +1,28 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1377356174.705908:@value"6
{I"
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1378655478.5032089:@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-08-24T21:45:56+08:00; FI"length; FiT I"digest; F"%d2ecda964c6082c0e64a424466ab77bdI"source; FI"T 'use strict';
+mtime; FI"2013-09-08T23:51:16+08:00; FI"length; Fiå I"digest; F"%eb852bf44bc0e65833fc22bac2d93311I"source; FI"å 'use strict';
function ApiController($scope, $http, $location) {
$scope.rootUrl = '/api'
$scope.goTo = function(url, fromRel) {
$scope.fromRel = fromRel
- get(url)
+ $location.url(url)
}
$scope.submit = function() {
- $scope.fromRel === 'edit-form' ? put() : post()
+ console.log('=============> ', $scope.item)
+ $scope.item === $scope.collection.href ? post() : put()
}
$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) {
@@ -35,17 +35,20 @@
// helpers
function get(url, successHandler) {
$scope.loading = true
- if(successHandler === undefined)
+ var updateUrl = false
+ if(successHandler === undefined) {
successHandler = responseHandler
+ updateUrl = true
+ }
$http.get(url).success(function(data, status){
successHandler(data, status)
- $location.url(url)
- }).error(function(){ $scope.loading = false })
+ if(updateUrl) $location.url(url)
+ }).error(responseHandler)
}
function destroy(url) {
$scope.loading = true
$http.delete(url).
@@ -60,11 +63,11 @@
error(responseHandler)
}
function put() {
$scope.loading = true
- $http.put($location.url(), formData()).
+ $http.put($scope.collection.items[0].href, formData()).
success(responseHandler).
error(responseHandler)
}
function formData() {
@@ -80,38 +83,35 @@
$scope.raw = JSON.stringify(data, undefined, 2)
setTemplate(data)
var items = data.collection.items
- $scope.itemPaths = [{ name: "-- None (POST create) --", value: ''}]
- if(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.item = $scope.itemPaths[0].value
$scope.status = status
$scope.loading = false
}
function getTemplate(item) {
- if(item === undefined || item == '') {
- //TODO
- //empty fields
- //post
- } else {
- get(item, setTemplate)
- //TODO
- //put
- }
+ 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'];
-; FI"dependency_digest; F"%7099aa91356881d2e1fb8705212cc864I"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-08-24T21:45:56+08:00; FI"digest; F"%d2ecda964c6082c0e64a424466ab77bdI"
_version; F"%6776f581a4329e299531e1d52aa59832
+; FI"dependency_digest; F"%4b953a3dab2209be48df7dbf5eb77fa8I"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-08T23:51:16+08:00; FI"digest; F"%eb852bf44bc0e65833fc22bac2d93311I"
_version; F"%6776f581a4329e299531e1d52aa59832
\ No newline at end of file