From 62170f092e8c8031559acf66f54d5abc87cb13cd Mon Sep 17 00:00:00 2001
From: 박지현 <jhpark@maprex.co.kr>
Date: 수, 23 2월 2022 17:44:41 +0900
Subject: [PATCH] 워크플로우 상태 목록 선택 시 상태이름(상태속성) 으로표시되도록 수정 완료

---
 src/main/webapp/custom_components/js-workflow/js-workflow.directive.js |  140 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/src/main/webapp/custom_components/js-workflow/js-workflow.directive.js b/src/main/webapp/custom_components/js-workflow/js-workflow.directive.js
index b96b1b7..9b1096e 100644
--- a/src/main/webapp/custom_components/js-workflow/js-workflow.directive.js
+++ b/src/main/webapp/custom_components/js-workflow/js-workflow.directive.js
@@ -5,8 +5,8 @@
 
 define(['app', 'angular', 'd3'],
     function (app, angular, d3) {
-        app.directive('jsWorkflow', ["$log", "$rootScope", "IssueStatus", "$resourceProvider", "SweetAlert", '$filter',
-            function ($log, $rootScope, IssueStatus, $resourceProvider, SweetAlert, $filter) {
+        app.directive('jsWorkflow', ["$log", "$rootScope", "IssueStatus", "$resourceProvider", "SweetAlert", '$filter', '$injector', '$controller',
+            function ($log, $rootScope, IssueStatus, $resourceProvider, SweetAlert, $filter, $injector, $controller) {
                 return {
                     scope : {
                         issueStatusList : '=issueStatusList',
@@ -15,6 +15,7 @@
                         firstStatusExist : "=firstStatusExist",
                         middleStatusExist : "=middleStatusExist",
                         lastStatusExist : "=lastStatusExist",
+                        departments : "=departments"
                     },
                     restrict : 'E',
                     replace : true,
@@ -54,12 +55,15 @@
                             defaultAddIssueStatusId : defaultAddIssueStatusId,   //  �씠�뒋 �긽�깭 異붽� ���젆�듃 諛뺤뒪�뿉�꽌 泥ル쾲吏� �샃�뀡 �빆紐⑹쓣 湲곕낯 �꽑�깮�릺寃� �븳�떎.
                             checkReadyType : checkReadyType,    //  �떎�씠�뼱洹몃옩�븞�뿉 �긽�깭 �냽�꽦 '��湲�'�씤 �씠�뒋 �긽�깭媛� 議댁옱�븯�뒗吏� �솗�씤�븳�떎.
                             getOptionColor : getOptionColor,  //  �씠�뒋 �긽�깭�쓽 �깋�긽 �젙蹂대�� 媛��졇�삩�떎.
+                            changeDepartment : changeDepartment,
+                            removeDepartment : removeDepartment
                         };
 
                         //  蹂��닔 紐⑥쓬
                         $scope.vm.targetIssueStatusList = [];
                         $scope.vm.issueStatuses = [];   //  �꽑�깮 媛��뒫�븳 �씠�뒋 �긽�깭 紐⑸줉
                         $scope.vm.addIssueStatusId = null;   //  異붽��븯�뒗 �씠�뒋 �긽�깭 �븘�씠�뵒
+                        $scope.vm.issueStatusVos = []; // �솕硫댁뿉 �엳�뒗 �씠�뒋 �긽�깭 紐⑸줉
                         $scope.vm.width = 0;  //  �꼻�씠
                         $scope.vm.height = 0;  //  �넂�씠
                         $scope.vm.svg = null;   //  svg �젙蹂�
@@ -76,12 +80,34 @@
                         $scope.vm.targetStatusId = null;    //  �뿰寃고븯�뒗 �씠�뒋 �긽�깭 �븘�씠�뵒
                         $scope.vm.transitionIdGenerator = 100;  //  �쟾�씠�꽑 �엫�떆 id 媛�
 
+                        $scope.vm.departments = []; // 遺��꽌 紐⑸줉
+                        $scope.vm.departmentName = "" // �꽑�깮�맂 遺��꽌 �씠由�
+
+                        angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector}));
 
                         $scope.$watch("issueStatusList", function (newValue) {
                             if ($rootScope.isDefined(newValue)) {
                                 $scope.fn.startDiagram();
+                                setWorkflowDepartments();
                             }
-                        });
+                        })
+
+                        // ���옣�맂 �떞�떦遺��꽌 �꽕�젙�븯湲�
+                        function setWorkflowDepartments() {
+                            var workflowDepartmentVos = [];
+
+                            angular.forEach($scope.issueStatusList, function (issueStatus) {
+                                angular.forEach($scope.vm.issueStatusVos, function (issueStatusVo) {
+                                    if (issueStatusVo.id === issueStatus.id) {
+                                        var issueStatusWorkflowDepartments = {
+                                            workflowDepartmentVos : workflowDepartmentVos,
+                                            workflowDepartmentName : ""
+                                        }
+                                        issueStatusVo = Object.assign(issueStatusVo, issueStatusWorkflowDepartments);
+                                    }
+                                });
+                            })
+                        }
 
                         //  �씠�뒋 �긽�깭 異붽� ���젆�듃 諛뺤뒪�뿉�꽌 泥ル쾲吏� �샃�뀡 �빆紐⑹쓣 湲곕낯 �꽑�깮�릺寃� �븳�떎.
                         function defaultAddIssueStatusId() {
@@ -256,6 +282,7 @@
                             return color;
                         }
 
+
                         //  �씠�뒋 �긽�깭瑜� �떎�씠�뼱洹몃옩�뿉 異붽��븳�떎.
                         function addStatus() {
                             if ($rootScope.isDefined($scope.vm.addIssueStatusId)) {
@@ -278,6 +305,9 @@
                                         issueStatus.yLocation = Math.random() * ($scope.vm.height - 50);
 
                                         $scope.vm.issueStatusVos.push(issueStatus);
+
+                                        // �떞�떦 遺��꽌 異붽�
+                                        addWorkflowDepartment(issueStatus);
                                         break;
                                     }
                                 }
@@ -286,6 +316,8 @@
 
                                 $scope.fn.defaultAddIssueStatusId();
                                 $scope.fn.startDiagram();
+
+
                             }
                         }
 
@@ -333,6 +365,8 @@
                             $scope.fn.updateClientChangePosition();
 
                             $scope.fn.startDiagram();
+
+                            removeWorkflowDepartment(targetIssueStatus);
                         }
 
                         //  �쟾�씠�꽑�쓣 �떎�씠�뼱洹몃옩�뿉 異붽��븳�떎.
