From c88104169bc4fe457f98f33a91574c4dd33da573 Mon Sep 17 00:00:00 2001 From: jhjang <jhjang@maprex.co.kr> Date: 금, 03 12월 2021 20:08:01 +0900 Subject: [PATCH] - api 입력 오류 수정 - api 기본값 및 중복 설정 적용 수정 --- src/main/webapp/scripts/app/api/apiSetting.controller.js | 195 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 177 insertions(+), 18 deletions(-) diff --git a/src/main/webapp/scripts/app/api/apiSetting.controller.js b/src/main/webapp/scripts/app/api/apiSetting.controller.js index a96bc8c..9031cce 100644 --- a/src/main/webapp/scripts/app/api/apiSetting.controller.js +++ b/src/main/webapp/scripts/app/api/apiSetting.controller.js @@ -7,8 +7,8 @@ 'app', 'angular' ], function (app, angular) { - app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', - function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter, $injector, $controller, Api, Priority, Severity) { + app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', 'IssueType', 'IssueTypeCustomField', + function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter, $injector, $controller, Api, Priority, Severity, IssueType, IssueTypeCustomField) { $scope.fn = { changeTab : changeTab, @@ -19,7 +19,17 @@ initForm : initForm, getPriorities : getPriorities, getSeverities : getSeverities, - start : start + start : start, + getIssueTypes : getIssueTypes, + onChangeIssueType : onChangeIssueType, + reset : reset, + resetOverlap : resetOverlap, + formSubmitOverlap : formSubmitOverlap, + removeCustomField : removeCustomField, + getOverlapList : getOverlapList, + onChangeIssueTypeOverlap : onChangeIssueTypeOverlap, + getIssueTypeCustomFields : getIssueTypeCustomFields, + getCurrentIssueTypeVo : getCurrentIssueTypeVo }; $scope.vm = { @@ -29,13 +39,16 @@ priorities : [], // projects : [], form : { + issueCustomFields : [], issueApiDefault : { title : "", description : "", priorityId : "", severityId : "", + customFields : [], // projectName : "", - } + }, + customFieldId : "", }, autoCompletePage : { @@ -48,8 +61,9 @@ // totalPage : 0 // } }, + issueTypeId : "", issueTypeName : "", - issueTypeData : null // �씠�뒋 �쑀�삎 媛앹껜 + customFieldName : "", }; angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); @@ -61,22 +75,92 @@ $scope.vm.form.issueApiDefault.severityId = ""; } - // �씠�뒋 �쑀�삎 �겢由��떆 - $scope.$on("onClickIssueType", function (evnet, args) { - if (args != null && args.length > 0) { + function reset() { + $scope.fn.initForm(); + $scope.fn.formSubmit(); + } + function resetOverlap() { + $scope.vm.form.customFieldIds = []; + $scope.fn.form.formSubmitOverlap(); + } + + function getOverlapList() { + let conditions = { + issueTypeId: $scope.vm.issueTypeId + } + + Api.findApiOverlap($resourceProvider.getContent( + conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { + if (result.data.message.status === "success") { + + let customFieldApiOverlaps = result.data.data; + $scope.vm.form.customFields = []; + + if (customFieldApiOverlaps != null) { + customFieldApiOverlaps.forEach(function (customFieldApiOverlap) { + $scope.vm.form.customFields.push(customFieldApiOverlap.customFieldVo); + }); + } + } + else { + SweetAlert.swal($filter("translate")("issue.failedToIssueTypeListLookup"), result.data.message.message, "error"); // "�씠�뒋 �쑀�삎 紐⑸줉 議고쉶 �떎�뙣" + } + }); + } + + function getIssueTypes() { + var conditions = { + }; + + IssueType.find($resourceProvider.getContent( + conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { + if (result.data.message.status === "success") { + $scope.vm.issueTypes = result.data.data; + if ($scope.vm.issueTypes != null && $scope.vm.issueTypes.length > 0) { + $scope.vm.issueTypeId = $scope.vm.issueTypes[0].id.toString(); + $scope.fn.onChangeIssueType(); + } + } + else { + SweetAlert.swal($filter("translate")("issue.failedToIssueTypeListLookup"), result.data.message.message, "error"); // "�씠�뒋 �쑀�삎 紐⑸줉 議고쉶 �떎�뙣" + } + }); + } + + function getCurrentIssueTypeVo() { + var issueTypeId = $scope.vm.issueTypeId; + + var issueTypeVo = null; + $scope.vm.issueTypes.forEach(function (issueType) { + if (issueType.id == issueTypeId) { + issueTypeVo = issueType; + } + }); + return issueTypeVo; + } + + function onChangeIssueTypeOverlap() { + $scope.fn.getOverlapList(); + } + + function onChangeIssueType() { + if ($scope.vm.issueTypeId != null) { let conditions = { - issueTypeId: args[0].id + issueTypeId: $scope.vm.issueTypeId } Api.findApiDefault($resourceProvider.getContent( - conditions, $resourceProvider.getPageContent(0, 0))).then(function (result) { + conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { $scope.fn.initForm(); + $scope.fn.getIssueTypeCustomFields(); + if (result.data.message.status === "success") { if (angular.isDefined(result.data.data)) { $scope.vm.form.issueApiDefault = result.data.data; - $scope.vm.form.issueApiDefault.priorityId = result.data.data.priorityId.toString(); - $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId.toString(); + $scope.vm.form.issueApiDefault.priorityId = result.data.data.priorityId != null ? result.data.data.priorityId.toString() : ""; + $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId != null ? result.data.data.severityId.toString() : ""; + // if (angular.isDefined(result.data.data.projectVo)) { // $scope.vm.projects = []; @@ -88,7 +172,8 @@ } }); } - }); + + } // �뤌 泥댄겕 function formCheck(formInvalid) { @@ -100,11 +185,11 @@ } function formSubmit() { - if ($scope.vm.issueTypes == null || $scope.vm.issueTypes.length === 0) + if ($scope.vm.issueTypeId == null) return; let condition = { - issueTypeId : $scope.vm.issueTypes[0].id, + issueTypeId : $scope.vm.issueTypeId, title : $scope.vm.form.issueApiDefault.title, // projectId : $scope.vm.projects != null && $scope.vm.projects.length > 0 ? $scope.vm.projects[0].id : null, priorityId : $scope.vm.form.issueApiDefault.priorityId, @@ -116,10 +201,45 @@ $resourceProvider.getPageContent(0, 1))).then(function (result) { if (result.data.message.status === "success") { - SweetAlert.swal($filter("translate")("api.successToApiIssueDefault"), result.data.message.message, "success"); // "api �넗�겙 �깮�꽦 �꽦怨�" + SweetAlert.swal($filter("translate")("api.successToApiIssueDefault"), result.data.message.message, "success"); // "api 湲곕낯媛� �꽕�젙 �꽦怨�" } else { - SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api �넗�겙 �깮�꽦 �떎�뙣" + SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api 湲곕낯媛� �꽕�젙 �떎�뙣" + } + }); + } + + // �궗�슜�옄 �젙�쓽 �븘�뱶 �꽑�깮 �빆紐� �궘�젣 + function removeCustomField(index) { + $scope.vm.form.customFields.splice(index, 1); + } + + // 以묐났 �빆紐� �쟾�넚 + function formSubmitOverlap() { + if ($scope.vm.issueTypeId === null) + return; + + let condition = { + issueTypeId : $scope.vm.issueTypeId, + customFieldIds : (function () { + var ids = []; + + angular.forEach($scope.vm.form.customFields, function (customField) { + ids.push(customField.id); + }); + + return ids; + })(), + } + + Api.modifyApiOverlap($resourceProvider.getContent(condition, + $resourceProvider.getPageContent(0, 1))).then(function (result) { + + if (result.data.message.status === "success") { + SweetAlert.swal($filter("translate")("api.successToApiIssueOverlap"), result.data.message.message, "success"); // "api 以묐났媛� �꽕�젙 �꽦怨�" + } + else { + SweetAlert.swal($filter("translate")("api.failedToApiIssueOverlap"), result.data.message.message, "error"); // "api 以묐났媛� �꽕�젙 �떎�뙣" } }); } @@ -146,6 +266,34 @@ }); } + // �씠�뒋 �쑀�삎�뿉 �뿰寃곕맂 �궗�슜�옄 �젙�쓽 �븘�뱶 + function getIssueTypeCustomFields() { + + $scope.vm.form.issueCustomFields = []; + + var issueTypeVo = $scope.fn.getCurrentIssueTypeVo(); + if (issueTypeVo.projectVo == null) return; + + IssueTypeCustomField.find($resourceProvider.getContent({ + projectId : issueTypeVo.projectVo.id, + IssueTypeId : issueTypeVo.id }, + $resourceProvider.getPageContent(0, 1000))).then(function (result) { + + if (result.data.message.status === "success") { + + $scope.vm.form.issueCustomFields = []; + angular.forEach(result.data.data, function (issueTypeCustomField) { + $scope.vm.form.issueCustomFields.push(issueTypeCustomField); + }); + } + else { + SweetAlert.swal($filter("translate")("issue.failedToUserDefinedFieldListAssociatedLookup"), result.data.message.message, "error"); // �씠�뒋 �쑀�삎�뿉 �뿰寃곕맂 �궗�슜�옄 �젙�쓽 �븘�뱶 紐⑸줉 議고쉶 �떎�뙣 + } + + }); + } + + // 以묒슂�룄 紐⑸줉 function getSeverities() { Severity.find($resourceProvider.getContent({}, @@ -159,6 +307,15 @@ } }); } + + $rootScope.$on("changeColumnSettingTab", function (event, args){ + $scope.fn.start(); + }); + + + $rootScope.$on("changeOverlapSettingTab", function (event, args){ + $scope.fn.getOverlapList(); + }); function changeTab(tab) { @@ -175,8 +332,10 @@ $scope.fn.initForm(); $scope.fn.getSeverities(); $scope.fn.getPriorities(); - } + $scope.fn.getIssueTypes(); + } $scope.fn.start(); + }]); }); -- Gitblit v1.8.0