anthtrigger
Version:
Trigger events via http service
38 lines (35 loc) • 1.11 kB
JavaScript
(function() {
angular.module('anthTrigger').controller('createScriptController', function($scope, $http, $location, notify) {
var convertTags, _st;
_st = {};
$scope.status = _st;
$scope.script = {};
convertTags = function(data) {
return data != null ? typeof data.map === "function" ? data.map(function(v) {
if (v.text) {
return v.text;
} else {
return {
text: v
};
}
}) : void 0 : void 0;
};
$scope.save = function() {
var script;
_st.save = 'saving';
script = $scope.script;
script.tags = convertTags(script.tags);
return $http.post('/scripts/create', script).success(function(result) {
_st.save = result.success ? 'done' : 'error';
if (result.success) {
notify("脚本 (" + script.title + ") 创建成功!");
return $location.url('/scripts');
} else {
return notify("脚本 (" + script.title + ") 创建失败!");
}
});
};
});
}).call(this);
//# sourceMappingURL=createScriptController.js.map