test/dummy/tmp/cache/assets/CC8/CC0/sprockets%2F77ac1342b1ae62c0123f399257a703aa in collection-json-browser-0.0.7 vs test/dummy/tmp/cache/assets/CC8/CC0/sprockets%2F77ac1342b1ae62c0123f399257a703aa in collection-json-browser-0.0.8

- old
+ new

@@ -1,8 +1,8 @@ -o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1375609943.916607: @value"é {I" +o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1377356174.706941: @value"6 {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-04T17:37:18+08:00;FI" length;FiI" digest;F"%2e9ea927a6858d188f367a468d77a884I" source;FI"'use strict'; +mtime;FI"2013-08-24T21:45:56+08:00;FI" length;FiT I" digest;F"%d2ecda964c6082c0e64a424466ab77bdI" source;FI"T 'use strict'; function ApiController($scope, $http, $location) { $scope.rootUrl = '/api' $scope.goTo = function(url, fromRel) { @@ -21,18 +21,29 @@ }, function(url, oldUrl) { 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) { + function get(url, successHandler) { $scope.loading = true + + if(successHandler === undefined) + successHandler = responseHandler + $http.get(url).success(function(data, status){ - responseHandler(data, status) + successHandler(data, status) $location.url(url) }).error(function(){ $scope.loading = false }) } function destroy(url) { @@ -56,20 +67,51 @@ error(responseHandler) } function formData() { var data = {}; - $scope.collection.template.data.forEach(function(f){ data[f.name] = f.value }) + $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: ''}] + if(items) + items.forEach(function(i){ + $scope.itemPaths.push({name: i.href, value: i.href}) + }) + $scope.item = "" + $scope.status = status $scope.loading = false } + + function getTemplate(item) { + if(item === undefined || item == '') { + //TODO + //empty fields + //post + } else { + get(item, setTemplate) + //TODO + //put + } + } + + function setTemplate(data){ + if(data.collection.template) { + $scope.template = data.collection.template.data + } + } } ApiController.$inject = ['$scope', '$http', '$location']; -;FI"dependency_digest;F"%8fc62ab13f0d86ee05205f13d5984a9cI"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-04T17:37:18+08:00;FI" digest;F"%2e9ea927a6858d188f367a468d77a884I" _version;F"%6776f581a4329e299531e1d52aa59832 +;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 \ No newline at end of file