{I" class:ETI"ProcessedAsset;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() { angular.module("hyperadmin").controller("FormCtrl", function($scope, $state, Restangular, Flash) { var method, mode, successMessage, target; this.resource = {}; mode = $state.current.data.mode; if (mode === "new") { method = "post"; target = "admin/" + $scope.resourceClass.plural; successMessage = "" + $scope.resourceClass.singular_human + " created successfully."; } else { method = "patch"; 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) { 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 attr.key === key; }); }); this.submit = (function(_this) { return function() { var onError, onSuccess; onError = function(response) { return _this.errors = response.data; }; onSuccess = function(resource) { $state.go("^.show", { id: resource.id }); return Flash.setMessage("success", successMessage); }; if (method === "post") { return Restangular.all(target).post(_this.resource).then(onSuccess, onError); } else if (method === "patch") { return Restangular.one(target).patch(_this.resource).then(onSuccess, onError); } }; })(this); return this; }); }).call(this); ;TI"dependency_digest;TI"%f2d92fded74b5f6bbc219a3c3b2ffab5;FI"required_paths;T[I"u/home/sindre/Code/hyper/hyper_admin/app/assets/javascripts/hyper_admin/angularjs/controllers/form_ctrl.js.coffee;FI"dependency_paths;T[{I" path;TI"u/home/sindre/Code/hyper/hyper_admin/app/assets/javascripts/hyper_admin/angularjs/controllers/form_ctrl.js.coffee;FI" mtime;TI"2014-09-18T22:39:20+02:00;TI" digest;TI"%dab0c124cd805ca63143d664c32a402d;FI" _version;TI"%6584930913c75ff69ba506e1cfbae2c9;F