spec/dummy/tmp/cache/assets/development/sprockets/5817d714b843218e26feb1bbf2c64a4a in hyper_admin-0.3.0 vs spec/dummy/tmp/cache/assets/development/sprockets/5817d714b843218e26feb1bbf2c64a4a in hyper_admin-0.4.0

- old
+ new

@@ -1,10 +1,12 @@ {I" class:ETI"BundledAsset;FI"logical_path;TI"3hyper_admin/angularjs/controllers/form_ctrl.js;FI" pathname;TI"u/home/sindre/Code/hyper/hyper_admin/app/assets/javascripts/hyper_admin/angularjs/controllers/form_ctrl.js.coffee;FI"content_type;TI"application/javascript;TI" -mtime;Tl+øBTI" length;TiÑI" digest;TI"%a420f7c57f394932fe9ec10bc0f80c63;FI" source;TI"Ñ(function() { +mtime;Tl+æÙ)TI" length;Tiî I" digest;TI"%c9004231fbd6116666e59e9aa942b6e7;FI" source;TI"î (function() { + var __hasProp = {}.hasOwnProperty; + angular.module("hyperadmin").controller("FormCtrl", function($scope, $state, Restangular, Flash) { - var method, mode, successMessage, target; + var method, mode, prettifyErrors, successMessage, target; this.resource = {}; mode = $state.current.data.mode; if (mode === "new") { method = "post"; target = "admin/" + $scope.resourceClass.plural; @@ -14,30 +16,44 @@ target = "admin/" + $scope.resourceClass.plural + "/" + $state.params.id; successMessage = "" + $scope.resourceClass.singular_human + " updated successfully."; Restangular.one(target).get().then((function(_this) { return function(resource) { _this.resource = resource; - return $scope.resourceClass.attributes.forEach(function(attr) { + return $scope.resourceClass.form_attributes.forEach(function(attr) { if (attr.type === "date" || attr.type === "datetime") { if (_this.resource[attr.key]) { return _this.resource[attr.key] = new Date(_this.resource[attr.key]); } } }); }; })(this)); } ["id", "created_at", "updated_at"].forEach(function(key) { - return _.remove($scope.resourceClass.attributes, function(attr) { + return _.remove($scope.resourceClass.form_attributes, function(attr) { return attr.key === key; }); }); + prettifyErrors = function(errors) { + var attr, attrSchema, result; + result = {}; + for (attr in errors) { + if (!__hasProp.call(errors, attr)) continue; + attrSchema = _.find($scope.resourceClass.form_attributes, (function(_this) { + return function(attribute) { + return attribute.key === attr; + }; + })(this)); + result[attrSchema.human] = errors[attr]; + } + return result; + }; this.submit = (function(_this) { return function() { var onError, onSuccess; onError = function(response) { - return _this.errors = response.data; + return _this.errors = prettifyErrors(response.data); }; onSuccess = function(resource) { $state.go("^.show", { id: resource.id }); @@ -52,6 +68,6 @@ })(this); return this; }); }).call(this); -;TI"required_assets_digest;TI"%f2d92fded74b5f6bbc219a3c3b2ffab5;FI" _version;TI"%6584930913c75ff69ba506e1cfbae2c9;F +;TI"required_assets_digest;TI"%c1ebe86203eb62fde83a2862a7116711;FI" _version;TI"%6584930913c75ff69ba506e1cfbae2c9;F \ No newline at end of file