diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 532ca672de..a4004ed959 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -118,6 +118,12 @@ public class TestPlanController { testPlanService.editReportConfig(testPlanDTO); } + @PostMapping("/edit/follows/{planId}") + @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT) + public void editTestFollows(@PathVariable String planId,@RequestBody List follows) { + testPlanService.editTestFollows(planId,follows); + } + @PostMapping("/delete/{testPlanId}") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_DELETE) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class) diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 667d20ab92..38196bda52 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -228,6 +228,8 @@ public class TestPlanService { return testPlan; } + + public List getTestPlanByName(String name) { TestPlanExample example = new TestPlanExample(); example.createCriteria() @@ -254,19 +256,22 @@ public class TestPlanService { } } List follows = request.getFollows(); - if (StringUtils.isNotBlank(request.getId())) { - testPlanFollowService.deleteTestPlanFollowByPlanId(request.getId()); + editTestFollows(request.getId(),follows); + return this.editTestPlan(request); + } + + public void editTestFollows(String planId, List follows){ + if (StringUtils.isNotBlank(planId)) { + testPlanFollowService.deleteTestPlanFollowByPlanId(planId); if (!CollectionUtils.isEmpty(follows)) { for (String follow : follows) { TestPlanFollow testPlanFollow = new TestPlanFollow(); - testPlanFollow.setTestPlanId(request.getId()); + testPlanFollow.setTestPlanId(planId); testPlanFollow.setFollowId(follow); testPlanFollowService.insert(testPlanFollow); } } } - - return this.editTestPlan(request); } public TestPlan editTestPlan(TestPlanWithBLOBs testPlan) { diff --git a/frontend/src/business/components/settings/CurrentUser.vue b/frontend/src/business/components/settings/CurrentUser.vue index 3ad85ee1af..becdc9eaaa 100644 --- a/frontend/src/business/components/settings/CurrentUser.vue +++ b/frontend/src/business/components/settings/CurrentUser.vue @@ -1,21 +1,29 @@ @@ -881,4 +909,7 @@ height: 32px; width: 56px; } + .icon-style{ + + } diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index 0bae7124ea..f80311cef0 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -185,7 +185,7 @@ + @@ -266,7 +272,7 @@ import HeaderCustom from "@/business/components/common/head/HeaderCustom"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import MsTag from "@/business/components/common/components/MsTag"; import MsTestPlanScheduleMaintain from "@/business/components/track/plan/components/ScheduleMaintain"; -import {getCurrentProjectID, getCurrentUserId, hasPermission} from "@/common/js/utils"; +import {getCurrentProjectID, getCurrentUser, getCurrentUserId, hasPermission} from "@/common/js/utils"; import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv"; import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview"; import MsTaskCenter from "@/business/components/task/TaskCenter"; @@ -339,6 +345,9 @@ export default { this.initTableData(); }, methods: { + currentUser: () => { + return getCurrentUser(); + }, init() { this.initTableData(); }, @@ -388,6 +397,7 @@ export default { let data = res.data; let follow = ""; let followIds = data.map(d => d.id); + let showFollow = false; if (data) { data.forEach(d => { if (follow !== "") { @@ -395,11 +405,15 @@ export default { } else { follow = follow + d.name; } + if(this.currentUser().id===d.id){ + showFollow = true; + } }) } this.$set(item, "follow", follow); // 编辑时初始化id this.$set(item, "follows", followIds); + this.$set(item, "showFollow", showFollow); }) }); }); @@ -529,6 +543,30 @@ export default { }, () => { this.$error(this.$t('commons.run_fail')); }); + }, + saveFollow(row){ + if(row.showFollow){ + row.showFollow = false; + for (let i = 0; i < row.follows.length; i++) { + if(row.follows[i]===this.currentUser().id){ + row.follows.splice(i,1) + break; + } + } + this.$post('/test/plan/edit/follows/' + row.id, row.follows,() => { + this.initTableData(); + }); + return + } + if(!row.showFollow){ + row.showFollow = true; + row.follows.push(this.currentUser().id); + this.$post('/test/plan/edit/follows/' + row.id, row.follows,() => { + this.initTableData(); + }); + return + } + } } }; diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 8c35f6c43f..d22d16cb49 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -94,6 +94,7 @@ export default { create: 'Create', edit: 'Edit', copy: 'Copy', + follow:'Follow', refresh: 'Refresh', remark: 'Remark', delete: 'Delete', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 4a3cfc56cc..049c4c5955 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -95,6 +95,7 @@ export default { create: '新建', edit: '编辑', copy: '复制', + follow:'关注', refresh: '刷新', remark: '备注', delete: '删除', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 1ddf787d91..1f43e34e9b 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -95,6 +95,7 @@ export default { create: '新建', edit: '編輯', copy: '復製', + follow:'關注', refresh: '刷新', remark: '備註', delete: '刪除',