From 577502fbd1ec01a3023ca0eb515ab6ec52d67a5e Mon Sep 17 00:00:00 2001 From: jhjang <jhjang@maprex.co.kr> Date: 금, 26 11월 2021 17:21:29 +0900 Subject: [PATCH] - api 기본값 설정 기능 추가 --- src/main/webapp/scripts/app/api/apiSetting.controller.js | 158 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 147 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/scripts/app/api/apiSetting.controller.js b/src/main/webapp/scripts/app/api/apiSetting.controller.js index db6427d..a96bc8c 100644 --- a/src/main/webapp/scripts/app/api/apiSetting.controller.js +++ b/src/main/webapp/scripts/app/api/apiSetting.controller.js @@ -7,30 +7,159 @@ 'app', 'angular' ], function (app, angular) { - app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', - function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter) { + 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) { $scope.fn = { changeTab : changeTab, - add : add, + getIssueTypeCallback : getIssueTypeCallback, + getProjectListCallback : getProjectListCallback, + formSubmit : formSubmit, + formCheck : formCheck, + initForm : initForm, + getPriorities : getPriorities, + getSeverities : getSeverities, + start : start }; $scope.vm = { tab : "API_COL_SETTING", + issueTypes : [], + severities : [], + priorities : [], + // projects : [], form : { + issueApiDefault : { + title : "", + description : "", + priorityId : "", + severityId : "", + // projectName : "", + } + }, - } + autoCompletePage : { + issueType : { + page : 0, + totalPage : 0 + }, + // project : { + // page : 0, + // totalPage : 0 + // } + }, + issueTypeName : "", + issueTypeData : null // �씠�뒋 �쑀�삎 媛앹껜 }; - // �깮�꽦 �뙘�뾽 - function add() { - $uibModal.open({ - templateUrl : 'views/api/apiOverlapAdd.html', - size : "sm", - // controller : 'apiOverlapAddController', - backdrop : 'static' + angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); + + function initForm() { + $scope.vm.form.issueApiDefault.title = ""; + $scope.vm.form.issueApiDefault.description = ""; + $scope.vm.form.issueApiDefault.priorityId = ""; + $scope.vm.form.issueApiDefault.severityId = ""; + } + + // �씠�뒋 �쑀�삎 �겢由��떆 + $scope.$on("onClickIssueType", function (evnet, args) { + if (args != null && args.length > 0) { + + let conditions = { + issueTypeId: args[0].id + } + + Api.findApiDefault($resourceProvider.getContent( + conditions, $resourceProvider.getPageContent(0, 0))).then(function (result) { + $scope.fn.initForm(); + 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(); + + // if (angular.isDefined(result.data.data.projectVo)) { + // $scope.vm.projects = []; + // $scope.vm.projects.push(result.data.data.projectVo); + // } + } + } else { + SweetAlert.swal($filter("translate")("common.failedToIssueTypeDefault"), result.data.message.message, "error"); // "�봽濡쒖젥�듃 紐⑸줉 議고쉶 �떎�뙣" + } + }); + } + }); + + // �뤌 泥댄겕 + function formCheck(formInvalid) { + if (formInvalid) { + return true; + } + + return false; + } + + function formSubmit() { + if ($scope.vm.issueTypes == null || $scope.vm.issueTypes.length === 0) + return; + + let condition = { + issueTypeId : $scope.vm.issueTypes[0].id, + 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, + severityId : $scope.vm.form.issueApiDefault.severityId, + description : $scope.vm.form.issueApiDefault.description, + } + + Api.modifyApiDefault($resourceProvider.getContent(condition, + $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 �넗�겙 �깮�꽦 �꽦怨�" + } + else { + SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api �넗�겙 �깮�꽦 �떎�뙣" + } }); } + + function getIssueTypeCallback(result) { + $scope.vm.autoCompletePage.issueType.totalPage = result.data.page.totalPage; + } + + function getProjectListCallback(result) { + $scope.vm.autoCompletePage.project.totalPage = result.data.page.totalPage; + } + + // �슦�꽑�닚�쐞 紐⑸줉 + function getPriorities() { + Priority.find($resourceProvider.getContent({}, + $resourceProvider.getPageContent(0, 1000))).then(function (result) { + + if (result.data.message.status === "success") { + $scope.vm.priorities = result.data.data; + } + else { + SweetAlert.swal($filter("translate")("issue.failedToPriorityListLookup"), result.data.message.message, "error"); // �슦�꽑�닚�쐞 紐⑸줉 議고쉶 �떎�뙣 + } + }); + } + + // 以묒슂�룄 紐⑸줉 + function getSeverities() { + Severity.find($resourceProvider.getContent({}, + $resourceProvider.getPageContent(0, 1000))).then(function (result) { + + if (result.data.message.status === "success") { + $scope.vm.severities = result.data.data; + } + else { + SweetAlert.swal($filter("translate")("issue.failedToCriticalListLookup"), result.data.message.message, "error"); // 以묒슂�룄 紐⑸줉 議고쉶 �떎�뙣 + } + }); + } + function changeTab(tab) { $scope.vm.tab = tab; @@ -42,5 +171,12 @@ } } + function start() { + $scope.fn.initForm(); + $scope.fn.getSeverities(); + $scope.fn.getPriorities(); + } + + $scope.fn.start(); }]); }); -- Gitblit v1.8.0