/** * Created by wisestone on 2018-05-08. */ 'use strict'; define([ 'app' ], function (app) { app.controller('issueStatusAddController', ['$scope', '$rootScope', '$log', '$resourceProvider', 'User', '$uibModalInstance', 'IssueStatus', 'SweetAlert', '$filter', function ($scope, $rootScope, $log, $resourceProvider, User, $uibModalInstance, IssueStatus, SweetAlert, $filter) { $scope.fn = { cancel : cancel, // 팝업 창 닫기 formSubmit : formSubmit, // 폼 전송 formCheck : formCheck // 폼 체크 }; $scope.vm = { form : { name : "", // 이슈 상태 명 issueStatusType : "OPEN", // 이슈 상태 유형 color : "#febd35" // 색상 } }; function formCheck(formInvalid) { if (formInvalid) { return true; } return false; } function formSubmit() { $rootScope.spinner = true; $scope.vm.form.name = $rootScope.preventXss($scope.vm.form.name); IssueStatus.add($resourceProvider.getContent( $scope.vm.form, $resourceProvider.getPageContent(0, 10))).then(function (result) { if (result.data.message.status === "success") { $scope.fn.cancel(); // 목록 화면 갱신 $rootScope.$broadcast("getIssueStatusList", {}); } else { SweetAlert.error($filter("translate")("managementStatus.failedToCreateIssueStatus"), result.data.message.message); //"이슈 상태 생성 실패" } $rootScope.spinner = false; }); } function cancel() { $rootScope.$broadcast("closeLayer"); // 팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정 $uibModalInstance.dismiss('cancel'); $(document).unbind("keydown"); // 단축키 이벤트 제거 } }]); });