@@ -549,6 +583,17 @@
                                         }
 
                                         if (!exist) {
+                                            switch (issueStatus.issueStatusType) {
+                                                case 'READY' :
+                                                    issueStatus.issueStatusTypeKr = '��湲�'
+                                                    break;
+                                                case 'OPEN' :
+                                                    issueStatus.issueStatusTypeKr = '吏꾪뻾'
+                                                    break;
+                                                case 'CLOSE' :
+                                                    issueStatus.issueStatusTypeKr = '醫낅즺'
+                                                    break;
+                                            }
                                             $scope.vm.issueStatuses.push(issueStatus);
                                         }
                                     });
@@ -599,10 +644,99 @@
                             });
                         }
 
+                        // function  getWorkflowDepartments() {
+                        //     $scope.vm.departments = [];
+                        //
+                        //     if ($scope.vm.activeTarget != null) {
+                        //         return issueStatus.workflowDepartments;
+                        //     }
+                        //     return null;
+                        // }
+
+                        // �떞�떦遺��꽌 �꽕�젙
+                        function setWorkflowDepartment(targetIssueStatus) {
+                            if (targetIssueStatus != null) {
+                                angular.forEach($scope.vm.issueStatusVos, function (issueStatusVo) {
+                                    if (issueStatusVo.id === targetIssueStatus.id) {
+                                        $scope.vm.departmentName = issueStatusVo.workflowDepartmentName;
+                                        $scope.vm.departments = [];
+                                        angular.forEach(issueStatusVo.workflowDepartmentVos, function (workflowDepartment) {
+                                            $scope.vm.departments.push(workflowDepartment.departmentVo);
+                                        });
+                                    }
+                                });
+                            }
+                        }
+
+                        //  �꽑�깮 �븳 遺��꽌 �젣嫄�
+                        function removeDepartment(index) {
+                            if (index < $scope.vm.departments.length) {
+                                $scope.vm.departments.splice(index, 1);
+                                changeDepartment();
+                            }
+                        }
+
+                        function changeDepartment() {
+                            if ($scope.vm.activeTarget != null) {
+                                var targetIssueStatus = $scope.vm.activeTarget.issueStatus;
+
+                                // null 泥댄겕
+                                if (targetIssueStatus != null) {
+                                    var myIssueStatus = null;
+                                    angular.forEach($scope.vm.issueStatusVos, function (issueStatusVo) {
+                                        if (issueStatusVo.id === targetIssueStatus.id) {
+                                            myIssueStatus = issueStatusVo;
+                                        }
+                                    });
+
+                                    if (myIssueStatus != null) {
+                                        if ($scope.vm.departments != null) {
+                                            var workflowDepartments = [];
+
+                                            angular.forEach($scope.vm.departments, function (department) {
+                                                var workflowDepartment = {
+                                                    departmentVo : department
+                                                }
+                                                workflowDepartments.push(workflowDepartment);
+                                            });
+                                            myIssueStatus.workflowDepartmentVos = workflowDepartments;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+
+                        // �떞�떦遺��꽌 異붽�
+                        function addWorkflowDepartment(targetIssueStatus)
+                        {
+                            if ($scope.departments != null && $scope.departments.length > 0) {
+                                var workflowDepartmentVos = [];
+                                angular.forEach($scope.vm.issueStatusVos, function (issueStatusVo) {
+                                    if (issueStatusVo.id === targetIssueStatus.id) {
+                                        var issueStatusWorkflowDepartments = {
+                                            workflowDepartmentVos : workflowDepartmentVos,
+                                            workflowDepartmentName : ""
+                                        }
+                                        issueStatusVo = Object.assign(issueStatusVo, issueStatusWorkflowDepartments);
+                                    }
+                                });
+                            }
+                        }
+
+                        // �떞�떦遺��꽌 �궘�젣
+                        function removeWorkflowDepartment(targetIssueStatus)
+                        {
+                            if ($scope.vm.workflowDepartmentVos != null && $scope.vm.workflowDepartmentVos.length > 0) {
+                                $scope.vm.workflowDepartmentVos = $scope.vm.workflowDepartmentVos.filter((el) => el.issueStatus.id === targetIssueStatus.id);
+                            }
+                        }
+
                         //  ��寃잛쓣 �겢由��뻽�쓣 �븣 �깋�긽�쓣 蹂�寃쏀븳�떎.
+                        //  �떞�떦 遺��꽌瑜� 遺덈윭�삩�떎
                         function targetClick(target) {
                             $scope.vm.activeTarget = angular.copy(target[0][0]["__data__"]);
 
+                            setWorkflowDepartment($scope.vm.activeTarget.issueStatus);
                             // node �씪寃쎌슦
                             if ($scope.vm.activeTarget.type == "01") {
                                 //  �끂�뱶, 留곹겕 �쟾泥� 珥덇린�솕

--
Gitblit v1.8.0