{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+ƬTI" length;TišI" digest;TI"%2f77cc0abc2589d1b2fdb4331a9b0e87;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) { return _this.resource = resource; }; })(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"required_assets_digest;TI"%a94690c992be8f68e12928aa2c8bef4e;FI" _version;TI"%3e3098c8a5e9a7f3b984ba95ac600637;F