/**
|
* Created by wisestone on 2018-05-08.
|
*/
|
'use strict';
|
|
define([
|
'app',
|
'angular',
|
'saveSvgAsPng'
|
],
|
function (app, angular, saveSvgAsPng) {
|
app.controller('workflowModifyController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'Workflow', 'parameter', 'SweetAlert', '$window', '$filter',
|
function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, Workflow, parameter, SweetAlert, $window, $filter) {
|
|
$scope.fn = {
|
cancel : cancel, // 팝업 창 닫기
|
formSubmit : formSubmit, // 폼 전송
|
formCheck : formCheck, // 폼 체크
|
detail : detail // 상세 정보 조회
|
};
|
|
$scope.vm = {
|
search : {
|
id : parameter.id,
|
deep : "01" // 워크플로우 연관된 모든 정보를 어느정도까지 가져올지 결정, 01 - 일반 정보, 연관된 정보
|
},
|
form : {
|
id : parameter.id,
|
name : "",
|
issueStatusVos : [], // 다이어그램에 상태를 주입하고 만들어진 상태 모음 - 워크플로우 생성과 조금 다르게 사용된다.
|
},
|
step : "01",
|
isolationWorkflow : true, // 워크플로우에 고립된 이슈 상태가 있는지 여부를 체크한다.
|
firstStatusExist : true, // 워크플로우에 상태 속성 '대기'인 상태가 존재하는지 체크한다.
|
middleStatusExist : true, // 워크플로우에 상태 속성 '진행'인 상태가 존재하는지 체크한다.
|
lastStatusExist : true, // 워크플로우에 상태 속성 '종료'인 상태가 존재하는지 체크한다.
|
};
|
|
function formCheck(formInvalid) {
|
if (formInvalid) {
|
return true;
|
}
|
|
return false;
|
}
|
|
|
function formSubmit() {
|
$rootScope.spinner = true;
|
|
var content = {
|
id : parameter.id,
|
name : $rootScope.preventXss($scope.vm.form.name),
|
issueStatusVos : $scope.vm.form.issueStatusVos,
|
nodes : (function () {
|
var keys = Object.keys($scope.vm.form.nodes);
|
var nodes = [];
|
|
angular.forEach(keys, function (key) {
|
var node = $scope.vm.form.nodes[key];
|
|
if ($rootScope.isDefined(node)) {
|
nodes.push(node);
|
}
|
});
|
|
return nodes;
|
})(),
|
links : $scope.vm.form.links
|
};
|
|
Workflow.modify($resourceProvider.getContent(
|
content,
|
$resourceProvider.getPageContent(0, 0))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
$scope.fn.cancel();
|
// 목록 화면 갱신
|
$rootScope.$broadcast("getWorkflowList", {});
|
}
|
else {
|
SweetAlert.error($filter("translate")("managementWorkflow.failedToModifyWorkflow"), result.data.message.message); // 워크플로우 수정 실패
|
}
|
|
$rootScope.spinner = false;
|
});
|
}
|
|
// 팝업 창 닫기
|
function cancel() {
|
$rootScope.$broadcast("closeLayer"); // 팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
|
$uibModalInstance.dismiss('cancel');
|
$(document).unbind("keydown"); // 단축키 이벤트 제거
|
}
|
|
function detail() {
|
Workflow.detail($resourceProvider.getContent(
|
$scope.vm.search,
|
$resourceProvider.getPageContent(0, 1))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
if (angular.isDefined(result.data.data)) {
|
$scope.vm.form.name = result.data.data.name;
|
$scope.vm.form.issueStatusVos = result.data.data.issueStatusVos;
|
$scope.vm.issueStatusVos = []; // 다이어그램 에디터에서 이 값을 감지하면서 조회가 시작된다.
|
}
|
}
|
else {
|
SweetAlert.error($filter("translate")("managementWorkflow.failedToWorkflowDetails"), result.data.message.message); // 워크플로우 상세 정보 조회 실패
|
}
|
});
|
}
|
|
$scope.fn.detail();
|
}]);
|
});
|